On Mon, Feb 16, 2026 at 02:01:19PM +0100, Nicolas Frattaroli wrote:
> With the introduction of the "color format" DRM property, which allows
> userspace to request a specific color format, the HDMI state helper
> should implement this.
> 
> Implement it by translating the requested drm_color_format_enum to an
> hdmi_colorspace enum value. Auto is translated to RGB, and a fallback to
> YUV420 is only performed if the original color format was auto.
> 
> Signed-off-by: Nicolas Frattaroli <[email protected]>
> ---
>  drivers/gpu/drm/display/drm_hdmi_state_helper.c | 28 
> +++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c 
> b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> index a1d16762ac7a..3ba752200984 100644
> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> @@ -649,10 +649,34 @@ hdmi_compute_config(const struct drm_connector 
> *connector,
>       unsigned int max_bpc = clamp_t(unsigned int,
>                                      conn_state->max_bpc,
>                                      8, connector->max_bpc);
> +     enum hdmi_colorspace fmt;
>       int ret;
>  
> -     ret = hdmi_compute_format_bpc(connector, conn_state, mode, max_bpc,
> -                                   HDMI_COLORSPACE_RGB);
> +     switch (conn_state->color_format) {
> +     case DRM_COLOR_FORMAT_ENUM_AUTO:
> +     case DRM_COLOR_FORMAT_ENUM_RGB444:
> +             fmt = HDMI_COLORSPACE_RGB;
> +             break;
> +     case DRM_COLOR_FORMAT_ENUM_YCBCR444:
> +             fmt = HDMI_COLORSPACE_YUV444;
> +             break;
> +     case DRM_COLOR_FORMAT_ENUM_YCBCR422:
> +             fmt = HDMI_COLORSPACE_YUV422;
> +             break;
> +     case DRM_COLOR_FORMAT_ENUM_YCBCR420:
> +             fmt = HDMI_COLORSPACE_YUV420;
> +             break;
> +     default:
> +             drm_dbg_kms(connector->dev, "HDMI does not support color format 
> '%s'.\n",
> +                         
> drm_get_color_format_name(conn_state->color_format));
> +             return -EINVAL;
> +     }
> +
> +     ret = hdmi_compute_format_bpc(connector, conn_state, mode, max_bpc, 
> fmt);
> +
> +     if (conn_state->color_format != DRM_COLOR_FORMAT_ENUM_AUTO)
> +             return ret;
> +

This should also be greatly simplified since you don't need to deal with
hdmi_colorspace anymore, and thus you'll just be able to use the
construct I hinted at in the previous version.

Maxime

Attachment: signature.asc
Description: PGP signature

Reply via email to