mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Ripard <mripard@kernel.org>
To: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>,
	 Simona Vetter <simona@ffwll.ch>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	 Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	kernel@collabora.com, dri-devel@lists.freedesktop.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/7] drm/connector: hdmi: Use YUV420 output format as an RGB fallback
Date: Tue, 11 Mar 2025 16:55:17 +0100	[thread overview]
Message-ID: <20250311-hypersonic-mature-leopard-d3afdc@houat> (raw)
In-Reply-To: <20250311-hdmi-conn-yuv-v2-4-fbdb94f02562@collabora.com>

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

Hi,

I think the first thing we need to address is that we will need to
differentiate between HDMI 1.4 devices and HDMI 2.0.

It applies to YUV420, which is HDMI 2.0-only, and I guess your patches
are good enough if you consider YUV420 support only, but scrambler setup
for example is a thing we want to support in that infrastructure
eventually, and is conditioned on HDMI 2.0 as well.

On Tue, Mar 11, 2025 at 12:57:36PM +0200, Cristian Ciocaltea wrote:
> Try to make use of YUV420 when computing the best output format and
> RGB cannot be supported for any of the available color depths.
> 
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
>  drivers/gpu/drm/display/drm_hdmi_state_helper.c | 69 +++++++++++++------------
>  1 file changed, 35 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> index a70e204a8df3ac1c2d7318e81cde87a83267dd21..f2052781b797dd09b41127e33d98fe25408a9b23 100644
> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> @@ -287,8 +287,9 @@ hdmi_try_format_bpc(const struct drm_connector *connector,
>  	struct drm_device *dev = connector->dev;
>  	int ret;
>  
> -	drm_dbg_kms(dev, "Trying %s output format\n",
> -		    drm_hdmi_connector_get_output_format_name(fmt));
> +	drm_dbg_kms(dev, "Trying %s output format with %u bpc\n",
> +		    drm_hdmi_connector_get_output_format_name(fmt),
> +		    bpc);

That part should be in a separate patch, it's independant of the rest.

>  	if (!sink_supports_format_bpc(connector, info, mode, fmt, bpc)) {
>  		drm_dbg_kms(dev, "%s output format not supported with %u bpc\n",
> @@ -313,47 +314,22 @@ hdmi_try_format_bpc(const struct drm_connector *connector,
>  }
>  
>  static int
> -hdmi_compute_format(const struct drm_connector *connector,
> -		    struct drm_connector_state *conn_state,
> -		    const struct drm_display_mode *mode,
> -		    unsigned int bpc)
> -{
> -	struct drm_device *dev = connector->dev;
> -
> -	/*
> -	 * TODO: Add support for YCbCr420 output for HDMI 2.0 capable
> -	 * devices, for modes that only support YCbCr420.
> -	 */
> -	if (hdmi_try_format_bpc(connector, conn_state, mode, bpc, HDMI_COLORSPACE_RGB)) {
> -		conn_state->hdmi.output_format = HDMI_COLORSPACE_RGB;
> -		return 0;
> -	}
> -
> -	drm_dbg_kms(dev, "Failed. No Format Supported for that bpc count.\n");
> -
> -	return -EINVAL;
> -}
> -
> -static int
> -hdmi_compute_config(const struct drm_connector *connector,
> -		    struct drm_connector_state *conn_state,
> -		    const struct drm_display_mode *mode)
> +hdmi_try_format(const struct drm_connector *connector,
> +		struct drm_connector_state *conn_state,
> +		const struct drm_display_mode *mode,
> +		unsigned int max_bpc, enum hdmi_colorspace fmt)
>  {
>  	struct drm_device *dev = connector->dev;
> -	unsigned int max_bpc = clamp_t(unsigned int,
> -				       conn_state->max_bpc,
> -				       8, connector->max_bpc);
>  	unsigned int bpc;
>  	int ret;
>  
>  	for (bpc = max_bpc; bpc >= 8; bpc -= 2) {
> -		drm_dbg_kms(dev, "Trying with a %d bpc output\n", bpc);
> -
> -		ret = hdmi_compute_format(connector, conn_state, mode, bpc);
> -		if (ret)
> +		ret = hdmi_try_format_bpc(connector, conn_state, mode, bpc, fmt);
> +		if (!ret)
>  			continue;
>  
>  		conn_state->hdmi.output_bpc = bpc;
> +		conn_state->hdmi.output_format = fmt;

I guess it's a matter of semantics, but if it sets the value in the
state, it doesn't try. Maybe the function should be named
hdmi_compute_format_bpc then?

That renaming should be in a separate patch too (possibly several).

>  		drm_dbg_kms(dev,
>  			    "Mode %ux%u @ %uHz: Found configuration: bpc: %u, fmt: %s, clock: %llu\n",
> @@ -368,6 +344,31 @@ hdmi_compute_config(const struct drm_connector *connector,
>  	return -EINVAL;
>  }
>  
> +static int
> +hdmi_compute_config(const struct drm_connector *connector,
> +		    struct drm_connector_state *conn_state,
> +		    const struct drm_display_mode *mode)
> +{
> +	unsigned int max_bpc = clamp_t(unsigned int,
> +				       conn_state->max_bpc,
> +				       8, connector->max_bpc);
> +	int ret;
> +
> +	ret = hdmi_try_format(connector, conn_state, mode, max_bpc,
> +			      HDMI_COLORSPACE_RGB);
> +	if (!ret)
> +		return 0;
> +
> +	if (connector->ycbcr_420_allowed)
> +		ret = hdmi_try_format(connector, conn_state, mode, max_bpc,
> +				      HDMI_COLORSPACE_YUV420);

I think that's conditioned on a few more things:
  - That the driver supports HDMI 2.0
  - That the display is an HDMI output
  - That the mode is allowed YUV420 by the sink EDIDs

> +	else
> +		drm_dbg_kms(connector->dev,
> +			    "%s output format not allowed for connector\n",
> +			    drm_hdmi_connector_get_output_format_name(HDMI_COLORSPACE_YUV420));

And I think we should keep the catch-all failure message we had.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-03-11 15:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 10:57 [PATCH v2 0/7] drm/connector: hdmi: Allow using the YUV420 output format Cristian Ciocaltea
2025-03-11 10:57 ` [PATCH v2 1/7] drm/connector: hdmi: Evaluate limited range after computing format Cristian Ciocaltea
2025-03-11 19:36   ` Dmitry Baryshkov
2025-03-11 10:57 ` [PATCH v2 2/7] drm/connector: hdmi: Add support for YUV420 format verification Cristian Ciocaltea
2025-03-11 15:30   ` Maxime Ripard
2025-03-11 17:06     ` Cristian Ciocaltea
2025-03-11 10:57 ` [PATCH v2 3/7] drm/connector: hdmi: Improve debug message for supported format Cristian Ciocaltea
2025-03-11 15:31   ` Maxime Ripard
2025-03-11 10:57 ` [PATCH v2 4/7] drm/connector: hdmi: Use YUV420 output format as an RGB fallback Cristian Ciocaltea
2025-03-11 15:55   ` Maxime Ripard [this message]
2025-03-11 18:59     ` Cristian Ciocaltea
2025-03-14 13:57       ` Maxime Ripard
2025-03-11 19:46     ` Dmitry Baryshkov
2025-03-14 13:47       ` Maxime Ripard
2025-03-14 15:00         ` Dmitry Baryshkov
2025-03-11 10:57 ` [PATCH v2 5/7] drm/tests: hdmi: Add macros to simplify EDID setup Cristian Ciocaltea
2025-03-11 16:12   ` Maxime Ripard
2025-03-11 22:44     ` Cristian Ciocaltea
2025-03-19 15:32       ` Maxime Ripard
2025-03-19 21:33         ` Cristian Ciocaltea
2025-03-11 10:57 ` [PATCH v2 6/7] drm/tests: hdmi: Add limited range tests for YUV420 mode Cristian Ciocaltea
2025-03-11 16:17   ` Maxime Ripard
2025-03-11 22:54     ` Cristian Ciocaltea
2025-03-14 13:52       ` Maxime Ripard
2025-03-11 10:57 ` [PATCH v2 7/7] drm/tests: hdmi: Add max TMDS rate fallback " Cristian Ciocaltea
2025-03-12 12:02   ` kernel test robot
2025-03-12 18:14   ` kernel test robot

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=20250311-hypersonic-mature-leopard-d3afdc@houat \
    --to=mripard@kernel.org \
    --cc=airlied@gmail.com \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®