<div dir="ltr">Hi, <br><br>On Tue, 21 May 2024 at 18:52, Maxime Ripard <<a href="mailto:mripard@kernel.org">mripard@kernel.org</a>> wrote:<br>><br>> HDMI controller drivers will need to figure out the RGB range they need<br>> to configure based on a mode and property values. Let's expose that in<br>> the HDMI connector state so drivers can just use that value.<br>><br>> Reviewed-by: Dave Stevenson <<a href="mailto:dave.stevenson@raspberrypi.com">dave.stevenson@raspberrypi.com</a>><br>> Signed-off-by: Maxime Ripard <<a href="mailto:mripard@kernel.org">mripard@kernel.org</a>><br>> ---<br>>  drivers/gpu/drm/display/drm_hdmi_state_helper.c | 29 +++++++++++++++++++++++++<br>>  drivers/gpu/drm/drm_atomic.c                    |  1 +<br>>  include/drm/drm_connector.h                     |  6 +++++<br>>  3 files changed, 36 insertions(+)<br>><br>> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c<br>> index 888fe1fe9594..6d30c47fca65 100644<br>> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c<br>> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c<br>> @@ -49,10 +49,37 @@ connector_state_get_mode(const struct drm_connector_state *conn_state)<br>>                 return NULL;<br>><br>>         return &crtc_state->mode;<br>>  }<br>><br>> +static bool hdmi_is_limited_range(const struct drm_connector *connector,<br>> +                                 const struct drm_connector_state *conn_state)<br>> +{<br>> +       const struct drm_display_info *info = &connector->display_info;<br>> +       const struct drm_display_mode *mode =<br>> +               connector_state_get_mode(conn_state);<br>> +<br>> +       /*<br>> +        * The Broadcast RGB property only applies to RGB format, and<br>> +        * i915 just assumes limited range for YCbCr output, so let's<br>> +        * just do the same.<br>> +        */<br>> +       if (conn_state->hdmi.output_format != HDMI_COLORSPACE_RGB)<br>> +               return true;<br>> +<br>> +       if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_FULL)<br>> +               return false;<br>> +<br>> +       if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED)<br>> +               return true;<br>> +<br>> +       if (!info->is_hdmi)<br>> +               return false;<br>> +<br>> +       return drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_LIMITED;<br>> +}<br>> +<br>>  static bool<br>>  sink_supports_format_bpc(const struct drm_connector *connector,<br>>                          const struct drm_display_info *info,<br>>                          const struct drm_display_mode *mode,<br>>                          unsigned int format, unsigned int bpc)<br>> @@ -315,10 +342,12 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,<br>>                 drm_atomic_get_new_connector_state(state, connector);<br>>         const struct drm_display_mode *mode =<br>>                 connector_state_get_mode(new_conn_state);<br>>         int ret;<br>><br>> +       new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state);<br>> +<br>>         ret = hdmi_compute_config(connector, new_conn_state, mode);<br>>         if (ret)<br>>                 return ret;<br>><br>>         if (old_conn_state->hdmi.broadcast_rgb != new_conn_state->hdmi.broadcast_rgb ||<br>> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c<br>> index 3e57d98d8418..07b4b394e3bf 100644<br>> --- a/drivers/gpu/drm/drm_atomic.c<br>> +++ b/drivers/gpu/drm/drm_atomic.c<br>> @@ -1145,10 +1145,11 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,<br>><br>>         if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||<br>>             connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {<br>>                 drm_printf(p, "\tbroadcast_rgb=%s\n",<br>>                            drm_hdmi_connector_get_broadcast_rgb_name(state->hdmi.broadcast_rgb));<br>> +               drm_printf(p, "\tis_limited_range=%c\n", state->hdmi.is_limited_range ? 'y' : 'n');<br>>                 drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc);<br>>                 drm_printf(p, "\toutput_format=%s\n",<br>>                            drm_hdmi_connector_get_output_format_name(state->hdmi.output_format));<br>>                 drm_printf(p, "\ttmds_char_rate=%llu\n", state->hdmi.tmds_char_rate);<br>>         }<br>> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h<br>> index a40eaf3a8ce4..1fca26d51218 100644<br>> --- a/include/drm/drm_connector.h<br>> +++ b/include/drm/drm_connector.h<br>> @@ -1068,10 +1068,16 @@ struct drm_connector_state {<br>>                  * @broadcast_rgb: Connector property to pass the<br>>                  * Broadcast RGB selection value.<br>>                  */<br>>                 enum drm_hdmi_broadcast_rgb broadcast_rgb;<br>><br>> +               /**<br>> +                * @is_full_range: Is the output supposed to use a full<div><br></div><div>s/full/limited/g ?</div><div><br>> +                * RGB Quantization Range or not?<br>> +                */<br>> +               bool is_limited_range;<br>> +<br>>                 /**<br>>                  * @output_bpc: Bits per color channel to output.<br>>                  */<br>>                 unsigned int output_bpc;<br>><br>><br>> --<br>> 2.45.0<br>><br><br><br>-- <br>Luc</div></div>