ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: "Maxime Ripard" <mripard@kernel.org>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"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>,
	"Andy Yan" <andy.yan@rock-chips.com>
Cc: "Hans Verkuil" <hverkuil@xs4all.nl>,
	"Sebastian Wick" <sebastian.wick@redhat.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.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,
	"Dave Stevenson" <dave.stevenson@raspberrypi.com>,
	"Sui Jingfeng" <sui.jingfeng@linux.dev>,
	"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>
Subject: Re: [PATCH v15 01/29] drm/connector: Introduce an HDMI connector initialization function
Date: Thu, 1 Aug 2024 11:08:31 +0200	[thread overview]
Message-ID: <5934b4b2-3a99-4b6b-b3e3-e57eb82b9b16@suse.de> (raw)
In-Reply-To: <20240527-kms-hdmi-connector-state-v15-1-c5af16c3aae2@kernel.org>

Hi

Am 27.05.24 um 15:57 schrieb Maxime Ripard:
> A lot of the various HDMI drivers duplicate some logic that depends on
> the HDMI spec itself and not really a particular hardware
> implementation.
>
> Output BPC or format selection, infoframe generation are good examples
> of such areas.
>
> This creates a lot of boilerplate, with a lot of variations, which makes
> it hard for userspace to rely on, and makes it difficult to get it right
> for drivers.
>
> In the next patches, we'll add a lot of infrastructure around the
> drm_connector and drm_connector_state structures, which will allow to
> abstract away the duplicated logic. This infrastructure comes with a few
> requirements though, and thus we need a new initialization function.
>
> Hopefully, this will make drivers simpler to handle, and their behaviour
> more consistent.
>
> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Reviewed-by: Sui Jingfeng <sui.jingfeng@linux.dev>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>   drivers/gpu/drm/drm_connector.c | 39 +++++++++++++++++++++++++++++++++++++++
>   include/drm/drm_connector.h     |  5 +++++
>   2 files changed, 44 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index b0516505f7ae..d9961cce8245 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -450,10 +450,49 @@ int drmm_connector_init(struct drm_device *dev,
>   
>   	return 0;
>   }
>   EXPORT_SYMBOL(drmm_connector_init);
>   
> +/**
> + * drmm_connector_hdmi_init - Init a preallocated HDMI connector
> + * @dev: DRM device
> + * @connector: A pointer to the HDMI connector to init
> + * @funcs: callbacks for this connector
> + * @connector_type: user visible type of the connector
> + * @ddc: optional pointer to the associated ddc adapter
> + *
> + * Initialises a preallocated HDMI connector. Connectors can be
> + * subclassed as part of driver connector objects.
> + *
> + * Cleanup is automatically handled with a call to
> + * drm_connector_cleanup() in a DRM-managed action.
> + *
> + * The connector structure should be allocated with drmm_kzalloc().
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int drmm_connector_hdmi_init(struct drm_device *dev,
> +			     struct drm_connector *connector,
> +			     const struct drm_connector_funcs *funcs,
> +			     int connector_type,
> +			     struct i2c_adapter *ddc)

I know I'm late to the review.

Wouldn't it be better to make a separate HDMI-setup helper instead of 
yet another init function? The type of init function to use is mostly 
about memory management within the driver, while the new HDMI state is 
about features.

Maybe rather add something like drm_connector_init_hdmi_state(), which 
takes an initialized connector and sets all the values coming the other 
patches. Drivers would not have to subscribe to a certain way of memory 
management. AFAICT this would also allow to protect the helper and the 
new drm_connector.hdmi field behind DRM_DISPLAY_HDMI_STATE_HELPER. Best 
regards Thomas
> +{
> +	int ret;
> +
> +	if (!(connector_type == DRM_MODE_CONNECTOR_HDMIA ||
> +	      connector_type == DRM_MODE_CONNECTOR_HDMIB))
> +		return -EINVAL;
> +
> +	ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc);
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drmm_connector_hdmi_init);
> +
>   /**
>    * drm_connector_attach_edid_property - attach edid property.
>    * @connector: the connector
>    *
>    * Some connector types like DRM_MODE_CONNECTOR_VIRTUAL do not get a
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index fe88d7fc6b8f..4491c4c2fb6e 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -1902,10 +1902,15 @@ int drm_connector_init_with_ddc(struct drm_device *dev,
>   int drmm_connector_init(struct drm_device *dev,
>   			struct drm_connector *connector,
>   			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 struct drm_connector_funcs *funcs,
> +			     int connector_type,
> +			     struct i2c_adapter *ddc);
>   void drm_connector_attach_edid_property(struct drm_connector *connector);
>   int drm_connector_register(struct drm_connector *connector);
>   void drm_connector_unregister(struct drm_connector *connector);
>   int drm_connector_attach_encoder(struct drm_connector *connector,
>   				      struct drm_encoder *encoder);
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


  reply	other threads:[~2024-08-01  9:08 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 13:57 [PATCH v15 00/29] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 01/29] drm/connector: Introduce an HDMI connector initialization function Maxime Ripard
2024-08-01  9:08   ` Thomas Zimmermann [this message]
2024-05-27 13:57 ` [PATCH v15 02/29] drm/tests: connector: Add tests for drmm_connector_hdmi_init Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 03/29] drm/connector: hdmi: Create an HDMI sub-state Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 04/29] drm/connector: hdmi: Add output BPC to the connector state Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 05/29] drm/mode_object: Export drm_mode_obj_find_prop_id for tests Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 06/29] drm/tests: Add output bpc tests Maxime Ripard
2024-05-27 15:14   ` [v15,06/29] " Sui Jingfeng
2024-05-27 15:27   ` Sui Jingfeng
2024-05-27 13:57 ` [PATCH v15 07/29] drm/connector: hdmi: Add support for output format Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 08/29] drm/tests: Add output formats tests Maxime Ripard
2024-05-27 13:57 ` [PATCH v15 09/29] drm/display: hdmi: Add HDMI compute clock helper Maxime Ripard
2024-05-28  1:00   ` Dmitry Baryshkov
2024-05-27 13:57 ` [PATCH v15 10/29] drm/tests: Add HDMI TDMS character rate tests Maxime Ripard
2024-05-28  1:01   ` Dmitry Baryshkov
2024-05-27 13:58 ` [PATCH v15 11/29] drm/connector: hdmi: Calculate TMDS character rate Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 12/29] drm/tests: Add TDMS character rate connector state tests Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 13/29] drm/connector: hdmi: Add custom hook to filter TMDS character rate Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 14/29] drm/tests: Add HDMI connector rate filter hook tests Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 15/29] drm/connector: hdmi: Compute bpc and format automatically Maxime Ripard
2024-05-28  1:01   ` Dmitry Baryshkov
2024-05-27 13:58 ` [PATCH v15 16/29] drm/tests: Add HDMI connector bpc and format tests Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 17/29] drm/doc: Remove unused Broadcast RGB Property Maxime Ripard
2024-05-28  1:02   ` Dmitry Baryshkov
2024-05-27 13:58 ` [PATCH v15 18/29] drm/connector: hdmi: Add Broadcast RGB property Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 19/29] drm/tests: Add tests for " Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 20/29] drm/connector: hdmi: Add RGB Quantization Range to the connector state Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 21/29] drm/tests: Add RGB Quantization tests Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 22/29] drm/connector: hdmi: Add Infoframes generation Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 23/29] drm/tests: Add infoframes test Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 24/29] drm/connector: hdmi: Create Infoframe DebugFS entries Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 25/29] drm/vc4: hdmi: Switch to HDMI connector Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 26/29] drm/vc4: tests: Remove vc4_dummy_plane structure Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 27/29] drm/vc4: tests: Convert to plane creation helper Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 28/29] drm/rockchip: inno_hdmi: Switch to HDMI connector Maxime Ripard
2024-05-27 13:58 ` [PATCH v15 29/29] drm/sun4i: hdmi: " Maxime Ripard
2024-05-28  8:34 ` [PATCH v15 00/29] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2024-05-31 18:43 ` Jani Nikula
2024-06-03  9:19   ` Maxime Ripard
2024-06-03  9:28     ` Jani Nikula
2024-07-31 14:56 ` Hans Verkuil
2024-08-01  8:23   ` 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=5934b4b2-3a99-4b6b-b3e3-e57eb82b9b16@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=andy.yan@rock-chips.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dmitry.baryshkov@linaro.org \
    --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=sui.jingfeng@linux.dev \
    --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