diff mbox series

drm/edid: ignore the CEA modes not defined in CEA-861-D

Message ID 20220531101322.26757-1-william.tseng@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/edid: ignore the CEA modes not defined in CEA-861-D | expand

Commit Message

William Tseng May 31, 2022, 10:13 a.m. UTC
This is a workaround for HDMI 1.4 sink which has a CEA mode with higher vic
than what is defined in CEA-861-D.

As an example, a HDMI 1.4 sink has the video format 2560x1080p to be
displayed and the video format is indicated by both SVD (with vic 90 and
pictuure aspect ratio 64:27) and DTD.  When connecting to such sink,
source can't output the video format in SVD because an error is returned by
drm_hdmi_avi_infoframe_from_display_mode(), which can't fill the infoframe
with pictuure aspect ratio 64:27 and the vic, which is originally 90 and is
changed to 0 by drm_mode_cea_vic().

To work around it, this patch ignores such CEA modes in do_cea_modes() so
the modes won't be processed in drm_hdmi_avi_infoframe_from_display_mode().
And only the video format in DTD can be dispalyed.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Wayne Lin <waynelin@amd.com>
Cc: Lee Shawn C <shawn.c.lee@intel.com>
Signed-off-by: William Tseng <william.tseng@intel.com>
---
 drivers/gpu/drm/drm_edid.c | 39 +++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

Comments

Andrzej Hajda May 31, 2022, 3 p.m. UTC | #1
On 31.05.2022 12:13, William Tseng wrote:
> This is a workaround for HDMI 1.4 sink which has a CEA mode with higher vic
> than what is defined in CEA-861-D.
> 
> As an example, a HDMI 1.4 sink has the video format 2560x1080p to be
> displayed and the video format is indicated by both SVD (with vic 90 and
> pictuure aspect ratio 64:27) and DTD.  When connecting to such sink,
> source can't output the video format in SVD because an error is returned by
> drm_hdmi_avi_infoframe_from_display_mode(), which can't fill the infoframe
> with pictuure aspect ratio 64:27 and the vic, which is originally 90 and is
> changed to 0 by drm_mode_cea_vic().
> 
> To work around it, this patch ignores such CEA modes in do_cea_modes() so
> the modes won't be processed in drm_hdmi_avi_infoframe_from_display_mode().
> And only the video format in DTD can be dispalyed.
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Wayne Lin <waynelin@amd.com>
> Cc: Lee Shawn C <shawn.c.lee@intel.com>
> Signed-off-by: William Tseng <william.tseng@intel.com>
> ---
>   drivers/gpu/drm/drm_edid.c | 39 +++++++++++++++++++++++++-------------
>   1 file changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index bc43e1b32092..a93f68878bfd 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3982,6 +3982,19 @@ drm_display_mode_from_cea_vic(struct drm_device *dev,
>   }
>   EXPORT_SYMBOL(drm_display_mode_from_cea_vic);
>   
> +static bool is_hdmi2_sink(const struct drm_connector *connector)
> +{
> +	/*
> +	 * FIXME: sil-sii8620 doesn't have a connector around when
> +	 * we need one, so we have to be prepared for a NULL connector.
> +	 */
> +	if (!connector)
> +		return true;
> +
> +	return connector->display_info.hdmi.scdc.supported ||
> +		connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420;
> +}
> +
>   static int
>   do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len)
>   {
> @@ -3993,6 +4006,19 @@ do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len)
>   
>   		mode = drm_display_mode_from_vic_index(connector, db, len, i);
>   		if (mode) {
> +			u8 vic = svd_to_vic(db[i]);
> +
> +			if (!drm_valid_cea_vic(vic))
> +				continue;

It duplicates check from drm_display_mode_from_vic_index

> +
> +			/*
> +			 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
> +			 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
> +			 * have to make sure we dont break HDMI 1.4 sinks.
> +			 */
> +			if (!is_hdmi2_sink(connector) && vic > 64)
> +				continue;

So maybe adding this check to drm_display_mode_from_vic_index would be 
enough?

Regards
Andrzej

> +
>   			/*
>   			 * YCBCR420 capability block contains a bitmap which
>   			 * gives the index of CEA modes from CEA VDB, which
> @@ -5846,19 +5872,6 @@ void drm_set_preferred_mode(struct drm_connector *connector,
>   }
>   EXPORT_SYMBOL(drm_set_preferred_mode);
>   
> -static bool is_hdmi2_sink(const struct drm_connector *connector)
> -{
> -	/*
> -	 * FIXME: sil-sii8620 doesn't have a connector around when
> -	 * we need one, so we have to be prepared for a NULL connector.
> -	 */
> -	if (!connector)
> -		return true;
> -
> -	return connector->display_info.hdmi.scdc.supported ||
> -		connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420;
> -}
> -
>   static u8 drm_mode_hdmi_vic(const struct drm_connector *connector,
>   			    const struct drm_display_mode *mode)
>   {
William Tseng June 1, 2022, 10:08 a.m. UTC | #2
Thanks, Andrzej.

Sounds good.  It is better to make drm_display_mode_from_vic_index() return a mode with valid VIC.
So it ends up with that all probed modes have valid VICs for HDMI 1.4 and 2.0 respectively.


Regards
William

-----Original Message-----
From: Hajda, Andrzej <andrzej.hajda@intel.com> 
Sent: Tuesday, May 31, 2022 11:00 PM
To: Tseng, William <william.tseng@intel.com>; intel-gfx@lists.freedesktop.org
Cc: Wayne Lin <waynelin@amd.com>
Subject: Re: [Intel-gfx] [PATCH] drm/edid: ignore the CEA modes not defined in CEA-861-D

On 31.05.2022 12:13, William Tseng wrote:
> This is a workaround for HDMI 1.4 sink which has a CEA mode with 
> higher vic than what is defined in CEA-861-D.
> 
> As an example, a HDMI 1.4 sink has the video format 2560x1080p to be 
> displayed and the video format is indicated by both SVD (with vic 90 
> and pictuure aspect ratio 64:27) and DTD.  When connecting to such 
> sink, source can't output the video format in SVD because an error is 
> returned by drm_hdmi_avi_infoframe_from_display_mode(), which can't 
> fill the infoframe with pictuure aspect ratio 64:27 and the vic, which 
> is originally 90 and is changed to 0 by drm_mode_cea_vic().
> 
> To work around it, this patch ignores such CEA modes in do_cea_modes() 
> so the modes won't be processed in drm_hdmi_avi_infoframe_from_display_mode().
> And only the video format in DTD can be dispalyed.
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Wayne Lin <waynelin@amd.com>
> Cc: Lee Shawn C <shawn.c.lee@intel.com>
> Signed-off-by: William Tseng <william.tseng@intel.com>
> ---
>   drivers/gpu/drm/drm_edid.c | 39 +++++++++++++++++++++++++-------------
>   1 file changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c 
> index bc43e1b32092..a93f68878bfd 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3982,6 +3982,19 @@ drm_display_mode_from_cea_vic(struct drm_device *dev,
>   }
>   EXPORT_SYMBOL(drm_display_mode_from_cea_vic);
>   
> +static bool is_hdmi2_sink(const struct drm_connector *connector) {
> +	/*
> +	 * FIXME: sil-sii8620 doesn't have a connector around when
> +	 * we need one, so we have to be prepared for a NULL connector.
> +	 */
> +	if (!connector)
> +		return true;
> +
> +	return connector->display_info.hdmi.scdc.supported ||
> +		connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420; 
> +}
> +
>   static int
>   do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len)
>   {
> @@ -3993,6 +4006,19 @@ do_cea_modes(struct drm_connector *connector, 
> const u8 *db, u8 len)
>   
>   		mode = drm_display_mode_from_vic_index(connector, db, len, i);
>   		if (mode) {
> +			u8 vic = svd_to_vic(db[i]);
> +
> +			if (!drm_valid_cea_vic(vic))
> +				continue;

It duplicates check from drm_display_mode_from_vic_index

> +
> +			/*
> +			 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
> +			 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
> +			 * have to make sure we dont break HDMI 1.4 sinks.
> +			 */
> +			if (!is_hdmi2_sink(connector) && vic > 64)
> +				continue;

So maybe adding this check to drm_display_mode_from_vic_index would be enough?

Regards
Andrzej

> +
>   			/*
>   			 * YCBCR420 capability block contains a bitmap which
>   			 * gives the index of CEA modes from CEA VDB, which @@ -5846,19 
> +5872,6 @@ void drm_set_preferred_mode(struct drm_connector *connector,
>   }
>   EXPORT_SYMBOL(drm_set_preferred_mode);
>   
> -static bool is_hdmi2_sink(const struct drm_connector *connector) -{
> -	/*
> -	 * FIXME: sil-sii8620 doesn't have a connector around when
> -	 * we need one, so we have to be prepared for a NULL connector.
> -	 */
> -	if (!connector)
> -		return true;
> -
> -	return connector->display_info.hdmi.scdc.supported ||
> -		connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420;
> -}
> -
>   static u8 drm_mode_hdmi_vic(const struct drm_connector *connector,
>   			    const struct drm_display_mode *mode)
>   {
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index bc43e1b32092..a93f68878bfd 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3982,6 +3982,19 @@  drm_display_mode_from_cea_vic(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_display_mode_from_cea_vic);
 
+static bool is_hdmi2_sink(const struct drm_connector *connector)
+{
+	/*
+	 * FIXME: sil-sii8620 doesn't have a connector around when
+	 * we need one, so we have to be prepared for a NULL connector.
+	 */
+	if (!connector)
+		return true;
+
+	return connector->display_info.hdmi.scdc.supported ||
+		connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420;
+}
+
 static int
 do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len)
 {
@@ -3993,6 +4006,19 @@  do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len)
 
 		mode = drm_display_mode_from_vic_index(connector, db, len, i);
 		if (mode) {
+			u8 vic = svd_to_vic(db[i]);
+
+			if (!drm_valid_cea_vic(vic))
+				continue;
+
+			/*
+			 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
+			 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
+			 * have to make sure we dont break HDMI 1.4 sinks.
+			 */
+			if (!is_hdmi2_sink(connector) && vic > 64)
+				continue;
+
 			/*
 			 * YCBCR420 capability block contains a bitmap which
 			 * gives the index of CEA modes from CEA VDB, which
@@ -5846,19 +5872,6 @@  void drm_set_preferred_mode(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_set_preferred_mode);
 
-static bool is_hdmi2_sink(const struct drm_connector *connector)
-{
-	/*
-	 * FIXME: sil-sii8620 doesn't have a connector around when
-	 * we need one, so we have to be prepared for a NULL connector.
-	 */
-	if (!connector)
-		return true;
-
-	return connector->display_info.hdmi.scdc.supported ||
-		connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420;
-}
-
 static u8 drm_mode_hdmi_vic(const struct drm_connector *connector,
 			    const struct drm_display_mode *mode)
 {