linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.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>,
	"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 v9 20/27] drm/connector: hdmi: Add Infoframes generation
Date: Fri, 15 Mar 2024 10:22:05 +0200	[thread overview]
Message-ID: <ZfQFLR2xO6vUpAJ9@intel.com> (raw)
In-Reply-To: <20240311-kms-hdmi-connector-state-v9-20-d45890323344@kernel.org>

On Mon, Mar 11, 2024 at 03:49:48PM +0100, Maxime Ripard wrote:
> Infoframes in KMS is usually handled by a bunch of low-level helpers
> that require quite some boilerplate for drivers. This leads to
> discrepancies with how drivers generate them, and which are actually
> sent.
> 
> Now that we have everything needed to generate them in the HDMI
> connector state, we can generate them in our common logic so that
> drivers can simply reuse what we precomputed.
> 
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  drivers/gpu/drm/Kconfig                            |   1 +
>  drivers/gpu/drm/drm_atomic_state_helper.c          | 323 +++++++++++++++++++++
>  drivers/gpu/drm/drm_connector.c                    |  14 +
>  .../gpu/drm/tests/drm_atomic_state_helper_test.c   |   1 +
>  drivers/gpu/drm/tests/drm_connector_test.c         |  12 +
>  include/drm/drm_atomic_state_helper.h              |   8 +
>  include/drm/drm_connector.h                        | 133 +++++++++
>  7 files changed, 492 insertions(+)
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index 872edb47bb53..ad9c467e20ce 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -97,10 +97,11 @@ config DRM_KUNIT_TEST
>  	  If in doubt, say "N".
>  
>  config DRM_KMS_HELPER
>  	tristate
>  	depends on DRM
> +	select DRM_DISPLAY_HDMI_HELPER
>  	help
>  	  CRTC helpers for KMS drivers.
>  
>  config DRM_DEBUG_DP_MST_TOPOLOGY_REFS
>          bool "Enable refcount backtrace history in the DP MST helpers"
> diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
> index e66272c0d006..2bf53666fc9d 100644
> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
> @@ -36,10 +36,12 @@
>  #include <drm/drm_plane.h>
>  #include <drm/drm_print.h>
>  #include <drm/drm_vblank.h>
>  #include <drm/drm_writeback.h>
>  
> +#include <drm/display/drm_hdmi_helper.h>
> +
>  #include <linux/slab.h>
>  #include <linux/dma-fence.h>
>  
>  /**
>   * DOC: atomic state reset and initialization
> @@ -912,10 +914,143 @@ hdmi_compute_config(const struct drm_connector *connector,
>  	}
>  
>  	return -EINVAL;
>  }
>  
> +static int hdmi_generate_avi_infoframe(const struct drm_connector *connector,
> +				       struct drm_connector_state *state)
> +{
> +	const struct drm_display_mode *mode =
> +		connector_state_get_mode(state);
> +	struct drm_connector_hdmi_infoframe *infoframe =
> +		&state->hdmi.infoframes.avi;
> +	struct hdmi_avi_infoframe *frame =
> +		&infoframe->data.avi;
> +	bool is_full_range = state->hdmi.is_full_range;
> +	enum hdmi_quantization_range rgb_quant_range =
> +		is_full_range ? HDMI_QUANTIZATION_RANGE_FULL : HDMI_QUANTIZATION_RANGE_LIMITED;
> +	int ret;
> +
> +	ret = drm_hdmi_avi_infoframe_from_display_mode(frame, connector, mode);
> +	if (ret)
> +		return ret;
> +
> +	frame->colorspace = state->hdmi.output_format;
> +
> +	drm_hdmi_avi_infoframe_quant_range(frame, connector, mode, rgb_quant_range);

drm_hdmi_avi_infoframe_quant_range() doesn't handle YCbCr currently.

> +	drm_hdmi_avi_infoframe_colorimetry(frame, state);
> +	drm_hdmi_avi_infoframe_bars(frame, state);
> +
> +	infoframe->set = true;
> +
> +	return 0;
> +}
> +
<snip>
> +
> +#define UPDATE_INFOFRAME(c, os, ns, i)				\
> +	write_or_clear_infoframe(c,				\
> +				 &(c)->hdmi.infoframes.i,	\
> +				 &(os)->hdmi.infoframes.i,	\
> +				 &(ns)->hdmi.infoframes.i)

This macro feels like pointless obfuscation to me.

<snip>
> @@ -1984,20 +2063,73 @@ struct drm_connector {
>  
>  	/**
>  	 * @hdmi: HDMI-related variable and properties.
>  	 */
>  	struct {
> +#define DRM_CONNECTOR_HDMI_VENDOR_LEN	8
> +		/**
> +		 * @vendor: HDMI Controller Vendor Name
> +		 */
> +		unsigned char vendor[DRM_CONNECTOR_HDMI_VENDOR_LEN] __nonstring;
> +
> +#define DRM_CONNECTOR_HDMI_PRODUCT_LEN	16
> +		/**
> +		 * @product: HDMI Controller Product Name
> +		 */
> +		unsigned char product[DRM_CONNECTOR_HDMI_PRODUCT_LEN] __nonstring;
> +
>  		/**
>  		 * @supported_formats: Bitmask of @hdmi_colorspace
>  		 * supported by the controller.
>  		 */
>  		unsigned long supported_formats;
>  
>  		/**
>  		 * @funcs: HDMI connector Control Functions
>  		 */
>  		const struct drm_connector_hdmi_funcs *funcs;
> +
> +		/**
> +		 * @infoframes: Current Infoframes output by the connector
> +		 */
> +		struct {
> +			/**
> +			 * @lock: Mutex protecting against concurrent access to
> +			 * the infoframes, most notably between KMS and ALSA.
> +			 */
> +			struct mutex lock;
> +
> +			/**
> +			 * @audio: Current Audio Infoframes structure. Protected
> +			 * by @lock.
> +			 */
> +			struct drm_connector_hdmi_infoframe audio;
> +
> +			/**
> +			 * @avi: Current AVI Infoframes structure. Protected by
> +			 * @lock.
> +			 */
> +			struct drm_connector_hdmi_infoframe avi;
> +
> +			/**
> +			 * @hdr_drm: Current DRM (Dynamic Range and Mastering)
> +			 * Infoframes structure. Protected by @lock.
> +			 */
> +			struct drm_connector_hdmi_infoframe hdr_drm;
> +
> +			/**
> +			 * @spd: Current SPD Infoframes structure. Protected by
> +			 * @lock.
> +			 */
> +			struct drm_connector_hdmi_infoframe spd;
> +
> +			/**
> +			 * @vendor: Current HDMI Vendor Infoframes structure.
> +			 * Protected by @lock.
> +			 */
> +			struct drm_connector_hdmi_infoframe hdmi;
> +		} infoframes;
>  	} hdmi;

What's the deal with this bloat? These are already tracked in the
connector's state so this looks entirely redundant.

>  };
>  
>  #define obj_to_connector(x) container_of(x, struct drm_connector, base)
>  
> @@ -2015,10 +2147,11 @@ int drmm_connector_init(struct drm_device *dev,
>  			const struct drm_connector_funcs *funcs,
>  			int connector_type,
>  			struct i2c_adapter *ddc);
>  int drmm_connector_hdmi_init(struct drm_device *dev,
>  			     struct drm_connector *connector,
> +			     const char *vendor, const char *product,
>  			     const struct drm_connector_funcs *funcs,
>  			     const struct drm_connector_hdmi_funcs *hdmi_funcs,
>  			     int connector_type,
>  			     struct i2c_adapter *ddc,
>  			     unsigned long supported_formats,
> 
> -- 
> 2.43.2

-- 
Ville Syrjälä
Intel

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

  reply	other threads:[~2024-03-15  8:22 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 14:49 [PATCH v9 00/27] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 01/27] drm/connector: Introduce an HDMI connector initialization function Maxime Ripard
2024-03-13 23:34   ` [v9,01/27] " Sui Jingfeng
2024-03-11 14:49 ` [PATCH v9 02/27] drm/tests: connector: Add tests for drmm_connector_hdmi_init Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 03/27] drm/connector: hdmi: Create an HDMI sub-state Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 04/27] drm/connector: hdmi: Add output BPC to the connector state Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 05/27] drm/tests: Add output bpc tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 06/27] drm/connector: hdmi: Add support for output format Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 07/27] drm/tests: Add output formats tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 08/27] drm/connector: hdmi: Add HDMI compute clock helper Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 09/27] drm/tests: Add HDMI TDMS character rate tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 10/27] drm/connector: hdmi: Calculate TMDS character rate Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 11/27] drm/tests: Add TDMS character rate connector state tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 12/27] drm/connector: hdmi: Add custom hook to filter TMDS character rate Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 13/27] drm/tests: Add HDMI connector rate filter hook tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 14/27] drm/connector: hdmi: Compute bpc and format automatically Maxime Ripard
2024-03-15  8:05   ` Ville Syrjälä
2024-03-18 12:05     ` Maxime Ripard
2024-03-18 13:37       ` Ville Syrjälä
2024-03-11 14:49 ` [PATCH v9 15/27] drm/tests: Add HDMI connector bpc and format tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 16/27] drm/connector: hdmi: Add Broadcast RGB property Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 17/27] drm/tests: Add tests for " Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 18/27] drm/connector: hdmi: Add RGB Quantization Range to the connector state Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 19/27] drm/tests: Add RGB Quantization tests Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 20/27] drm/connector: hdmi: Add Infoframes generation Maxime Ripard
2024-03-15  8:22   ` Ville Syrjälä [this message]
2024-03-18 13:49     ` Maxime Ripard
2024-03-18 16:11       ` Ville Syrjälä
2024-03-19 10:21         ` Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 21/27] drm/tests: Add infoframes test Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 22/27] drm/connector: hdmi: Create Infoframe DebugFS entries Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 23/27] drm/vc4: hdmi: Switch to HDMI connector Maxime Ripard
2024-03-13 23:54   ` [v9,23/27] " Sui Jingfeng
2024-03-11 14:49 ` [PATCH v9 24/27] drm/vc4: tests: Remove vc4_dummy_plane structure Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 25/27] drm/vc4: tests: Convert to plane creation helper Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 26/27] drm/rockchip: inno_hdmi: Switch to HDMI connector Maxime Ripard
2024-03-11 14:49 ` [PATCH v9 27/27] 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=ZfQFLR2xO6vUpAJ9@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --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=mripard@kernel.org \
    --cc=samuel@sholland.org \
    --cc=sebastian.wick@redhat.com \
    --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).