linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pekka Paalanen <ppaalanen@gmail.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Emma Anholt" <emma@anholt.net>,
	"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>,
	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 RFC v2 03/37] drm/connector: hdmi: Add Broadcast RGB property
Date: Thu, 21 Sep 2023 11:39:11 +0300	[thread overview]
Message-ID: <20230921113911.7799583d@eldfell> (raw)
In-Reply-To: <20230920-kms-hdmi-connector-state-v2-3-17932daddd7d@kernel.org>

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

On Wed, 20 Sep 2023 16:35:18 +0200
Maxime Ripard <mripard@kernel.org> 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.
> 
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  Documentation/gpu/kms-properties.csv      |  1 -
>  drivers/gpu/drm/drm_atomic.c              |  5 +++
>  drivers/gpu/drm/drm_atomic_state_helper.c | 17 +++++++
>  drivers/gpu/drm/drm_atomic_uapi.c         |  4 ++
>  drivers/gpu/drm/drm_connector.c           | 74 +++++++++++++++++++++++++++++++
>  include/drm/drm_connector.h               | 39 ++++++++++++++++
>  6 files changed, 139 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/gpu/kms-properties.csv b/Documentation/gpu/kms-properties.csv
> index 0f9590834829..caef14c532d4 100644
> --- a/Documentation/gpu/kms-properties.csv
> +++ b/Documentation/gpu/kms-properties.csv
> @@ -17,7 +17,6 @@ Owner Module/Drivers,Group,Property Name,Type,Property Values,Object attached,De
>  ,Virtual GPU,“suggested X”,RANGE,"Min=0, Max=0xffffffff",Connector,property to suggest an X offset for a connector
>  ,,“suggested Y”,RANGE,"Min=0, Max=0xffffffff",Connector,property to suggest an Y offset for a connector
>  ,Optional,"""aspect ratio""",ENUM,"{ ""None"", ""4:3"", ""16:9"" }",Connector,TDB
> -i915,Generic,"""Broadcast RGB""",ENUM,"{ ""Automatic"", ""Full"", ""Limited 16:235"" }",Connector,"When this property is set to Limited 16:235 and CTM is set, the hardware will be programmed with the result of the multiplication of CTM by the limited range matrix to ensure the pixels normally in the range 0..1.0 are remapped to the range 16/255..235/255."

Hi,

have a look at this old doc for the property, and...

>  ,,“audio”,ENUM,"{ ""force-dvi"", ""off"", ""auto"", ""on"" }",Connector,TBD
>  ,SDVO-TV,“mode”,ENUM,"{ ""NTSC_M"", ""NTSC_J"", ""NTSC_443"", ""PAL_B"" } etc.",Connector,TBD
>  ,,"""left_margin""",RANGE,"Min=0, Max= SDVO dependent",Connector,TBD

...

> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index d9a7e101e4e5..b45471d540ac 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1174,6 +1174,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);
> +
>  /**
>   * DOC: standard connector properties
>   *
> @@ -1640,6 +1663,24 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
>  /**
>   * DOC: HDMI connector properties
>   *
> + * Broadcast RGB (HDMI Specific):
> + *      Indicates the RGB Range (Full vs Limited) used.
> + *
> + *      The value of this property can be one of the following:
> + *
> + *      Automatic:
> + *              RGB Range is selected automatically based on the mode
> + *              according to the HDMI specifications.
> + *
> + *      Full:
> + *              Full RGB Range is forced.
> + *
> + *      Limited 16:235:
> + *              Limited RGB Range is forced.
> + *
> + *      Drivers can set up this property by calling
> + *      drm_connector_attach_broadcast_rgb_property().

...compare it to this. There is one crucial detail lost: setting this
property does two or three things: it clips conversion input values to
[0.0, 1.0] range, programs a conversion matrix to convert full-range
RGB to destination RGB, and sends infoframes to indicate the chosen
destination RGB.

The distinction is important, because use cases like PLUGE calibration
(Rec. ITU-R BT.814-4) rely on indicating limited range while pixel
values are still able to carry sub-black values. Other procedures might
also want to use super-whites. This is impossible with the existing
"Broadcast RGB" property, but that is a different matter.

The old doc didn't exactly say it sets the infoframe fields either, but
I presume it does.

I feel the documentation needs to be much more explicit here.

> + *
>   * 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
> @@ -2500,6 +2541,39 @@ int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *conn
>  }
>  EXPORT_SYMBOL(drm_connector_attach_hdr_output_metadata_property);
>  
> +/**
> + * drm_connector_attach_broadcast_rgb_property - attach "Broadcast RGB" property
> + * @connector: connector to attach max bpc property on.

"max bpc" pasta.

> + *
> + * This is used to add support for forcing the RGB range on a connector
> + *
> + * Returns:
> + * Zero on success, negative errno on failure.
> + */
> +int drm_connector_attach_broadcast_rgb_property(struct drm_connector *connector)
> +{
> +	struct drm_device *dev = connector->dev;
> +	struct drm_property *prop;
> +
> +	prop = connector->broadcast_rgb_property;
> +	if (!prop) {
> +		prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM,
> +						"Broadcast RGB",
> +						broadcast_rgb_names,
> +						ARRAY_SIZE(broadcast_rgb_names));
> +		if (!prop)
> +			return -EINVAL;
> +
> +		connector->broadcast_rgb_property = prop;
> +	}
> +
> +	drm_object_attach_property(&connector->base, prop,
> +				   DRM_HDMI_BROADCAST_RGB_AUTO);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_connector_attach_broadcast_rgb_property);
> +
>  /**
>   * drm_connector_attach_colorspace_property - attach "Colorspace" property
>   * @connector: connector to attach the property on.
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 5961f2ad48b1..fdcf64ab91a9 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -368,6 +368,33 @@ enum drm_panel_orientation {
>  	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
>  };
>  
> +/**
> + * enum drm_hdmi_broadcast_rgb - Broadcast RGB Selection for a @drm_hdmi_connector
> + *
> + * This enum is used to track broadcast RGB selection. There are no
> + * separate #defines for the uapi!

Why the "no separate defines" comment? That's the norm.

The KMS property UAPI works by string names for enum values. Some enum
properties might expose C enums for the values, but that is an
exception that cannot be fixed due to stable UAPI.


Thanks,
pq

> + */
> +enum drm_hdmi_broadcast_rgb {
> +	/**
> +	 * @DRM_HDMI_BROADCAST_RGB_AUTO: The RGB range is selected
> +	 * automatically based on the mode.
> +	 */
> +	DRM_HDMI_BROADCAST_RGB_AUTO,
> +
> +	/**
> +	 * @DRM_HDMI_BROADCAST_RGB_FULL: Full range RGB is forced.
> +	 */
> +	DRM_HDMI_BROADCAST_RGB_FULL,
> +
> +	/**
> +	 * @DRM_HDMI_BROADCAST_RGB_LIMITED: Limited range RGB is forced.
> +	 */
> +	DRM_HDMI_BROADCAST_RGB_LIMITED,
> +};

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-09-21 18:36 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-20 14:35 [PATCH RFC v2 00/37] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 01/37] drm/connector: Introduce an HDMI connector Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 02/37] drm/connector: hdmi: Create a custom state Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 03/37] drm/connector: hdmi: Add Broadcast RGB property Maxime Ripard
2023-09-21  8:39   ` Pekka Paalanen [this message]
2023-09-20 14:35 ` [PATCH RFC v2 04/37] drm/connector: hdmi: Add helper to get the RGB range Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 05/37] drm/connector: hdmi: Add output BPC to the connector state Maxime Ripard
2023-09-21  8:48   ` Pekka Paalanen
2023-09-21  8:56     ` Jani Nikula
2023-09-20 14:35 ` [PATCH RFC v2 06/37] drm/connector: hdmi: Add support for output format Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 07/37] drm/connector: hdmi: Add HDMI compute clock helper Maxime Ripard
2023-09-20 17:15   ` Jernej Škrabec
2023-09-20 14:35 ` [PATCH RFC v2 08/37] drm/connector: hdmi: Calculate TMDS character rate Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 09/37] drm/connector: hdmi: Add custom hook to filter " Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 10/37] drm/connector: hdmi: Compute bpc and format automatically Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 11/37] drm/connector: hdmi: Add Infoframes generation Maxime Ripard
2023-09-20 17:11   ` Jernej Škrabec
2023-09-20 14:35 ` [PATCH RFC v2 12/37] drm/connector: hdmi: Create Infoframe DebugFS entries Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 13/37] drm/vc4: hdmi: Create destroy state implementation Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 14/37] drm/vc4: hdmi: Switch to HDMI connector Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 15/37] drm/rockchip: inno_hdmi: Remove useless mode_fixup Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 16/37] drm/rockchip: inno_hdmi: Remove useless copy of drm_display_mode Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 17/37] drm/rockchip: inno_hdmi: Switch encoder hooks to atomic Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 18/37] drm/rockchip: inno_hdmi: Get rid of mode_set Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 19/37] drm/rockchip: inno_hdmi: no need to store vic Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 20/37] drm/rockchip: inno_hdmi: Remove unneeded has audio flag Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 21/37] drm/rockchip: inno_hdmi: Remove useless input format Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 22/37] drm/rockchip: inno_hdmi: Remove useless output format Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 23/37] drm/rockchip: inno_hdmi: Remove useless colorimetry Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 24/37] drm/rockchip: inno_hdmi: Remove useless enum Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 25/37] drm/rockchip: inno_hdmi: Remove tmds rate from structure Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 26/37] drm/rockchip: inno_hdmi: Remove useless coeff_csc matrix Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 27/37] drm/rockchip: inno_hdmi: Remove useless mode_valid Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 28/37] drm/rockchip: inno_hdmi: Move infoframe disable to separate function Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 29/37] drm/rockchip: inno_hdmi: Create mask retrieval functions Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 30/37] drm/rockchip: inno_hdmi: Switch to infoframe type Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 31/37] drm/rockchip: inno_hdmi: Remove unused drm device pointer Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 32/37] drm/rockchip: inno_hdmi: Switch to HDMI connector Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 33/37] drm/sun4i: hdmi: Convert encoder to atomic Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 34/37] drm/sun4i: hdmi: Move mode_set into enable Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 35/37] drm/sun4i: hdmi: Switch to container_of_const Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 36/37] drm/sun4i: hdmi: Consolidate atomic_check and mode_valid Maxime Ripard
2023-09-20 14:35 ` [PATCH RFC v2 37/37] drm/sun4i: hdmi: Switch to HDMI connector Maxime Ripard
2023-09-21 16:29 ` [PATCH RFC v2 00/37] drm/connector: Create HDMI Connector infrastructure Hans Verkuil
2023-09-21 16:48   ` 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=20230921113911.7799583d@eldfell \
    --to=ppaalanen@gmail.com \
    --cc=airlied@gmail.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --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=mripard@kernel.org \
    --cc=samuel@sholland.org \
    --cc=tzimmermann@suse.de \
    --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).