Skip to contentSkip to conversation

drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

PATCH In review Wayne Lin 3 participants 7 messages Sep 24, 2019 – Oct 14, 2019 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Wayne Lin

author
#0 lore raw

PATCH 1/1 drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be corrected. The same situation occurs in drm_hdmi_vendor_infoframe_from_display_mode and should set HDMI_VIC when the mode is one defined in HDMI 1.4b 4K modes.

---
 drivers/gpu/drm/drm_edid.c | 95 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_edid.c +92 -3
index 649cfd8b4200..0fea9bf4ec67 100644
@@ -1306,6 +1306,37 @@ static const struct drm_display_mode edid_4k_modes[] = {
 	  .vrefresh = 24, },
 };
 
+/*
+ * 4k modes of HDMI 1.4 defined in HDMI 2.0. Index using the VIC.
+ */
+static const struct drm_display_mode hdmi_1_4_edid_4k_modes[] = {
+	/* 0 - dummy, VICs start at 1 */
+	{ },
+	/* 1 - 3840x2160@30Hz */
+	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   3840, 4016, 4104, 4400, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	/* 2 - 3840x2160@25Hz */
+	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   3840, 4896, 4984, 5280, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	/* 3 - 3840x2160@24Hz */
+	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   3840, 5116, 5204, 5500, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	/* 4 - 4096x2160@24Hz (SMPTE) */
+	{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   4096, 5116, 5204, 5500, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
+};
 /*** DDC fetch and block validation ***/
 
 static const u8 edid_header[] = {
@@ -3061,6 +3092,19 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
 	return cea_mode_alternate_clock(hdmi_mode);
 }
 
+/*
+ * Calculate the alternate clock for HDMI modes (those from the HDMI vendor
+ * specific block).
+ *
+ * It's almost like hdmi_mode_alternate_clock(), but no exception for VIC 4 mode.
+ * There is an alternate clock (23.98Hz) of VIC 4 mode (4096x2160@24Hz) in HDMI 2.0
+ */
+static unsigned int
+hdmi_1_4_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
+{
+	return cea_mode_alternate_clock(hdmi_mode);
+}
+
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
 					      unsigned int clock_tolerance)
 {
@@ -3121,11 +3165,53 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
 	return 0;
 }
 
+/*
+ * drm_match_hdmi_1_4_mode - look for a HDMI 1.4 mode matching given mode
+ * @to_match: display mode
+ *
+ * An HDMI mode is one defined in the HDMI vendor specific block.
+ * In HDMI 2.0, only few 4k resolutions with specific aspect ratio should
+ * utilize H14b VSIF.
+ *
+ * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one.
+ */
+static u8 drm_match_hdmi_1_4_mode(const struct drm_display_mode *to_match)
+{
+	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
+	u8 vic;
+
+	if (!to_match->clock)
+		return 0;
+
+	if (to_match->picture_aspect_ratio)
+		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
+
+	for (vic = 1; vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes); vic++) {
+		const struct drm_display_mode *hdmi_1_4_mode = &hdmi_1_4_edid_4k_modes[vic];
+		unsigned int clock1, clock2;
+
+		/* Make sure to also match alternate clocks */
+		clock1 = hdmi_1_4_mode->clock;
+		clock2 = hdmi_1_4_mode_alternate_clock(hdmi_1_4_mode);
+
+		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
+		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
+		    drm_mode_match(to_match, hdmi_1_4_mode, match_flags))
+			return vic;
+	}
+	return 0;
+}
+
 static bool drm_valid_hdmi_vic(u8 vic)
 {
 	return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes);
 }
 
+static bool drm_valid_hdmi_1_4_vic(u8 vic)
+{
+	return vic > 0 && vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes);
+}
+
 static int
 add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
@@ -4894,10 +4980,12 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 	 * HDMI 1.4b 4K modes
 	 */
 	if (frame->video_code) {
-		u8 vendor_if_vic = drm_match_hdmi_mode(mode);
+		u8 vendor_if_vic = is_hdmi2_sink(connector) ?
+			drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
 		bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
-		if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
+		if (!is_s3d && is_hdmi2_sink(connector) ?
+			drm_valid_hdmi_1_4_vic(vendor_if_vic) : drm_valid_hdmi_vic(vendor_if_vic))
 			frame->video_code = 0;
 	}
 
@@ -5125,7 +5213,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 	if (!has_hdmi_infoframe)
 		return -EINVAL;
 
-	vic = drm_match_hdmi_mode(mode);
+	vic = is_hdmi2_sink(connector) ?
+			drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
 	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
 	/*
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 8 lines · Wayne Lin

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.

Quoted 5 lines

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be corrected.

Where is that being done? We only set the AVI VIC to zero if we're going to use the HDMI VIC instead.

Quoted 3 lines

The same situation occurs in drm_hdmi_vendor_infoframe_from_display_mode and should set HDMI_VIC when the mode is one defined in HDMI 1.4b 4K modes.

Yes, and we do that. "vic = drm_match_hdmi_mode(mode);"

Apart from adding the aspect ratios I don't really understand what you're trying to achieve here.

Quoted 152 lines
---
 drivers/gpu/drm/drm_edid.c | 95 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_edid.c +92 -3
index 649cfd8b4200..0fea9bf4ec67 100644
@@ -1306,6 +1306,37 @@ static const struct drm_display_mode edid_4k_modes[] = {
 	  .vrefresh = 24, },
 };
 
+/*
+ * 4k modes of HDMI 1.4 defined in HDMI 2.0. Index using the VIC.
+ */
+static const struct drm_display_mode hdmi_1_4_edid_4k_modes[] = {
+	/* 0 - dummy, VICs start at 1 */
+	{ },
+	/* 1 - 3840x2160@30Hz */
+	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   3840, 4016, 4104, 4400, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	/* 2 - 3840x2160@25Hz */
+	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   3840, 4896, 4984, 5280, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	/* 3 - 3840x2160@24Hz */
+	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   3840, 5116, 5204, 5500, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	/* 4 - 4096x2160@24Hz (SMPTE) */
+	{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,
+		   4096, 5116, 5204, 5500, 0,
+		   2160, 2168, 2178, 2250, 0,
+		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+	  .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
+};
 /*** DDC fetch and block validation ***/
 
 static const u8 edid_header[] = {
@@ -3061,6 +3092,19 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
 	return cea_mode_alternate_clock(hdmi_mode);
 }
 
+/*
+ * Calculate the alternate clock for HDMI modes (those from the HDMI vendor
+ * specific block).
+ *
+ * It's almost like hdmi_mode_alternate_clock(), but no exception for VIC 4 mode.
+ * There is an alternate clock (23.98Hz) of VIC 4 mode (4096x2160@24Hz) in HDMI 2.0
+ */
+static unsigned int
+hdmi_1_4_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
+{
+	return cea_mode_alternate_clock(hdmi_mode);
+}
+
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
 					      unsigned int clock_tolerance)
 {
@@ -3121,11 +3165,53 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
 	return 0;
 }
 
+/*
+ * drm_match_hdmi_1_4_mode - look for a HDMI 1.4 mode matching given mode
+ * @to_match: display mode
+ *
+ * An HDMI mode is one defined in the HDMI vendor specific block.
+ * In HDMI 2.0, only few 4k resolutions with specific aspect ratio should
+ * utilize H14b VSIF.
+ *
+ * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one.
+ */
+static u8 drm_match_hdmi_1_4_mode(const struct drm_display_mode *to_match)
+{
+	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
+	u8 vic;
+
+	if (!to_match->clock)
+		return 0;
+
+	if (to_match->picture_aspect_ratio)
+		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
+
+	for (vic = 1; vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes); vic++) {
+		const struct drm_display_mode *hdmi_1_4_mode = &hdmi_1_4_edid_4k_modes[vic];
+		unsigned int clock1, clock2;
+
+		/* Make sure to also match alternate clocks */
+		clock1 = hdmi_1_4_mode->clock;
+		clock2 = hdmi_1_4_mode_alternate_clock(hdmi_1_4_mode);
+
+		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
+		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
+		    drm_mode_match(to_match, hdmi_1_4_mode, match_flags))
+			return vic;
+	}
+	return 0;
+}
+
 static bool drm_valid_hdmi_vic(u8 vic)
 {
 	return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes);
 }
 
+static bool drm_valid_hdmi_1_4_vic(u8 vic)
+{
+	return vic > 0 && vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes);
+}
+
 static int
 add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
@@ -4894,10 +4980,12 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 	 * HDMI 1.4b 4K modes
 	 */
 	if (frame->video_code) {
-		u8 vendor_if_vic = drm_match_hdmi_mode(mode);
+		u8 vendor_if_vic = is_hdmi2_sink(connector) ?
+			drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
 		bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
-		if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
+		if (!is_s3d && is_hdmi2_sink(connector) ?
+			drm_valid_hdmi_1_4_vic(vendor_if_vic) : drm_valid_hdmi_vic(vendor_if_vic))
 			frame->video_code = 0;
 	}
 
@@ -5125,7 +5213,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 	if (!has_hdmi_infoframe)
 		return -EINVAL;
 
-	vic = drm_match_hdmi_mode(mode);
+	vic = is_hdmi2_sink(connector) ?
+			drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
 	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
 	/*
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#4 lore raw

________________________________
From: Ville Syrjälä <ville.syrjala-VuQAYsv1563Yd54FQh9/[email protected]>
Sent: Wednesday, October 2, 2019 19:58
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 8 lines · Wayne Lin

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.

Quoted 8 lines

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be corrected.

Where is that being done? We only set the AVI VIC to zero if we're going to use the HDMI VIC instead.

Appreciate for your time and apologize for not explaining it clearly. Current code in drm_hdmi_avi_infoframe_from_display_mode() will call drm_match_hdmi_mode() to set up vendor_if_vic. By checking drm_valid_hdmi_vic(vendor_if_vic) to see if the vic info should be conveyed by avi or not.

But in drm_match_hdmi_mode(), code doesn't enable match_flags with DRM_MODE_MATCH_ASPECT_RATIO. I think it's due to HDMI1.4b doesn't specify
4K mode conveyed by HDMI VIC with particular aspect ratio. But in Appendix E of HDMI 2.0 spec, it specify only 4k modes with particular aspect ratio should use VSIF to convey. Hence, when the sink support HDMI 2.0 and set the mode to be VIC_103, calling drm_match_hdmi_mode(mode) will return vendor_if_vic = 3 (VIC_93 and VIC_103 are having the same timing but different aspect ratio). Thereafter will set the frame->video_code to 0. However, VIC_103 should use AVI VIC according to HDMI 2.0 spec (only VIC: 93, 94, 95 & 98 should use VSIF).

This patch try to revise that, when the sink support HDMI 2.0, drm_match_hdmi_mode() should also take aspect ratio into consideration.
But for easy reading, I add another function "drm_match_hdmi_1_4_mode" to do so.

Quoted 8 lines

The same situation occurs in drm_hdmi_vendor_infoframe_from_display_mode and should set HDMI_VIC when the mode is one defined in HDMI 1.4b 4K modes.

Yes, and we do that. "vic = drm_match_hdmi_mode(mode);"

Apart from adding the aspect ratios I don't really understand what you're trying to achieve here.

For HDMI 2.0 sink, drm_match_hdmi_mode() should also take aspect ratio into consideration. Once again, very appreciate for your time.

Quoted 148 lines
---
 drivers/gpu/drm/drm_edid.c | 95 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_edid.c +92 -4
index 649cfd8b4200..0fea9bf4ec67 100644
@@ -1306,6 +1306,37 @@ static const struct drm_display_mode edid_4k_modes[] = {
         .vrefresh = 24, },
 };
 
+/*
+ * 4k modes of HDMI 1.4 defined in HDMI 2.0. Index using the VIC.
+ */
+static const struct drm_display_mode hdmi_1_4_edid_4k_modes[] = {
+     /* 0 - dummy, VICs start at 1 */
+     { },
+     /* 1 - 3840x2160@30Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 4016, 4104, 4400, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 2 - 3840x2160@25Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 4896, 4984, 5280, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 3 - 3840x2160@24Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 5116, 5204, 5500, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 4 - 4096x2160@24Hz (SMPTE) */
+     { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                4096, 5116, 5204, 5500, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
+};
 /*** DDC fetch and block validation ***/
 
 static const u8 edid_header[] = {
@@ -3061,6 +3092,19 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
       return cea_mode_alternate_clock(hdmi_mode);
 }
 
+/*
+ * Calculate the alternate clock for HDMI modes (those from the HDMI vendor
+ * specific block).
+ *
+ * It's almost like hdmi_mode_alternate_clock(), but no exception for VIC 4 mode.
+ * There is an alternate clock (23.98Hz) of VIC 4 mode (4096x2160@24Hz) in HDMI 2.0
+ */
+static unsigned int
+hdmi_1_4_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
+{
+     return cea_mode_alternate_clock(hdmi_mode);
+}
+
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
                                             unsigned int clock_tolerance)
 {
@@ -3121,11 +3165,53 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
       return 0;
 }
 
+/*
+ * drm_match_hdmi_1_4_mode - look for a HDMI 1.4 mode matching given mode
+ * @to_match: display mode
+ *
+ * An HDMI mode is one defined in the HDMI vendor specific block.
+ * In HDMI 2.0, only few 4k resolutions with specific aspect ratio should
+ * utilize H14b VSIF.
+ *
+ * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one.
+ */
+static u8 drm_match_hdmi_1_4_mode(const struct drm_display_mode *to_match)
+{
+     unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
+     u8 vic;
+
+     if (!to_match->clock)
+             return 0;
+
+     if (to_match->picture_aspect_ratio)
+             match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
+
+     for (vic = 1; vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes); vic++) {
+             const struct drm_display_mode *hdmi_1_4_mode = &hdmi_1_4_edid_4k_modes[vic];
+             unsigned int clock1, clock2;
+
+             /* Make sure to also match alternate clocks */
+             clock1 = hdmi_1_4_mode->clock;
+             clock2 = hdmi_1_4_mode_alternate_clock(hdmi_1_4_mode);
+
+             if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
+                  KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
+                 drm_mode_match(to_match, hdmi_1_4_mode, match_flags))
+                     return vic;
+     }
+     return 0;
+}
+
 static bool drm_valid_hdmi_vic(u8 vic)
 {
       return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes);
 }
 
+static bool drm_valid_hdmi_1_4_vic(u8 vic)
+{
+     return vic > 0 && vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes);
+}
+
 static int
 add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
@@ -4894,10 +4980,12 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
        * HDMI 1.4b 4K modes
        */
       if (frame->video_code) {
-             u8 vendor_if_vic = drm_match_hdmi_mode(mode);
+             u8 vendor_if_vic = is_hdmi2_sink(connector) ?
+                     drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
               bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
-             if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
+             if (!is_s3d && is_hdmi2_sink(connector) ?
+                     drm_valid_hdmi_1_4_vic(vendor_if_vic) : drm_valid_hdmi_vic(vendor_if_vic))
                       frame->video_code = 0;
       }
 
@@ -5125,7 +5213,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
       if (!has_hdmi_infoframe)
               return -EINVAL;
 
-     vic = drm_match_hdmi_mode(mode);
+     vic = is_hdmi2_sink(connector) ?
+                     drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
       s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
       /*
--

2.17.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw
Quoted 43 lines · Wayne

________________________________
From: Ville Syrjälä <[email protected]>
Sent: Wednesday, October 2, 2019 19:58
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 8 lines · Wayne Lin

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.

Quoted 8 lines

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be corrected.

Where is that being done? We only set the AVI VIC to zero if we're going to use the HDMI VIC instead.

Appreciate for your time and apologize for not explaining it clearly. Current code in drm_hdmi_avi_infoframe_from_display_mode() will call drm_match_hdmi_mode() to set up vendor_if_vic. By checking drm_valid_hdmi_vic(vendor_if_vic) to see if the vic info should be conveyed by avi or not.

But in drm_match_hdmi_mode(), code doesn't enable match_flags with DRM_MODE_MATCH_ASPECT_RATIO. I think it's due to HDMI1.4b doesn't specify
4K mode conveyed by HDMI VIC with particular aspect ratio. But in Appendix E of HDMI 2.0 spec, it specify only 4k modes with particular aspect ratio should use VSIF to convey. Hence, when the sink support HDMI 2.0 and set the mode to be VIC_103, calling drm_match_hdmi_mode(mode) will return vendor_if_vic = 3 (VIC_93 and VIC_103 are having the same timing but different aspect ratio). Thereafter will set the frame->video_code to 0. However, VIC_103 should use AVI VIC according to HDMI 2.0 spec (only VIC: 93, 94, 95 & 98 should use VSIF).

Quoted 3 lines

This patch try to revise that, when the sink support HDMI 2.0, drm_match_hdmi_mode() should also take aspect ratio into consideration.
But for easy reading, I add another function "drm_match_hdmi_1_4_mode" to do so.

Seems rather convoluted. I think we should just add the aspect ratios to edid_4k_modes[]. Or is there some problem with that approach?

Quoted 169 lines
Quoted 9 lines

The same situation occurs in drm_hdmi_vendor_infoframe_from_display_mode and should set HDMI_VIC when the mode is one defined in HDMI 1.4b 4K modes.

Yes, and we do that. "vic = drm_match_hdmi_mode(mode);"

Apart from adding the aspect ratios I don't really understand what you're trying to achieve here.

For HDMI 2.0 sink, drm_match_hdmi_mode() should also take aspect ratio into consideration. Once again, very appreciate for your time.

Quoted 148 lines
---
 drivers/gpu/drm/drm_edid.c | 95 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_edid.c +92 -4
index 649cfd8b4200..0fea9bf4ec67 100644
@@ -1306,6 +1306,37 @@ static const struct drm_display_mode edid_4k_modes[] = {
         .vrefresh = 24, },
 };
 
+/*
+ * 4k modes of HDMI 1.4 defined in HDMI 2.0. Index using the VIC.
+ */
+static const struct drm_display_mode hdmi_1_4_edid_4k_modes[] = {
+     /* 0 - dummy, VICs start at 1 */
+     { },
+     /* 1 - 3840x2160@30Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 4016, 4104, 4400, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 2 - 3840x2160@25Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 4896, 4984, 5280, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 3 - 3840x2160@24Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 5116, 5204, 5500, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 4 - 4096x2160@24Hz (SMPTE) */
+     { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                4096, 5116, 5204, 5500, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
+};
 /*** DDC fetch and block validation ***/
 
 static const u8 edid_header[] = {
@@ -3061,6 +3092,19 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
       return cea_mode_alternate_clock(hdmi_mode);
 }
 
+/*
+ * Calculate the alternate clock for HDMI modes (those from the HDMI vendor
+ * specific block).
+ *
+ * It's almost like hdmi_mode_alternate_clock(), but no exception for VIC 4 mode.
+ * There is an alternate clock (23.98Hz) of VIC 4 mode (4096x2160@24Hz) in HDMI 2.0
+ */
+static unsigned int
+hdmi_1_4_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
+{
+     return cea_mode_alternate_clock(hdmi_mode);
+}
+
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
                                             unsigned int clock_tolerance)
 {
@@ -3121,11 +3165,53 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
       return 0;
 }
 
+/*
+ * drm_match_hdmi_1_4_mode - look for a HDMI 1.4 mode matching given mode
+ * @to_match: display mode
+ *
+ * An HDMI mode is one defined in the HDMI vendor specific block.
+ * In HDMI 2.0, only few 4k resolutions with specific aspect ratio should
+ * utilize H14b VSIF.
+ *
+ * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one.
+ */
+static u8 drm_match_hdmi_1_4_mode(const struct drm_display_mode *to_match)
+{
+     unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
+     u8 vic;
+
+     if (!to_match->clock)
+             return 0;
+
+     if (to_match->picture_aspect_ratio)
+             match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
+
+     for (vic = 1; vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes); vic++) {
+             const struct drm_display_mode *hdmi_1_4_mode = &hdmi_1_4_edid_4k_modes[vic];
+             unsigned int clock1, clock2;
+
+             /* Make sure to also match alternate clocks */
+             clock1 = hdmi_1_4_mode->clock;
+             clock2 = hdmi_1_4_mode_alternate_clock(hdmi_1_4_mode);
+
+             if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
+                  KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
+                 drm_mode_match(to_match, hdmi_1_4_mode, match_flags))
+                     return vic;
+     }
+     return 0;
+}
+
 static bool drm_valid_hdmi_vic(u8 vic)
 {
       return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes);
 }
 
+static bool drm_valid_hdmi_1_4_vic(u8 vic)
+{
+     return vic > 0 && vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes);
+}
+
 static int
 add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
@@ -4894,10 +4980,12 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
        * HDMI 1.4b 4K modes
        */
       if (frame->video_code) {
-             u8 vendor_if_vic = drm_match_hdmi_mode(mode);
+             u8 vendor_if_vic = is_hdmi2_sink(connector) ?
+                     drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
               bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
-             if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
+             if (!is_s3d && is_hdmi2_sink(connector) ?
+                     drm_valid_hdmi_1_4_vic(vendor_if_vic) : drm_valid_hdmi_vic(vendor_if_vic))
                       frame->video_code = 0;
       }
 
@@ -5125,7 +5213,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
       if (!has_hdmi_infoframe)
               return -EINVAL;
 
-     vic = drm_match_hdmi_mode(mode);
+     vic = is_hdmi2_sink(connector) ?
+                     drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
       s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
       /*
--

2.17.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#7 lore raw

________________________________
From: Ville Syrjälä <ville.syrjala-VuQAYsv1563Yd54FQh9/[email protected]>
Sent: Thursday, October 3, 2019 21:29
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 43 lines · Wayne

________________________________
From: Ville Syrjälä <ville.syrjala-VuQAYsv1563Yd54FQh9/[email protected]>
Sent: Wednesday, October 2, 2019 19:58
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 8 lines · Wayne Lin

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.

Quoted 8 lines

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be corrected.

Where is that being done? We only set the AVI VIC to zero if we're going to use the HDMI VIC instead.

Appreciate for your time and apologize for not explaining it clearly. Current code in drm_hdmi_avi_infoframe_from_display_mode() will call drm_match_hdmi_mode() to set up vendor_if_vic. By checking drm_valid_hdmi_vic(vendor_if_vic) to see if the vic info should be conveyed by avi or not.

But in drm_match_hdmi_mode(), code doesn't enable match_flags with DRM_MODE_MATCH_ASPECT_RATIO. I think it's due to HDMI1.4b doesn't specify
4K mode conveyed by HDMI VIC with particular aspect ratio. But in Appendix E of HDMI 2.0 spec, it specify only 4k modes with particular aspect ratio should use VSIF to convey. Hence, when the sink support HDMI 2.0 and set the mode to be VIC_103, calling drm_match_hdmi_mode(mode) will return vendor_if_vic = 3 (VIC_93 and VIC_103 are having the same timing but different aspect ratio). Thereafter will set the frame->video_code to 0. However, VIC_103 should use AVI VIC according to HDMI 2.0 spec (only VIC: 93, 94, 95 & 98 should use VSIF).

Quoted 6 lines

This patch try to revise that, when the sink support HDMI 2.0, drm_match_hdmi_mode() should also take aspect ratio into consideration.
But for easy reading, I add another function "drm_match_hdmi_1_4_mode" to do so.

Seems rather convoluted. I think we should just add the aspect ratios to edid_4k_modes[]. Or is there some problem with that approach?

Thanks for your time.

Since HDMI 1.4b doesn't require edid_4k_modes[] with specific aspect ratio, modes as the same timing in edid_4k_modes[] but with different aspect ratios are also expected to convey VIC by VSIF to HDMI 1.4 sink. Might can't guarantee that there wont't be any compatibility side effect with that approach when the sink is HDMI 1.4b .

Quoted 170 lines
Quoted 9 lines

The same situation occurs in drm_hdmi_vendor_infoframe_from_display_mode and should set HDMI_VIC when the mode is one defined in HDMI 1.4b 4K modes.

Yes, and we do that. "vic = drm_match_hdmi_mode(mode);"

Apart from adding the aspect ratios I don't really understand what you're trying to achieve here.

For HDMI 2.0 sink, drm_match_hdmi_mode() should also take aspect ratio into consideration. Once again, very appreciate for your time.

Quoted 148 lines
---
 drivers/gpu/drm/drm_edid.c | 95 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_edid.c +92 -4
index 649cfd8b4200..0fea9bf4ec67 100644
@@ -1306,6 +1306,37 @@ static const struct drm_display_mode edid_4k_modes[] = {
         .vrefresh = 24, },
 };
 
+/*
+ * 4k modes of HDMI 1.4 defined in HDMI 2.0. Index using the VIC.
+ */
+static const struct drm_display_mode hdmi_1_4_edid_4k_modes[] = {
+     /* 0 - dummy, VICs start at 1 */
+     { },
+     /* 1 - 3840x2160@30Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 4016, 4104, 4400, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 2 - 3840x2160@25Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 4896, 4984, 5280, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 3 - 3840x2160@24Hz */
+     { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                3840, 5116, 5204, 5500, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+     /* 4 - 4096x2160@24Hz (SMPTE) */
+     { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,
+                4096, 5116, 5204, 5500, 0,
+                2160, 2168, 2178, 2250, 0,
+                DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
+       .vrefresh = 24, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
+};
 /*** DDC fetch and block validation ***/
 
 static const u8 edid_header[] = {
@@ -3061,6 +3092,19 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
       return cea_mode_alternate_clock(hdmi_mode);
 }
 
+/*
+ * Calculate the alternate clock for HDMI modes (those from the HDMI vendor
+ * specific block).
+ *
+ * It's almost like hdmi_mode_alternate_clock(), but no exception for VIC 4 mode.
+ * There is an alternate clock (23.98Hz) of VIC 4 mode (4096x2160@24Hz) in HDMI 2.0
+ */
+static unsigned int
+hdmi_1_4_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
+{
+     return cea_mode_alternate_clock(hdmi_mode);
+}
+
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
                                             unsigned int clock_tolerance)
 {
@@ -3121,11 +3165,53 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
       return 0;
 }
 
+/*
+ * drm_match_hdmi_1_4_mode - look for a HDMI 1.4 mode matching given mode
+ * @to_match: display mode
+ *
+ * An HDMI mode is one defined in the HDMI vendor specific block.
+ * In HDMI 2.0, only few 4k resolutions with specific aspect ratio should
+ * utilize H14b VSIF.
+ *
+ * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one.
+ */
+static u8 drm_match_hdmi_1_4_mode(const struct drm_display_mode *to_match)
+{
+     unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
+     u8 vic;
+
+     if (!to_match->clock)
+             return 0;
+
+     if (to_match->picture_aspect_ratio)
+             match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
+
+     for (vic = 1; vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes); vic++) {
+             const struct drm_display_mode *hdmi_1_4_mode = &hdmi_1_4_edid_4k_modes[vic];
+             unsigned int clock1, clock2;
+
+             /* Make sure to also match alternate clocks */
+             clock1 = hdmi_1_4_mode->clock;
+             clock2 = hdmi_1_4_mode_alternate_clock(hdmi_1_4_mode);
+
+             if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
+                  KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
+                 drm_mode_match(to_match, hdmi_1_4_mode, match_flags))
+                     return vic;
+     }
+     return 0;
+}
+
 static bool drm_valid_hdmi_vic(u8 vic)
 {
       return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes);
 }
 
+static bool drm_valid_hdmi_1_4_vic(u8 vic)
+{
+     return vic > 0 && vic < ARRAY_SIZE(hdmi_1_4_edid_4k_modes);
+}
+
 static int
 add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
 {
@@ -4894,10 +4980,12 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
        * HDMI 1.4b 4K modes
        */
       if (frame->video_code) {
-             u8 vendor_if_vic = drm_match_hdmi_mode(mode);
+             u8 vendor_if_vic = is_hdmi2_sink(connector) ?
+                     drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
               bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
-             if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
+             if (!is_s3d && is_hdmi2_sink(connector) ?
+                     drm_valid_hdmi_1_4_vic(vendor_if_vic) : drm_valid_hdmi_vic(vendor_if_vic))
                       frame->video_code = 0;
       }
 
@@ -5125,7 +5213,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
       if (!has_hdmi_infoframe)
               return -EINVAL;
 
-     vic = drm_match_hdmi_mode(mode);
+     vic = is_hdmi2_sink(connector) ?
+                     drm_match_hdmi_1_4_mode(mode) : drm_match_hdmi_mode(mode);
       s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
       /*
--

2.17.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel

Quoted 3 lines

--
Ville Syrjälä
Intel

--
Best regards,
Wayne Lin

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#8 lore raw
Quoted 60 lines · Wayne

________________________________
From: Ville Syrjälä <[email protected]>
Sent: Thursday, October 3, 2019 21:29
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 43 lines · Wayne

________________________________
From: Ville Syrjälä <[email protected]>
Sent: Wednesday, October 2, 2019 19:58
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 8 lines · Wayne Lin

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K modes. Otherwise, use AVI infoframes to convey VIC.

Quoted 8 lines

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be corrected.

Where is that being done? We only set the AVI VIC to zero if we're going to use the HDMI VIC instead.

Appreciate for your time and apologize for not explaining it clearly. Current code in drm_hdmi_avi_infoframe_from_display_mode() will call drm_match_hdmi_mode() to set up vendor_if_vic. By checking drm_valid_hdmi_vic(vendor_if_vic) to see if the vic info should be conveyed by avi or not.

But in drm_match_hdmi_mode(), code doesn't enable match_flags with DRM_MODE_MATCH_ASPECT_RATIO. I think it's due to HDMI1.4b doesn't specify
4K mode conveyed by HDMI VIC with particular aspect ratio. But in Appendix E of HDMI 2.0 spec, it specify only 4k modes with particular aspect ratio should use VSIF to convey. Hence, when the sink support HDMI 2.0 and set the mode to be VIC_103, calling drm_match_hdmi_mode(mode) will return vendor_if_vic = 3 (VIC_93 and VIC_103 are having the same timing but different aspect ratio). Thereafter will set the frame->video_code to 0. However, VIC_103 should use AVI VIC according to HDMI 2.0 spec (only VIC: 93, 94, 95 & 98 should use VSIF).

Quoted 6 lines

This patch try to revise that, when the sink support HDMI 2.0, drm_match_hdmi_mode() should also take aspect ratio into consideration.
But for easy reading, I add another function "drm_match_hdmi_1_4_mode" to do so.

Seems rather convoluted. I think we should just add the aspect ratios to edid_4k_modes[]. Or is there some problem with that approach?

Quoted 6 lines

Thanks for your time.

Since HDMI 1.4b doesn't require edid_4k_modes[] with specific aspect ratio, modes as the same timing in edid_4k_modes[] but with different aspect ratios are also expected to convey VIC by VSIF to HDMI 1.4 sink. Might can't guarantee that there wont't be any compatibility side effect with that approach when the sink is HDMI 1.4b .

I think adding them should be fine. But while checking the existing code I noticed a few problems, so I sent out some fixes (cc:d you).

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#10 lore raw
Quoted 91 lines

-----Original Message-----
From: Ville Syrjälä <[email protected]>
Sent: Friday, October 4, 2019 10:24 PM
To: Lin, Wayne <[email protected]>
Cc: [email protected]; [email protected]; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 13 lines · Wayne

________________________________
From: Ville Syrjälä <[email protected]>
Sent: Thursday, October 3, 2019 21:29
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 22 lines
Quoted 21 lines · Wayne

________________________________
From: Ville Syrjälä <[email protected]>
Sent: Wednesday, October 2, 2019 19:58
To: Lin, Wayne <[email protected]>
Cc: [email protected] <[email protected]>; [email protected] <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Kazlauskas, Nicholas <[email protected]>
Subject: Re: [PATCH] drm/drm_edid: correct VIC and HDMI_VIC under HDMI 2.0

Quoted 6 lines · Wayne Lin

In HDMI 1.4 defines 4k modes without specific aspect ratio. However, in HDMI 2.0, adds aspect ratio attribute to distinguish different 4k modes.

According to Appendix E of HDMI 2.0 spec, source should use VSIF to indicate VIC mode only when the mode is one defined in HDMI 1.4b 4K

modes.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Otherwise, use AVI infoframes to convey VIC.

eg: VIC_103 should use AVI infoframes and VIC_93 use VSIF

When the sink is HDMI 2.0, current code in drm_hdmi_avi_infoframe_from_display_mode will also force mode VIC_103 to have VIC value 0. This violates the spec and needs to be

corrected.

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

Where is that being done? We only set the AVI VIC to zero if we're going to use the HDMI VIC instead.

Appreciate for your time and apologize for not explaining it clearly. Current code in drm_hdmi_avi_infoframe_from_display_mode() will call drm_match_hdmi_mode() to set up vendor_if_vic. By checking drm_valid_hdmi_vic(vendor_if_vic) to see if the vic info should be conveyed by avi or not.

Quoted 4 lines
Quoted 4 lines

But in drm_match_hdmi_mode(), code doesn't enable match_flags with DRM_MODE_MATCH_ASPECT_RATIO. I think it's due to HDMI1.4b doesn't specify 4K mode conveyed by HDMI VIC with particular aspect ratio. But in Appendix E of HDMI 2.0 spec, it specify only 4k modes with

particular aspect ratio should use VSIF to convey.

Quoted 4 lines
Quoted 4 lines

Hence, when the sink support HDMI 2.0 and set the mode to be VIC_103, calling
drm_match_hdmi_mode(mode) will return vendor_if_vic = 3 (VIC_93 and VIC_103 are having the same timing but different aspect ratio). Thereafter

will set the frame->video_code to 0.

Quoted 7 lines
Quoted 7 lines

However, VIC_103 should use AVI VIC according to HDMI 2.0 spec (only
VIC: 93, 94, 95 &
98 should use VSIF).

This patch try to revise that, when the sink support HDMI 2.0, drm_match_hdmi_mode() should also take aspect ratio into consideration. But for easy reading, I add another function

"drm_match_hdmi_1_4_mode" to do so.

Quoted 6 lines
Quoted 3 lines

Seems rather convoluted. I think we should just add the aspect ratios to edid_4k_modes[]. Or is there some problem with that approach?

Thanks for your time.

Quoted 8 lines
Quoted 4 lines

Since HDMI 1.4b doesn't require edid_4k_modes[] with specific aspect ratio, modes as the same timing in edid_4k_modes[] but with different aspect ratios are also expected to convey VIC by VSIF to HDMI 1.4 sink. Might can't guarantee that there wont't be any compatibility side effect

with that approach when the sink is HDMI 1.4b .

I think adding them should be fine. But while checking the existing code I noticed a few problems, so I sent out some fixes (cc:d you).

Thanks for your time and sorry for late reply.
I will try out those received fixes and leave messages there.

Quoted 4 lines

--
Ville Syrjälä
Intel

--
Wayne Lin
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx