All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka Paalanen <ppaalanen@gmail.com>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: "Sebastian Wick" <sebastian.wick@redhat.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"Jonas Ådahl" <jadahl@redhat.com>,
	"Vitaly Prosyak" <vitaly.prosyak@amd.com>
Subject: Re: How should "max bpc" KMS property work?
Date: Wed, 27 Apr 2022 13:52:59 +0300	[thread overview]
Message-ID: <20220427135259.5e615945@eldfell> (raw)
In-Reply-To: <YmgyArRaJCh6JkQh@intel.com>

[-- Attachment #1: Type: text/plain, Size: 6335 bytes --]

Hi Ville and Alex,

thanks for the replies. More below.

TL;DR:

My take-away from this is that I should slam 'max bpc' to the max by
default, and offer a knob for the user in case they want to lower it.


On Tue, 26 Apr 2022 20:55:14 +0300
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Tue, Apr 26, 2022 at 11:35:02AM +0300, Pekka Paalanen wrote:
> > Hi all,
> > 
> > I'm working on setting HDR & WCG video modes in Weston, and I thought
> > setting "max bpc" KMS property on the connector would be a good idea.
> > I'm confused about how it works though.
> > 
> > I did some digging in https://gitlab.freedesktop.org/wayland/weston/-/issues/612
> > 
> > Summary:
> > 
> > - Apparently the property was originally added as a manual workaround
> >   for sink hardware behaving badly with high depth. A simple end user
> >   setting for "max bpc" would suffice for this use.
> > 
> > - Drivers will sometimes automatically choose a lower bpc than the "max
> >   bpc" value, but never bigger.
> > 
> > - amdgpu seems to (did?) default "max bpc" to 8, meaning that I
> >   definitely want to raise it.  
> 
> I've occasionally pondered about doing the same for i915, just to have
> the safest default possible. But I'd hate to lose the deep color testing
> coverage knowing very few people would in practice raise the limit.
> Also the number of systems where deep color doesn't work reliably
> (or can't be made to work by not using a crap cable) seems to be quite
> low.

I think when HDR and WCG get into display servers, setting 'max bpc'
will become a standard action.

It's bit moot to e.g. render everything in electrical 10 bit RGB, if
the link is just going to squash that into electrical 8 bit RGB, right?

So even 10 bit color would require setting 'max bpc' to at least 10 to
be able to actually see it, source-side dithering aside.

> > 
> > If I always slam "max bpc" to the highest supported value for that
> > property, do I lose more than workarounds for bad sink hardware?  
> 
> We don't have any workarounds implemented like this in the kernel.
> Or should not have at least. "max bpc" exists purely for the user
> to have a say in the matter in addition to whatever the EDID/quirks
> say. Ie. if the kernel knows for sure that deep color won't work on
> a particular setup then it should just not allow deep color at all
> despite what the prop value says.
> 
> So the only danger is fighting with the user's wishes which I guess
> you can overcome with some kind of user visible knob.

Right, good.

Furthermore, as a KMS client cannot make much assumptions about the KMS
state it inherits from some other KMS client, it should know and
program all possible KMS properties according to its own desires
anyway. That, and the DRM master concept make sure that there cannot be
any "third party" KMS configuration programs, like V4L2 has.

> > Do I lose the ability to set video modes that take too much bandwidth
> > at uncapped driver-selected bpc while capping the bpc lower would allow
> > me to use those video modes?
> > 
> > Or, are drivers required to choose a lower-than-usual but highest
> > usable bpc to make the requested video mode squeeze through the
> > connector and link?  
> 
> IMO drivers should implement the "reduce bpc until it fits"
> fallback. We have that in i915, except for MST where we'd need
> to potentially involve multiple streams in the fallback. That
> is something we intend to remedy eventually but it's not an
> entirely trivial thing to implement so will take some actual
> work. ATM we just cap MST to <=8bpc to avoid users getting into
> this situation so often.

Excellent, but judging from what Alex said, this is also not what
amdgpu does. We have two drivers doing different things then?

So with Weston I probably have to document, that if you can't get the
video mode you want working, try turning the 'max bpc' knob down and
try again.

Or, I could cap 'max bpc' based on my framebuffer depth. If I have an
electrical 8 bit FB (default in Weston), then there is not much use for
having 'max bpc' > 8. This ignores the KMS color pipeline a bit. Does
that make sense?

Does KMS use dithering automatically, btw?

The only mention of dithering in KMS docs is some nouveau-specific KMS
properties and another for radeon.

> > 
> > Do I need to implement a fallback strategy in a display server,
> > starting from the highest possible "max bpc" value, and if my modeset
> > is rejected, repeatedly try with lower "max bpc" setting until it works
> > or I'm out of bpc options?  
> 
> IMO the bpc part should be handled by the kernel since we already
> had this behaviour even before the "max bpc" prop was introduced
> and we didn't add an explicit "use this bpc or fail" prop. But of
> course you should have some kind of sensible fallback strategy for
> things that just fail for other reasons.

Right, but this means that I don't have to add 'max bpc' as yet another
dimension in the combinatorial explosion of KMS parameters I would need
to search to find a working setup. That's really good.

The one thing missing is seeing what format and bpc we actually got on
the link.

> The one problem we have in the kernel is that we have no way to
> ask the user if the display we tried to light up is actually
> working. So our policy decisions can't really involve user input.
> Userspace should not generally have that problem.

Indeed.

Also like Alex said, the kernel does not know if the user prefers high
color depth or high refresh rate either. One way to solve that is to
light up the requested video mode any way the kernel can, and then
report what the resulting color depth is. Another way is to have
explicit "use this bpc or fail" KMS property, maybe in the form of 'min
bpc' as I recall being discussed in the past, and let userspace guess
what might work. The former is easier to light up, but probing requires
actually setting the modes. The latter may require a lot of
trial-and-error from userspace to find anything that works, but it
takes only time and not blinking - as far as things can be detected
with TEST_ONLY commits. Then one still has to ask the user if it
actually worked.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-04-27 10:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-26  8:35 How should "max bpc" KMS property work? Pekka Paalanen
2022-04-26 17:55 ` Ville Syrjälä
2022-04-27 10:52   ` Pekka Paalanen [this message]
2022-04-27 15:02     ` Michel Dänzer
2022-04-27 15:41     ` Harry Wentland
2022-04-27 21:29       ` Sebastian Wick
2022-04-28  7:50         ` Pekka Paalanen
2022-04-28  7:52           ` Simon Ser
2022-04-28 14:50             ` Ville Syrjälä
2022-04-28 19:00               ` Sebastian Wick
2022-05-20 15:20   ` Hans de Goede
2022-05-23  8:22     ` Pekka Paalanen
2022-05-23 11:54       ` Sebastian Wick
2022-05-24  9:36         ` Hans de Goede
2022-05-24 15:43           ` Ville Syrjälä
2022-05-24 22:03             ` Alex Deucher
2022-05-25  6:04               ` Simon Ser
2022-05-25  7:17                 ` Pekka Paalanen
2022-05-25  8:42               ` Michel Dänzer
2022-05-25  7:28         ` Pekka Paalanen
2022-05-25  8:35           ` Michel Dänzer
2022-05-25  9:23             ` Simon Ser
2022-05-25 10:36               ` Pekka Paalanen
2022-05-30 10:21                 ` Jani Nikula
2022-05-31 17:37                 ` Ville Syrjälä
2022-06-01  7:21                   ` How should "max bpc" and "Colorspace" " Pekka Paalanen
2022-06-01  7:26                     ` Simon Ser
2022-06-01 14:06                     ` Ville Syrjälä
2022-06-01 22:25                       ` Sebastian Wick
2022-06-02  7:47                       ` Pekka Paalanen
2022-06-02 16:40                         ` Ville Syrjälä
2022-06-02 17:08                           ` Sebastian Wick
2022-06-02 17:20                             ` Ville Syrjälä
2022-06-03  7:19                           ` Pekka Paalanen
2022-06-03 16:27                             ` Ville Syrjälä
2022-04-26 19:38 ` How should "max bpc" " Alex Deucher
2022-04-26 19:55   ` Ville Syrjälä

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=20220427135259.5e615945@eldfell \
    --to=ppaalanen@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jadahl@redhat.com \
    --cc=sebastian.wick@redhat.com \
    --cc=ville.syrjala@linux.intel.com \
    --cc=vitaly.prosyak@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.