Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

drm backend: set "Broadcast RGB" = "Full" for all connections #2310

Open
wants to merge 138 commits into
base: master
Choose a base branch
from

Conversation

akvadrako
Copy link

I have a new monitor which has three similar modes:

  • 3840x2160 @ 59.939999 Hz
  • 3840x2160 @ 60.000000 Hz
  • 3840x2160 @ 59.997002 Hz

The last one works fine, but the first two have issues displaying colors, because the "Broadcast RGB" property on the connector defaults to "Auto" which means "Limited 16:235", squashing the dynamic range.

Since there is really no way for a sway user to know that 3840x2160@60Hz displays colors poorly, while 3840x2160@59.997Hz will be fine, I was using the wrong mode for weeks.

This patch causes wlroots to always set "Broadcast RGB" = "Full", which I think most people want.

@emersion
Copy link
Member

  1. It doesn't seem like switching to "Full" unconditionally is a good idea, as TVs tend to use "Limited" instead.
  2. "Broadcast RGB" is an Intel-specific property.

@akvadrako
Copy link
Author

1. It doesn't seem like switching to "Full" unconditionally is a good idea, as TVs tend to use "Limited" instead.

If it won't be the default, then it would be nice if sway could inform the user which modes use the limited mode; looking at the driver the logic seems to be in drm_default_rgb_quant_range(); it seems like userspace can only guess unless it copied all that logic. The aspect ratio flags seem to be a clue.

Do you have any other ideas for how it might be done? Perhaps setting full just for DP.

2. "Broadcast RGB" is an Intel-specific property.

Yes, I wonder how other drivers handle it. In regards to the patch, if the property doesn't exist it won't cause an issue.

@cyanreg
Copy link

cyanreg commented Jun 30, 2020

Its still a good idea even on TVs to always use Full. Most TVs will autodetect, since its trivial to do, and adjust accordingly. Some let you override it, but not as many as you think always assume its always going to be limited. Furthermore, HDR is a thing now, and a lot of HDR content these days, including all of youtube, is in full range. Hence its not unreasonable to assume HDR TVs would also expect full-range. Losing 10% of your dynamic range (possibly more depending on dithering) with HDR is much more fatal than with bt709 (IEC61966-2.1) gamma.
Also, a DisplayPort connection is guaranteed to use full range, just like DVI. And embedded, transparent DP <=> HDMI converters exist, which complicates assumptions further.
Autodetection will result in more fragile configuration, even if you use EDID parsing. In fact, most TVs have broken/unreliable EDID, and I'd be willing to bet the number is higher than TVs that assume limited range RGB always.. If you need a reference on how much will break, take a look at interlaced modes: wlroots has disabled them for years and no one has complained.

@akvadrako
Copy link
Author

I see there was a proposed DRM_MODE_FLAG_CEA_861_CE_MODE flag, I wonder if it has any chance of being implemented.

@emersion
Copy link
Member

emersion commented Jul 1, 2020

23:35 <vsyrjala> yes. "ce" modes use limited range, "it" modes use full range
23:43 <vsyrjala> this is one of those things we can't get it right 100% of the time due to broken displays
23:45 <vsyrjala> and sadly we don't know whether broken or non-broken display are more common

@cyanreg
Copy link

cyanreg commented Jul 9, 2020

Ping? I've been running this for a while without problems.

@emersion
Copy link
Member

emersion commented Jul 9, 2020

I'd still like to make this a standard property before starting to use it.

@akvadrako
Copy link
Author

I’m sure you are better informed but from here it looks like that patch to lkml that’s adds that standard property from a few months ago has stalled.

@emersion
Copy link
Member

Yes, those patches need some work. For reference:

@cyanreg
Copy link

cyanreg commented Oct 20, 2020

Ping again, been running this since it was posted, had no problems, already had to help out one person who was wondering why colors look washed out.

@emersion
Copy link
Member

This email thread also suggests that we should stick to full range unconditionally (especially when we'll implement color management): https://lists.freedesktop.org/archives/dri-devel/2020-October/283396.html

This PR is still blocked on registering the property as a standard one.

@emersion
Copy link
Member

More info on turning "Broadcast RGB" into a generic prop: https://dri.freedesktop.org/docs/drm/gpu/todo.html#consolidate-custom-driver-modeset-properties

@Matombo
Copy link

Matombo commented Jun 22, 2021

This email thread also suggests that we should stick to full range unconditionally (especially when we'll implement color management): https://lists.freedesktop.org/archives/dri-devel/2020-October/283396.html

This PR is still blocked on registering the property as a standard one.

Is this the only blockage for this patch?

Because in this patchset https://lkml.org/lkml/2021/6/18/294, I standardized "Broadcast RGB" and implemented it for Intel and AMD. And if you say this MR is ready to be merged once the patch got accepted it would help with: https://www.kernel.org/doc/html/v5.12/gpu/drm-uapi.html#open-source-userspace-requirements

@emersion
Copy link
Member

Yes, this is the only blocker. I trust @cyanreg that this is the correct thing to do. This patch also needs to be rebased.

@cyanreg
Copy link

cyanreg commented Jun 22, 2021

I'm still using this locally and rebasing if needed. Repo is https://github.com/cyanreg/wlroots if you need it for now.

@akvadrako
Copy link
Author

Yes, this is the only blocker. I trust @cyanreg that this is the correct thing to do. This patch also needs to be rebased.

rebased

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments

backend/drm/atomic.c Outdated Show resolved Hide resolved
backend/drm/atomic.c Outdated Show resolved Hide resolved
include/backend/drm/properties.h Outdated Show resolved Hide resolved
@akvadrako
Copy link
Author

A few minor comments

Thanks, I've applied the feedback and squashed.

@cyanreg
Copy link

cyanreg commented Aug 20, 2021

Not all HDR on youtube is limited-range, some is full range.
Not all Blu-Rays are limited-range, since some Dolby Vision HDR is full range.
Who cares about DVDs, it's 2021. They're badly-mastered interlaced garbage anyway.
Not all streams are limited-range, twitch happily accepts full-range, and in fact, AMD hardware encoders by default encode in full-range. I estimate about 20-30% of twitch streams are full-range.

And finally,
All computer monitors are full-range. All. Not some. All. If they accept RGB, and are a monitor meant for computers, they operate on full-range. All TVs made in the past 15 years with a digital input accept full-range. All of them also autodetect its presence and adjust their settings accordingly. In fact, outputting limited-range is more likely to create confusion on our side, since nothing to do with computers accepts or even acknowledges limited-range RGB. No codec, including AV1 nor VP9, can signal limited-range RGB either, only full-range.

@@ -220,6 +225,10 @@ static bool atomic_crtc_commit(struct wlr_drm_connector *conn,

struct atomic atom;
atomic_begin(&atom);
if (conn->props.broadcast_rgb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required on every commit? I'd assume that it is enough to set this on modeset.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always set all of our state on each commit. Simplifies the code and I don't think it's a real performance concern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@emersion

This comment has been minimized.

@emersion

This comment has been minimized.

This is a glue file to allow integration with builds.sr.ht.
@emersion
Copy link
Member

emersion commented Nov 1, 2021

wlroots has migrated to gitlab.freedesktop.org. This pull request has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/2310

Kirill Primak and others added 30 commits December 9, 2021 18:26
Subsurface position is considered to be a part of the parent surface's
state, therefore it should be modified when the parent is committed.
This commit fixes the way the damage that doesn't come directly from the
client is handled.
Two new events are added: name and description. The name is
immutable. The description can be updated on-the-fly.
The multi backend was returned instead of the primary DRM backend.
This helper is responsible for listening for new DRM devices and
create new child DRM backends as necessary.
Co-authored-by: Simon Ser <contact@emersion.fr>
This allows compositors to avoid sending multiple frame done events
to a surface that is rendered on multiple outputs at once. This may
also be used in the same way for presentation feedback.
This doesn't work if scene outputs are not used as the primary output of
scene surfaces will always be NULL.

Therefore, take a wlr_scene_output instead of separate wlr_scene and
wlr_output arguments and rename the function to
wlr_scene_output_send_frame_done().

The actual behavior of the function is unchanged.
Otherwise it will send enter events to clients that already
have keyboard/pointer focus.
Notably Qt applications warns about this.
Allows the compositor to submit tokens to the pool of
currently active tokens. This can be useful when the
launcher doesn't use or support xdg-activation-v1 by
itself - e.g. when it is X11 based or use gtk_shell1.
This avoids open-coding our own logic. The resulting code is more
readable.

References: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146
This has been added in [1] and allows us to close buffer handles
without manually calling drmIoctl.

[1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/192
This helper automates sending presentation feedback to clients based on
the primary output of scene surfaces.
This fixes configure loop in Sway when clients re-send same properties
on every configure event.

Original issue: https://todo.sr.ht/~mil/sxmo-tickets/413
This patch makes it so we bind to zwp_linux_dmabuf_v1 version 4 and
we use it to grab the main device. v4 sends supported formats via a
table so we need to handle this as well.

v4 allows wlroots to remove the requirement for Mesa's internal
wl_drm interface.
These currently use uint32_t while they are an int32_t in the protocol.
According to [1] this should be done at each release with breaking ABI
changes.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/wikis/Core-contributor-guide#releasing-a-new-version

Fixes: 7360810 ("build: bump to version 0.16.0")
Compositors should've all been updated to use the new header by now.
All of these projects use meson.override_dependency() so we can
stop referencing their internal variable name to grab the
depndencies we need.
The libinput backend is now optional. However, this means that a
user building wlroots without the correct libinput dependencies
will end up with a compositor which doesn't respond to input events.

wlr_backend_autocreate is supposed to return a sensible setup, so in
this case let's just error out and explain what happened. Users can
suppress the check by setting WLR_LIBINPUT_NO_DEVICES=1 (already used
to suppress the zero input device case inside the libinput backend).

Compositors which really want to create a bare DRM backend can easily
create it manually instead of using wlr_backend_autocreate.
This function was already removed in e5b5592 but it was forgotten to
remove it from the header.
Some clients (e.g. mpv, Firefox) request a new wl_surface.frame
callback without damaging their surface. When this happens,
schedule a new output frame.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3350
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet