linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <mripard@kernel.org>
To: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Cc: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Sandy Huang" <hjc@rock-chips.com>,
	"Heiko Stübner" <heiko@sntech.de>, "Chen-Yu Tsai" <wens@csie.org>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Samuel Holland" <samuel@sholland.org>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Sebastian Wick" <sebastian.wick@redhat.com>,
	dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v11 15/28] drm/connector: hdmi: Compute bpc and format automatically
Date: Fri, 19 Apr 2024 15:01:10 +0200	[thread overview]
Message-ID: <20240419-illegal-rose-heron-e2ff64@houat> (raw)
In-Reply-To: <Zh6CQhD-2Yl5LUVb@intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 4388 bytes --]

On Tue, Apr 16, 2024 at 04:50:58PM +0300, Ville Syrjälä wrote:
> On Tue, Mar 26, 2024 at 04:40:19PM +0100, Maxime Ripard wrote:
> > Now that we have all the infrastructure needed, we can add some code
> > that will, for a given connector state and mode, compute the best output
> > format and bpc.
> > 
> > The algorithm is equivalent to the one already found in i915 and vc4.
> > 
> > Signed-off-by: Maxime Ripard <mripard@kernel.org>
> > ---
> >  drivers/gpu/drm/display/drm_hdmi_state_helper.c    | 197 ++++++++++++++++++++-
> >  drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c |  25 ++-
> >  2 files changed, 210 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> > index 063421835dba..b9bc0fb027ea 100644
> > --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> > +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> > @@ -1,9 +1,11 @@
> >  // SPDX-License-Identifier: MIT
> >  
> >  #include <drm/drm_atomic.h>
> >  #include <drm/drm_connector.h>
> > +#include <drm/drm_edid.h>
> > +#include <drm/drm_print.h>
> >  
> >  #include <drm/display/drm_hdmi_helper.h>
> >  #include <drm/display/drm_hdmi_state_helper.h>
> >  
> >  /**
> > @@ -46,10 +48,110 @@ connector_state_get_mode(const struct drm_connector_state *conn_state)
> >  		return NULL;
> >  
> >  	return &crtc_state->mode;
> >  }
> >  
> > +static bool
> > +sink_supports_format_bpc(const struct drm_connector *connector,
> > +			 const struct drm_display_info *info,
> > +			 const struct drm_display_mode *mode,
> > +			 unsigned int format, unsigned int bpc)
> > +{
> > +	struct drm_device *dev = connector->dev;
> > +	u8 vic = drm_match_cea_mode(mode);
> > +
> > +	/*
> > +	 * CTA-861-F, section 5.4 - Color Coding & Quantization states
> > +	 * that the bpc must be 8, 10, 12 or 16 except for the default
> > +	 * 640x480 VIC1 where the value must be 8.
> > +	 *
> > +	 * The definition of default here is ambiguous but the spec
> > +	 * refers to VIC1 being the default timing in several occasions
> > +	 * so our understanding is that for the default timing (ie,
> > +	 * VIC1), the bpc must be 8.
> > +	 */
> > +	if (vic == 1 && bpc != 8) {
> > +		drm_dbg_kms(dev, "VIC1 requires a bpc of 8, got %u\n", bpc);
> > +		return false;
> > +	}
> > +
> > +	if (!info->is_hdmi &&
> > +	    (format != HDMI_COLORSPACE_RGB || bpc != 8)) {
> > +		drm_dbg_kms(dev, "DVI Monitors require an RGB output at 8 bpc\n");
> > +		return false;
> > +	}
> > +
> > +	if (!(connector->hdmi.supported_formats & BIT(format))) {
> 
> These are the capabilities of the souce I take it?
>
> > +		drm_dbg_kms(dev, "%s format unsupported by the connector.\n",
> > +			    drm_hdmi_connector_get_output_format_name(format));
> > +		return false;
> > +	}
> > +
> > +	switch (format) {
> > +	case HDMI_COLORSPACE_RGB:
> > +		drm_dbg_kms(dev, "RGB Format, checking the constraints.\n");
> > +
> > +		if (!(info->color_formats & DRM_COLOR_FORMAT_RGB444))
> > +			return false;
> 
> and this is the sink.
>
> Maybe we should use the same bits for both? Anyways, that seems like
> material for a followup series.

Ack

> > +
> > +		if (bpc == 10 && !(info->edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_30)) {
> > +			drm_dbg_kms(dev, "10 BPC but sink doesn't support Deep Color 30.\n");
> > +			return false;
> > +		}
> > +
> > +		if (bpc == 12 && !(info->edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_36)) {
> > +			drm_dbg_kms(dev, "12 BPC but sink doesn't support Deep Color 36.\n");
> > +			return false;
> > +		}
> > +
> > +		drm_dbg_kms(dev, "RGB format supported in that configuration.\n");
> > +
> > +		return true;
> > +
> > +	case HDMI_COLORSPACE_YUV422:
> > +		drm_dbg_kms(dev, "YUV422 format, checking the constraints.\n");
> > +
> > +		if (!(info->color_formats & DRM_COLOR_FORMAT_YCBCR422)) {
> > +			drm_dbg_kms(dev, "Sink doesn't support YUV422.\n");
> > +			return false;
> > +		}
> > +
> > +		if (bpc != 12) {
> > +			drm_dbg_kms(dev, "YUV422 only supports 12 bpc.\n");
> > +			return false;
> > +		}
> 
> Did something change around here from the last time?

The format selection code now prefers to select a lower bpc rather than
another format, which is what you asked for in the previous version.


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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-04-19 13:02 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 15:40 [PATCH v11 00/28] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 01/28] drm/connector: Introduce an HDMI connector initialization function Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 02/28] drm/mode_object: Export drm_mode_obj_find_prop_id for tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 03/28] drm/tests: connector: Add tests for drmm_connector_hdmi_init Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 04/28] drm/connector: hdmi: Create an HDMI sub-state Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 05/28] drm/connector: hdmi: Add output BPC to the connector state Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 06/28] drm/tests: Add output bpc tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 07/28] drm/connector: hdmi: Add support for output format Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 08/28] drm/tests: Add output formats tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 09/28] drm/display: hdmi: Add HDMI compute clock helper Maxime Ripard
2024-04-16 13:44   ` Ville Syrjälä
2024-04-18 16:33     ` Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 10/28] drm/tests: Add HDMI TDMS character rate tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 11/28] drm/connector: hdmi: Calculate TMDS character rate Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 12/28] drm/tests: Add TDMS character rate connector state tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 13/28] drm/connector: hdmi: Add custom hook to filter TMDS character rate Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 14/28] drm/tests: Add HDMI connector rate filter hook tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 15/28] drm/connector: hdmi: Compute bpc and format automatically Maxime Ripard
2024-04-16 13:50   ` Ville Syrjälä
2024-04-19 13:01     ` Maxime Ripard [this message]
2024-03-26 15:40 ` [PATCH v11 16/28] drm/tests: Add HDMI connector bpc and format tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 17/28] drm/connector: hdmi: Add Broadcast RGB property Maxime Ripard
2024-04-16 14:00   ` Ville Syrjälä
2024-04-19 11:36     ` Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 18/28] drm/tests: Add tests for " Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 19/28] drm/connector: hdmi: Add RGB Quantization Range to the connector state Maxime Ripard
2024-04-16 14:09   ` Ville Syrjälä
2024-03-26 15:40 ` [PATCH v11 20/28] drm/tests: Add RGB Quantization tests Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 21/28] drm/connector: hdmi: Add Infoframes generation Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 22/28] drm/tests: Add infoframes test Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 23/28] drm/connector: hdmi: Create Infoframe DebugFS entries Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 24/28] drm/vc4: hdmi: Switch to HDMI connector Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 25/28] drm/vc4: tests: Remove vc4_dummy_plane structure Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 26/28] drm/vc4: tests: Convert to plane creation helper Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 27/28] drm/rockchip: inno_hdmi: Switch to HDMI connector Maxime Ripard
2024-03-26 15:40 ` [PATCH v11 28/28] drm/sun4i: hdmi: " Maxime Ripard

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=20240419-illegal-rose-heron-e2ff64@houat \
    --to=mripard@kernel.org \
    --cc=airlied@gmail.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=samuel@sholland.org \
    --cc=sebastian.wick@redhat.com \
    --cc=tzimmermann@suse.de \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wens@csie.org \
    /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;
as well as URLs for NNTP newsgroup(s).