From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: "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>,
dri-devel@lists.freedesktop.org
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,
"Maxime Ripard" <mripard@kernel.org>,
"Maxime Ripard" <mripard@kernel.org>
Subject: Re: [PATCH v8 20/27] drm/connector: hdmi: Add Infoframes generation
Date: Fri, 08 Mar 2024 13:47:08 +0100 [thread overview]
Message-ID: <3612623.R56niFO833@steina-w> (raw)
In-Reply-To: <20240307-kms-hdmi-connector-state-v8-20-ef6a6f31964b@kernel.org>
Hi Maxime,
Am Donnerstag, 7. März 2024, 14:38:47 CET schrieb Maxime Ripard:
> 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 | 327 +++++++++++++++++++++
> 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, 496 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..46d9fd2ea8fa 100644
> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
> [snip]
> @@ -958,10 +1100,195 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
>
> return 0;
> }
> EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
>
> +#define HDMI_MAX_INFOFRAME_SIZE 29
> +
> +static int clear_device_infoframe(struct drm_connector *connector,
> + enum hdmi_infoframe_type type)
> +{
> + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
> +
> + if (!funcs || !funcs->clear_infoframe)
> + return 0;
> +
> + return funcs->clear_infoframe(connector, type);
> +}
> +
> +static int clear_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *old_frame)
> +{
> + int ret;
> +
> + ret = clear_device_infoframe(connector, old_frame->data.any.type);
> + if (ret)
> + return ret;
> +
> + memset(old_frame, 0, sizeof(*old_frame));
> +
> + return 0;
> +}
> +
> +static int write_device_infoframe(struct drm_connector *connector,
> + union hdmi_infoframe *frame)
> +{
> + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
> + u8 buffer[HDMI_MAX_INFOFRAME_SIZE];
> + int len;
> +
> + if (!funcs || !funcs->write_infoframe)
> + return -ENOSYS;
> +
> + len = hdmi_infoframe_pack(frame, buffer, sizeof(buffer));
> + if (len < 0)
> + return len;
> +
> + return funcs->write_infoframe(connector, frame->any.type, buffer, len);
> +}
> +
> +static int write_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *new_frame)
> +{
> + int ret;
> +
> + ret = write_device_infoframe(connector, &new_frame->data);
> + if (ret)
> + return ret;
> +
> + if (conn_frame)
> + memcpy(conn_frame, new_frame, sizeof(*conn_frame));
> +
> + return 0;
> +}
> +
> +static int write_or_clear_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *old_frame,
> + struct drm_connector_hdmi_infoframe *new_frame)
> +{
> + if (new_frame->set)
> + return write_infoframe(connector, conn_frame, new_frame);
> +
> + if (old_frame->set && !new_frame->set)
> + return clear_infoframe(connector, conn_frame, old_frame);
> +
> + return 0;
> +}
> +
> +#define UPDATE_INFOFRAME(c, os, ns, i) \
> + write_or_clear_infoframe(c, \
> + &(c)->hdmi.infoframes.i, \
> + &(os)->hdmi.infoframes.i, \
> + &(ns)->hdmi.infoframes.i)
> +
> +/**
> + * drm_atomic_helper_connector_hdmi_update_infoframes - Update the Infoframes
> + * @connector: A pointer to the HDMI connector
> + * @state: The HDMI connector state to generate the infoframe from
> + *
> + * This function is meant for HDMI connector drivers to write their
> + * infoframes. It will typically be used in a
> + * @drm_connector_helper_funcs.atomic_enable implementation.
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *connector,
> + struct drm_atomic_state *state)
> +{
> + struct drm_connector_state *old_state =
> + drm_atomic_get_old_connector_state(state, connector);
> + struct drm_connector_state *new_state =
> + drm_atomic_get_new_connector_state(state, connector);
> + struct drm_display_info *info = &connector->display_info;
> + int ret;
> +
> + if (!info->is_hdmi)
> + return 0;
> +
> + if (!info->has_hdmi_infoframe)
> + return 0;
> +
> + mutex_lock(&connector->hdmi.infoframes.lock);
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, avi);
> + if (ret)
> + goto out;
> +
> + if (connector->hdmi.infoframes.audio.set) {
> + ret = write_infoframe(connector,
> + NULL,
> + &connector->hdmi.infoframes.audio);
> + if (ret)
> + goto out;
> + }
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdr_drm);
> + if (ret)
> + goto out;
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, spd);
> + if (ret)
> + goto out;
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdmi);
> + if (ret)
> + goto out;
> +
> +out:
> + mutex_unlock(&connector->hdmi.infoframes.lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes);
> +
> +#undef UPDATE_INFOFRAME
> +#undef UPDATE_INFOFRAME_TOGGLE
UPDATE_INFOFRAME_TOGGLE seems to never be defined.
Best regards,
Alexadner
> +
> +/**
> + * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
> + * @connector: A pointer to the HDMI connector
> + * @frame: A pointer to the audio infoframe to write
> + *
> + * This function is meant for HDMI connector drivers to update their
> + * audio infoframe. It will typically be used in one of the ALSA hooks
> + * (most likely prepare).
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int
> +drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *connector,
> + struct hdmi_audio_infoframe *frame)
> +{
> + struct drm_connector_hdmi_infoframe infoframe = {};
> + struct drm_display_info *info = &connector->display_info;
> + int ret;
> +
> + if (!info->is_hdmi)
> + return 0;
> +
> + if (!info->has_hdmi_infoframe)
> + return 0;
> +
> + memcpy(&infoframe.data, frame, sizeof(infoframe.data));
> + infoframe.set = true;
> +
> + mutex_lock(&connector->hdmi.infoframes.lock);
> +
> + ret = write_infoframe(connector,
> + &connector->hdmi.infoframes.audio,
> + &infoframe);
> +
> + mutex_unlock(&connector->hdmi.infoframes.lock);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_audio_infoframe);
> +
> /**
> * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
> * @connector: connector object
> * @state: atomic connector state
> *
> [snip]
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: "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>,
dri-devel@lists.freedesktop.org
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,
"Maxime Ripard" <mripard@kernel.org>,
"Maxime Ripard" <mripard@kernel.org>
Subject: Re: [PATCH v8 20/27] drm/connector: hdmi: Add Infoframes generation
Date: Fri, 08 Mar 2024 13:47:08 +0100 [thread overview]
Message-ID: <3612623.R56niFO833@steina-w> (raw)
In-Reply-To: <20240307-kms-hdmi-connector-state-v8-20-ef6a6f31964b@kernel.org>
Hi Maxime,
Am Donnerstag, 7. März 2024, 14:38:47 CET schrieb Maxime Ripard:
> 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 | 327 +++++++++++++++++++++
> 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, 496 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..46d9fd2ea8fa 100644
> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
> [snip]
> @@ -958,10 +1100,195 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
>
> return 0;
> }
> EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
>
> +#define HDMI_MAX_INFOFRAME_SIZE 29
> +
> +static int clear_device_infoframe(struct drm_connector *connector,
> + enum hdmi_infoframe_type type)
> +{
> + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
> +
> + if (!funcs || !funcs->clear_infoframe)
> + return 0;
> +
> + return funcs->clear_infoframe(connector, type);
> +}
> +
> +static int clear_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *old_frame)
> +{
> + int ret;
> +
> + ret = clear_device_infoframe(connector, old_frame->data.any.type);
> + if (ret)
> + return ret;
> +
> + memset(old_frame, 0, sizeof(*old_frame));
> +
> + return 0;
> +}
> +
> +static int write_device_infoframe(struct drm_connector *connector,
> + union hdmi_infoframe *frame)
> +{
> + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
> + u8 buffer[HDMI_MAX_INFOFRAME_SIZE];
> + int len;
> +
> + if (!funcs || !funcs->write_infoframe)
> + return -ENOSYS;
> +
> + len = hdmi_infoframe_pack(frame, buffer, sizeof(buffer));
> + if (len < 0)
> + return len;
> +
> + return funcs->write_infoframe(connector, frame->any.type, buffer, len);
> +}
> +
> +static int write_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *new_frame)
> +{
> + int ret;
> +
> + ret = write_device_infoframe(connector, &new_frame->data);
> + if (ret)
> + return ret;
> +
> + if (conn_frame)
> + memcpy(conn_frame, new_frame, sizeof(*conn_frame));
> +
> + return 0;
> +}
> +
> +static int write_or_clear_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *old_frame,
> + struct drm_connector_hdmi_infoframe *new_frame)
> +{
> + if (new_frame->set)
> + return write_infoframe(connector, conn_frame, new_frame);
> +
> + if (old_frame->set && !new_frame->set)
> + return clear_infoframe(connector, conn_frame, old_frame);
> +
> + return 0;
> +}
> +
> +#define UPDATE_INFOFRAME(c, os, ns, i) \
> + write_or_clear_infoframe(c, \
> + &(c)->hdmi.infoframes.i, \
> + &(os)->hdmi.infoframes.i, \
> + &(ns)->hdmi.infoframes.i)
> +
> +/**
> + * drm_atomic_helper_connector_hdmi_update_infoframes - Update the Infoframes
> + * @connector: A pointer to the HDMI connector
> + * @state: The HDMI connector state to generate the infoframe from
> + *
> + * This function is meant for HDMI connector drivers to write their
> + * infoframes. It will typically be used in a
> + * @drm_connector_helper_funcs.atomic_enable implementation.
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *connector,
> + struct drm_atomic_state *state)
> +{
> + struct drm_connector_state *old_state =
> + drm_atomic_get_old_connector_state(state, connector);
> + struct drm_connector_state *new_state =
> + drm_atomic_get_new_connector_state(state, connector);
> + struct drm_display_info *info = &connector->display_info;
> + int ret;
> +
> + if (!info->is_hdmi)
> + return 0;
> +
> + if (!info->has_hdmi_infoframe)
> + return 0;
> +
> + mutex_lock(&connector->hdmi.infoframes.lock);
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, avi);
> + if (ret)
> + goto out;
> +
> + if (connector->hdmi.infoframes.audio.set) {
> + ret = write_infoframe(connector,
> + NULL,
> + &connector->hdmi.infoframes.audio);
> + if (ret)
> + goto out;
> + }
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdr_drm);
> + if (ret)
> + goto out;
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, spd);
> + if (ret)
> + goto out;
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdmi);
> + if (ret)
> + goto out;
> +
> +out:
> + mutex_unlock(&connector->hdmi.infoframes.lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes);
> +
> +#undef UPDATE_INFOFRAME
> +#undef UPDATE_INFOFRAME_TOGGLE
UPDATE_INFOFRAME_TOGGLE seems to never be defined.
Best regards,
Alexadner
> +
> +/**
> + * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
> + * @connector: A pointer to the HDMI connector
> + * @frame: A pointer to the audio infoframe to write
> + *
> + * This function is meant for HDMI connector drivers to update their
> + * audio infoframe. It will typically be used in one of the ALSA hooks
> + * (most likely prepare).
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int
> +drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *connector,
> + struct hdmi_audio_infoframe *frame)
> +{
> + struct drm_connector_hdmi_infoframe infoframe = {};
> + struct drm_display_info *info = &connector->display_info;
> + int ret;
> +
> + if (!info->is_hdmi)
> + return 0;
> +
> + if (!info->has_hdmi_infoframe)
> + return 0;
> +
> + memcpy(&infoframe.data, frame, sizeof(infoframe.data));
> + infoframe.set = true;
> +
> + mutex_lock(&connector->hdmi.infoframes.lock);
> +
> + ret = write_infoframe(connector,
> + &connector->hdmi.infoframes.audio,
> + &infoframe);
> +
> + mutex_unlock(&connector->hdmi.infoframes.lock);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_audio_infoframe);
> +
> /**
> * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
> * @connector: connector object
> * @state: atomic connector state
> *
> [snip]
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: "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>,
dri-devel@lists.freedesktop.org
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,
"Maxime Ripard" <mripard@kernel.org>,
"Maxime Ripard" <mripard@kernel.org>
Subject: Re: [PATCH v8 20/27] drm/connector: hdmi: Add Infoframes generation
Date: Fri, 08 Mar 2024 13:47:08 +0100 [thread overview]
Message-ID: <3612623.R56niFO833@steina-w> (raw)
In-Reply-To: <20240307-kms-hdmi-connector-state-v8-20-ef6a6f31964b@kernel.org>
Hi Maxime,
Am Donnerstag, 7. März 2024, 14:38:47 CET schrieb Maxime Ripard:
> 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 | 327 +++++++++++++++++++++
> 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, 496 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..46d9fd2ea8fa 100644
> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
> [snip]
> @@ -958,10 +1100,195 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
>
> return 0;
> }
> EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
>
> +#define HDMI_MAX_INFOFRAME_SIZE 29
> +
> +static int clear_device_infoframe(struct drm_connector *connector,
> + enum hdmi_infoframe_type type)
> +{
> + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
> +
> + if (!funcs || !funcs->clear_infoframe)
> + return 0;
> +
> + return funcs->clear_infoframe(connector, type);
> +}
> +
> +static int clear_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *old_frame)
> +{
> + int ret;
> +
> + ret = clear_device_infoframe(connector, old_frame->data.any.type);
> + if (ret)
> + return ret;
> +
> + memset(old_frame, 0, sizeof(*old_frame));
> +
> + return 0;
> +}
> +
> +static int write_device_infoframe(struct drm_connector *connector,
> + union hdmi_infoframe *frame)
> +{
> + const struct drm_connector_hdmi_funcs *funcs = connector->hdmi.funcs;
> + u8 buffer[HDMI_MAX_INFOFRAME_SIZE];
> + int len;
> +
> + if (!funcs || !funcs->write_infoframe)
> + return -ENOSYS;
> +
> + len = hdmi_infoframe_pack(frame, buffer, sizeof(buffer));
> + if (len < 0)
> + return len;
> +
> + return funcs->write_infoframe(connector, frame->any.type, buffer, len);
> +}
> +
> +static int write_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *new_frame)
> +{
> + int ret;
> +
> + ret = write_device_infoframe(connector, &new_frame->data);
> + if (ret)
> + return ret;
> +
> + if (conn_frame)
> + memcpy(conn_frame, new_frame, sizeof(*conn_frame));
> +
> + return 0;
> +}
> +
> +static int write_or_clear_infoframe(struct drm_connector *connector,
> + struct drm_connector_hdmi_infoframe *conn_frame,
> + struct drm_connector_hdmi_infoframe *old_frame,
> + struct drm_connector_hdmi_infoframe *new_frame)
> +{
> + if (new_frame->set)
> + return write_infoframe(connector, conn_frame, new_frame);
> +
> + if (old_frame->set && !new_frame->set)
> + return clear_infoframe(connector, conn_frame, old_frame);
> +
> + return 0;
> +}
> +
> +#define UPDATE_INFOFRAME(c, os, ns, i) \
> + write_or_clear_infoframe(c, \
> + &(c)->hdmi.infoframes.i, \
> + &(os)->hdmi.infoframes.i, \
> + &(ns)->hdmi.infoframes.i)
> +
> +/**
> + * drm_atomic_helper_connector_hdmi_update_infoframes - Update the Infoframes
> + * @connector: A pointer to the HDMI connector
> + * @state: The HDMI connector state to generate the infoframe from
> + *
> + * This function is meant for HDMI connector drivers to write their
> + * infoframes. It will typically be used in a
> + * @drm_connector_helper_funcs.atomic_enable implementation.
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *connector,
> + struct drm_atomic_state *state)
> +{
> + struct drm_connector_state *old_state =
> + drm_atomic_get_old_connector_state(state, connector);
> + struct drm_connector_state *new_state =
> + drm_atomic_get_new_connector_state(state, connector);
> + struct drm_display_info *info = &connector->display_info;
> + int ret;
> +
> + if (!info->is_hdmi)
> + return 0;
> +
> + if (!info->has_hdmi_infoframe)
> + return 0;
> +
> + mutex_lock(&connector->hdmi.infoframes.lock);
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, avi);
> + if (ret)
> + goto out;
> +
> + if (connector->hdmi.infoframes.audio.set) {
> + ret = write_infoframe(connector,
> + NULL,
> + &connector->hdmi.infoframes.audio);
> + if (ret)
> + goto out;
> + }
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdr_drm);
> + if (ret)
> + goto out;
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, spd);
> + if (ret)
> + goto out;
> +
> + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdmi);
> + if (ret)
> + goto out;
> +
> +out:
> + mutex_unlock(&connector->hdmi.infoframes.lock);
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes);
> +
> +#undef UPDATE_INFOFRAME
> +#undef UPDATE_INFOFRAME_TOGGLE
UPDATE_INFOFRAME_TOGGLE seems to never be defined.
Best regards,
Alexadner
> +
> +/**
> + * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe
> + * @connector: A pointer to the HDMI connector
> + * @frame: A pointer to the audio infoframe to write
> + *
> + * This function is meant for HDMI connector drivers to update their
> + * audio infoframe. It will typically be used in one of the ALSA hooks
> + * (most likely prepare).
> + *
> + * Returns:
> + * Zero on success, error code on failure.
> + */
> +int
> +drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *connector,
> + struct hdmi_audio_infoframe *frame)
> +{
> + struct drm_connector_hdmi_infoframe infoframe = {};
> + struct drm_display_info *info = &connector->display_info;
> + int ret;
> +
> + if (!info->is_hdmi)
> + return 0;
> +
> + if (!info->has_hdmi_infoframe)
> + return 0;
> +
> + memcpy(&infoframe.data, frame, sizeof(infoframe.data));
> + infoframe.set = true;
> +
> + mutex_lock(&connector->hdmi.infoframes.lock);
> +
> + ret = write_infoframe(connector,
> + &connector->hdmi.infoframes.audio,
> + &infoframe);
> +
> + mutex_unlock(&connector->hdmi.infoframes.lock);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_audio_infoframe);
> +
> /**
> * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
> * @connector: connector object
> * @state: atomic connector state
> *
> [snip]
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-03-08 12:47 UTC|newest]
Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-07 13:38 [PATCH v8 00/27] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 01/27] drm/connector: Introduce an HDMI connector initialization function Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 02/27] drm/tests: connector: Add tests for drmm_connector_hdmi_init Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 03/27] drm/connector: hdmi: Create an HDMI sub-state Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 04/27] drm/connector: hdmi: Add output BPC to the connector state Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 05/27] drm/tests: Add output bpc tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-08 8:39 ` Alexander Stein
2024-03-08 8:39 ` Alexander Stein
2024-03-08 8:39 ` Alexander Stein
2024-03-07 13:38 ` [PATCH v8 06/27] drm/connector: hdmi: Add support for output format Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 07/27] drm/tests: Add output formats tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 08/27] drm/connector: hdmi: Add HDMI compute clock helper Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 09/27] drm/tests: Add HDMI TDMS character rate tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 10/27] drm/connector: hdmi: Calculate TMDS character rate Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 11/27] drm/tests: Add TDMS character rate connector state tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-08 11:11 ` Alexander Stein
2024-03-08 11:11 ` Alexander Stein
2024-03-08 11:11 ` Alexander Stein
2024-03-07 13:38 ` [PATCH v8 12/27] drm/connector: hdmi: Add custom hook to filter TMDS character rate Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 13/27] drm/tests: Add HDMI connector rate filter hook tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 14/27] drm/connector: hdmi: Compute bpc and format automatically Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 15/27] drm/tests: Add HDMI connector bpc and format tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 16/27] drm/connector: hdmi: Add Broadcast RGB property Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-08 11:26 ` Alexander Stein
2024-03-08 11:26 ` Alexander Stein
2024-03-08 11:26 ` Alexander Stein
2024-03-08 15:26 ` Pekka Paalanen
2024-03-08 15:26 ` Pekka Paalanen
2024-03-08 15:26 ` Pekka Paalanen
2024-03-07 13:38 ` [PATCH v8 17/27] drm/tests: Add tests for " Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 18/27] drm/connector: hdmi: Add RGB Quantization Range to the connector state Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 19/27] drm/tests: Add RGB Quantization tests Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 20/27] drm/connector: hdmi: Add Infoframes generation Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 21:34 ` Dmitry Baryshkov
2024-03-07 21:34 ` Dmitry Baryshkov
2024-03-07 21:34 ` Dmitry Baryshkov
2024-03-07 22:02 ` Dmitry Baryshkov
2024-03-07 22:02 ` Dmitry Baryshkov
2024-03-07 22:02 ` Dmitry Baryshkov
2024-03-08 12:47 ` Alexander Stein [this message]
2024-03-08 12:47 ` Alexander Stein
2024-03-08 12:47 ` Alexander Stein
2024-03-07 13:38 ` [PATCH v8 21/27] drm/tests: Add infoframes test Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 22/27] drm/connector: hdmi: Create Infoframe DebugFS entries Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 23/27] drm/vc4: hdmi: Switch to HDMI connector Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 24/27] drm/vc4: tests: Remove vc4_dummy_plane structure Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 25/27] drm/vc4: tests: Convert to plane creation helper Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 26/27] drm/rockchip: inno_hdmi: Switch to HDMI connector Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` [PATCH v8 27/27] drm/sun4i: hdmi: " Maxime Ripard
2024-03-07 13:38 ` Maxime Ripard
2024-03-07 13:38 ` 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=3612623.R56niFO833@steina-w \
--to=alexander.stein@ew.tq-group.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.