dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Simon Ser <contact@emersion.fr>
To: Pekka Paalanen <ppaalanen@gmail.com>
Cc: DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: KMS enums and bitfields UAPI
Date: Fri, 03 Apr 2020 12:38:57 +0000	[thread overview]
Message-ID: <k5yRNTOMD1TpC3d6lv7pVxNyDrKEPJrCT8Syw18SEgUEXDpdAZPkOU0LDnSDfEeGyTjq2-QshBGwk8DO4lELhy5yQn-sf0faWHajiK4PDLk=@emersion.fr> (raw)
In-Reply-To: <20200403152400.55fe5eac@eldfell.localdomain>

On Friday, April 3, 2020 2:24 PM, Pekka Paalanen <ppaalanen@gmail.com> wrote:

> On Fri, 03 Apr 2020 10:15:21 +0000
> Simon Ser contact@emersion.fr wrote:
>
> > Hi all,
> > I've been working on a library called libliftoff 1. This library allows users
> > to set KMS properties on a hardware planes abstraction called layers.
> > Basically, library users create as many layers as they want with the KMS
> > properties they want, and libliftoff will map layers to actual hardware planes
> > when possible. The layer-to-plane mapping is dynamic. In other words, when
> > setting a layer's properties, the library user can't guess which KMS plane will
> > be used (if any).
> > This works fine for many properties, but doesn't work for enums and bitfields 2.
> > The KMS UAPI expects clients to retrieve the list of enum entries for each
> > object via drmModeGetProperty. The KMS UAPI allows a lot of freedom here: each
> > driver and even each plane can assign a different meaning to a given enum
> > value. For instance, in theory a plane could expose a "rotation" property where
> > 0x01 means "rotate-180", while another plane could expose a "rotation" property
> > where 0x01 means "rotate-90".
> > This makes things complicated for all KMS clients, not only for libliftoff. All
> > clients need to have an internal enum for e.g. "rotation", then when applying
> > properties to a plane needs to convert their internal value enum to the
> > per-plane enum value.
> > However, this isn't true for all properties. A bunch of properties have
> > hardcoded values in the UAPI headers. Looking at my copy of drm_mode.h I can
> > see DRM_MODE_SCALE_, DRM_MODE_DITHERING, DRM_MODE_LINK_STATUS_,
> > DRM_MODE_ROTATE_, DRM_MODE_REFLECT_ and DRM_MODE_CONTENT_PROTECTION_*.
> > (That's why I said "in theory" when I referred to the "rotation" property
> > above.)
> > I understand the intent is to allow adding new KMS properties without having to
> > update the UAPI headers. However having a nice KMS UAPI for dynamically listing
> > all enum entries for a property doesn't forbid us from also exposing the values
> > in the UAPI header to make things easier and simpler for user-space.
> > Additionally, I've heard Pekka saying that it would be nice to have constants
> > for property names in the UAPI headers. Indeed, this would prevent
> > hard-to-debug typo issues. I have a very good example of such a typo issue that
> > took literally hours to debug, with X11 atoms which also use free-form strings
> > like KMS properties 3.
> > If we have constants for property names in UAPI headers, it wouldn't be a big
> > hurdle to also have constants for enum values alongside.
>
> To clarify, the property names would be of the form
>
> #define DRM_KMS_PROPERTY_KERBLAH "KerBlah"
>
> while enum values would be integers, i.e. the raw values.
>
> Daniel Stone did have a good counter-argument to defining property
> names: userspace would be full of
>
> #ifndef DRM_KMS_PROPERTY_KERBLAH
> #define DRM_KMS_PROPERTY_KERBLAH "KerBleh"
> #endif
>
> anyway as long as they cannot rely on the headers to be recent enough.
> (The typo is intentional.)

Well, it depends on the user-space policy for dependencies. Weston
chooses to only bump its dependencies version when strictly necessary,
so Weston could choose to continue to use the hardcoded strings. OTOH,
other projects like wlroots have a different policy and require the
latest versions of its dependencies, and can use the constants from the
headers.

> > Are there any use-cases for defining a standard property which uses different
> > enum values depending on the driver/device/object (ie. the same enum value
> > can have a different meaning depending on the driver/device/object)?
> > At the very least, having a clear policy for both kernel public headers and
> > user-space would help a lot. Right now it's unclear for both parties what to do
> > regarding enum values.
> > What do you think?
>
> I do not think it is unclear at all. You have to query the kernel for
> value by string names. Maybe it's not clearly communicated though?

What's unclear right now is that half the enum properties have
constants in the UAPI headers (maybe more than half actually?). So
looking at the UAPI headers it's not clear whether this is just an
oversight (someone forgot to add enum values), or whether the policy
has changed. I only know about the policy because I asked, it's not
documented anywhere.

> But I also don't have anything against changing that policy, if kernel
> maintainers agree.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-04-03 12:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 10:15 KMS enums and bitfields UAPI Simon Ser
2020-04-03 12:24 ` Pekka Paalanen
2020-04-03 12:38   ` Simon Ser [this message]
2020-04-03 14:23   ` Adam Jackson
2020-04-06 13:55     ` Simon Ser
2020-04-07  8:18   ` Daniel Stone
2020-04-07  9:26     ` Daniel Vetter
2020-04-13 22:38 ` Simon Ser
2020-04-14 12:24   ` Daniel Vetter
2020-04-14 12:34     ` Simon Ser
2020-04-14 12:39       ` Daniel Vetter
2020-04-14 13:25         ` Simon Ser
2020-04-14 13:33           ` Daniel Vetter
2020-04-15 10:40             ` Simon Ser
2020-04-16  8:51               ` UAPI doc (Re: KMS enums and bitfields UAPI) Pekka Paalanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='k5yRNTOMD1TpC3d6lv7pVxNyDrKEPJrCT8Syw18SEgUEXDpdAZPkOU0LDnSDfEeGyTjq2-QshBGwk8DO4lELhy5yQn-sf0faWHajiK4PDLk=@emersion.fr' \
    --to=contact@emersion.fr \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ppaalanen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).