On Thu, 22 Feb 2024 19:14:07 +0100 Maxime Ripard <mripard@xxxxxxxxxx> wrote: > The i915 driver has a property to force the RGB range of an HDMI output. > The vc4 driver then implemented the same property with the same > semantics. KWin has support for it, and a PR for mutter is also there to > support it. > > Both drivers implementing the same property with the same semantics, > plus the userspace having support for it, is proof enough that it's > pretty much a de-facto standard now and we can provide helpers for it. > > Let's plumb it into the newly created HDMI connector. > > Reviewed-by: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx> > Signed-off-by: Maxime Ripard <mripard@xxxxxxxxxx> > --- > Documentation/gpu/kms-properties.csv | 1 - > drivers/gpu/drm/drm_atomic.c | 2 + > drivers/gpu/drm/drm_atomic_state_helper.c | 4 +- > drivers/gpu/drm/drm_atomic_uapi.c | 4 ++ > drivers/gpu/drm/drm_connector.c | 89 +++++++++++++++++++++++++++++++ > include/drm/drm_connector.h | 36 +++++++++++++ > 6 files changed, 134 insertions(+), 2 deletions(-) ... > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c > index 591d2d500f61..6ffe59d01698 100644 > --- a/drivers/gpu/drm/drm_connector.c > +++ b/drivers/gpu/drm/drm_connector.c > @@ -1212,6 +1212,29 @@ static const u32 dp_colorspaces = > BIT(DRM_MODE_COLORIMETRY_BT2020_CYCC) | > BIT(DRM_MODE_COLORIMETRY_BT2020_YCC); > > +static const struct drm_prop_enum_list broadcast_rgb_names[] = { > + { DRM_HDMI_BROADCAST_RGB_AUTO, "Automatic" }, > + { DRM_HDMI_BROADCAST_RGB_FULL, "Full" }, > + { DRM_HDMI_BROADCAST_RGB_LIMITED, "Limited 16:235" }, > +}; > + > +/* > + * drm_hdmi_connector_get_broadcast_rgb_name - Return a string for HDMI connector RGB broadcast selection > + * @broadcast_rgb: Broadcast RGB selection to compute name of > + * > + * Returns: the name of the Broadcast RGB selection, or NULL if the type > + * is not valid. > + */ > +const char * > +drm_hdmi_connector_get_broadcast_rgb_name(enum drm_hdmi_broadcast_rgb broadcast_rgb) > +{ > + if (broadcast_rgb > DRM_HDMI_BROADCAST_RGB_LIMITED) > + return NULL; > + > + return broadcast_rgb_names[broadcast_rgb].name; > +} > +EXPORT_SYMBOL(drm_hdmi_connector_get_broadcast_rgb_name); > + > static const char * const output_format_str[] = { > [HDMI_COLORSPACE_RGB] = "RGB", > [HDMI_COLORSPACE_YUV420] = "YUV 4:2:0", > @@ -1708,6 +1731,39 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property); > /** > * DOC: HDMI connector properties > * > + * Broadcast RGB (HDMI specific) > + * Indicates the Quantization Range (Full vs Limited) used. The color > + * processing pipeline will be adjusted to match the value of the > + * property, and the Infoframes will be generated and sent accordingly. > + * > + * This property is only relevant if the HDMI output format is RGB. If > + * it's one of the YCbCr variant, it will be ignored and the output will > + * use a limited quantization range. > + * > + * The CRTC attached to the connector must be configured by user-space to > + * always produce full-range pixels. > + * > + * The value of this property can be one of the following: > + * > + * Automatic: > + * The quantization range is selected automatically based on the > + * mode according to the HDMI specifications (HDMI 1.4b - Section > + * 6.6 - Video Quantization Ranges). > + * > + * Full: > + * Full quantization range is forced. > + * > + * Limited 16:235: > + * Limited quantization range is forced. Unlike the name suggests, > + * this works for any number of bits-per-component. > + * > + * Property values other than Automatic can result in colors being off (if > + * limited is selected but the display expects full), or a black screen > + * (if full is selected but the display expects limited). > + * > + * Drivers can set up this property by calling > + * drm_connector_attach_broadcast_rgb_property(). > + * > * content type (HDMI specific): > * Indicates content type setting to be used in HDMI infoframes to indicate > * content type for the external device, so that it adjusts its display This piece of doc looks good to me, so Acked-by: Pekka Paalanen <pekka.paalanen@xxxxxxxxxxxxx> Thanks, pq
Attachment:
pgpdagbaed46Y.pgp
Description: OpenPGP digital signature