[PATCH 8/9] drm/rockchip: inno-hdmi: handle unsupported InfoFrames

Dmitry Baryshkov posted 9 patches 4 days, 21 hours ago
There is a newer version of this series
[PATCH 8/9] drm/rockchip: inno-hdmi: handle unsupported InfoFrames
Posted by Dmitry Baryshkov 4 days, 21 hours ago
Make write_hdmi_infoframe() and clear_infoframe() callbacks
return -EOPNOTSUPP for unsupported InfoFrames and make sure that
atomic_check() callback doesn't allow unsupported InfoFrames to be
enabled.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/gpu/drm/rockchip/inno_hdmi.c | 46 +++++++++++++++++++++++++++---------
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index f24827dc1421cf5e0c1be63a80da23d645cf3f24..dc2d68b9c87f7ae7b06ecbeaebc82b9689c1abfd 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -641,11 +641,8 @@ static int inno_hdmi_disable_frame(struct drm_connector *connector,
 {
 	struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector);
 
-	if (type != HDMI_INFOFRAME_TYPE_AVI) {
-		drm_err(connector->dev,
-			"Unsupported infoframe type: %u\n", type);
-		return 0;
-	}
+	if (type != HDMI_INFOFRAME_TYPE_AVI)
+		return -EOPNOTSUPP;
 
 	hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_BUF_INDEX, INFOFRAME_AVI);
 
@@ -659,11 +656,8 @@ static int inno_hdmi_upload_frame(struct drm_connector *connector,
 	struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector);
 	ssize_t i;
 
-	if (type != HDMI_INFOFRAME_TYPE_AVI) {
-		drm_err(connector->dev,
-			"Unsupported infoframe type: %u\n", type);
-		return 0;
-	}
+	if (type != HDMI_INFOFRAME_TYPE_AVI)
+		return -EOPNOTSUPP;
 
 	inno_hdmi_disable_frame(connector, type);
 
@@ -673,6 +667,36 @@ static int inno_hdmi_upload_frame(struct drm_connector *connector,
 	return 0;
 }
 
+static int inno_hdmi_connector_atomic_check(struct drm_connector *connector,
+					    struct drm_atomic_state *state)
+{
+	struct drm_connector_state *conn_state =
+		drm_atomic_get_new_connector_state(state, connector);
+	int ret;
+
+	ret = drm_atomic_helper_connector_hdmi_check(connector, state);
+	if (ret)
+		return ret;
+
+	/* not supported by the driver */
+	conn_state->hdmi.infoframes.spd.set = false;
+
+	/* FIXME: not supported by the driver */
+	conn_state->hdmi.infoframes.hdmi.set = false;
+
+	/* should not happen, HDR support not enabled */
+	if (drm_WARN_ON_ONCE(connector->dev,
+			     connector->hdmi.infoframes.audio.set))
+		return -EOPNOTSUPP;
+
+	/* should not happen, audio support not enabled */
+	if (drm_WARN_ON_ONCE(connector->dev,
+			     conn_state->hdmi.infoframes.hdr_drm.set))
+		return -EOPNOTSUPP;
+
+	return 0;
+}
+
 static const struct drm_connector_hdmi_funcs inno_hdmi_hdmi_connector_funcs = {
 	.clear_infoframe	= inno_hdmi_disable_frame,
 	.write_infoframe	= inno_hdmi_upload_frame,
@@ -1029,7 +1053,7 @@ static const struct drm_connector_funcs inno_hdmi_connector_funcs = {
 };
 
 static struct drm_connector_helper_funcs inno_hdmi_connector_helper_funcs = {
-	.atomic_check = drm_atomic_helper_connector_hdmi_check,
+	.atomic_check = inno_hdmi_connector_atomic_check,
 	.get_modes = inno_hdmi_connector_get_modes,
 	.mode_valid = inno_hdmi_connector_mode_valid,
 };

-- 
2.47.3
Re: [PATCH 8/9] drm/rockchip: inno-hdmi: handle unsupported InfoFrames
Posted by Diederik de Haas 4 days, 12 hours ago
On Sat Sep 27, 2025 at 3:04 AM CEST, Dmitry Baryshkov wrote:
> Make write_hdmi_infoframe() and clear_infoframe() callbacks
> return -EOPNOTSUPP for unsupported InfoFrames and make sure that
> atomic_check() callback doesn't allow unsupported InfoFrames to be
> enabled.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---
>  drivers/gpu/drm/rockchip/inno_hdmi.c | 46 +++++++++++++++++++++++++++---------
>  1 file changed, 35 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
> index f24827dc1421cf5e0c1be63a80da23d645cf3f24..dc2d68b9c87f7ae7b06ecbeaebc82b9689c1abfd 100644
> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c
> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
> @@ -641,11 +641,8 @@ static int inno_hdmi_disable_frame(struct drm_connector *connector,
>  {
>  	struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector);
>  
> -	if (type != HDMI_INFOFRAME_TYPE_AVI) {
> -		drm_err(connector->dev,
> -			"Unsupported infoframe type: %u\n", type);
> -		return 0;
> -	}
> +	if (type != HDMI_INFOFRAME_TYPE_AVI)
> +		return -EOPNOTSUPP;
>  
>  	hdmi_writeb(hdmi, HDMI_CONTROL_PACKET_BUF_INDEX, INFOFRAME_AVI);
>  
> @@ -659,11 +656,8 @@ static int inno_hdmi_upload_frame(struct drm_connector *connector,
>  	struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector);
>  	ssize_t i;
>  
> -	if (type != HDMI_INFOFRAME_TYPE_AVI) {
> -		drm_err(connector->dev,
> -			"Unsupported infoframe type: %u\n", type);
> -		return 0;
> -	}
> +	if (type != HDMI_INFOFRAME_TYPE_AVI)
> +		return -EOPNOTSUPP;
>  
>  	inno_hdmi_disable_frame(connector, type);
>  
> @@ -673,6 +667,36 @@ static int inno_hdmi_upload_frame(struct drm_connector *connector,
>  	return 0;
>  }
>  
> +static int inno_hdmi_connector_atomic_check(struct drm_connector *connector,
> +					    struct drm_atomic_state *state)
> +{
> +	struct drm_connector_state *conn_state =
> +		drm_atomic_get_new_connector_state(state, connector);
> +	int ret;
> +
> +	ret = drm_atomic_helper_connector_hdmi_check(connector, state);
> +	if (ret)
> +		return ret;
> +
> +	/* not supported by the driver */
> +	conn_state->hdmi.infoframes.spd.set = false;
> +
> +	/* FIXME: not supported by the driver */
> +	conn_state->hdmi.infoframes.hdmi.set = false;
> +
> +	/* should not happen, HDR support not enabled */
> +	if (drm_WARN_ON_ONCE(connector->dev,
> +			     connector->hdmi.infoframes.audio.set))
> +		return -EOPNOTSUPP;
> +
> +	/* should not happen, audio support not enabled */
> +	if (drm_WARN_ON_ONCE(connector->dev,
> +			     conn_state->hdmi.infoframes.hdr_drm.set))
> +		return -EOPNOTSUPP;

Looks like the comments are on the wrong line? Also in patch 7.

Cheers,
  Diederik

> +
> +	return 0;
> +}
> +
>  static const struct drm_connector_hdmi_funcs inno_hdmi_hdmi_connector_funcs = {
>  	.clear_infoframe	= inno_hdmi_disable_frame,
>  	.write_infoframe	= inno_hdmi_upload_frame,
> @@ -1029,7 +1053,7 @@ static const struct drm_connector_funcs inno_hdmi_connector_funcs = {
>  };
>  
>  static struct drm_connector_helper_funcs inno_hdmi_connector_helper_funcs = {
> -	.atomic_check = drm_atomic_helper_connector_hdmi_check,
> +	.atomic_check = inno_hdmi_connector_atomic_check,
>  	.get_modes = inno_hdmi_connector_get_modes,
>  	.mode_valid = inno_hdmi_connector_mode_valid,
>  };