All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] drm/edid: Infoframe cleanups and fixes
@ 2017-11-13 17:04 Ville Syrjala
  2017-11-13 17:04   ` Ville Syrjala
                   ` (11 more replies)
  0 siblings, 12 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Akashdeep Sharma, Andrzej Hajda, Daniel Vetter,
	Emil Velikov, Hans Verkuil, Jim Bride, Jose Abreu,
	Laurent Pinchart, Lin, Jia, linux-media, Sean Paul,
	Shashank Sharma, Thierry Reding

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

This series tries to fix some issues with HDMI infoframes. In particular
we can currently send a bogus picture aspect ratio in the infoframe. I
included stuff to to make the infoframe unpakc more robust, evne though
we don't (yet) use it in drm. Additionally I included my earlier "empty"
HDMI infoframe support.

I have further work piled up on top which allows us to precompuet the
infoframes during the atomic check phase. But the series would have
become rather big, so I wanted to post these fixes and cleanups first.

Entire series (with the infoframe precompute) is available here:
git://github.com/vsyrjala/linux.git infoframe_precompute

Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Jim Bride <jim.bride@linux.intel.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "Lin, Jia" <lin.a.jia@intel.com>
Cc: linux-media@vger.kernel.org
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>

Ville Syrjälä (10):
  video/hdmi: Allow "empty" HDMI infoframes
  drm/edid: Allow HDMI infoframe without VIC or S3D
  drm/modes: Introduce drm_mode_match()
  drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy
  drm/edid: Fix up edid_cea_modes[] formatting
  drm/edid: Fix cea mode aspect ratio handling
  drm/edid: Don't send bogus aspect ratios in AVI infoframes
  video/hdmi: Reject illegal picture aspect ratios
  video/hdmi: Constify 'buffer' to the unpack functions
  video/hdmi: Pass buffer size to infoframe unpack functions

 drivers/gpu/drm/bridge/sil-sii8620.c      |   3 +-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |   4 +-
 drivers/gpu/drm/drm_edid.c                | 159 +++++++++++++++++++-----------
 drivers/gpu/drm/drm_modes.c               | 134 +++++++++++++++++++------
 drivers/gpu/drm/exynos/exynos_hdmi.c      |   2 +-
 drivers/gpu/drm/i915/intel_hdmi.c         |  14 +--
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |   3 +-
 drivers/gpu/drm/nouveau/nv50_display.c    |   3 +-
 drivers/gpu/drm/rockchip/inno_hdmi.c      |   1 +
 drivers/gpu/drm/sti/sti_hdmi.c            |   4 +-
 drivers/gpu/drm/zte/zx_hdmi.c             |   1 +
 drivers/media/i2c/adv7511.c               |   2 +-
 drivers/media/i2c/adv7604.c               |   2 +-
 drivers/media/i2c/adv7842.c               |   2 +-
 drivers/media/i2c/tc358743.c              |   2 +-
 drivers/video/hdmi.c                      | 118 ++++++++++++++--------
 include/drm/drm_connector.h               |   5 +
 include/drm/drm_edid.h                    |   1 +
 include/drm/drm_modes.h                   |   9 ++
 include/linux/hdmi.h                      |   3 +-
 20 files changed, 326 insertions(+), 146 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
@ 2017-11-13 17:04   ` Ville Syrjala
  2017-11-13 17:04 ` [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D Ville Syrjala
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Shashank Sharma, Andrzej Hajda, Thierry Reding,
	Hans Verkuil, linux-media

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

HDMI 2.0 Appendix F suggest that we should keep sending the infoframe
when switching from 3D to 2D mode, even if the infoframe isn't strictly
necessary (ie. not needed to transmit the VIC or stereo information).
This is a workaround against some sinks that fail to realize that they
should switch from 3D to 2D mode when the source stop transmitting
the infoframe.

v2: Handle unpack() as well
    Pull the length calculation into a helper

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: linux-media@vger.kernel.org
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> #v1
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/video/hdmi.c | 51 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 1cf907ecded4..111a0ab6280a 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
 }
 EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
 
+static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
+{
+	/* for side by side (half) we also need to provide 3D_Ext_Data */
+	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
+		return 6;
+	else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
+		return 5;
+	else
+		return 4;
+}
+
 /**
  * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
  * @frame: HDMI infoframe
@@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	u8 *ptr = buffer;
 	size_t length;
 
-	/* empty info frame */
-	if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
-		return -EINVAL;
-
 	/* only one of those can be supplied */
 	if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
 		return -EINVAL;
 
-	/* for side by side (half) we also need to provide 3D_Ext_Data */
-	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
-		frame->length = 6;
-	else
-		frame->length = 5;
+	frame->length = hdmi_vendor_infoframe_length(frame);
 
 	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
 
@@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	ptr[5] = 0x0c;
 	ptr[6] = 0x00;
 
-	if (frame->vic) {
-		ptr[7] = 0x1 << 5;	/* video format */
-		ptr[8] = frame->vic;
-	} else {
+	if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
 		ptr[7] = 0x2 << 5;	/* video format */
 		ptr[8] = (frame->s3d_struct & 0xf) << 4;
 		if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
 			ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
+	} else if (frame->vic) {
+		ptr[7] = 0x1 << 5;	/* video format */
+		ptr[8] = frame->vic;
+	} else {
+		ptr[7] = 0x0 << 5;	/* video format */
 	}
 
 	hdmi_infoframe_set_checksum(buffer, length);
@@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
 	    ptr[1] != 1 ||
-	    (ptr[2] != 5 && ptr[2] != 6))
+	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
 		return -EINVAL;
 
 	length = ptr[2];
@@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 
 	hvf->length = length;
 
-	if (hdmi_video_format == 0x1) {
-		hvf->vic = ptr[4];
-	} else if (hdmi_video_format == 0x2) {
+	if (hdmi_video_format == 0x2) {
+		if (length != 5 && length != 6)
+			return -EINVAL;
 		hvf->s3d_struct = ptr[4] >> 4;
 		if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
-			if (length == 6)
-				hvf->s3d_ext_data = ptr[5] >> 4;
-			else
+			if (length != 6)
 				return -EINVAL;
+			hvf->s3d_ext_data = ptr[5] >> 4;
 		}
+	} else if (hdmi_video_format == 0x1) {
+		if (length != 5)
+			return -EINVAL;
+		hvf->vic = ptr[4];
+	} else {
+		if (length != 4)
+			return -EINVAL;
 	}
 
 	return 0;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes
@ 2017-11-13 17:04   ` Ville Syrjala
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Thierry Reding, Hans Verkuil, linux-media

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

HDMI 2.0 Appendix F suggest that we should keep sending the infoframe
when switching from 3D to 2D mode, even if the infoframe isn't strictly
necessary (ie. not needed to transmit the VIC or stereo information).
This is a workaround against some sinks that fail to realize that they
should switch from 3D to 2D mode when the source stop transmitting
the infoframe.

v2: Handle unpack() as well
    Pull the length calculation into a helper

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: linux-media@vger.kernel.org
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> #v1
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/video/hdmi.c | 51 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 1cf907ecded4..111a0ab6280a 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
 }
 EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
 
+static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
+{
+	/* for side by side (half) we also need to provide 3D_Ext_Data */
+	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
+		return 6;
+	else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
+		return 5;
+	else
+		return 4;
+}
+
 /**
  * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
  * @frame: HDMI infoframe
@@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	u8 *ptr = buffer;
 	size_t length;
 
-	/* empty info frame */
-	if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
-		return -EINVAL;
-
 	/* only one of those can be supplied */
 	if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
 		return -EINVAL;
 
-	/* for side by side (half) we also need to provide 3D_Ext_Data */
-	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
-		frame->length = 6;
-	else
-		frame->length = 5;
+	frame->length = hdmi_vendor_infoframe_length(frame);
 
 	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
 
@@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	ptr[5] = 0x0c;
 	ptr[6] = 0x00;
 
-	if (frame->vic) {
-		ptr[7] = 0x1 << 5;	/* video format */
-		ptr[8] = frame->vic;
-	} else {
+	if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
 		ptr[7] = 0x2 << 5;	/* video format */
 		ptr[8] = (frame->s3d_struct & 0xf) << 4;
 		if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
 			ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
+	} else if (frame->vic) {
+		ptr[7] = 0x1 << 5;	/* video format */
+		ptr[8] = frame->vic;
+	} else {
+		ptr[7] = 0x0 << 5;	/* video format */
 	}
 
 	hdmi_infoframe_set_checksum(buffer, length);
@@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
 	    ptr[1] != 1 ||
-	    (ptr[2] != 5 && ptr[2] != 6))
+	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
 		return -EINVAL;
 
 	length = ptr[2];
@@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 
 	hvf->length = length;
 
-	if (hdmi_video_format == 0x1) {
-		hvf->vic = ptr[4];
-	} else if (hdmi_video_format == 0x2) {
+	if (hdmi_video_format == 0x2) {
+		if (length != 5 && length != 6)
+			return -EINVAL;
 		hvf->s3d_struct = ptr[4] >> 4;
 		if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
-			if (length == 6)
-				hvf->s3d_ext_data = ptr[5] >> 4;
-			else
+			if (length != 6)
 				return -EINVAL;
+			hvf->s3d_ext_data = ptr[5] >> 4;
 		}
+	} else if (hdmi_video_format == 0x1) {
+		if (length != 5)
+			return -EINVAL;
+		hvf->vic = ptr[4];
+	} else {
+		if (length != 4)
+			return -EINVAL;
 	}
 
 	return 0;
-- 
2.13.6

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
  2017-11-13 17:04   ` Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-16 14:40   ` Sharma, Shashank
  2017-11-13 17:04 ` [PATCH 03/10] drm/modes: Introduce drm_mode_match() Ville Syrjala
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Laurent Pinchart

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Appedix F of HDMI 2.0 says that some HDMI sink may fail to switch from
3D to 2D mode in a timely fashion if the source simply stops sending the
HDMI infoframe. The suggested workaround is to keep sending the
infoframe even when strictly not necessary (ie. no VIC and no S3D).
HDMI 1.4 does allow for this behaviour, stating that sending the
infoframe is optional in this case.

The infoframe was first specified in HDMI 1.4, so in theory sinks
predating that may not appreciate us sending an uknown infoframe
their way. To avoid regressions let's try to determine if the sink
supports the infoframe or not. Unfortunately there's no direct way
to do that, so instead we'll just check if we managed to parse any
HDMI 1.4 4k or stereo modes from the EDID, and if so we assume the
sink will accept the infoframe. Also if the EDID contains the HDMI
2.0 HDMI Forum VSDB we can assume the sink is prepared to receive
the infoframe.

v2: Fix the getting has_hdmi_infoframe from display_info
    Always fail constructing the infoframe if the display
    possibly can't handle it

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/bridge/sil-sii8620.c      |  3 ++-
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  4 +++-
 drivers/gpu/drm/drm_edid.c                | 34 +++++++++++++++++++++++++------
 drivers/gpu/drm/exynos/exynos_hdmi.c      |  2 +-
 drivers/gpu/drm/i915/intel_hdmi.c         | 14 +++++++------
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |  3 ++-
 drivers/gpu/drm/nouveau/nv50_display.c    |  3 ++-
 drivers/gpu/drm/rockchip/inno_hdmi.c      |  1 +
 drivers/gpu/drm/sti/sti_hdmi.c            |  4 +++-
 drivers/gpu/drm/zte/zx_hdmi.c             |  1 +
 include/drm/drm_connector.h               |  5 +++++
 include/drm/drm_edid.h                    |  1 +
 12 files changed, 57 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
index b7eb704d0a8a..4417276ba02e 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -2220,8 +2220,9 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
 			union hdmi_infoframe frm;
 			u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
 
+			/* FIXME: We need the connector here */
 			drm_hdmi_vendor_infoframe_from_display_mode(
-				&frm.vendor.hdmi, adjusted_mode);
+				&frm.vendor.hdmi, NULL, adjusted_mode);
 			vic = frm.vendor.hdmi.vic;
 			if (vic >= ARRAY_SIZE(mhl_vic))
 				vic = 0;
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index a64ce7112288..b172139502d6 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -1437,7 +1437,9 @@ static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi,
 	u8 buffer[10];
 	ssize_t err;
 
-	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
+	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
+							  &hdmi->connector,
+							  mode);
 	if (err < 0)
 		/*
 		 * Going into that statement does not means vendor infoframe
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 749d07a01772..9ada0ccf50df 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3393,6 +3393,7 @@ static int
 do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
 		   const u8 *video_db, u8 video_len)
 {
+	struct drm_display_info *info = &connector->display_info;
 	int modes = 0, offset = 0, i, multi_present = 0, multi_len;
 	u8 vic_len, hdmi_3d_len = 0;
 	u16 mask;
@@ -3520,6 +3521,8 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
 	}
 
 out:
+	if (modes > 0)
+		info->has_hdmi_infoframe = true;
 	return modes;
 }
 
@@ -4243,6 +4246,8 @@ static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
 	struct drm_display_info *display = &connector->display_info;
 	struct drm_hdmi_info *hdmi = &display->hdmi;
 
+	display->has_hdmi_infoframe = true;
+
 	if (hf_vsdb[6] & 0x80) {
 		hdmi->scdc.supported = true;
 		if (hf_vsdb[6] & 0x40)
@@ -4416,6 +4421,7 @@ static void drm_add_display_info(struct drm_connector *connector,
 	info->cea_rev = 0;
 	info->max_tmds_clock = 0;
 	info->dvi_dual = false;
+	info->has_hdmi_infoframe = false;
 
 	if (edid->revision < 3)
 		return;
@@ -4903,6 +4909,7 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
  * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
  * data from a DRM display mode
  * @frame: HDMI vendor infoframe
+ * @connector: the connector
  * @mode: DRM display mode
  *
  * Note that there's is a need to send HDMI vendor infoframes only when using a
@@ -4913,8 +4920,15 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
  */
 int
 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
+					    struct drm_connector *connector,
 					    const struct drm_display_mode *mode)
 {
+	/*
+	 * FIXME: sil-sii8620 doesn't have a connector around when
+	 * we need one, so we have to be prepared for a NULL connector.
+	 */
+	bool has_hdmi_infoframe = connector ?
+		connector->display_info.has_hdmi_infoframe : false;
 	int err;
 	u32 s3d_flags;
 	u8 vic;
@@ -4922,11 +4936,21 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 	if (!frame || !mode)
 		return -EINVAL;
 
+	if (!has_hdmi_infoframe)
+		return -EINVAL;
+
 	vic = drm_match_hdmi_mode(mode);
 	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
 
-	if (!vic && !s3d_flags)
-		return -EINVAL;
+	/*
+	 * Even if it's not absolutely necessary to send the infoframe
+	 * (ie.vic==0 and s3d_struct==0) we will still send it if we
+	 * know that the sink can handle it. This is based on a
+	 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
+	 * have trouble realizing that they shuld switch from 3D to 2D
+	 * mode if the source simply stops sending the infoframe when
+	 * it wants to switch from 3D to 2D.
+	 */
 
 	if (vic && s3d_flags)
 		return -EINVAL;
@@ -4935,10 +4959,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 	if (err < 0)
 		return err;
 
-	if (vic)
-		frame->vic = vic;
-	else
-		frame->s3d_struct = s3d_structure_from_display_mode(mode);
+	frame->vic = vic;
+	frame->s3d_struct = s3d_structure_from_display_mode(mode);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 0109ff40b1db..812b2773ed69 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -795,7 +795,7 @@ static void hdmi_reg_infoframes(struct hdmi_context *hdata)
 	}
 
 	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi,
-			&hdata->current_mode);
+			&hdata->connector, &hdata->current_mode);
 	if (!ret)
 		ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf,
 				sizeof(buf));
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 2d95db64cdf2..2ccba4ccf7ad 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -512,12 +512,14 @@ static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder,
 
 static void
 intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder,
-			      const struct intel_crtc_state *crtc_state)
+			      const struct intel_crtc_state *crtc_state,
+			      const struct drm_connector_state *conn_state)
 {
 	union hdmi_infoframe frame;
 	int ret;
 
 	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
+							  conn_state->connector,
 							  &crtc_state->base.adjusted_mode);
 	if (ret < 0)
 		return;
@@ -584,7 +586,7 @@ static void g4x_set_infoframes(struct drm_encoder *encoder,
 
 	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
 	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
-	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
+	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
 }
 
 static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state)
@@ -725,7 +727,7 @@ static void ibx_set_infoframes(struct drm_encoder *encoder,
 
 	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
 	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
-	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
+	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
 }
 
 static void cpt_set_infoframes(struct drm_encoder *encoder,
@@ -768,7 +770,7 @@ static void cpt_set_infoframes(struct drm_encoder *encoder,
 
 	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
 	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
-	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
+	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
 }
 
 static void vlv_set_infoframes(struct drm_encoder *encoder,
@@ -821,7 +823,7 @@ static void vlv_set_infoframes(struct drm_encoder *encoder,
 
 	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
 	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
-	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
+	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
 }
 
 static void hsw_set_infoframes(struct drm_encoder *encoder,
@@ -854,7 +856,7 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
 
 	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
 	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
-	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
+	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
 }
 
 void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index b78791061983..59a11026dceb 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1054,7 +1054,8 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
 	u8 buffer[10];
 	ssize_t err;
 
-	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
+	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
+							  &hdmi->conn, mode);
 	if (err) {
 		dev_err(hdmi->dev,
 			"Failed to get vendor infoframe from mode: %zd\n", err);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index b26a506d20ca..9d7b2afd7cfc 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -2754,7 +2754,8 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
 			= hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
 	}
 
-	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi, mode);
+	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
+							  &nv_connector->base, mode);
 	if (!ret) {
 		/* We have a Vendor InfoFrame, populate it to the display */
 		args.pwr.vendor_infoframe_length
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
index ee584d87111f..fab30927a889 100644
--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -282,6 +282,7 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi,
 	int rc;
 
 	rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
+							 &hdmi->connector,
 							 mode);
 
 	return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI,
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index d1902750a85d..c3b292ab17a5 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -515,7 +515,9 @@ static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi)
 
 	DRM_DEBUG_DRIVER("\n");
 
-	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe, mode);
+	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe,
+							  hdmi->drm_connector,
+							  mode);
 	if (ret < 0) {
 		/*
 		 * Going into that statement does not means vendor infoframe
diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
index b8abb1b496ff..13ea90f7a185 100644
--- a/drivers/gpu/drm/zte/zx_hdmi.c
+++ b/drivers/gpu/drm/zte/zx_hdmi.c
@@ -108,6 +108,7 @@ static int zx_hdmi_config_video_vsi(struct zx_hdmi *hdmi,
 	int ret;
 
 	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
+							  &hdmi->connector,
 							  mode);
 	if (ret) {
 		DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n",
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2b97d1e28f60..1543212b0449 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -270,6 +270,11 @@ struct drm_display_info {
 	bool dvi_dual;
 
 	/**
+	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
+	 */
+	bool has_hdmi_infoframe;
+
+	/**
 	 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
 	 * more stuff redundant with @bus_formats.
 	 */
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 9e4e23524840..3c8740ad1db6 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -356,6 +356,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 					 bool is_hdmi2_sink);
 int
 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
+					    struct drm_connector *connector,
 					    const struct drm_display_mode *mode);
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
-- 
2.13.6

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 03/10] drm/modes: Introduce drm_mode_match()
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
  2017-11-13 17:04   ` Ville Syrjala
  2017-11-13 17:04 ` [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 17:04 ` [PATCH 04/10] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Ville Syrjala
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Make mode matching less confusing by allowing the caller to specify
which parts of the modes should match via some flags.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_modes.c | 134 ++++++++++++++++++++++++++++++++++----------
 include/drm/drm_modes.h     |   9 +++
 2 files changed, 112 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 4a3f68a33844..8128dbb098be 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -940,17 +940,68 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_duplicate);
 
+static bool drm_mode_match_timings(const struct drm_display_mode *mode1,
+				   const struct drm_display_mode *mode2)
+{
+	return mode1->hdisplay == mode2->hdisplay &&
+		mode1->hsync_start == mode2->hsync_start &&
+		mode1->hsync_end == mode2->hsync_end &&
+		mode1->htotal == mode2->htotal &&
+		mode1->hskew == mode2->hskew &&
+		mode1->vdisplay == mode2->vdisplay &&
+		mode1->vsync_start == mode2->vsync_start &&
+		mode1->vsync_end == mode2->vsync_end &&
+		mode1->vtotal == mode2->vtotal &&
+		mode1->vscan == mode2->vscan;
+}
+
+static bool drm_mode_match_clock(const struct drm_display_mode *mode1,
+				  const struct drm_display_mode *mode2)
+{
+	/*
+	 * do clock check convert to PICOS
+	 * so fb modes get matched the same
+	 */
+	if (mode1->clock && mode2->clock)
+		return KHZ2PICOS(mode1->clock) == KHZ2PICOS(mode2->clock);
+	else
+		return mode1->clock == mode2->clock;
+}
+
+static bool drm_mode_match_flags(const struct drm_display_mode *mode1,
+				 const struct drm_display_mode *mode2)
+{
+	return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
+		(mode2->flags & ~DRM_MODE_FLAG_3D_MASK);
+}
+
+static bool drm_mode_match_3d_flags(const struct drm_display_mode *mode1,
+				    const struct drm_display_mode *mode2)
+{
+	return (mode1->flags & DRM_MODE_FLAG_3D_MASK) ==
+		(mode2->flags & DRM_MODE_FLAG_3D_MASK);
+}
+
+static bool drm_mode_match_aspect_ratio(const struct drm_display_mode *mode1,
+					const struct drm_display_mode *mode2)
+{
+	return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio;
+}
+
 /**
- * drm_mode_equal - test modes for equality
+ * drm_mode_match - test modes for (partial) equality
  * @mode1: first mode
  * @mode2: second mode
+ * @match_flags: which parts need to match (DRM_MODE_MATCH_*)
  *
  * Check to see if @mode1 and @mode2 are equivalent.
  *
  * Returns:
- * True if the modes are equal, false otherwise.
+ * True if the modes are (partially) equal, false otherwise.
  */
-bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
+bool drm_mode_match(const struct drm_display_mode *mode1,
+		    const struct drm_display_mode *mode2,
+		    unsigned int match_flags)
 {
 	if (!mode1 && !mode2)
 		return true;
@@ -958,15 +1009,48 @@ bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_displ
 	if (!mode1 || !mode2)
 		return false;
 
-	/* do clock check convert to PICOS so fb modes get matched
-	 * the same */
-	if (mode1->clock && mode2->clock) {
-		if (KHZ2PICOS(mode1->clock) != KHZ2PICOS(mode2->clock))
-			return false;
-	} else if (mode1->clock != mode2->clock)
+	if (match_flags & DRM_MODE_MATCH_TIMINGS &&
+	    !drm_mode_match_timings(mode1, mode2))
+		return false;
+
+	if (match_flags & DRM_MODE_MATCH_CLOCK &&
+	    !drm_mode_match_clock(mode1, mode2))
+		return false;
+
+	if (match_flags & DRM_MODE_MATCH_FLAGS &&
+	    !drm_mode_match_flags(mode1, mode2))
+		return false;
+
+	if (match_flags & DRM_MODE_MATCH_3D_FLAGS &&
+	    !drm_mode_match_3d_flags(mode1, mode2))
 		return false;
 
-	return drm_mode_equal_no_clocks(mode1, mode2);
+	if (match_flags & DRM_MODE_MATCH_ASPECT_RATIO &&
+	    !drm_mode_match_aspect_ratio(mode1, mode2))
+		return false;
+
+	return true;
+}
+EXPORT_SYMBOL(drm_mode_match);
+
+/**
+ * drm_mode_equal - test modes for equality
+ * @mode1: first mode
+ * @mode2: second mode
+ *
+ * Check to see if @mode1 and @mode2 are equivalent.
+ *
+ * Returns:
+ * True if the modes are equal, false otherwise.
+ */
+bool drm_mode_equal(const struct drm_display_mode *mode1,
+		    const struct drm_display_mode *mode2)
+{
+	return drm_mode_match(mode1, mode2,
+			      DRM_MODE_MATCH_TIMINGS |
+			      DRM_MODE_MATCH_CLOCK |
+			      DRM_MODE_MATCH_FLAGS |
+			      DRM_MODE_MATCH_3D_FLAGS);
 }
 EXPORT_SYMBOL(drm_mode_equal);
 
@@ -981,13 +1065,13 @@ EXPORT_SYMBOL(drm_mode_equal);
  * Returns:
  * True if the modes are equal, false otherwise.
  */
-bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2)
+bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
+			      const struct drm_display_mode *mode2)
 {
-	if ((mode1->flags & DRM_MODE_FLAG_3D_MASK) !=
-	    (mode2->flags & DRM_MODE_FLAG_3D_MASK))
-		return false;
-
-	return drm_mode_equal_no_clocks_no_stereo(mode1, mode2);
+	return drm_mode_match(mode1, mode2,
+			      DRM_MODE_MATCH_TIMINGS |
+			      DRM_MODE_MATCH_FLAGS |
+			      DRM_MODE_MATCH_3D_FLAGS);
 }
 EXPORT_SYMBOL(drm_mode_equal_no_clocks);
 
@@ -1005,21 +1089,9 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks);
 bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
 					const struct drm_display_mode *mode2)
 {
-	if (mode1->hdisplay == mode2->hdisplay &&
-	    mode1->hsync_start == mode2->hsync_start &&
-	    mode1->hsync_end == mode2->hsync_end &&
-	    mode1->htotal == mode2->htotal &&
-	    mode1->hskew == mode2->hskew &&
-	    mode1->vdisplay == mode2->vdisplay &&
-	    mode1->vsync_start == mode2->vsync_start &&
-	    mode1->vsync_end == mode2->vsync_end &&
-	    mode1->vtotal == mode2->vtotal &&
-	    mode1->vscan == mode2->vscan &&
-	    (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
-	     (mode2->flags & ~DRM_MODE_FLAG_3D_MASK))
-		return true;
-
-	return false;
+	return drm_mode_match(mode1, mode2,
+			      DRM_MODE_MATCH_TIMINGS |
+			      DRM_MODE_MATCH_FLAGS);
 }
 EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
 
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 9f3421c8efcd..839eb9c3a029 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -150,6 +150,12 @@ enum drm_mode_status {
 
 #define DRM_MODE_FLAG_3D_MAX	DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
 
+#define DRM_MODE_MATCH_TIMINGS (1 << 0)
+#define DRM_MODE_MATCH_CLOCK (1 << 1)
+#define DRM_MODE_MATCH_FLAGS (1 << 2)
+#define DRM_MODE_MATCH_3D_FLAGS (1 << 3)
+#define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4)
+
 /**
  * struct drm_display_mode - DRM kernel-internal display mode structure
  * @hdisplay: horizontal display size
@@ -493,6 +499,9 @@ void drm_mode_copy(struct drm_display_mode *dst,
 		   const struct drm_display_mode *src);
 struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
 					    const struct drm_display_mode *mode);
+bool drm_mode_match(const struct drm_display_mode *mode1,
+		    const struct drm_display_mode *mode2,
+		    unsigned int match_flags);
 bool drm_mode_equal(const struct drm_display_mode *mode1,
 		    const struct drm_display_mode *mode2);
 bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
-- 
2.13.6

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 04/10] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (2 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 03/10] drm/modes: Introduce drm_mode_match() Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 17:04 ` [PATCH 05/10] drm/edid: Fix up edid_cea_modes[] formatting Ville Syrjala
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Use drm_mode_equal_no_clocks_no_stereo() in
drm_match_hdmi_mode_clock_tolerance() for consistency as we
also use it in drm_match_hdmi_mode() and the cea mode matching
functions.

This doesn't actually change anything since the input mode
comes from detailed timings and we match it against
edid_4k_modes[] which. So none of those modes can have stereo
flags set.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 9ada0ccf50df..b575c4b5a313 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3020,7 +3020,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
 		    abs(to_match->clock - clock2) > clock_tolerance)
 			continue;
 
-		if (drm_mode_equal_no_clocks(to_match, hdmi_mode))
+		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
 			return vic;
 	}
 
-- 
2.13.6

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 05/10] drm/edid: Fix up edid_cea_modes[] formatting
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (3 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 04/10] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 17:04 ` [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling Ville Syrjala
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Fix up a bunch of bad indentation and insconsistent comments
in edid_cea_modes[].

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 84 +++++++++++++++++++++++-----------------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b575c4b5a313..7220b8f9a7e8 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -685,43 +685,43 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008,
 		   2052, 2200, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 6 - 720(1440)x480i@60Hz */
 	{ DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
 		   801, 858, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 7 - 720(1440)x480i@60Hz */
 	{ DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
 		   801, 858, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 8 - 720(1440)x240@60Hz */
 	{ DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
 		   801, 858, 0, 240, 244, 247, 262, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 9 - 720(1440)x240@60Hz */
 	{ DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
 		   801, 858, 0, 240, 244, 247, 262, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 10 - 2880x480i@60Hz */
 	{ DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
 		   3204, 3432, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 11 - 2880x480i@60Hz */
 	{ DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
 		   3204, 3432, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 12 - 2880x240@60Hz */
 	{ DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
@@ -767,43 +767,43 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448,
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 21 - 720(1440)x576i@50Hz */
 	{ DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
 		   795, 864, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 22 - 720(1440)x576i@50Hz */
 	{ DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
 		   795, 864, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 23 - 720(1440)x288@50Hz */
 	{ DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
 		   795, 864, 0, 288, 290, 293, 312, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 24 - 720(1440)x288@50Hz */
 	{ DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
 		   795, 864, 0, 288, 290, 293, 312, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 25 - 2880x576i@50Hz */
 	{ DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
 		   3180, 3456, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 26 - 2880x576i@50Hz */
 	{ DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
 		   3180, 3456, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 27 - 2880x288@50Hz */
 	{ DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
@@ -869,13 +869,13 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 72000, 1920, 1952,
 		   2120, 2304, 0, 1080, 1126, 1136, 1250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 40 - 1920x1080i@100Hz */
 	{ DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448,
 		   2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 41 - 1280x720@100Hz */
 	{ DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720,
@@ -896,19 +896,19 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732,
 		   795, 864, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 45 - 720(1440)x576i@100Hz */
 	{ DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732,
 		   795, 864, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 46 - 1920x1080i@120Hz */
 	{ DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008,
 		   2052, 2200, 0, 1080, 1084, 1094, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
-			DRM_MODE_FLAG_INTERLACE),
+		   DRM_MODE_FLAG_INTERLACE),
 	  .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 47 - 1280x720@120Hz */
 	{ DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390,
@@ -929,13 +929,13 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739,
 		   801, 858, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 51 - 720(1440)x480i@120Hz */
 	{ DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739,
 		   801, 858, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 52 - 720x576@200Hz */
 	{ DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732,
@@ -951,13 +951,13 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732,
 		   795, 864, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 55 - 720(1440)x576i@200Hz */
 	{ DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732,
 		   795, 864, 0, 576, 580, 586, 625, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 200, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 56 - 720x480@240Hz */
 	{ DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736,
@@ -973,13 +973,13 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739,
 		   801, 858, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
 	/* 59 - 720(1440)x480i@240Hz */
 	{ DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739,
 		   801, 858, 0, 480, 488, 494, 525, 0,
 		   DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
-			DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
+		   DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
 	  .vrefresh = 240, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 60 - 1280x720@24Hz */
 	{ DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040,
@@ -1000,12 +1000,12 @@ static const struct drm_display_mode edid_cea_modes[] = {
 	{ DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008,
 		   2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
-	 .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	  .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 64 - 1920x1080@100Hz */
 	{ DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448,
 		   2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
-	 .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
+	  .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
 	/* 65 - 1280x720@24Hz */
 	{ DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040,
 		   3080, 3300, 0, 720, 725, 730, 750, 0,
@@ -1146,77 +1146,77 @@ static const struct drm_display_mode edid_cea_modes[] = {
 		   3152, 3300, 0, 1080, 1084, 1089, 1250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
-	/* 93 - 3840x2160p@24Hz 16:9 */
+	/* 93 - 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, },
-	/* 94 - 3840x2160p@25Hz 16:9 */
+	/* 94 - 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, },
-	/* 95 - 3840x2160p@30Hz 16:9 */
+	/* 95 - 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, },
-	/* 96 - 3840x2160p@50Hz 16:9 */
+	/* 96 - 3840x2160@50Hz */
 	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896,
 		   4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
-	/* 97 - 3840x2160p@60Hz 16:9 */
+	/* 97 - 3840x2160@60Hz */
 	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016,
 		   4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
-	/* 98 - 4096x2160p@24Hz 256:135 */
+	/* 98 - 4096x2160@24Hz */
 	{ 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, },
-	/* 99 - 4096x2160p@25Hz 256:135 */
+	/* 99 - 4096x2160@25Hz */
 	{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5064,
 		   5152, 5280, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 25, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
-	/* 100 - 4096x2160p@30Hz 256:135 */
+	/* 100 - 4096x2160@30Hz */
 	{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 4184,
 		   4272, 4400, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 30, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
-	/* 101 - 4096x2160p@50Hz 256:135 */
+	/* 101 - 4096x2160@50Hz */
 	{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 5064,
 		   5152, 5280, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
-	/* 102 - 4096x2160p@60Hz 256:135 */
+	/* 102 - 4096x2160@60Hz */
 	{ DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 4184,
 		   4272, 4400, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 60, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
-	/* 103 - 3840x2160p@24Hz 64:27 */
+	/* 103 - 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_64_27, },
-	/* 104 - 3840x2160p@25Hz 64:27 */
+	/* 104 - 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_64_27, },
-	/* 105 - 3840x2160p@30Hz 64:27 */
+	/* 105 - 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_64_27, },
-	/* 106 - 3840x2160p@50Hz 64:27 */
+	/* 106 - 3840x2160@50Hz */
 	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896,
 		   4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
 	  .vrefresh = 50, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
-	/* 107 - 3840x2160p@60Hz 64:27 */
+	/* 107 - 3840x2160@60Hz */
 	{ DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016,
 		   4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
 		   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
-- 
2.13.6

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (4 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 05/10] drm/edid: Fix up edid_cea_modes[] formatting Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 18:13   ` Jose Abreu
  2017-11-16 14:51   ` Sharma, Shashank
  2017-11-13 17:04 ` [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Ville Syrjala
                   ` (5 subsequent siblings)
  11 siblings, 2 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: Jose Abreu, Lin, Jia, intel-gfx, Daniel Vetter

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
cause us to not send out any VICs in the AVI infoframes. That commit
was since reverted, but if and when we add aspect ratio handing back
we need to be more careful.

Let's handle this by considering the aspect ratio as a requirement
for cea mode matching only if the passed in mode actually has a
non-zero aspect ratio field. This will keep userspace that doesn't
provide an aspect ratio working as before by matching it to the
first otherwise equal cea mode. And once userspace starts to
provide the aspect ratio it will be considerd a hard requirement
for the match.

Also change the hdmi mode matching to use drm_mode_match() for
consistency, but we don't match on aspect ratio there since the
spec doesn't list a specific aspect ratio for those modes.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: "Lin, Jia" <lin.a.jia@intel.com>
Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
Cc: Jim Bride <jim.bride@linux.intel.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7220b8f9a7e8..00aa98f3e55d 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
 static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
 					     unsigned int clock_tolerance)
 {
+	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(edid_cea_modes); vic++) {
 		struct drm_display_mode cea_mode = edid_cea_modes[vic];
 		unsigned int clock1, clock2;
@@ -2921,7 +2925,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
 			continue;
 
 		do {
-			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
+			if (drm_mode_match(to_match, &cea_mode, match_flags))
 				return vic;
 		} while (cea_mode_alternate_timings(vic, &cea_mode));
 	}
@@ -2938,11 +2942,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
  */
 u8 drm_match_cea_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(edid_cea_modes); vic++) {
 		struct drm_display_mode cea_mode = edid_cea_modes[vic];
 		unsigned int clock1, clock2;
@@ -2956,7 +2964,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
 			continue;
 
 		do {
-			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
+			if (drm_mode_match(to_match, &cea_mode, match_flags))
 				return vic;
 		} while (cea_mode_alternate_timings(vic, &cea_mode));
 	}
@@ -3003,6 +3011,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
 					      unsigned int clock_tolerance)
 {
+	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
 	u8 vic;
 
 	if (!to_match->clock)
@@ -3020,7 +3029,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
 		    abs(to_match->clock - clock2) > clock_tolerance)
 			continue;
 
-		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
+		if (drm_mode_match(to_match, hdmi_mode, match_flags))
 			return vic;
 	}
 
@@ -3037,6 +3046,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
  */
 static u8 drm_match_hdmi_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)
@@ -3052,7 +3062,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
 
 		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
 		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
-		    drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
+		    drm_mode_match(to_match, hdmi_mode, match_flags))
 			return vic;
 	}
 	return 0;
-- 
2.13.6

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (5 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 18:30   ` Jose Abreu
  2017-11-16 15:01   ` Sharma, Shashank
  2017-11-13 17:04 ` [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios Ville Syrjala
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: Jose Abreu, Daniel Vetter, intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

If the user mode would specify an aspect ratio other than 4:3 or 16:9
we now silently ignore it. Maybe a better apporoach is to return an
error? Let's try that.

Also we must be careful that we don't try to send illegal picture
aspect in the infoframe as it's only capable of signalling none,
4:3, and 16:9. Currently we're sending these bogus infoframes
whenever the cea mode specifies some other aspect ratio.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 00aa98f3e55d..bafb3ee4ea97 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4786,6 +4786,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 					 const struct drm_display_mode *mode,
 					 bool is_hdmi2_sink)
 {
+	enum hdmi_picture_aspect picture_aspect;
 	int err;
 
 	if (!frame || !mode)
@@ -4828,13 +4829,23 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 	 * Populate picture aspect ratio from either
 	 * user input (if specified) or from the CEA mode list.
 	 */
-	if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 ||
-		mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9)
-		frame->picture_aspect = mode->picture_aspect_ratio;
-	else if (frame->video_code > 0)
-		frame->picture_aspect = drm_get_cea_aspect_ratio(
-						frame->video_code);
+	picture_aspect = mode->picture_aspect_ratio;
+	if (picture_aspect == HDMI_PICTURE_ASPECT_NONE)
+		picture_aspect = drm_get_cea_aspect_ratio(frame->video_code);
 
+	/*
+	 * The infoframe can't convey anything but none, 4:3
+	 * and 16:9, so if the user has asked for anything else
+	 * we can only satisfy it by specifying the right VIC.
+	 */
+	if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
+		if (picture_aspect !=
+		    drm_get_cea_aspect_ratio(frame->video_code))
+			return -EINVAL;
+		picture_aspect = HDMI_PICTURE_ASPECT_NONE;
+	}
+
+	frame->picture_aspect = picture_aspect;
 	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
 	frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
 
-- 
2.13.6

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (6 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 18:33     ` Jose Abreu
  2017-11-13 17:04 ` [PATCH 09/10] video/hdmi: Constify 'buffer' to the unpack functions Ville Syrjala
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, Shashank Sharma, Lin, Jia, Akashdeep Sharma,
	Jim Bride, Jose Abreu, Daniel Vetter, Emil Velikov,
	Thierry Reding, Hans Verkuil, linux-media

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

AVI infoframe can only carry none, 4:3, or 16:9 picture aspect
ratios. Return an error if the user asked for something different.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: "Lin, Jia" <lin.a.jia@intel.com>
Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
Cc: Jim Bride <jim.bride@linux.intel.com>
Cc: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/video/hdmi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 111a0ab6280a..38716eb50408 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -93,6 +93,9 @@ ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
 	if (size < length)
 		return -ENOSPC;
 
+	if (frame->picture_aspect > HDMI_PICTURE_ASPECT_16_9)
+		return -EINVAL;
+
 	memset(buffer, 0, size);
 
 	ptr[0] = frame->type;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 09/10] video/hdmi: Constify 'buffer' to the unpack functions
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (7 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-13 17:04 ` [PATCH 10/10] video/hdmi: Pass buffer size to infoframe " Ville Syrjala
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Thierry Reding, Hans Verkuil, linux-media

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The unpack functions just read from the passed in buffer,
so make it const.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/video/hdmi.c | 23 ++++++++++++-----------
 include/linux/hdmi.h |  3 ++-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 38716eb50408..65b915ea4936 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -31,7 +31,7 @@
 
 #define hdmi_log(fmt, ...) dev_printk(level, dev, fmt, ##__VA_ARGS__)
 
-static u8 hdmi_infoframe_checksum(u8 *ptr, size_t size)
+static u8 hdmi_infoframe_checksum(const u8 *ptr, size_t size)
 {
 	u8 csum = 0;
 	size_t i;
@@ -1016,9 +1016,9 @@ EXPORT_SYMBOL(hdmi_infoframe_log);
  * Returns 0 on success or a negative error code on failure.
  */
 static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
-				     void *buffer)
+				     const void *buffer)
 {
-	u8 *ptr = buffer;
+	const u8 *ptr = buffer;
 	int ret;
 
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
@@ -1079,9 +1079,9 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
  * Returns 0 on success or a negative error code on failure.
  */
 static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
-				     void *buffer)
+				     const void *buffer)
 {
-	u8 *ptr = buffer;
+	const u8 *ptr = buffer;
 	int ret;
 
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_SPD ||
@@ -1117,9 +1117,9 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
  * Returns 0 on success or a negative error code on failure.
  */
 static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
-				       void *buffer)
+				       const void *buffer)
 {
-	u8 *ptr = buffer;
+	const u8 *ptr = buffer;
 	int ret;
 
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_AUDIO ||
@@ -1163,9 +1163,9 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
  */
 static int
 hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
-				 void *buffer)
+				 const void *buffer)
 {
-	u8 *ptr = buffer;
+	const u8 *ptr = buffer;
 	size_t length;
 	int ret;
 	u8 hdmi_video_format;
@@ -1234,10 +1234,11 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
  *
  * Returns 0 on success or a negative error code on failure.
  */
-int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer)
+int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
+			  const void *buffer)
 {
 	int ret;
-	u8 *ptr = buffer;
+	const u8 *ptr = buffer;
 
 	switch (ptr[0]) {
 	case HDMI_INFOFRAME_TYPE_AVI:
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index d271ff23984f..d3816170c062 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -332,7 +332,8 @@ union hdmi_infoframe {
 
 ssize_t
 hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
-int hdmi_infoframe_unpack(union hdmi_infoframe *frame, void *buffer);
+int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
+			  const void *buffer);
 void hdmi_infoframe_log(const char *level, struct device *dev,
 			union hdmi_infoframe *frame);
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 10/10] video/hdmi: Pass buffer size to infoframe unpack functions
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (8 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 09/10] video/hdmi: Constify 'buffer' to the unpack functions Ville Syrjala
@ 2017-11-13 17:04 ` Ville Syrjala
  2017-11-20 13:36   ` Hans Verkuil
  2017-11-13 17:52 ` ✓ Fi.CI.BAT: success for drm/edid: Infoframe cleanups and fixes Patchwork
  2017-11-13 19:07 ` ✓ Fi.CI.IGT: " Patchwork
  11 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjala @ 2017-11-13 17:04 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Thierry Reding, Hans Verkuil, linux-media

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

To make sure the infoframe unpack functions don't end up examining
stack garbage or oopsing, let's pass in the size of the buffer.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/media/i2c/adv7511.c  |  2 +-
 drivers/media/i2c/adv7604.c  |  2 +-
 drivers/media/i2c/adv7842.c  |  2 +-
 drivers/media/i2c/tc358743.c |  2 +-
 drivers/video/hdmi.c         | 51 ++++++++++++++++++++++++++++++++------------
 include/linux/hdmi.h         |  2 +-
 6 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 2817bafc67bf..dec09c18ea34 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -562,7 +562,7 @@ static void log_infoframe(struct v4l2_subdev *sd, const struct adv7511_cfg_read_
 	buffer[3] = 0;
 	buffer[3] = hdmi_infoframe_checksum(buffer, len + 4);
 
-	if (hdmi_infoframe_unpack(&frame, buffer) < 0) {
+	if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
 		v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc);
 		return;
 	}
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index f289b8aca1da..8500438af0d3 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2429,7 +2429,7 @@ static int adv76xx_read_infoframe(struct v4l2_subdev *sd, int index,
 		buffer[i + 3] = infoframe_read(sd,
 				       adv76xx_cri[index].payload_addr + i);
 
-	if (hdmi_infoframe_unpack(frame, buffer) < 0) {
+	if (hdmi_infoframe_unpack(frame, buffer, sizeof(buffer)) < 0) {
 		v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__,
 			 adv76xx_cri[index].desc);
 		return -ENOENT;
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 65f34e7e146f..fd5d5e84dcbf 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2576,7 +2576,7 @@ static void log_infoframe(struct v4l2_subdev *sd, struct adv7842_cfg_read_infofr
 	for (i = 0; i < len; i++)
 		buffer[i + 3] = infoframe_read(sd, cri->payload_addr + i);
 
-	if (hdmi_infoframe_unpack(&frame, buffer) < 0) {
+	if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
 		v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc);
 		return;
 	}
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index e6f5c363ccab..f6a5ebffd9c6 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -453,7 +453,7 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
 
 	i2c_rd(sd, PK_AVI_0HEAD, buffer, HDMI_INFOFRAME_SIZE(AVI));
 
-	if (hdmi_infoframe_unpack(&frame, buffer) < 0) {
+	if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
 		v4l2_err(sd, "%s: unpack of AVI infoframe failed\n", __func__);
 		return;
 	}
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 65b915ea4936..b5d491014b0b 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -1005,8 +1005,9 @@ EXPORT_SYMBOL(hdmi_infoframe_log);
 
 /**
  * hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe
- * @buffer: source buffer
  * @frame: HDMI AVI infoframe
+ * @buffer: source buffer
+ * @size: size of buffer
  *
  * Unpacks the information contained in binary @buffer into a structured
  * @frame of the HDMI Auxiliary Video (AVI) information frame.
@@ -1016,11 +1017,14 @@ EXPORT_SYMBOL(hdmi_infoframe_log);
  * Returns 0 on success or a negative error code on failure.
  */
 static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
-				     const void *buffer)
+				     const void *buffer, size_t size)
 {
 	const u8 *ptr = buffer;
 	int ret;
 
+	if (size < HDMI_INFOFRAME_SIZE(AVI))
+		return -EINVAL;
+
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
 	    ptr[1] != 2 ||
 	    ptr[2] != HDMI_AVI_INFOFRAME_SIZE)
@@ -1068,8 +1072,9 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
 
 /**
  * hdmi_spd_infoframe_unpack() - unpack binary buffer to a HDMI SPD infoframe
- * @buffer: source buffer
  * @frame: HDMI SPD infoframe
+ * @buffer: source buffer
+ * @size: size of buffer
  *
  * Unpacks the information contained in binary @buffer into a structured
  * @frame of the HDMI Source Product Description (SPD) information frame.
@@ -1079,11 +1084,14 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
  * Returns 0 on success or a negative error code on failure.
  */
 static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
-				     const void *buffer)
+				     const void *buffer, size_t size)
 {
 	const u8 *ptr = buffer;
 	int ret;
 
+	if (size < HDMI_INFOFRAME_SIZE(SPD))
+		return -EINVAL;
+
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_SPD ||
 	    ptr[1] != 1 ||
 	    ptr[2] != HDMI_SPD_INFOFRAME_SIZE) {
@@ -1106,8 +1114,9 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
 
 /**
  * hdmi_audio_infoframe_unpack() - unpack binary buffer to a HDMI AUDIO infoframe
- * @buffer: source buffer
  * @frame: HDMI Audio infoframe
+ * @buffer: source buffer
+ * @size: size of buffer
  *
  * Unpacks the information contained in binary @buffer into a structured
  * @frame of the HDMI Audio information frame.
@@ -1117,11 +1126,14 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
  * Returns 0 on success or a negative error code on failure.
  */
 static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
-				       const void *buffer)
+				       const void *buffer, size_t size)
 {
 	const u8 *ptr = buffer;
 	int ret;
 
+	if (size < HDMI_INFOFRAME_SIZE(AUDIO))
+		return -EINVAL;
+
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_AUDIO ||
 	    ptr[1] != 1 ||
 	    ptr[2] != HDMI_AUDIO_INFOFRAME_SIZE) {
@@ -1151,8 +1163,9 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
 
 /**
  * hdmi_vendor_infoframe_unpack() - unpack binary buffer to a HDMI vendor infoframe
- * @buffer: source buffer
  * @frame: HDMI Vendor infoframe
+ * @buffer: source buffer
+ * @size: size of buffer
  *
  * Unpacks the information contained in binary @buffer into a structured
  * @frame of the HDMI Vendor information frame.
@@ -1163,7 +1176,7 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
  */
 static int
 hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
-				 const void *buffer)
+				 const void *buffer, size_t size)
 {
 	const u8 *ptr = buffer;
 	size_t length;
@@ -1171,6 +1184,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 	u8 hdmi_video_format;
 	struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
 
+	if (size < HDMI_INFOFRAME_HEADER_SIZE)
+		return -EINVAL;
+
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
 	    ptr[1] != 1 ||
 	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
@@ -1178,6 +1194,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 
 	length = ptr[2];
 
+	if (size < HDMI_INFOFRAME_HEADER_SIZE + length)
+		return -EINVAL;
+
 	if (hdmi_infoframe_checksum(buffer,
 				    HDMI_INFOFRAME_HEADER_SIZE + length) != 0)
 		return -EINVAL;
@@ -1224,8 +1243,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
 
 /**
  * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe
- * @buffer: source buffer
  * @frame: HDMI infoframe
+ * @buffer: source buffer
+ * @size: size of buffer
  *
  * Unpacks the information contained in binary buffer @buffer into a structured
  * @frame of a HDMI infoframe.
@@ -1235,23 +1255,26 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
  * Returns 0 on success or a negative error code on failure.
  */
 int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
-			  const void *buffer)
+			  const void *buffer, size_t size)
 {
 	int ret;
 	const u8 *ptr = buffer;
 
+	if (size < HDMI_INFOFRAME_HEADER_SIZE)
+		return -EINVAL;
+
 	switch (ptr[0]) {
 	case HDMI_INFOFRAME_TYPE_AVI:
-		ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer);
+		ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer, size);
 		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
-		ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer);
+		ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer, size);
 		break;
 	case HDMI_INFOFRAME_TYPE_AUDIO:
-		ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer);
+		ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer, size);
 		break;
 	case HDMI_INFOFRAME_TYPE_VENDOR:
-		ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer);
+		ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer, size);
 		break;
 	default:
 		ret = -EINVAL;
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index d3816170c062..a577d4ae2570 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -333,7 +333,7 @@ union hdmi_infoframe {
 ssize_t
 hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
 int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
-			  const void *buffer);
+			  const void *buffer, size_t size);
 void hdmi_infoframe_log(const char *level, struct device *dev,
 			union hdmi_infoframe *frame);
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* ✓ Fi.CI.BAT: success for drm/edid: Infoframe cleanups and fixes
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (9 preceding siblings ...)
  2017-11-13 17:04 ` [PATCH 10/10] video/hdmi: Pass buffer size to infoframe " Ville Syrjala
@ 2017-11-13 17:52 ` Patchwork
  2017-11-13 19:07 ` ✓ Fi.CI.IGT: " Patchwork
  11 siblings, 0 replies; 44+ messages in thread
From: Patchwork @ 2017-11-13 17:52 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

== Series Details ==

Series: drm/edid: Infoframe cleanups and fixes
URL   : https://patchwork.freedesktop.org/series/33730/
State : success

== Summary ==

Series 33730v1 drm/edid: Infoframe cleanups and fixes
https://patchwork.freedesktop.org/api/1.0/series/33730/revisions/1/mbox/

Test chamelium:
        Subgroup dp-crc-fast:
                dmesg-fail -> PASS       (fi-kbl-7500u) fdo#102514
Test vgem_basic:
        Subgroup dmabuf-export:
                incomplete -> PASS       (fi-byt-n2820) fdo#103714
                pass       -> INCOMPLETE (fi-bxt-dsi) fdo#103706 +1
        Subgroup unload:
                notrun     -> INCOMPLETE (fi-byt-n2820) fdo#103702 +1

fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514
fdo#103714 https://bugs.freedesktop.org/show_bug.cgi?id=103714
fdo#103706 https://bugs.freedesktop.org/show_bug.cgi?id=103706
fdo#103702 https://bugs.freedesktop.org/show_bug.cgi?id=103702

fi-bdw-5557u     total:285  pass:263  dwarn:0   dfail:1   fail:0   skip:20 
fi-bdw-gvtdvm    total:285  pass:260  dwarn:0   dfail:1   fail:0   skip:23 
fi-blb-e6850     total:285  pass:218  dwarn:1   dfail:1   fail:0   skip:64 
fi-bsw-n3050     total:285  pass:238  dwarn:0   dfail:1   fail:0   skip:45 
fi-bwr-2160      total:285  pass:178  dwarn:0   dfail:1   fail:0   skip:105
fi-bxt-dsi       total:278  pass:247  dwarn:0   dfail:1   fail:0   skip:29 
fi-bxt-j4205     total:285  pass:255  dwarn:0   dfail:1   fail:0   skip:28 
fi-byt-j1900     total:285  pass:249  dwarn:0   dfail:1   fail:0   skip:34 
fi-byt-n2820     total:285  pass:245  dwarn:0   dfail:1   fail:0   skip:38 
fi-elk-e7500     total:285  pass:224  dwarn:0   dfail:1   fail:0   skip:59 
fi-gdg-551       total:285  pass:174  dwarn:0   dfail:1   fail:1   skip:108
fi-glk-1         total:285  pass:256  dwarn:0   dfail:1   fail:0   skip:27 
fi-hsw-4770      total:285  pass:257  dwarn:0   dfail:1   fail:0   skip:26 
fi-hsw-4770r     total:285  pass:257  dwarn:0   dfail:1   fail:0   skip:26 
fi-ilk-650       total:285  pass:223  dwarn:0   dfail:1   fail:0   skip:60 
fi-ivb-3520m     total:285  pass:255  dwarn:0   dfail:1   fail:0   skip:28 
fi-ivb-3770      total:285  pass:255  dwarn:0   dfail:1   fail:0   skip:28 
fi-kbl-7500u     total:285  pass:259  dwarn:1   dfail:1   fail:0   skip:23 
fi-kbl-7560u     total:285  pass:265  dwarn:0   dfail:1   fail:0   skip:18 
fi-kbl-7567u     total:285  pass:264  dwarn:0   dfail:1   fail:0   skip:19 
fi-kbl-r         total:285  pass:257  dwarn:0   dfail:1   fail:0   skip:26 
fi-pnv-d510      total:285  pass:217  dwarn:1   dfail:1   fail:0   skip:65 
fi-skl-6260u     total:285  pass:264  dwarn:0   dfail:1   fail:0   skip:19 
fi-skl-6600u     total:285  pass:257  dwarn:0   dfail:1   fail:0   skip:26 
fi-skl-6700hq    total:285  pass:258  dwarn:0   dfail:1   fail:0   skip:25 
fi-skl-6700k     total:285  pass:260  dwarn:0   dfail:1   fail:0   skip:23 
fi-skl-6770hq    total:285  pass:264  dwarn:0   dfail:1   fail:0   skip:19 
fi-skl-gvtdvm    total:285  pass:261  dwarn:0   dfail:1   fail:0   skip:22 
fi-snb-2520m     total:285  pass:245  dwarn:0   dfail:1   fail:0   skip:38 
fi-snb-2600      total:285  pass:244  dwarn:0   dfail:1   fail:0   skip:39 
Blacklisted hosts:
fi-cfl-s         total:285  pass:252  dwarn:0   dfail:1   fail:0   skip:31 

9891b4090c6e6a5299a4134f7bd6c463fb2cd485 drm-tip: 2017y-11m-13d-16h-04m-46s UTC integration manifest
2d305bb901cc video/hdmi: Pass buffer size to infoframe unpack functions
9161733e0c67 video/hdmi: Constify 'buffer' to the unpack functions
5298f77013f6 video/hdmi: Reject illegal picture aspect ratios
e8cc0955a59d drm/edid: Don't send bogus aspect ratios in AVI infoframes
76160a03d4d4 drm/edid: Fix cea mode aspect ratio handling
2df0375a1d11 drm/edid: Fix up edid_cea_modes[] formatting
7178bb61b138 drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy
72e507c9f3b3 drm/modes: Introduce drm_mode_match()
e9cc41ee0390 drm/edid: Allow HDMI infoframe without VIC or S3D
1a18a539358a video/hdmi: Allow "empty" HDMI infoframes

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7098/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-13 17:04 ` [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling Ville Syrjala
@ 2017-11-13 18:13   ` Jose Abreu
  2017-11-13 18:53     ` Ville Syrjälä
  2017-11-16 14:51   ` Sharma, Shashank
  1 sibling, 1 reply; 44+ messages in thread
From: Jose Abreu @ 2017-11-13 18:13 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Lin, Jia, Daniel Vetter, intel-gfx, Emil Velikov,
	Akashdeep Sharma, Jim Bride

Hi Ville,

On 13-11-2017 17:04, Ville Syrjala wrote:
>  
> +	if (to_match->picture_aspect_ratio)
> +		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
> +
>

Maybe "if (to_match->picture_aspect_ratio !=
HDMI_PICTURE_ASPECT_NONE && to_match->picture_aspect_ratio !=
HDMI_PICTURE_ASPECT_RESERVED)"?

Or some kind of helper to validate the aspect ratio from userspace?

Best Regards,
Jose Miguel Abreu
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-13 17:04 ` [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Ville Syrjala
@ 2017-11-13 18:30   ` Jose Abreu
  2017-11-13 19:00     ` Ville Syrjälä
  2017-11-16 15:01   ` Sharma, Shashank
  1 sibling, 1 reply; 44+ messages in thread
From: Jose Abreu @ 2017-11-13 18:30 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: Daniel Vetter, intel-gfx



On 13-11-2017 17:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> If the user mode would specify an aspect ratio other than 4:3 or 16:9
> we now silently ignore it. Maybe a better apporoach is to return an
> error? Let's try that.
>
> Also we must be careful that we don't try to send illegal picture
> aspect in the infoframe as it's only capable of signalling none,
> 4:3, and 16:9. Currently we're sending these bogus infoframes
> whenever the cea mode specifies some other aspect ratio.
>
>

Yes, this is a bug. Following my input from the previous patch I
think you should also check for HDMI_PICTURE_ASPECT_RESERVED or
user a helper to check that. I'm also wondering if this should go
to stable since the vics with aspect ratio > 16:9 were
introduced. We are indeed corrupting the AVI infoframe.

Best Regards,
Jose Miguel Abreu
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios
  2017-11-13 17:04 ` [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios Ville Syrjala
@ 2017-11-13 18:33     ` Jose Abreu
  0 siblings, 0 replies; 44+ messages in thread
From: Jose Abreu @ 2017-11-13 18:33 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Shashank Sharma, Lin, Jia, Akashdeep Sharma,
	Jim Bride, Daniel Vetter, Emil Velikov, Thierry Reding,
	Hans Verkuil, linux-media



On 13-11-2017 17:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> AVI infoframe can only carry none, 4:3, or 16:9 picture aspect
> ratios. Return an error if the user asked for something different.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: "Lin, Jia" <lin.a.jia@intel.com>
> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> Cc: Jim Bride <jim.bride@linux.intel.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: linux-media@vger.kernel.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jose Abreu <joabreu@synopsys.com>

Best Regards,
Jose Miguel Abreu

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios
@ 2017-11-13 18:33     ` Jose Abreu
  0 siblings, 0 replies; 44+ messages in thread
From: Jose Abreu @ 2017-11-13 18:33 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Shashank Sharma, Lin, Jia, Akashdeep Sharma,
	Jim Bride, Daniel Vetter, Emil Velikov, Thierry Reding,
	Hans Verkuil, linux-media



On 13-11-2017 17:04, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> AVI infoframe can only carry none, 4:3, or 16:9 picture aspect
> ratios. Return an error if the user asked for something different.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: "Lin, Jia" <lin.a.jia@intel.com>
> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> Cc: Jim Bride <jim.bride@linux.intel.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: linux-media@vger.kernel.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jose Abreu <joabreu@synopsys.com>

Best Regards,
Jose Miguel Abreu

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-13 18:13   ` Jose Abreu
@ 2017-11-13 18:53     ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-13 18:53 UTC (permalink / raw)
  To: Jose Abreu; +Cc: Lin, Jia, intel-gfx, dri-devel, Daniel Vetter

On Mon, Nov 13, 2017 at 06:13:37PM +0000, Jose Abreu wrote:
> Hi Ville,
> 
> On 13-11-2017 17:04, Ville Syrjala wrote:
> >  
> > +	if (to_match->picture_aspect_ratio)
> > +		match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
> > +
> >
> 
> Maybe "if (to_match->picture_aspect_ratio !=
> HDMI_PICTURE_ASPECT_NONE && to_match->picture_aspect_ratio !=
> HDMI_PICTURE_ASPECT_RESERVED)"?
> 
> Or some kind of helper to validate the aspect ratio from userspace?

We can't currently get an aspect ratio from userspace. Well we had
it but I reverted it due to regressions. When we add it back it will
obviously need to be validated, just like any other information we
get from userspace.

Hmm. Except we don't even validate the current mode flags/type
at all. Fail.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-13 18:30   ` Jose Abreu
@ 2017-11-13 19:00     ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-13 19:00 UTC (permalink / raw)
  To: Jose Abreu; +Cc: Daniel Vetter, intel-gfx, Emil Velikov, dri-devel

On Mon, Nov 13, 2017 at 06:30:47PM +0000, Jose Abreu wrote:
> 
> 
> On 13-11-2017 17:04, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > If the user mode would specify an aspect ratio other than 4:3 or 16:9
> > we now silently ignore it. Maybe a better apporoach is to return an
> > error? Let's try that.
> >
> > Also we must be careful that we don't try to send illegal picture
> > aspect in the infoframe as it's only capable of signalling none,
> > 4:3, and 16:9. Currently we're sending these bogus infoframes
> > whenever the cea mode specifies some other aspect ratio.
> >
> >
> 
> Yes, this is a bug. Following my input from the previous patch I
> think you should also check for HDMI_PICTURE_ASPECT_RESERVED or

RESERVED > 16_9

> user a helper to check that. I'm also wondering if this should go
> to stable since the vics with aspect ratio > 16:9 were
> introduced. We are indeed corrupting the AVI infoframe.

Possibly. Just need to be careful we don't end up making a bigger mess
in stable. I has some concerns about the ordering of these patches, but
I guess that was between this patch and the next patch that starts to
reject the illegal aspect ratios in the infoframe code. So just
backporting this one alone (or both patches) should be fine.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* ✓ Fi.CI.IGT: success for drm/edid: Infoframe cleanups and fixes
  2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
                   ` (10 preceding siblings ...)
  2017-11-13 17:52 ` ✓ Fi.CI.BAT: success for drm/edid: Infoframe cleanups and fixes Patchwork
@ 2017-11-13 19:07 ` Patchwork
  11 siblings, 0 replies; 44+ messages in thread
From: Patchwork @ 2017-11-13 19:07 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

== Series Details ==

Series: drm/edid: Infoframe cleanups and fixes
URL   : https://patchwork.freedesktop.org/series/33730/
State : success

== Summary ==

Test kms_atomic_transition:
        Subgroup plane-all-modeset-transition-fencing:
                pass       -> DMESG-WARN (shard-hsw) fdo#102614

fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614

shard-hsw        total:2584 pass:1471 dwarn:3   dfail:2   fail:9   skip:1099 time:9464s
Blacklisted hosts:
shard-apl        total:2543 pass:1582 dwarn:2   dfail:1   fail:21  skip:936 time:12922s
shard-kbl        total:2438 pass:1600 dwarn:22  dfail:6   fail:23  skip:784 time:9793s
shard-snb        total:2584 pass:1204 dwarn:2   dfail:2   fail:11  skip:1365 time:7730s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7098/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes
  2017-11-13 17:04   ` Ville Syrjala
  (?)
@ 2017-11-16 14:36   ` Sharma, Shashank
  2017-11-16 16:16     ` Ville Syrjälä
  -1 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-16 14:36 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Andrzej Hajda, Thierry Reding, Hans Verkuil, linux-media

Regards

Shashank


On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> HDMI 2.0 Appendix F suggest that we should keep sending the infoframe
> when switching from 3D to 2D mode, even if the infoframe isn't strictly
> necessary (ie. not needed to transmit the VIC or stereo information).
> This is a workaround against some sinks that fail to realize that they
> should switch from 3D to 2D mode when the source stop transmitting
> the infoframe.
>
> v2: Handle unpack() as well
>      Pull the length calculation into a helper
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: linux-media@vger.kernel.org
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> #v1
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/video/hdmi.c | 51 +++++++++++++++++++++++++++++++--------------------
>   1 file changed, 31 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> index 1cf907ecded4..111a0ab6280a 100644
> --- a/drivers/video/hdmi.c
> +++ b/drivers/video/hdmi.c
> @@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
>   }
>   EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
>   
> +static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
> +{
> +	/* for side by side (half) we also need to provide 3D_Ext_Data */
> +	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
> +		return 6;
> +	else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
> +		return 5;
> +	else
> +		return 4;
> +}
> +
>   /**
>    * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
>    * @frame: HDMI infoframe
> @@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
>   	u8 *ptr = buffer;
>   	size_t length;
>   
> -	/* empty info frame */
> -	if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
> -		return -EINVAL;
> -
>   	/* only one of those can be supplied */
>   	if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
>   		return -EINVAL;
>   
> -	/* for side by side (half) we also need to provide 3D_Ext_Data */
> -	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
> -		frame->length = 6;
> -	else
> -		frame->length = 5;
> +	frame->length = hdmi_vendor_infoframe_length(frame);
>   
>   	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
>   
> @@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
>   	ptr[5] = 0x0c;
>   	ptr[6] = 0x00;
>   
> -	if (frame->vic) {
> -		ptr[7] = 0x1 << 5;	/* video format */
> -		ptr[8] = frame->vic;
> -	} else {
> +	if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
>   		ptr[7] = 0x2 << 5;	/* video format */
>   		ptr[8] = (frame->s3d_struct & 0xf) << 4;
>   		if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>   			ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
> +	} else if (frame->vic) {
Please correct me if I dint understand this properly, but for a HDMI 2.0 
sink + 3D transmission, wouldn't I be sending
HDMI 2.0 VIC = 94 as well as some valid s3d flag (like side by side) ?

- Shashank
> +		ptr[7] = 0x1 << 5;	/* video format */
> +		ptr[8] = frame->vic;
> +	} else {
> +		ptr[7] = 0x0 << 5;	/* video format */
>   	}
>   
>   	hdmi_infoframe_set_checksum(buffer, length);
> @@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>   
>   	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
>   	    ptr[1] != 1 ||
> -	    (ptr[2] != 5 && ptr[2] != 6))
> +	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
>   		return -EINVAL;
>   
>   	length = ptr[2];
> @@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>   
>   	hvf->length = length;
>   
> -	if (hdmi_video_format == 0x1) {
> -		hvf->vic = ptr[4];
> -	} else if (hdmi_video_format == 0x2) {
> +	if (hdmi_video_format == 0x2) {
> +		if (length != 5 && length != 6)
> +			return -EINVAL;
>   		hvf->s3d_struct = ptr[4] >> 4;
>   		if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
> -			if (length == 6)
> -				hvf->s3d_ext_data = ptr[5] >> 4;
> -			else
> +			if (length != 6)
>   				return -EINVAL;
> +			hvf->s3d_ext_data = ptr[5] >> 4;
>   		}
> +	} else if (hdmi_video_format == 0x1) {
> +		if (length != 5)
> +			return -EINVAL;
> +		hvf->vic = ptr[4];
> +	} else {
> +		if (length != 4)
> +			return -EINVAL;
>   	}
>   
>   	return 0;

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D
  2017-11-13 17:04 ` [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D Ville Syrjala
@ 2017-11-16 14:40   ` Sharma, Shashank
  2017-11-16 16:21     ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-16 14:40 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: Andrzej Hajda, intel-gfx, Laurent Pinchart

Regards

Shashank


On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Appedix F of HDMI 2.0 says that some HDMI sink may fail to switch from
> 3D to 2D mode in a timely fashion if the source simply stops sending the
> HDMI infoframe. The suggested workaround is to keep sending the
> infoframe even when strictly not necessary (ie. no VIC and no S3D).
> HDMI 1.4 does allow for this behaviour, stating that sending the
> infoframe is optional in this case.
>
> The infoframe was first specified in HDMI 1.4, so in theory sinks
> predating that may not appreciate us sending an uknown infoframe
> their way. To avoid regressions let's try to determine if the sink
> supports the infoframe or not. Unfortunately there's no direct way
> to do that, so instead we'll just check if we managed to parse any
> HDMI 1.4 4k or stereo modes from the EDID, and if so we assume the
> sink will accept the infoframe. Also if the EDID contains the HDMI
> 2.0 HDMI Forum VSDB we can assume the sink is prepared to receive
> the infoframe.
I am trying to get some sense from HDMI 2.0 spec section 10.2.1, which 
talks about
switch from 3D to 2D.  To me it looks like:
If (sending_to_hdmi2_sinks) {
     - for 3d modes send HF-VSIF
     - for 2d modes && defined in H14b HFVSIF, send H14B-VSIF
       When you switch from 3d->2d {
          - send_HF-VSIF with 3D_valid bit = 0/1
      }
} else { /* HDMI 1.4b sinks from Appendix F */
     -  send H14b-VSIF with HDMI_video_format[2:0 = 0 OR 1]
}

Should we add a is_hdmi2 check and separate these cases ?

>
> v2: Fix the getting has_hdmi_infoframe from display_info
>      Always fail constructing the infoframe if the display
>      possibly can't handle it
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/bridge/sil-sii8620.c      |  3 ++-
>   drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  4 +++-
>   drivers/gpu/drm/drm_edid.c                | 34 +++++++++++++++++++++++++------
>   drivers/gpu/drm/exynos/exynos_hdmi.c      |  2 +-
>   drivers/gpu/drm/i915/intel_hdmi.c         | 14 +++++++------
>   drivers/gpu/drm/mediatek/mtk_hdmi.c       |  3 ++-
>   drivers/gpu/drm/nouveau/nv50_display.c    |  3 ++-
>   drivers/gpu/drm/rockchip/inno_hdmi.c      |  1 +
>   drivers/gpu/drm/sti/sti_hdmi.c            |  4 +++-
>   drivers/gpu/drm/zte/zx_hdmi.c             |  1 +
>   include/drm/drm_connector.h               |  5 +++++
>   include/drm/drm_edid.h                    |  1 +
>   12 files changed, 57 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
> index b7eb704d0a8a..4417276ba02e 100644
> --- a/drivers/gpu/drm/bridge/sil-sii8620.c
> +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
> @@ -2220,8 +2220,9 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
>   			union hdmi_infoframe frm;
>   			u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
>   
> +			/* FIXME: We need the connector here */
>   			drm_hdmi_vendor_infoframe_from_display_mode(
> -				&frm.vendor.hdmi, adjusted_mode);
> +				&frm.vendor.hdmi, NULL, adjusted_mode);
>   			vic = frm.vendor.hdmi.vic;
>   			if (vic >= ARRAY_SIZE(mhl_vic))
>   				vic = 0;
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index a64ce7112288..b172139502d6 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -1437,7 +1437,9 @@ static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi,
>   	u8 buffer[10];
>   	ssize_t err;
>   
> -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
> +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
> +							  &hdmi->connector,
> +							  mode);
>   	if (err < 0)
>   		/*
>   		 * Going into that statement does not means vendor infoframe
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 749d07a01772..9ada0ccf50df 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3393,6 +3393,7 @@ static int
>   do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
>   		   const u8 *video_db, u8 video_len)
>   {
> +	struct drm_display_info *info = &connector->display_info;
>   	int modes = 0, offset = 0, i, multi_present = 0, multi_len;
>   	u8 vic_len, hdmi_3d_len = 0;
>   	u16 mask;
> @@ -3520,6 +3521,8 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
>   	}
>   
>   out:
> +	if (modes > 0)
> +		info->has_hdmi_infoframe = true;
>   	return modes;
>   }
>   
> @@ -4243,6 +4246,8 @@ static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
>   	struct drm_display_info *display = &connector->display_info;
>   	struct drm_hdmi_info *hdmi = &display->hdmi;
>   
> +	display->has_hdmi_infoframe = true;
> +
>   	if (hf_vsdb[6] & 0x80) {
>   		hdmi->scdc.supported = true;
>   		if (hf_vsdb[6] & 0x40)
> @@ -4416,6 +4421,7 @@ static void drm_add_display_info(struct drm_connector *connector,
>   	info->cea_rev = 0;
>   	info->max_tmds_clock = 0;
>   	info->dvi_dual = false;
> +	info->has_hdmi_infoframe = false;
>   
>   	if (edid->revision < 3)
>   		return;
> @@ -4903,6 +4909,7 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
>    * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
>    * data from a DRM display mode
>    * @frame: HDMI vendor infoframe
> + * @connector: the connector
I remember our old discussion where we realized that we will need this 
connector for all types of infoframes,
eventually, do you think we should start thinking about creating a 
wrapper like drm_any_infoframe_from_display_mode(),
and pass connector and desired type to it ?Or I am getting too ambitious 
targeting this series :) ?
>    * @mode: DRM display mode
>    *
>    * Note that there's is a need to send HDMI vendor infoframes only when using a
> @@ -4913,8 +4920,15 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
>    */
>   int
>   drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> +					    struct drm_connector *connector,
>   					    const struct drm_display_mode *mode)
>   {
> +	/*
> +	 * FIXME: sil-sii8620 doesn't have a connector around when
> +	 * we need one, so we have to be prepared for a NULL connector.
> +	 */
> +	bool has_hdmi_infoframe = connector ?
> +		connector->display_info.has_hdmi_infoframe : false;
>   	int err;
>   	u32 s3d_flags;
>   	u8 vic;
> @@ -4922,11 +4936,21 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>   	if (!frame || !mode)
>   		return -EINVAL;
>   
> +	if (!has_hdmi_infoframe)
> +		return -EINVAL;
> +
>   	vic = drm_match_hdmi_mode(mode);
>   	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
>   
> -	if (!vic && !s3d_flags)
> -		return -EINVAL;
> +	/*
> +	 * Even if it's not absolutely necessary to send the infoframe
> +	 * (ie.vic==0 and s3d_struct==0) we will still send it if we
> +	 * know that the sink can handle it. This is based on a
> +	 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
> +	 * have trouble realizing that they shuld switch from 3D to 2D
> +	 * mode if the source simply stops sending the infoframe when
> +	 * it wants to switch from 3D to 2D.
> +	 */
>   
>   	if (vic && s3d_flags)
>   		return -EINVAL;
> @@ -4935,10 +4959,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>   	if (err < 0)
>   		return err;
>   
> -	if (vic)
> -		frame->vic = vic;
> -	else
> -		frame->s3d_struct = s3d_structure_from_display_mode(mode);
> +	frame->vic = vic;
> +	frame->s3d_struct = s3d_structure_from_display_mode(mode);
>   
>   	return 0;
>   }
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index 0109ff40b1db..812b2773ed69 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -795,7 +795,7 @@ static void hdmi_reg_infoframes(struct hdmi_context *hdata)
>   	}
>   
>   	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi,
> -			&hdata->current_mode);
> +			&hdata->connector, &hdata->current_mode);
>   	if (!ret)
>   		ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf,
>   				sizeof(buf));
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> index 2d95db64cdf2..2ccba4ccf7ad 100644
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -512,12 +512,14 @@ static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder,
>   
>   static void
>   intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder,
> -			      const struct intel_crtc_state *crtc_state)
> +			      const struct intel_crtc_state *crtc_state,
> +			      const struct drm_connector_state *conn_state)
>   {
>   	union hdmi_infoframe frame;
>   	int ret;
>   
>   	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> +							  conn_state->connector,
>   							  &crtc_state->base.adjusted_mode);
>   	if (ret < 0)
>   		return;
> @@ -584,7 +586,7 @@ static void g4x_set_infoframes(struct drm_encoder *encoder,
>   
>   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>   }
>   
>   static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state)
> @@ -725,7 +727,7 @@ static void ibx_set_infoframes(struct drm_encoder *encoder,
>   
>   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>   }
>   
>   static void cpt_set_infoframes(struct drm_encoder *encoder,
> @@ -768,7 +770,7 @@ static void cpt_set_infoframes(struct drm_encoder *encoder,
>   
>   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>   }
>   
>   static void vlv_set_infoframes(struct drm_encoder *encoder,
> @@ -821,7 +823,7 @@ static void vlv_set_infoframes(struct drm_encoder *encoder,
>   
>   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>   }
>   
>   static void hsw_set_infoframes(struct drm_encoder *encoder,
> @@ -854,7 +856,7 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
>   
>   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>   }
>   
>   void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index b78791061983..59a11026dceb 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -1054,7 +1054,8 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
>   	u8 buffer[10];
>   	ssize_t err;
>   
> -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
> +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
> +							  &hdmi->conn, mode);
>   	if (err) {
>   		dev_err(hdmi->dev,
>   			"Failed to get vendor infoframe from mode: %zd\n", err);
> diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
> index b26a506d20ca..9d7b2afd7cfc 100644
> --- a/drivers/gpu/drm/nouveau/nv50_display.c
> +++ b/drivers/gpu/drm/nouveau/nv50_display.c
> @@ -2754,7 +2754,8 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
>   			= hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
>   	}
>   
> -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi, mode);
> +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
> +							  &nv_connector->base, mode);
>   	if (!ret) {
>   		/* We have a Vendor InfoFrame, populate it to the display */
>   		args.pwr.vendor_infoframe_length
> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
> index ee584d87111f..fab30927a889 100644
> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c
> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
> @@ -282,6 +282,7 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi,
>   	int rc;
>   
>   	rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> +							 &hdmi->connector,
>   							 mode);
>   
>   	return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI,
> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> index d1902750a85d..c3b292ab17a5 100644
> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> @@ -515,7 +515,9 @@ static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi)
>   
>   	DRM_DEBUG_DRIVER("\n");
>   
> -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe, mode);
> +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe,
> +							  hdmi->drm_connector,
> +							  mode);
>   	if (ret < 0) {
>   		/*
>   		 * Going into that statement does not means vendor infoframe
> diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
> index b8abb1b496ff..13ea90f7a185 100644
> --- a/drivers/gpu/drm/zte/zx_hdmi.c
> +++ b/drivers/gpu/drm/zte/zx_hdmi.c
> @@ -108,6 +108,7 @@ static int zx_hdmi_config_video_vsi(struct zx_hdmi *hdmi,
>   	int ret;
>   
>   	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> +							  &hdmi->connector,
>   							  mode);
>   	if (ret) {
>   		DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n",
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 2b97d1e28f60..1543212b0449 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -270,6 +270,11 @@ struct drm_display_info {
>   	bool dvi_dual;
>   
>   	/**
> +	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
> +	 */
> +	bool has_hdmi_infoframe;
> +
> +	/**
>   	 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
>   	 * more stuff redundant with @bus_formats.
>   	 */
> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> index 9e4e23524840..3c8740ad1db6 100644
> --- a/include/drm/drm_edid.h
> +++ b/include/drm/drm_edid.h
> @@ -356,6 +356,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>   					 bool is_hdmi2_sink);
>   int
>   drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> +					    struct drm_connector *connector,
>   					    const struct drm_display_mode *mode);
>   void
>   drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
Otherwise looks good
- Shashank
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-13 17:04 ` [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling Ville Syrjala
  2017-11-13 18:13   ` Jose Abreu
@ 2017-11-16 14:51   ` Sharma, Shashank
  2017-11-16 16:23     ` Ville Syrjälä
  1 sibling, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-16 14:51 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Jose Abreu, Lin, Jia, Akashdeep Sharma, intel-gfx, Emil Velikov,
	Daniel Vetter, Nautiyal Ankit, Jim Bride

Regards

Shashank


On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
> cause us to not send out any VICs in the AVI infoframes. That commit
> was since reverted, but if and when we add aspect ratio handing back
> we need to be more careful.
>
> Let's handle this by considering the aspect ratio as a requirement
> for cea mode matching only if the passed in mode actually has a
> non-zero aspect ratio field. This will keep userspace that doesn't
> provide an aspect ratio working as before by matching it to the
> first otherwise equal cea mode. And once userspace starts to
> provide the aspect ratio it will be considerd a hard requirement
> for the match.
>
> Also change the hdmi mode matching to use drm_mode_match() for
> consistency, but we don't match on aspect ratio there since the
> spec doesn't list a specific aspect ratio for those modes.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: "Lin, Jia" <lin.a.jia@intel.com>
> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> Cc: Jim Bride <jim.bride@linux.intel.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
>   1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 7220b8f9a7e8..00aa98f3e55d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
>   static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
>   					     unsigned int clock_tolerance)
>   {
> +	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;
This doesn't look right. This means we are expecting a CEA mode without 
a pic aspect ratio field,
which is invalid.  Ankit is going to publish the aspect ratio patch 
series again, with proper DRM cap and flags check. Would it be
ok if we have a look that handling first ?
> +
>   	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
>   		struct drm_display_mode cea_mode = edid_cea_modes[vic];
>   		unsigned int clock1, clock2;
> @@ -2921,7 +2925,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
>   			continue;
>   
>   		do {
> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
>   				return vic;
>   		} while (cea_mode_alternate_timings(vic, &cea_mode));
>   	}
> @@ -2938,11 +2942,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
>    */
>   u8 drm_match_cea_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;
same here, and probably in other CEA match functions.
> +
>   	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
>   		struct drm_display_mode cea_mode = edid_cea_modes[vic];
>   		unsigned int clock1, clock2;
> @@ -2956,7 +2964,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
>   			continue;
>   
>   		do {
> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
>   				return vic;
>   		} while (cea_mode_alternate_timings(vic, &cea_mode));
>   	}
> @@ -3003,6 +3011,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
>   static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
>   					      unsigned int clock_tolerance)
>   {
> +	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
>   	u8 vic;
>   
>   	if (!to_match->clock)
> @@ -3020,7 +3029,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
>   		    abs(to_match->clock - clock2) > clock_tolerance)
>   			continue;
>   
> -		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
> +		if (drm_mode_match(to_match, hdmi_mode, match_flags))
>   			return vic;
>   	}
>   
> @@ -3037,6 +3046,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
>    */
>   static u8 drm_match_hdmi_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)
> @@ -3052,7 +3062,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
>   
>   		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
>   		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
> -		    drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
> +		    drm_mode_match(to_match, hdmi_mode, match_flags))
>   			return vic;
>   	}
>   	return 0;
- Shashank
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-13 17:04 ` [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Ville Syrjala
  2017-11-13 18:30   ` Jose Abreu
@ 2017-11-16 15:01   ` Sharma, Shashank
  2017-11-16 16:26     ` Ville Syrjälä
  1 sibling, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-16 15:01 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Jose Abreu, Daniel Vetter, intel-gfx, Emil Velikov, Nautiyal Ankit

Regards

Shashank


On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> If the user mode would specify an aspect ratio other than 4:3 or 16:9
> we now silently ignore it. Maybe a better apporoach is to return an
> error? Let's try that.
>
> Also we must be careful that we don't try to send illegal picture
> aspect in the infoframe as it's only capable of signalling none,
> 4:3, and 16:9. Currently we're sending these bogus infoframes
> whenever the cea mode specifies some other aspect ratio.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/drm_edid.c | 23 +++++++++++++++++------
>   1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 00aa98f3e55d..bafb3ee4ea97 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4786,6 +4786,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>   					 const struct drm_display_mode *mode,
>   					 bool is_hdmi2_sink)
>   {
> +	enum hdmi_picture_aspect picture_aspect;
>   	int err;
>   
>   	if (!frame || !mode)
> @@ -4828,13 +4829,23 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>   	 * Populate picture aspect ratio from either
>   	 * user input (if specified) or from the CEA mode list.
>   	 */
> -	if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 ||
> -		mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9)
> -		frame->picture_aspect = mode->picture_aspect_ratio;
> -	else if (frame->video_code > 0)
> -		frame->picture_aspect = drm_get_cea_aspect_ratio(
> -						frame->video_code);
> +	picture_aspect = mode->picture_aspect_ratio;
> +	if (picture_aspect == HDMI_PICTURE_ASPECT_NONE)
> +		picture_aspect = drm_get_cea_aspect_ratio(frame->video_code);
This is slightly going in the loop.
- During the modeset the driver cant specify the aspect ratio 
information, as DRM layer lacks this support.
- So we fill the VIC field, by comparing the mode with the 
DRM_CEA_MODES[] list. This will pick the first mode
   available in the list (regardless of its aspect ratio), and fill the 
VIC, as we don't consider aspect ratio while comparing timings.
- Again, now while sending the aspect ratio, we are picking up the VIC, 
which may not be correct.

So if we have 720x480(4:3) and 720x480(16:9) in the list, as 4:3 is 
first in list, we will always pick 4:3 aspect ratio.

- Shashank
>   
> +	/*
> +	 * The infoframe can't convey anything but none, 4:3
> +	 * and 16:9, so if the user has asked for anything else
> +	 * we can only satisfy it by specifying the right VIC.
> +	 */
> +	if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
> +		if (picture_aspect !=
> +		    drm_get_cea_aspect_ratio(frame->video_code))
> +			return -EINVAL;
> +		picture_aspect = HDMI_PICTURE_ASPECT_NONE;
> +	}
> +
> +	frame->picture_aspect = picture_aspect;
>   	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
>   	frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
>   

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes
  2017-11-16 14:36   ` Sharma, Shashank
@ 2017-11-16 16:16     ` Ville Syrjälä
  2017-11-17  3:05         ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-16 16:16 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: dri-devel, intel-gfx, Andrzej Hajda, Thierry Reding,
	Hans Verkuil, linux-media

On Thu, Nov 16, 2017 at 08:06:18PM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > HDMI 2.0 Appendix F suggest that we should keep sending the infoframe
> > when switching from 3D to 2D mode, even if the infoframe isn't strictly
> > necessary (ie. not needed to transmit the VIC or stereo information).
> > This is a workaround against some sinks that fail to realize that they
> > should switch from 3D to 2D mode when the source stop transmitting
> > the infoframe.
> >
> > v2: Handle unpack() as well
> >      Pull the length calculation into a helper
> >
> > Cc: Shashank Sharma <shashank.sharma@intel.com>
> > Cc: Andrzej Hajda <a.hajda@samsung.com>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Hans Verkuil <hans.verkuil@cisco.com>
> > Cc: linux-media@vger.kernel.org
> > Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> #v1
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/video/hdmi.c | 51 +++++++++++++++++++++++++++++++--------------------
> >   1 file changed, 31 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> > index 1cf907ecded4..111a0ab6280a 100644
> > --- a/drivers/video/hdmi.c
> > +++ b/drivers/video/hdmi.c
> > @@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
> >   }
> >   EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
> >   
> > +static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
> > +{
> > +	/* for side by side (half) we also need to provide 3D_Ext_Data */
> > +	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
> > +		return 6;
> > +	else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
> > +		return 5;
> > +	else
> > +		return 4;
> > +}
> > +
> >   /**
> >    * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
> >    * @frame: HDMI infoframe
> > @@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
> >   	u8 *ptr = buffer;
> >   	size_t length;
> >   
> > -	/* empty info frame */
> > -	if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
> > -		return -EINVAL;
> > -
> >   	/* only one of those can be supplied */
> >   	if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
> >   		return -EINVAL;
> >   
> > -	/* for side by side (half) we also need to provide 3D_Ext_Data */
> > -	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
> > -		frame->length = 6;
> > -	else
> > -		frame->length = 5;
> > +	frame->length = hdmi_vendor_infoframe_length(frame);
> >   
> >   	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
> >   
> > @@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
> >   	ptr[5] = 0x0c;
> >   	ptr[6] = 0x00;
> >   
> > -	if (frame->vic) {
> > -		ptr[7] = 0x1 << 5;	/* video format */
> > -		ptr[8] = frame->vic;
> > -	} else {
> > +	if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
> >   		ptr[7] = 0x2 << 5;	/* video format */
> >   		ptr[8] = (frame->s3d_struct & 0xf) << 4;
> >   		if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
> >   			ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
> > +	} else if (frame->vic) {
> Please correct me if I dint understand this properly, but for a HDMI 2.0 
> sink + 3D transmission, wouldn't I be sending
> HDMI 2.0 VIC = 94 as well as some valid s3d flag (like side by side) ?

That vic will be in the AVI infoframe. Here we're concerned about the
VIC in the HDMI vendor infoframe.

> 
> - Shashank
> > +		ptr[7] = 0x1 << 5;	/* video format */
> > +		ptr[8] = frame->vic;
> > +	} else {
> > +		ptr[7] = 0x0 << 5;	/* video format */
> >   	}
> >   
> >   	hdmi_infoframe_set_checksum(buffer, length);
> > @@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> >   
> >   	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
> >   	    ptr[1] != 1 ||
> > -	    (ptr[2] != 5 && ptr[2] != 6))
> > +	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
> >   		return -EINVAL;
> >   
> >   	length = ptr[2];
> > @@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> >   
> >   	hvf->length = length;
> >   
> > -	if (hdmi_video_format == 0x1) {
> > -		hvf->vic = ptr[4];
> > -	} else if (hdmi_video_format == 0x2) {
> > +	if (hdmi_video_format == 0x2) {
> > +		if (length != 5 && length != 6)
> > +			return -EINVAL;
> >   		hvf->s3d_struct = ptr[4] >> 4;
> >   		if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
> > -			if (length == 6)
> > -				hvf->s3d_ext_data = ptr[5] >> 4;
> > -			else
> > +			if (length != 6)
> >   				return -EINVAL;
> > +			hvf->s3d_ext_data = ptr[5] >> 4;
> >   		}
> > +	} else if (hdmi_video_format == 0x1) {
> > +		if (length != 5)
> > +			return -EINVAL;
> > +		hvf->vic = ptr[4];
> > +	} else {
> > +		if (length != 4)
> > +			return -EINVAL;
> >   	}
> >   
> >   	return 0;

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D
  2017-11-16 14:40   ` Sharma, Shashank
@ 2017-11-16 16:21     ` Ville Syrjälä
  2017-11-17  3:10       ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-16 16:21 UTC (permalink / raw)
  To: Sharma, Shashank; +Cc: Andrzej Hajda, intel-gfx, Laurent Pinchart, dri-devel

On Thu, Nov 16, 2017 at 08:10:55PM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Appedix F of HDMI 2.0 says that some HDMI sink may fail to switch from
> > 3D to 2D mode in a timely fashion if the source simply stops sending the
> > HDMI infoframe. The suggested workaround is to keep sending the
> > infoframe even when strictly not necessary (ie. no VIC and no S3D).
> > HDMI 1.4 does allow for this behaviour, stating that sending the
> > infoframe is optional in this case.
> >
> > The infoframe was first specified in HDMI 1.4, so in theory sinks
> > predating that may not appreciate us sending an uknown infoframe
> > their way. To avoid regressions let's try to determine if the sink
> > supports the infoframe or not. Unfortunately there's no direct way
> > to do that, so instead we'll just check if we managed to parse any
> > HDMI 1.4 4k or stereo modes from the EDID, and if so we assume the
> > sink will accept the infoframe. Also if the EDID contains the HDMI
> > 2.0 HDMI Forum VSDB we can assume the sink is prepared to receive
> > the infoframe.
> I am trying to get some sense from HDMI 2.0 spec section 10.2.1, which 
> talks about
> switch from 3D to 2D.  To me it looks like:
> If (sending_to_hdmi2_sinks) {
>      - for 3d modes send HF-VSIF
>      - for 2d modes && defined in H14b HFVSIF, send H14B-VSIF
>        When you switch from 3d->2d {
>           - send_HF-VSIF with 3D_valid bit = 0/1
>       }
> } else { /* HDMI 1.4b sinks from Appendix F */
>      -  send H14b-VSIF with HDMI_video_format[2:0 = 0 OR 1]
> }
> 
> Should we add a is_hdmi2 check and separate these cases ?

We don't support the HDMI forum infoframe. Maybe someone forgot to
implement that when adding the rest of HDMI 2.0 support? ;)

> 
> >
> > v2: Fix the getting has_hdmi_infoframe from display_info
> >      Always fail constructing the infoframe if the display
> >      possibly can't handle it
> >
> > Cc: Shashank Sharma <shashank.sharma@intel.com>
> > Cc: Andrzej Hajda <a.hajda@samsung.com>
> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/bridge/sil-sii8620.c      |  3 ++-
> >   drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  4 +++-
> >   drivers/gpu/drm/drm_edid.c                | 34 +++++++++++++++++++++++++------
> >   drivers/gpu/drm/exynos/exynos_hdmi.c      |  2 +-
> >   drivers/gpu/drm/i915/intel_hdmi.c         | 14 +++++++------
> >   drivers/gpu/drm/mediatek/mtk_hdmi.c       |  3 ++-
> >   drivers/gpu/drm/nouveau/nv50_display.c    |  3 ++-
> >   drivers/gpu/drm/rockchip/inno_hdmi.c      |  1 +
> >   drivers/gpu/drm/sti/sti_hdmi.c            |  4 +++-
> >   drivers/gpu/drm/zte/zx_hdmi.c             |  1 +
> >   include/drm/drm_connector.h               |  5 +++++
> >   include/drm/drm_edid.h                    |  1 +
> >   12 files changed, 57 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
> > index b7eb704d0a8a..4417276ba02e 100644
> > --- a/drivers/gpu/drm/bridge/sil-sii8620.c
> > +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
> > @@ -2220,8 +2220,9 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
> >   			union hdmi_infoframe frm;
> >   			u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
> >   
> > +			/* FIXME: We need the connector here */
> >   			drm_hdmi_vendor_infoframe_from_display_mode(
> > -				&frm.vendor.hdmi, adjusted_mode);
> > +				&frm.vendor.hdmi, NULL, adjusted_mode);
> >   			vic = frm.vendor.hdmi.vic;
> >   			if (vic >= ARRAY_SIZE(mhl_vic))
> >   				vic = 0;
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> > index a64ce7112288..b172139502d6 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> > @@ -1437,7 +1437,9 @@ static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi,
> >   	u8 buffer[10];
> >   	ssize_t err;
> >   
> > -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
> > +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
> > +							  &hdmi->connector,
> > +							  mode);
> >   	if (err < 0)
> >   		/*
> >   		 * Going into that statement does not means vendor infoframe
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 749d07a01772..9ada0ccf50df 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -3393,6 +3393,7 @@ static int
> >   do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
> >   		   const u8 *video_db, u8 video_len)
> >   {
> > +	struct drm_display_info *info = &connector->display_info;
> >   	int modes = 0, offset = 0, i, multi_present = 0, multi_len;
> >   	u8 vic_len, hdmi_3d_len = 0;
> >   	u16 mask;
> > @@ -3520,6 +3521,8 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
> >   	}
> >   
> >   out:
> > +	if (modes > 0)
> > +		info->has_hdmi_infoframe = true;
> >   	return modes;
> >   }
> >   
> > @@ -4243,6 +4246,8 @@ static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
> >   	struct drm_display_info *display = &connector->display_info;
> >   	struct drm_hdmi_info *hdmi = &display->hdmi;
> >   
> > +	display->has_hdmi_infoframe = true;
> > +
> >   	if (hf_vsdb[6] & 0x80) {
> >   		hdmi->scdc.supported = true;
> >   		if (hf_vsdb[6] & 0x40)
> > @@ -4416,6 +4421,7 @@ static void drm_add_display_info(struct drm_connector *connector,
> >   	info->cea_rev = 0;
> >   	info->max_tmds_clock = 0;
> >   	info->dvi_dual = false;
> > +	info->has_hdmi_infoframe = false;
> >   
> >   	if (edid->revision < 3)
> >   		return;
> > @@ -4903,6 +4909,7 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
> >    * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
> >    * data from a DRM display mode
> >    * @frame: HDMI vendor infoframe
> > + * @connector: the connector
> I remember our old discussion where we realized that we will need this 
> connector for all types of infoframes,
> eventually, do you think we should start thinking about creating a 
> wrapper like drm_any_infoframe_from_display_mode(),
> and pass connector and desired type to it ?Or I am getting too ambitious 
> targeting this series :) ?
> >    * @mode: DRM display mode
> >    *
> >    * Note that there's is a need to send HDMI vendor infoframes only when using a
> > @@ -4913,8 +4920,15 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
> >    */
> >   int
> >   drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> > +					    struct drm_connector *connector,
> >   					    const struct drm_display_mode *mode)
> >   {
> > +	/*
> > +	 * FIXME: sil-sii8620 doesn't have a connector around when
> > +	 * we need one, so we have to be prepared for a NULL connector.
> > +	 */
> > +	bool has_hdmi_infoframe = connector ?
> > +		connector->display_info.has_hdmi_infoframe : false;
> >   	int err;
> >   	u32 s3d_flags;
> >   	u8 vic;
> > @@ -4922,11 +4936,21 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >   	if (!frame || !mode)
> >   		return -EINVAL;
> >   
> > +	if (!has_hdmi_infoframe)
> > +		return -EINVAL;
> > +
> >   	vic = drm_match_hdmi_mode(mode);
> >   	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
> >   
> > -	if (!vic && !s3d_flags)
> > -		return -EINVAL;
> > +	/*
> > +	 * Even if it's not absolutely necessary to send the infoframe
> > +	 * (ie.vic==0 and s3d_struct==0) we will still send it if we
> > +	 * know that the sink can handle it. This is based on a
> > +	 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
> > +	 * have trouble realizing that they shuld switch from 3D to 2D
> > +	 * mode if the source simply stops sending the infoframe when
> > +	 * it wants to switch from 3D to 2D.
> > +	 */
> >   
> >   	if (vic && s3d_flags)
> >   		return -EINVAL;
> > @@ -4935,10 +4959,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >   	if (err < 0)
> >   		return err;
> >   
> > -	if (vic)
> > -		frame->vic = vic;
> > -	else
> > -		frame->s3d_struct = s3d_structure_from_display_mode(mode);
> > +	frame->vic = vic;
> > +	frame->s3d_struct = s3d_structure_from_display_mode(mode);
> >   
> >   	return 0;
> >   }
> > diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
> > index 0109ff40b1db..812b2773ed69 100644
> > --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> > +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> > @@ -795,7 +795,7 @@ static void hdmi_reg_infoframes(struct hdmi_context *hdata)
> >   	}
> >   
> >   	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi,
> > -			&hdata->current_mode);
> > +			&hdata->connector, &hdata->current_mode);
> >   	if (!ret)
> >   		ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf,
> >   				sizeof(buf));
> > diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> > index 2d95db64cdf2..2ccba4ccf7ad 100644
> > --- a/drivers/gpu/drm/i915/intel_hdmi.c
> > +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> > @@ -512,12 +512,14 @@ static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder,
> >   
> >   static void
> >   intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder,
> > -			      const struct intel_crtc_state *crtc_state)
> > +			      const struct intel_crtc_state *crtc_state,
> > +			      const struct drm_connector_state *conn_state)
> >   {
> >   	union hdmi_infoframe frame;
> >   	int ret;
> >   
> >   	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> > +							  conn_state->connector,
> >   							  &crtc_state->base.adjusted_mode);
> >   	if (ret < 0)
> >   		return;
> > @@ -584,7 +586,7 @@ static void g4x_set_infoframes(struct drm_encoder *encoder,
> >   
> >   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> > -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> > +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >   }
> >   
> >   static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state)
> > @@ -725,7 +727,7 @@ static void ibx_set_infoframes(struct drm_encoder *encoder,
> >   
> >   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> > -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> > +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >   }
> >   
> >   static void cpt_set_infoframes(struct drm_encoder *encoder,
> > @@ -768,7 +770,7 @@ static void cpt_set_infoframes(struct drm_encoder *encoder,
> >   
> >   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> > -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> > +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >   }
> >   
> >   static void vlv_set_infoframes(struct drm_encoder *encoder,
> > @@ -821,7 +823,7 @@ static void vlv_set_infoframes(struct drm_encoder *encoder,
> >   
> >   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> > -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> > +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >   }
> >   
> >   static void hsw_set_infoframes(struct drm_encoder *encoder,
> > @@ -854,7 +856,7 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
> >   
> >   	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >   	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> > -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> > +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >   }
> >   
> >   void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
> > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> > index b78791061983..59a11026dceb 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> > @@ -1054,7 +1054,8 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
> >   	u8 buffer[10];
> >   	ssize_t err;
> >   
> > -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
> > +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
> > +							  &hdmi->conn, mode);
> >   	if (err) {
> >   		dev_err(hdmi->dev,
> >   			"Failed to get vendor infoframe from mode: %zd\n", err);
> > diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
> > index b26a506d20ca..9d7b2afd7cfc 100644
> > --- a/drivers/gpu/drm/nouveau/nv50_display.c
> > +++ b/drivers/gpu/drm/nouveau/nv50_display.c
> > @@ -2754,7 +2754,8 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
> >   			= hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
> >   	}
> >   
> > -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi, mode);
> > +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
> > +							  &nv_connector->base, mode);
> >   	if (!ret) {
> >   		/* We have a Vendor InfoFrame, populate it to the display */
> >   		args.pwr.vendor_infoframe_length
> > diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
> > index ee584d87111f..fab30927a889 100644
> > --- a/drivers/gpu/drm/rockchip/inno_hdmi.c
> > +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
> > @@ -282,6 +282,7 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi,
> >   	int rc;
> >   
> >   	rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> > +							 &hdmi->connector,
> >   							 mode);
> >   
> >   	return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI,
> > diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> > index d1902750a85d..c3b292ab17a5 100644
> > --- a/drivers/gpu/drm/sti/sti_hdmi.c
> > +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> > @@ -515,7 +515,9 @@ static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi)
> >   
> >   	DRM_DEBUG_DRIVER("\n");
> >   
> > -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe, mode);
> > +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe,
> > +							  hdmi->drm_connector,
> > +							  mode);
> >   	if (ret < 0) {
> >   		/*
> >   		 * Going into that statement does not means vendor infoframe
> > diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
> > index b8abb1b496ff..13ea90f7a185 100644
> > --- a/drivers/gpu/drm/zte/zx_hdmi.c
> > +++ b/drivers/gpu/drm/zte/zx_hdmi.c
> > @@ -108,6 +108,7 @@ static int zx_hdmi_config_video_vsi(struct zx_hdmi *hdmi,
> >   	int ret;
> >   
> >   	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> > +							  &hdmi->connector,
> >   							  mode);
> >   	if (ret) {
> >   		DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n",
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index 2b97d1e28f60..1543212b0449 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -270,6 +270,11 @@ struct drm_display_info {
> >   	bool dvi_dual;
> >   
> >   	/**
> > +	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
> > +	 */
> > +	bool has_hdmi_infoframe;
> > +
> > +	/**
> >   	 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
> >   	 * more stuff redundant with @bus_formats.
> >   	 */
> > diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> > index 9e4e23524840..3c8740ad1db6 100644
> > --- a/include/drm/drm_edid.h
> > +++ b/include/drm/drm_edid.h
> > @@ -356,6 +356,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
> >   					 bool is_hdmi2_sink);
> >   int
> >   drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> > +					    struct drm_connector *connector,
> >   					    const struct drm_display_mode *mode);
> >   void
> >   drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
> Otherwise looks good
> - Shashank

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-16 14:51   ` Sharma, Shashank
@ 2017-11-16 16:23     ` Ville Syrjälä
  2017-11-17  3:19       ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-16 16:23 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: Jose Abreu, Lin, Jia, intel-gfx, dri-devel, Daniel Vetter,
	Nautiyal Ankit

On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
> > cause us to not send out any VICs in the AVI infoframes. That commit
> > was since reverted, but if and when we add aspect ratio handing back
> > we need to be more careful.
> >
> > Let's handle this by considering the aspect ratio as a requirement
> > for cea mode matching only if the passed in mode actually has a
> > non-zero aspect ratio field. This will keep userspace that doesn't
> > provide an aspect ratio working as before by matching it to the
> > first otherwise equal cea mode. And once userspace starts to
> > provide the aspect ratio it will be considerd a hard requirement
> > for the match.
> >
> > Also change the hdmi mode matching to use drm_mode_match() for
> > consistency, but we don't match on aspect ratio there since the
> > spec doesn't list a specific aspect ratio for those modes.
> >
> > Cc: Shashank Sharma <shashank.sharma@intel.com>
> > Cc: "Lin, Jia" <lin.a.jia@intel.com>
> > Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> > Cc: Jim Bride <jim.bride@linux.intel.com>
> > Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.l.velikov@gmail.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
> >   1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 7220b8f9a7e8..00aa98f3e55d 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
> >   static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
> >   					     unsigned int clock_tolerance)
> >   {
> > +	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;
> This doesn't look right. This means we are expecting a CEA mode without 
> a pic aspect ratio field,
> which is invalid.

No, it's perfectly valid. It's what we currently get from userspace.

> Ankit is going to publish the aspect ratio patch 
> series again, with proper DRM cap and flags check. Would it be
> ok if we have a look that handling first ?

This patch will be needed by that work. Otherwise we're going to stop
sending a VIC for CEA modes with current userspace.

> > +
> >   	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> >   		struct drm_display_mode cea_mode = edid_cea_modes[vic];
> >   		unsigned int clock1, clock2;
> > @@ -2921,7 +2925,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
> >   			continue;
> >   
> >   		do {
> > -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
> > +			if (drm_mode_match(to_match, &cea_mode, match_flags))
> >   				return vic;
> >   		} while (cea_mode_alternate_timings(vic, &cea_mode));
> >   	}
> > @@ -2938,11 +2942,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
> >    */
> >   u8 drm_match_cea_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;
> same here, and probably in other CEA match functions.
> > +
> >   	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> >   		struct drm_display_mode cea_mode = edid_cea_modes[vic];
> >   		unsigned int clock1, clock2;
> > @@ -2956,7 +2964,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
> >   			continue;
> >   
> >   		do {
> > -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
> > +			if (drm_mode_match(to_match, &cea_mode, match_flags))
> >   				return vic;
> >   		} while (cea_mode_alternate_timings(vic, &cea_mode));
> >   	}
> > @@ -3003,6 +3011,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
> >   static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
> >   					      unsigned int clock_tolerance)
> >   {
> > +	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
> >   	u8 vic;
> >   
> >   	if (!to_match->clock)
> > @@ -3020,7 +3029,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
> >   		    abs(to_match->clock - clock2) > clock_tolerance)
> >   			continue;
> >   
> > -		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
> > +		if (drm_mode_match(to_match, hdmi_mode, match_flags))
> >   			return vic;
> >   	}
> >   
> > @@ -3037,6 +3046,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
> >    */
> >   static u8 drm_match_hdmi_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)
> > @@ -3052,7 +3062,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
> >   
> >   		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
> >   		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
> > -		    drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
> > +		    drm_mode_match(to_match, hdmi_mode, match_flags))
> >   			return vic;
> >   	}
> >   	return 0;
> - Shashank

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-16 15:01   ` Sharma, Shashank
@ 2017-11-16 16:26     ` Ville Syrjälä
  2017-11-17  3:23       ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-16 16:26 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: Jose Abreu, Daniel Vetter, intel-gfx, Emil Velikov, dri-devel,
	Nautiyal Ankit

On Thu, Nov 16, 2017 at 08:31:36PM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > If the user mode would specify an aspect ratio other than 4:3 or 16:9
> > we now silently ignore it. Maybe a better apporoach is to return an
> > error? Let's try that.
> >
> > Also we must be careful that we don't try to send illegal picture
> > aspect in the infoframe as it's only capable of signalling none,
> > 4:3, and 16:9. Currently we're sending these bogus infoframes
> > whenever the cea mode specifies some other aspect ratio.
> >
> > Cc: Shashank Sharma <shashank.sharma@intel.com>
> > Cc: Sean Paul <seanpaul@chromium.org>
> > Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Emil Velikov <emil.l.velikov@gmail.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/drm_edid.c | 23 +++++++++++++++++------
> >   1 file changed, 17 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 00aa98f3e55d..bafb3ee4ea97 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -4786,6 +4786,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
> >   					 const struct drm_display_mode *mode,
> >   					 bool is_hdmi2_sink)
> >   {
> > +	enum hdmi_picture_aspect picture_aspect;
> >   	int err;
> >   
> >   	if (!frame || !mode)
> > @@ -4828,13 +4829,23 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
> >   	 * Populate picture aspect ratio from either
> >   	 * user input (if specified) or from the CEA mode list.
> >   	 */
> > -	if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 ||
> > -		mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9)
> > -		frame->picture_aspect = mode->picture_aspect_ratio;
> > -	else if (frame->video_code > 0)
> > -		frame->picture_aspect = drm_get_cea_aspect_ratio(
> > -						frame->video_code);
> > +	picture_aspect = mode->picture_aspect_ratio;
> > +	if (picture_aspect == HDMI_PICTURE_ASPECT_NONE)
> > +		picture_aspect = drm_get_cea_aspect_ratio(frame->video_code);
> This is slightly going in the loop.
> - During the modeset the driver cant specify the aspect ratio 
> information, as DRM layer lacks this support.
> - So we fill the VIC field, by comparing the mode with the 
> DRM_CEA_MODES[] list. This will pick the first mode
>    available in the list (regardless of its aspect ratio), and fill the 
> VIC, as we don't consider aspect ratio while comparing timings.
> - Again, now while sending the aspect ratio, we are picking up the VIC, 
> which may not be correct.
> 
> So if we have 720x480(4:3) and 720x480(16:9) in the list, as 4:3 is 
> first in list, we will always pick 4:3 aspect ratio.

Yes. The user didn't care about the aspect ratio (or rather couldn't
specify one) so we just pick one. Which is exactly what we've been
doing ever since we started sending the VIC in the infoframe.

> 
> - Shashank
> >   
> > +	/*
> > +	 * The infoframe can't convey anything but none, 4:3
> > +	 * and 16:9, so if the user has asked for anything else
> > +	 * we can only satisfy it by specifying the right VIC.
> > +	 */
> > +	if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
> > +		if (picture_aspect !=
> > +		    drm_get_cea_aspect_ratio(frame->video_code))
> > +			return -EINVAL;
> > +		picture_aspect = HDMI_PICTURE_ASPECT_NONE;
> > +	}
> > +
> > +	frame->picture_aspect = picture_aspect;
> >   	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
> >   	frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
> >   

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes
  2017-11-16 16:16     ` Ville Syrjälä
@ 2017-11-17  3:05         ` Sharma, Shashank
  0 siblings, 0 replies; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-17  3:05 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: dri-devel, intel-gfx, Andrzej Hajda, Thierry Reding,
	Hans Verkuil, linux-media

Regards

Shashank


On 11/16/2017 9:46 PM, Ville Syrjälä wrote:
> On Thu, Nov 16, 2017 at 08:06:18PM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> HDMI 2.0 Appendix F suggest that we should keep sending the infoframe
>>> when switching from 3D to 2D mode, even if the infoframe isn't strictly
>>> necessary (ie. not needed to transmit the VIC or stereo information).
>>> This is a workaround against some sinks that fail to realize that they
>>> should switch from 3D to 2D mode when the source stop transmitting
>>> the infoframe.
>>>
>>> v2: Handle unpack() as well
>>>       Pull the length calculation into a helper
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Andrzej Hajda <a.hajda@samsung.com>
>>> Cc: Thierry Reding <thierry.reding@gmail.com>
>>> Cc: Hans Verkuil <hans.verkuil@cisco.com>
>>> Cc: linux-media@vger.kernel.org
>>> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> #v1
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/video/hdmi.c | 51 +++++++++++++++++++++++++++++++--------------------
>>>    1 file changed, 31 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
>>> index 1cf907ecded4..111a0ab6280a 100644
>>> --- a/drivers/video/hdmi.c
>>> +++ b/drivers/video/hdmi.c
>>> @@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
>>>    }
>>>    EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
>>>    
>>> +static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
>>> +{
>>> +	/* for side by side (half) we also need to provide 3D_Ext_Data */
>>> +	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>>> +		return 6;
>>> +	else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
>>> +		return 5;
>>> +	else
>>> +		return 4;
>>> +}
>>> +
>>>    /**
>>>     * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
>>>     * @frame: HDMI infoframe
>>> @@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
>>>    	u8 *ptr = buffer;
>>>    	size_t length;
>>>    
>>> -	/* empty info frame */
>>> -	if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
>>> -		return -EINVAL;
>>> -
>>>    	/* only one of those can be supplied */
>>>    	if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
>>>    		return -EINVAL;
>>>    
>>> -	/* for side by side (half) we also need to provide 3D_Ext_Data */
>>> -	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>>> -		frame->length = 6;
>>> -	else
>>> -		frame->length = 5;
>>> +	frame->length = hdmi_vendor_infoframe_length(frame);
>>>    
>>>    	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
>>>    
>>> @@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
>>>    	ptr[5] = 0x0c;
>>>    	ptr[6] = 0x00;
>>>    
>>> -	if (frame->vic) {
>>> -		ptr[7] = 0x1 << 5;	/* video format */
>>> -		ptr[8] = frame->vic;
>>> -	} else {
>>> +	if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
>>>    		ptr[7] = 0x2 << 5;	/* video format */
>>>    		ptr[8] = (frame->s3d_struct & 0xf) << 4;
>>>    		if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>>>    			ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
>>> +	} else if (frame->vic) {
>> Please correct me if I dint understand this properly, but for a HDMI 2.0
>> sink + 3D transmission, wouldn't I be sending
>> HDMI 2.0 VIC = 94 as well as some valid s3d flag (like side by side) ?
> That vic will be in the AVI infoframe. Here we're concerned about the
> VIC in the HDMI vendor infoframe.
Yep, I was thinking if there is any way we can cross check that there is 
a valid HDMI 2 vic
before we do anything here, but seems like a long shot.

Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
>> - Shashank
>>> +		ptr[7] = 0x1 << 5;	/* video format */
>>> +		ptr[8] = frame->vic;
>>> +	} else {
>>> +		ptr[7] = 0x0 << 5;	/* video format */
>>>    	}
>>>    
>>>    	hdmi_infoframe_set_checksum(buffer, length);
>>> @@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>>>    
>>>    	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
>>>    	    ptr[1] != 1 ||
>>> -	    (ptr[2] != 5 && ptr[2] != 6))
>>> +	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
>>>    		return -EINVAL;
>>>    
>>>    	length = ptr[2];
>>> @@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>>>    
>>>    	hvf->length = length;
>>>    
>>> -	if (hdmi_video_format == 0x1) {
>>> -		hvf->vic = ptr[4];
>>> -	} else if (hdmi_video_format == 0x2) {
>>> +	if (hdmi_video_format == 0x2) {
>>> +		if (length != 5 && length != 6)
>>> +			return -EINVAL;
>>>    		hvf->s3d_struct = ptr[4] >> 4;
>>>    		if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
>>> -			if (length == 6)
>>> -				hvf->s3d_ext_data = ptr[5] >> 4;
>>> -			else
>>> +			if (length != 6)
>>>    				return -EINVAL;
>>> +			hvf->s3d_ext_data = ptr[5] >> 4;
>>>    		}
>>> +	} else if (hdmi_video_format == 0x1) {
>>> +		if (length != 5)
>>> +			return -EINVAL;
>>> +		hvf->vic = ptr[4];
>>> +	} else {
>>> +		if (length != 4)
>>> +			return -EINVAL;
>>>    	}
>>>    
>>>    	return 0;

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes
@ 2017-11-17  3:05         ` Sharma, Shashank
  0 siblings, 0 replies; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-17  3:05 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx, dri-devel, Andrzej Hajda, Hans Verkuil, linux-media

Regards

Shashank


On 11/16/2017 9:46 PM, Ville Syrjälä wrote:
> On Thu, Nov 16, 2017 at 08:06:18PM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> HDMI 2.0 Appendix F suggest that we should keep sending the infoframe
>>> when switching from 3D to 2D mode, even if the infoframe isn't strictly
>>> necessary (ie. not needed to transmit the VIC or stereo information).
>>> This is a workaround against some sinks that fail to realize that they
>>> should switch from 3D to 2D mode when the source stop transmitting
>>> the infoframe.
>>>
>>> v2: Handle unpack() as well
>>>       Pull the length calculation into a helper
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Andrzej Hajda <a.hajda@samsung.com>
>>> Cc: Thierry Reding <thierry.reding@gmail.com>
>>> Cc: Hans Verkuil <hans.verkuil@cisco.com>
>>> Cc: linux-media@vger.kernel.org
>>> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> #v1
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/video/hdmi.c | 51 +++++++++++++++++++++++++++++++--------------------
>>>    1 file changed, 31 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
>>> index 1cf907ecded4..111a0ab6280a 100644
>>> --- a/drivers/video/hdmi.c
>>> +++ b/drivers/video/hdmi.c
>>> @@ -321,6 +321,17 @@ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame)
>>>    }
>>>    EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
>>>    
>>> +static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame)
>>> +{
>>> +	/* for side by side (half) we also need to provide 3D_Ext_Data */
>>> +	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>>> +		return 6;
>>> +	else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
>>> +		return 5;
>>> +	else
>>> +		return 4;
>>> +}
>>> +
>>>    /**
>>>     * hdmi_vendor_infoframe_pack() - write a HDMI vendor infoframe to binary buffer
>>>     * @frame: HDMI infoframe
>>> @@ -341,19 +352,11 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
>>>    	u8 *ptr = buffer;
>>>    	size_t length;
>>>    
>>> -	/* empty info frame */
>>> -	if (frame->vic == 0 && frame->s3d_struct == HDMI_3D_STRUCTURE_INVALID)
>>> -		return -EINVAL;
>>> -
>>>    	/* only one of those can be supplied */
>>>    	if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
>>>    		return -EINVAL;
>>>    
>>> -	/* for side by side (half) we also need to provide 3D_Ext_Data */
>>> -	if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>>> -		frame->length = 6;
>>> -	else
>>> -		frame->length = 5;
>>> +	frame->length = hdmi_vendor_infoframe_length(frame);
>>>    
>>>    	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
>>>    
>>> @@ -372,14 +375,16 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
>>>    	ptr[5] = 0x0c;
>>>    	ptr[6] = 0x00;
>>>    
>>> -	if (frame->vic) {
>>> -		ptr[7] = 0x1 << 5;	/* video format */
>>> -		ptr[8] = frame->vic;
>>> -	} else {
>>> +	if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
>>>    		ptr[7] = 0x2 << 5;	/* video format */
>>>    		ptr[8] = (frame->s3d_struct & 0xf) << 4;
>>>    		if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
>>>    			ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
>>> +	} else if (frame->vic) {
>> Please correct me if I dint understand this properly, but for a HDMI 2.0
>> sink + 3D transmission, wouldn't I be sending
>> HDMI 2.0 VIC = 94 as well as some valid s3d flag (like side by side) ?
> That vic will be in the AVI infoframe. Here we're concerned about the
> VIC in the HDMI vendor infoframe.
Yep, I was thinking if there is any way we can cross check that there is 
a valid HDMI 2 vic
before we do anything here, but seems like a long shot.

Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
>> - Shashank
>>> +		ptr[7] = 0x1 << 5;	/* video format */
>>> +		ptr[8] = frame->vic;
>>> +	} else {
>>> +		ptr[7] = 0x0 << 5;	/* video format */
>>>    	}
>>>    
>>>    	hdmi_infoframe_set_checksum(buffer, length);
>>> @@ -1165,7 +1170,7 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>>>    
>>>    	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
>>>    	    ptr[1] != 1 ||
>>> -	    (ptr[2] != 5 && ptr[2] != 6))
>>> +	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
>>>    		return -EINVAL;
>>>    
>>>    	length = ptr[2];
>>> @@ -1193,16 +1198,22 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>>>    
>>>    	hvf->length = length;
>>>    
>>> -	if (hdmi_video_format == 0x1) {
>>> -		hvf->vic = ptr[4];
>>> -	} else if (hdmi_video_format == 0x2) {
>>> +	if (hdmi_video_format == 0x2) {
>>> +		if (length != 5 && length != 6)
>>> +			return -EINVAL;
>>>    		hvf->s3d_struct = ptr[4] >> 4;
>>>    		if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
>>> -			if (length == 6)
>>> -				hvf->s3d_ext_data = ptr[5] >> 4;
>>> -			else
>>> +			if (length != 6)
>>>    				return -EINVAL;
>>> +			hvf->s3d_ext_data = ptr[5] >> 4;
>>>    		}
>>> +	} else if (hdmi_video_format == 0x1) {
>>> +		if (length != 5)
>>> +			return -EINVAL;
>>> +		hvf->vic = ptr[4];
>>> +	} else {
>>> +		if (length != 4)
>>> +			return -EINVAL;
>>>    	}
>>>    
>>>    	return 0;

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D
  2017-11-16 16:21     ` Ville Syrjälä
@ 2017-11-17  3:10       ` Sharma, Shashank
  2017-11-22 18:28         ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-17  3:10 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Andrzej Hajda, intel-gfx, Laurent Pinchart, dri-devel

Regards

Shashank


On 11/16/2017 9:51 PM, Ville Syrjälä wrote:
> On Thu, Nov 16, 2017 at 08:10:55PM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> Appedix F of HDMI 2.0 says that some HDMI sink may fail to switch from
>>> 3D to 2D mode in a timely fashion if the source simply stops sending the
>>> HDMI infoframe. The suggested workaround is to keep sending the
>>> infoframe even when strictly not necessary (ie. no VIC and no S3D).
>>> HDMI 1.4 does allow for this behaviour, stating that sending the
>>> infoframe is optional in this case.
>>>
>>> The infoframe was first specified in HDMI 1.4, so in theory sinks
>>> predating that may not appreciate us sending an uknown infoframe
>>> their way. To avoid regressions let's try to determine if the sink
>>> supports the infoframe or not. Unfortunately there's no direct way
>>> to do that, so instead we'll just check if we managed to parse any
>>> HDMI 1.4 4k or stereo modes from the EDID, and if so we assume the
>>> sink will accept the infoframe. Also if the EDID contains the HDMI
>>> 2.0 HDMI Forum VSDB we can assume the sink is prepared to receive
>>> the infoframe.
>> I am trying to get some sense from HDMI 2.0 spec section 10.2.1, which
>> talks about
>> switch from 3D to 2D.  To me it looks like:
>> If (sending_to_hdmi2_sinks) {
>>       - for 3d modes send HF-VSIF
>>       - for 2d modes && defined in H14b HFVSIF, send H14B-VSIF
>>         When you switch from 3d->2d {
>>            - send_HF-VSIF with 3D_valid bit = 0/1
>>        }
>> } else { /* HDMI 1.4b sinks from Appendix F */
>>       -  send H14b-VSIF with HDMI_video_format[2:0 = 0 OR 1]
>> }
>>
>> Should we add a is_hdmi2 check and separate these cases ?
> We don't support the HDMI forum infoframe. Maybe someone forgot to
> implement that when adding the rest of HDMI 2.0 support? ;)
How to make an 'embarrassed smile ' smiley :) ?
Will start looking into it. Meanwhile
Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
>>> v2: Fix the getting has_hdmi_infoframe from display_info
>>>       Always fail constructing the infoframe if the display
>>>       possibly can't handle it
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Andrzej Hajda <a.hajda@samsung.com>
>>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/gpu/drm/bridge/sil-sii8620.c      |  3 ++-
>>>    drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  4 +++-
>>>    drivers/gpu/drm/drm_edid.c                | 34 +++++++++++++++++++++++++------
>>>    drivers/gpu/drm/exynos/exynos_hdmi.c      |  2 +-
>>>    drivers/gpu/drm/i915/intel_hdmi.c         | 14 +++++++------
>>>    drivers/gpu/drm/mediatek/mtk_hdmi.c       |  3 ++-
>>>    drivers/gpu/drm/nouveau/nv50_display.c    |  3 ++-
>>>    drivers/gpu/drm/rockchip/inno_hdmi.c      |  1 +
>>>    drivers/gpu/drm/sti/sti_hdmi.c            |  4 +++-
>>>    drivers/gpu/drm/zte/zx_hdmi.c             |  1 +
>>>    include/drm/drm_connector.h               |  5 +++++
>>>    include/drm/drm_edid.h                    |  1 +
>>>    12 files changed, 57 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
>>> index b7eb704d0a8a..4417276ba02e 100644
>>> --- a/drivers/gpu/drm/bridge/sil-sii8620.c
>>> +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
>>> @@ -2220,8 +2220,9 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
>>>    			union hdmi_infoframe frm;
>>>    			u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
>>>    
>>> +			/* FIXME: We need the connector here */
>>>    			drm_hdmi_vendor_infoframe_from_display_mode(
>>> -				&frm.vendor.hdmi, adjusted_mode);
>>> +				&frm.vendor.hdmi, NULL, adjusted_mode);
>>>    			vic = frm.vendor.hdmi.vic;
>>>    			if (vic >= ARRAY_SIZE(mhl_vic))
>>>    				vic = 0;
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>>> index a64ce7112288..b172139502d6 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>>> @@ -1437,7 +1437,9 @@ static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi,
>>>    	u8 buffer[10];
>>>    	ssize_t err;
>>>    
>>> -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
>>> +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
>>> +							  &hdmi->connector,
>>> +							  mode);
>>>    	if (err < 0)
>>>    		/*
>>>    		 * Going into that statement does not means vendor infoframe
>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>> index 749d07a01772..9ada0ccf50df 100644
>>> --- a/drivers/gpu/drm/drm_edid.c
>>> +++ b/drivers/gpu/drm/drm_edid.c
>>> @@ -3393,6 +3393,7 @@ static int
>>>    do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
>>>    		   const u8 *video_db, u8 video_len)
>>>    {
>>> +	struct drm_display_info *info = &connector->display_info;
>>>    	int modes = 0, offset = 0, i, multi_present = 0, multi_len;
>>>    	u8 vic_len, hdmi_3d_len = 0;
>>>    	u16 mask;
>>> @@ -3520,6 +3521,8 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
>>>    	}
>>>    
>>>    out:
>>> +	if (modes > 0)
>>> +		info->has_hdmi_infoframe = true;
>>>    	return modes;
>>>    }
>>>    
>>> @@ -4243,6 +4246,8 @@ static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
>>>    	struct drm_display_info *display = &connector->display_info;
>>>    	struct drm_hdmi_info *hdmi = &display->hdmi;
>>>    
>>> +	display->has_hdmi_infoframe = true;
>>> +
>>>    	if (hf_vsdb[6] & 0x80) {
>>>    		hdmi->scdc.supported = true;
>>>    		if (hf_vsdb[6] & 0x40)
>>> @@ -4416,6 +4421,7 @@ static void drm_add_display_info(struct drm_connector *connector,
>>>    	info->cea_rev = 0;
>>>    	info->max_tmds_clock = 0;
>>>    	info->dvi_dual = false;
>>> +	info->has_hdmi_infoframe = false;
>>>    
>>>    	if (edid->revision < 3)
>>>    		return;
>>> @@ -4903,6 +4909,7 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
>>>     * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
>>>     * data from a DRM display mode
>>>     * @frame: HDMI vendor infoframe
>>> + * @connector: the connector
>> I remember our old discussion where we realized that we will need this
>> connector for all types of infoframes,
>> eventually, do you think we should start thinking about creating a
>> wrapper like drm_any_infoframe_from_display_mode(),
>> and pass connector and desired type to it ?Or I am getting too ambitious
>> targeting this series :) ?
>>>     * @mode: DRM display mode
>>>     *
>>>     * Note that there's is a need to send HDMI vendor infoframes only when using a
>>> @@ -4913,8 +4920,15 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
>>>     */
>>>    int
>>>    drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>>> +					    struct drm_connector *connector,
>>>    					    const struct drm_display_mode *mode)
>>>    {
>>> +	/*
>>> +	 * FIXME: sil-sii8620 doesn't have a connector around when
>>> +	 * we need one, so we have to be prepared for a NULL connector.
>>> +	 */
>>> +	bool has_hdmi_infoframe = connector ?
>>> +		connector->display_info.has_hdmi_infoframe : false;
>>>    	int err;
>>>    	u32 s3d_flags;
>>>    	u8 vic;
>>> @@ -4922,11 +4936,21 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>>>    	if (!frame || !mode)
>>>    		return -EINVAL;
>>>    
>>> +	if (!has_hdmi_infoframe)
>>> +		return -EINVAL;
>>> +
>>>    	vic = drm_match_hdmi_mode(mode);
>>>    	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
>>>    
>>> -	if (!vic && !s3d_flags)
>>> -		return -EINVAL;
>>> +	/*
>>> +	 * Even if it's not absolutely necessary to send the infoframe
>>> +	 * (ie.vic==0 and s3d_struct==0) we will still send it if we
>>> +	 * know that the sink can handle it. This is based on a
>>> +	 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
>>> +	 * have trouble realizing that they shuld switch from 3D to 2D
>>> +	 * mode if the source simply stops sending the infoframe when
>>> +	 * it wants to switch from 3D to 2D.
>>> +	 */
>>>    
>>>    	if (vic && s3d_flags)
>>>    		return -EINVAL;
>>> @@ -4935,10 +4959,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>>>    	if (err < 0)
>>>    		return err;
>>>    
>>> -	if (vic)
>>> -		frame->vic = vic;
>>> -	else
>>> -		frame->s3d_struct = s3d_structure_from_display_mode(mode);
>>> +	frame->vic = vic;
>>> +	frame->s3d_struct = s3d_structure_from_display_mode(mode);
>>>    
>>>    	return 0;
>>>    }
>>> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
>>> index 0109ff40b1db..812b2773ed69 100644
>>> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
>>> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
>>> @@ -795,7 +795,7 @@ static void hdmi_reg_infoframes(struct hdmi_context *hdata)
>>>    	}
>>>    
>>>    	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi,
>>> -			&hdata->current_mode);
>>> +			&hdata->connector, &hdata->current_mode);
>>>    	if (!ret)
>>>    		ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf,
>>>    				sizeof(buf));
>>> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
>>> index 2d95db64cdf2..2ccba4ccf7ad 100644
>>> --- a/drivers/gpu/drm/i915/intel_hdmi.c
>>> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
>>> @@ -512,12 +512,14 @@ static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder,
>>>    
>>>    static void
>>>    intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder,
>>> -			      const struct intel_crtc_state *crtc_state)
>>> +			      const struct intel_crtc_state *crtc_state,
>>> +			      const struct drm_connector_state *conn_state)
>>>    {
>>>    	union hdmi_infoframe frame;
>>>    	int ret;
>>>    
>>>    	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
>>> +							  conn_state->connector,
>>>    							  &crtc_state->base.adjusted_mode);
>>>    	if (ret < 0)
>>>    		return;
>>> @@ -584,7 +586,7 @@ static void g4x_set_infoframes(struct drm_encoder *encoder,
>>>    
>>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
>>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
>>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>>>    }
>>>    
>>>    static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state)
>>> @@ -725,7 +727,7 @@ static void ibx_set_infoframes(struct drm_encoder *encoder,
>>>    
>>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
>>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
>>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>>>    }
>>>    
>>>    static void cpt_set_infoframes(struct drm_encoder *encoder,
>>> @@ -768,7 +770,7 @@ static void cpt_set_infoframes(struct drm_encoder *encoder,
>>>    
>>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
>>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
>>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>>>    }
>>>    
>>>    static void vlv_set_infoframes(struct drm_encoder *encoder,
>>> @@ -821,7 +823,7 @@ static void vlv_set_infoframes(struct drm_encoder *encoder,
>>>    
>>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
>>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
>>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>>>    }
>>>    
>>>    static void hsw_set_infoframes(struct drm_encoder *encoder,
>>> @@ -854,7 +856,7 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
>>>    
>>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
>>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
>>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
>>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
>>>    }
>>>    
>>>    void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
>>> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
>>> index b78791061983..59a11026dceb 100644
>>> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
>>> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
>>> @@ -1054,7 +1054,8 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
>>>    	u8 buffer[10];
>>>    	ssize_t err;
>>>    
>>> -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
>>> +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
>>> +							  &hdmi->conn, mode);
>>>    	if (err) {
>>>    		dev_err(hdmi->dev,
>>>    			"Failed to get vendor infoframe from mode: %zd\n", err);
>>> diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
>>> index b26a506d20ca..9d7b2afd7cfc 100644
>>> --- a/drivers/gpu/drm/nouveau/nv50_display.c
>>> +++ b/drivers/gpu/drm/nouveau/nv50_display.c
>>> @@ -2754,7 +2754,8 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
>>>    			= hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
>>>    	}
>>>    
>>> -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi, mode);
>>> +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
>>> +							  &nv_connector->base, mode);
>>>    	if (!ret) {
>>>    		/* We have a Vendor InfoFrame, populate it to the display */
>>>    		args.pwr.vendor_infoframe_length
>>> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
>>> index ee584d87111f..fab30927a889 100644
>>> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c
>>> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
>>> @@ -282,6 +282,7 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi,
>>>    	int rc;
>>>    
>>>    	rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
>>> +							 &hdmi->connector,
>>>    							 mode);
>>>    
>>>    	return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI,
>>> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
>>> index d1902750a85d..c3b292ab17a5 100644
>>> --- a/drivers/gpu/drm/sti/sti_hdmi.c
>>> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
>>> @@ -515,7 +515,9 @@ static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi)
>>>    
>>>    	DRM_DEBUG_DRIVER("\n");
>>>    
>>> -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe, mode);
>>> +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe,
>>> +							  hdmi->drm_connector,
>>> +							  mode);
>>>    	if (ret < 0) {
>>>    		/*
>>>    		 * Going into that statement does not means vendor infoframe
>>> diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
>>> index b8abb1b496ff..13ea90f7a185 100644
>>> --- a/drivers/gpu/drm/zte/zx_hdmi.c
>>> +++ b/drivers/gpu/drm/zte/zx_hdmi.c
>>> @@ -108,6 +108,7 @@ static int zx_hdmi_config_video_vsi(struct zx_hdmi *hdmi,
>>>    	int ret;
>>>    
>>>    	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
>>> +							  &hdmi->connector,
>>>    							  mode);
>>>    	if (ret) {
>>>    		DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n",
>>> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
>>> index 2b97d1e28f60..1543212b0449 100644
>>> --- a/include/drm/drm_connector.h
>>> +++ b/include/drm/drm_connector.h
>>> @@ -270,6 +270,11 @@ struct drm_display_info {
>>>    	bool dvi_dual;
>>>    
>>>    	/**
>>> +	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
>>> +	 */
>>> +	bool has_hdmi_infoframe;
>>> +
>>> +	/**
>>>    	 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
>>>    	 * more stuff redundant with @bus_formats.
>>>    	 */
>>> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
>>> index 9e4e23524840..3c8740ad1db6 100644
>>> --- a/include/drm/drm_edid.h
>>> +++ b/include/drm/drm_edid.h
>>> @@ -356,6 +356,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>>>    					 bool is_hdmi2_sink);
>>>    int
>>>    drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>>> +					    struct drm_connector *connector,
>>>    					    const struct drm_display_mode *mode);
>>>    void
>>>    drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
>> Otherwise looks good
>> - Shashank

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-16 16:23     ` Ville Syrjälä
@ 2017-11-17  3:19       ` Sharma, Shashank
  2017-11-17 11:35         ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-17  3:19 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jose Abreu, Lin, Jia, intel-gfx, dri-devel, Daniel Vetter,
	Nautiyal Ankit

Regards

Shashank


On 11/16/2017 9:53 PM, Ville Syrjälä wrote:
> On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
>>> cause us to not send out any VICs in the AVI infoframes. That commit
>>> was since reverted, but if and when we add aspect ratio handing back
>>> we need to be more careful.
>>>
>>> Let's handle this by considering the aspect ratio as a requirement
>>> for cea mode matching only if the passed in mode actually has a
>>> non-zero aspect ratio field. This will keep userspace that doesn't
>>> provide an aspect ratio working as before by matching it to the
>>> first otherwise equal cea mode. And once userspace starts to
>>> provide the aspect ratio it will be considerd a hard requirement
>>> for the match.
>>>
>>> Also change the hdmi mode matching to use drm_mode_match() for
>>> consistency, but we don't match on aspect ratio there since the
>>> spec doesn't list a specific aspect ratio for those modes.
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: "Lin, Jia" <lin.a.jia@intel.com>
>>> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
>>> Cc: Jim Bride <jim.bride@linux.intel.com>
>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
>>>    1 file changed, 14 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>> index 7220b8f9a7e8..00aa98f3e55d 100644
>>> --- a/drivers/gpu/drm/drm_edid.c
>>> +++ b/drivers/gpu/drm/drm_edid.c
>>> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
>>>    static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
>>>    					     unsigned int clock_tolerance)
>>>    {
>>> +	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;
>> This doesn't look right. This means we are expecting a CEA mode without
>> a pic aspect ratio field,
>> which is invalid.
> No, it's perfectly valid. It's what we currently get from userspace.
Yep, but that's due to missing Aspect ratio handling in the DRM layer. 
If that's fixed, as per the list of CEA modes,
each CEA VIC contains an aspect ratio, which is a part of its unique 
identity.

I guess once we have the aspect ratio handling in DRM layer, it 
would/should look like this:
- EDID gives you all supported modes, including CEA modes with Aspect ratio
- Userspcae gets the mode information, with aspect ratio (for CEA modes)
If ( Userspace picks one of the CEA modes)
     - sends a modeset
     - we find a matching CEA VIC, found one from modedb
     - we load this VIC = nonzero information in AVI IF VIC field,
else
     - sends a modeset
     - we could not find a matching CEA VIC, as aspect ratio is 0
     - we make VIC field in AVI IF as 0

This is important, as HDMI compliance test 7-27 inspects if the VIC 
field in the AVI IF is accurate.

- Shashank
>> Ankit is going to publish the aspect ratio patch
>> series again, with proper DRM cap and flags check. Would it be
>> ok if we have a look that handling first ?
> This patch will be needed by that work. Otherwise we're going to stop
> sending a VIC for CEA modes with current userspace.
I guess we should force userspaces to start bothering about aspect ratio 
field, right now we
are doing this for Wayland based compositors, may be we should extend it 
to X based too.

- Shashank
>
>>> +
>>>    	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
>>>    		struct drm_display_mode cea_mode = edid_cea_modes[vic];
>>>    		unsigned int clock1, clock2;
>>> @@ -2921,7 +2925,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
>>>    			continue;
>>>    
>>>    		do {
>>> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
>>> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
>>>    				return vic;
>>>    		} while (cea_mode_alternate_timings(vic, &cea_mode));
>>>    	}
>>> @@ -2938,11 +2942,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
>>>     */
>>>    u8 drm_match_cea_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;
>> same here, and probably in other CEA match functions.
>>> +
>>>    	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
>>>    		struct drm_display_mode cea_mode = edid_cea_modes[vic];
>>>    		unsigned int clock1, clock2;
>>> @@ -2956,7 +2964,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
>>>    			continue;
>>>    
>>>    		do {
>>> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
>>> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
>>>    				return vic;
>>>    		} while (cea_mode_alternate_timings(vic, &cea_mode));
>>>    	}
>>> @@ -3003,6 +3011,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
>>>    static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
>>>    					      unsigned int clock_tolerance)
>>>    {
>>> +	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
>>>    	u8 vic;
>>>    
>>>    	if (!to_match->clock)
>>> @@ -3020,7 +3029,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
>>>    		    abs(to_match->clock - clock2) > clock_tolerance)
>>>    			continue;
>>>    
>>> -		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
>>> +		if (drm_mode_match(to_match, hdmi_mode, match_flags))
>>>    			return vic;
>>>    	}
>>>    
>>> @@ -3037,6 +3046,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
>>>     */
>>>    static u8 drm_match_hdmi_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)
>>> @@ -3052,7 +3062,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
>>>    
>>>    		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
>>>    		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
>>> -		    drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
>>> +		    drm_mode_match(to_match, hdmi_mode, match_flags))
>>>    			return vic;
>>>    	}
>>>    	return 0;
>> - Shashank

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-16 16:26     ` Ville Syrjälä
@ 2017-11-17  3:23       ` Sharma, Shashank
  2017-11-17 11:38         ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-17  3:23 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jose Abreu, Daniel Vetter, intel-gfx, dri-devel, Nautiyal Ankit

Regards

Shashank


On 11/16/2017 9:56 PM, Ville Syrjälä wrote:
> On Thu, Nov 16, 2017 at 08:31:36PM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>
>>> If the user mode would specify an aspect ratio other than 4:3 or 16:9
>>> we now silently ignore it. Maybe a better apporoach is to return an
>>> error? Let's try that.
>>>
>>> Also we must be careful that we don't try to send illegal picture
>>> aspect in the infoframe as it's only capable of signalling none,
>>> 4:3, and 16:9. Currently we're sending these bogus infoframes
>>> whenever the cea mode specifies some other aspect ratio.
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Sean Paul <seanpaul@chromium.org>
>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> ---
>>>    drivers/gpu/drm/drm_edid.c | 23 +++++++++++++++++------
>>>    1 file changed, 17 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>> index 00aa98f3e55d..bafb3ee4ea97 100644
>>> --- a/drivers/gpu/drm/drm_edid.c
>>> +++ b/drivers/gpu/drm/drm_edid.c
>>> @@ -4786,6 +4786,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>>>    					 const struct drm_display_mode *mode,
>>>    					 bool is_hdmi2_sink)
>>>    {
>>> +	enum hdmi_picture_aspect picture_aspect;
>>>    	int err;
>>>    
>>>    	if (!frame || !mode)
>>> @@ -4828,13 +4829,23 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>>>    	 * Populate picture aspect ratio from either
>>>    	 * user input (if specified) or from the CEA mode list.
>>>    	 */
>>> -	if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 ||
>>> -		mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9)
>>> -		frame->picture_aspect = mode->picture_aspect_ratio;
>>> -	else if (frame->video_code > 0)
>>> -		frame->picture_aspect = drm_get_cea_aspect_ratio(
>>> -						frame->video_code);
>>> +	picture_aspect = mode->picture_aspect_ratio;
>>> +	if (picture_aspect == HDMI_PICTURE_ASPECT_NONE)
>>> +		picture_aspect = drm_get_cea_aspect_ratio(frame->video_code);
>> This is slightly going in the loop.
>> - During the modeset the driver cant specify the aspect ratio
>> information, as DRM layer lacks this support.
>> - So we fill the VIC field, by comparing the mode with the
>> DRM_CEA_MODES[] list. This will pick the first mode
>>     available in the list (regardless of its aspect ratio), and fill the
>> VIC, as we don't consider aspect ratio while comparing timings.
>> - Again, now while sending the aspect ratio, we are picking up the VIC,
>> which may not be correct.
>>
>> So if we have 720x480(4:3) and 720x480(16:9) in the list, as 4:3 is
>> first in list, we will always pick 4:3 aspect ratio.
> Yes. The user didn't care about the aspect ratio (or rather couldn't
> specify one) so we just pick one. Which is exactly what we've been
> doing ever since we started sending the VIC in the infoframe.
Correct, and we are hoping that this should be better (if not fixed) 
with the aspect ratio support
patches + DRM cap. If the userspace doesn't set the cap, then anyways 
there is no aspect ratio
field available, and VIC would be always 0, as this becomes a Non CEA mode.

Or do you think it would be a better idea to send some VIC instead of No 
VIC, when userspace doesn't
set the DRM cap for aspect ratio ?

- Shashank
>> - Shashank
>>>    
>>> +	/*
>>> +	 * The infoframe can't convey anything but none, 4:3
>>> +	 * and 16:9, so if the user has asked for anything else
>>> +	 * we can only satisfy it by specifying the right VIC.
>>> +	 */
>>> +	if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
>>> +		if (picture_aspect !=
>>> +		    drm_get_cea_aspect_ratio(frame->video_code))
>>> +			return -EINVAL;
>>> +		picture_aspect = HDMI_PICTURE_ASPECT_NONE;
>>> +	}
>>> +
>>> +	frame->picture_aspect = picture_aspect;
>>>    	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
>>>    	frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
>>>    

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-17  3:19       ` Sharma, Shashank
@ 2017-11-17 11:35         ` Ville Syrjälä
  2017-11-17 12:20           ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-17 11:35 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: Jose Abreu, Lin, Jia, Akashdeep Sharma, intel-gfx, Emil Velikov,
	dri-devel, Daniel Vetter, Nautiyal Ankit, Jim Bride

On Fri, Nov 17, 2017 at 08:49:49AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/16/2017 9:53 PM, Ville Syrjälä wrote:
> > On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
> >> Regards
> >>
> >> Shashank
> >>
> >>
> >> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> >>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>
> >>> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
> >>> cause us to not send out any VICs in the AVI infoframes. That commit
> >>> was since reverted, but if and when we add aspect ratio handing back
> >>> we need to be more careful.
> >>>
> >>> Let's handle this by considering the aspect ratio as a requirement
> >>> for cea mode matching only if the passed in mode actually has a
> >>> non-zero aspect ratio field. This will keep userspace that doesn't
> >>> provide an aspect ratio working as before by matching it to the
> >>> first otherwise equal cea mode. And once userspace starts to
> >>> provide the aspect ratio it will be considerd a hard requirement
> >>> for the match.
> >>>
> >>> Also change the hdmi mode matching to use drm_mode_match() for
> >>> consistency, but we don't match on aspect ratio there since the
> >>> spec doesn't list a specific aspect ratio for those modes.
> >>>
> >>> Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>> Cc: "Lin, Jia" <lin.a.jia@intel.com>
> >>> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> >>> Cc: Jim Bride <jim.bride@linux.intel.com>
> >>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> >>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> >>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>> ---
> >>>    drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
> >>>    1 file changed, 14 insertions(+), 4 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> >>> index 7220b8f9a7e8..00aa98f3e55d 100644
> >>> --- a/drivers/gpu/drm/drm_edid.c
> >>> +++ b/drivers/gpu/drm/drm_edid.c
> >>> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
> >>>    static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
> >>>    					     unsigned int clock_tolerance)
> >>>    {
> >>> +	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;
> >> This doesn't look right. This means we are expecting a CEA mode without
> >> a pic aspect ratio field,
> >> which is invalid.
> > No, it's perfectly valid. It's what we currently get from userspace.
> Yep, but that's due to missing Aspect ratio handling in the DRM layer. 
> If that's fixed, as per the list of CEA modes,
> each CEA VIC contains an aspect ratio, which is a part of its unique 
> identity.
> 
> I guess once we have the aspect ratio handling in DRM layer, it 
> would/should look like this:
> - EDID gives you all supported modes, including CEA modes with Aspect ratio
> - Userspcae gets the mode information, with aspect ratio (for CEA modes)
> If ( Userspace picks one of the CEA modes)
>      - sends a modeset
>      - we find a matching CEA VIC, found one from modedb
>      - we load this VIC = nonzero information in AVI IF VIC field,
> else
>      - sends a modeset
>      - we could not find a matching CEA VIC, as aspect ratio is 0
>      - we make VIC field in AVI IF as 0a

No. That would break current userspace.

> 
> This is important, as HDMI compliance test 7-27 inspects if the VIC 
> field in the AVI IF is accurate.

Complicance is secondary to not breaking things that work. Also I find
it hard to see what purpose there is in having a complicance test that
sets a CEA modes w/o aspect ratio and then expects the infoframe to have
VIC 0.

> 
> - Shashank
> >> Ankit is going to publish the aspect ratio patch
> >> series again, with proper DRM cap and flags check. Would it be
> >> ok if we have a look that handling first ?
> > This patch will be needed by that work. Otherwise we're going to stop
> > sending a VIC for CEA modes with current userspace.
> I guess we should force userspaces to start bothering about aspect ratio 
> field, right now we
> are doing this for Wayland based compositors, may be we should extend it 
> to X based too.

Yes, I've been saying that someone should look into extending the randr
protocol with the necessary bits. But that still doesn't allow us to
change the current behaviour as old userspace would anyway linger around
for a long time.

> 
> - Shashank
> >
> >>> +
> >>>    	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> >>>    		struct drm_display_mode cea_mode = edid_cea_modes[vic];
> >>>    		unsigned int clock1, clock2;
> >>> @@ -2921,7 +2925,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
> >>>    			continue;
> >>>    
> >>>    		do {
> >>> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
> >>> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
> >>>    				return vic;
> >>>    		} while (cea_mode_alternate_timings(vic, &cea_mode));
> >>>    	}
> >>> @@ -2938,11 +2942,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
> >>>     */
> >>>    u8 drm_match_cea_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;
> >> same here, and probably in other CEA match functions.
> >>> +
> >>>    	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
> >>>    		struct drm_display_mode cea_mode = edid_cea_modes[vic];
> >>>    		unsigned int clock1, clock2;
> >>> @@ -2956,7 +2964,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
> >>>    			continue;
> >>>    
> >>>    		do {
> >>> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
> >>> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
> >>>    				return vic;
> >>>    		} while (cea_mode_alternate_timings(vic, &cea_mode));
> >>>    	}
> >>> @@ -3003,6 +3011,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
> >>>    static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
> >>>    					      unsigned int clock_tolerance)
> >>>    {
> >>> +	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
> >>>    	u8 vic;
> >>>    
> >>>    	if (!to_match->clock)
> >>> @@ -3020,7 +3029,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
> >>>    		    abs(to_match->clock - clock2) > clock_tolerance)
> >>>    			continue;
> >>>    
> >>> -		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
> >>> +		if (drm_mode_match(to_match, hdmi_mode, match_flags))
> >>>    			return vic;
> >>>    	}
> >>>    
> >>> @@ -3037,6 +3046,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
> >>>     */
> >>>    static u8 drm_match_hdmi_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)
> >>> @@ -3052,7 +3062,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
> >>>    
> >>>    		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
> >>>    		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
> >>> -		    drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
> >>> +		    drm_mode_match(to_match, hdmi_mode, match_flags))
> >>>    			return vic;
> >>>    	}
> >>>    	return 0;
> >> - Shashank

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-17  3:23       ` Sharma, Shashank
@ 2017-11-17 11:38         ` Ville Syrjälä
  2017-11-24  8:55           ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-17 11:38 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: Jose Abreu, Daniel Vetter, intel-gfx, Emil Velikov, dri-devel,
	Nautiyal Ankit

On Fri, Nov 17, 2017 at 08:53:54AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/16/2017 9:56 PM, Ville Syrjälä wrote:
> > On Thu, Nov 16, 2017 at 08:31:36PM +0530, Sharma, Shashank wrote:
> >> Regards
> >>
> >> Shashank
> >>
> >>
> >> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> >>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>
> >>> If the user mode would specify an aspect ratio other than 4:3 or 16:9
> >>> we now silently ignore it. Maybe a better apporoach is to return an
> >>> error? Let's try that.
> >>>
> >>> Also we must be careful that we don't try to send illegal picture
> >>> aspect in the infoframe as it's only capable of signalling none,
> >>> 4:3, and 16:9. Currently we're sending these bogus infoframes
> >>> whenever the cea mode specifies some other aspect ratio.
> >>>
> >>> Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>> Cc: Sean Paul <seanpaul@chromium.org>
> >>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> >>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> >>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>> ---
> >>>    drivers/gpu/drm/drm_edid.c | 23 +++++++++++++++++------
> >>>    1 file changed, 17 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> >>> index 00aa98f3e55d..bafb3ee4ea97 100644
> >>> --- a/drivers/gpu/drm/drm_edid.c
> >>> +++ b/drivers/gpu/drm/drm_edid.c
> >>> @@ -4786,6 +4786,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
> >>>    					 const struct drm_display_mode *mode,
> >>>    					 bool is_hdmi2_sink)
> >>>    {
> >>> +	enum hdmi_picture_aspect picture_aspect;
> >>>    	int err;
> >>>    
> >>>    	if (!frame || !mode)
> >>> @@ -4828,13 +4829,23 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
> >>>    	 * Populate picture aspect ratio from either
> >>>    	 * user input (if specified) or from the CEA mode list.
> >>>    	 */
> >>> -	if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 ||
> >>> -		mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9)
> >>> -		frame->picture_aspect = mode->picture_aspect_ratio;
> >>> -	else if (frame->video_code > 0)
> >>> -		frame->picture_aspect = drm_get_cea_aspect_ratio(
> >>> -						frame->video_code);
> >>> +	picture_aspect = mode->picture_aspect_ratio;
> >>> +	if (picture_aspect == HDMI_PICTURE_ASPECT_NONE)
> >>> +		picture_aspect = drm_get_cea_aspect_ratio(frame->video_code);
> >> This is slightly going in the loop.
> >> - During the modeset the driver cant specify the aspect ratio
> >> information, as DRM layer lacks this support.
> >> - So we fill the VIC field, by comparing the mode with the
> >> DRM_CEA_MODES[] list. This will pick the first mode
> >>     available in the list (regardless of its aspect ratio), and fill the
> >> VIC, as we don't consider aspect ratio while comparing timings.
> >> - Again, now while sending the aspect ratio, we are picking up the VIC,
> >> which may not be correct.
> >>
> >> So if we have 720x480(4:3) and 720x480(16:9) in the list, as 4:3 is
> >> first in list, we will always pick 4:3 aspect ratio.
> > Yes. The user didn't care about the aspect ratio (or rather couldn't
> > specify one) so we just pick one. Which is exactly what we've been
> > doing ever since we started sending the VIC in the infoframe.
> Correct, and we are hoping that this should be better (if not fixed) 
> with the aspect ratio support
> patches + DRM cap. If the userspace doesn't set the cap, then anyways 
> there is no aspect ratio
> field available, and VIC would be always 0, as this becomes a Non CEA mode.
> 
> Or do you think it would be a better idea to send some VIC instead of No 
> VIC, when userspace doesn't
> set the DRM cap for aspect ratio ?

Yes. That's the current behaviour.

IIRC some crappy amplifiers etc. with HDMI passthrough don't even work
correctly unless VIC is specified. Hence we do want to send it whenever
possible.

> 
> - Shashank
> >> - Shashank
> >>>    
> >>> +	/*
> >>> +	 * The infoframe can't convey anything but none, 4:3
> >>> +	 * and 16:9, so if the user has asked for anything else
> >>> +	 * we can only satisfy it by specifying the right VIC.
> >>> +	 */
> >>> +	if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
> >>> +		if (picture_aspect !=
> >>> +		    drm_get_cea_aspect_ratio(frame->video_code))
> >>> +			return -EINVAL;
> >>> +		picture_aspect = HDMI_PICTURE_ASPECT_NONE;
> >>> +	}
> >>> +
> >>> +	frame->picture_aspect = picture_aspect;
> >>>    	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
> >>>    	frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
> >>>    

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-17 11:35         ` Ville Syrjälä
@ 2017-11-17 12:20           ` Sharma, Shashank
  2017-11-17 12:49             ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-17 12:20 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jose Abreu, Lin, Jia, Akashdeep Sharma, intel-gfx, Emil Velikov,
	dri-devel, Daniel Vetter, Nautiyal Ankit, Jim Bride

Regards

Shashank


On 11/17/2017 5:05 PM, Ville Syrjälä wrote:
> On Fri, Nov 17, 2017 at 08:49:49AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/16/2017 9:53 PM, Ville Syrjälä wrote:
>>> On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
>>>> Regards
>>>>
>>>> Shashank
>>>>
>>>>
>>>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>>
>>>>> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
>>>>> cause us to not send out any VICs in the AVI infoframes. That commit
>>>>> was since reverted, but if and when we add aspect ratio handing back
>>>>> we need to be more careful.
>>>>>
>>>>> Let's handle this by considering the aspect ratio as a requirement
>>>>> for cea mode matching only if the passed in mode actually has a
>>>>> non-zero aspect ratio field. This will keep userspace that doesn't
>>>>> provide an aspect ratio working as before by matching it to the
>>>>> first otherwise equal cea mode. And once userspace starts to
>>>>> provide the aspect ratio it will be considerd a hard requirement
>>>>> for the match.
>>>>>
>>>>> Also change the hdmi mode matching to use drm_mode_match() for
>>>>> consistency, but we don't match on aspect ratio there since the
>>>>> spec doesn't list a specific aspect ratio for those modes.
>>>>>
>>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>>>> Cc: "Lin, Jia" <lin.a.jia@intel.com>
>>>>> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
>>>>> Cc: Jim Bride <jim.bride@linux.intel.com>
>>>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>> ---
>>>>>     drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
>>>>>     1 file changed, 14 insertions(+), 4 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>>>> index 7220b8f9a7e8..00aa98f3e55d 100644
>>>>> --- a/drivers/gpu/drm/drm_edid.c
>>>>> +++ b/drivers/gpu/drm/drm_edid.c
>>>>> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
>>>>>     static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
>>>>>     					     unsigned int clock_tolerance)
>>>>>     {
>>>>> +	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;
>>>> This doesn't look right. This means we are expecting a CEA mode without
>>>> a pic aspect ratio field,
>>>> which is invalid.
>>> No, it's perfectly valid. It's what we currently get from userspace.
>> Yep, but that's due to missing Aspect ratio handling in the DRM layer.
>> If that's fixed, as per the list of CEA modes,
>> each CEA VIC contains an aspect ratio, which is a part of its unique
>> identity.
>>
>> I guess once we have the aspect ratio handling in DRM layer, it
>> would/should look like this:
>> - EDID gives you all supported modes, including CEA modes with Aspect ratio
>> - Userspcae gets the mode information, with aspect ratio (for CEA modes)
>> If ( Userspace picks one of the CEA modes)
>>       - sends a modeset
>>       - we find a matching CEA VIC, found one from modedb
>>       - we load this VIC = nonzero information in AVI IF VIC field,
>> else
>>       - sends a modeset
>>       - we could not find a matching CEA VIC, as aspect ratio is 0
>>       - we make VIC field in AVI IF as 0a
> No. That would break current userspace.
I guess I forgot to make it clear, that userspace will set the cap, only 
then we will provide aspect ratio information.
So this should not break userspace, isn't it ?
>> This is important, as HDMI compliance test 7-27 inspects if the VIC
>> field in the AVI IF is accurate.
> Complicance is secondary to not breaking things that work. Also I find
> it hard to see what purpose there is in having a complicance test that
> sets a CEA modes w/o aspect ratio and then expects the infoframe to have
> VIC 0.
Again, typically this is how these analyzers force modeset:
- They send EDID with only one mode, which is the test mode, with aspect 
ratio.
- They expect that VIC to be present in AVI IF
>> - Shashank
>>>> Ankit is going to publish the aspect ratio patch
>>>> series again, with proper DRM cap and flags check. Would it be
>>>> ok if we have a look that handling first ?
>>> This patch will be needed by that work. Otherwise we're going to stop
>>> sending a VIC for CEA modes with current userspace.
>> I guess we should force userspaces to start bothering about aspect ratio
>> field, right now we
>> are doing this for Wayland based compositors, may be we should extend it
>> to X based too.
> Yes, I've been saying that someone should look into extending the randr
> protocol with the necessary bits. But that still doesn't allow us to
> change the current behaviour as old userspace would anyway linger around
> for a long time.
I think cap will cove this part

- Shashank
>> - Shashank
>>>>> +
>>>>>     	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
>>>>>     		struct drm_display_mode cea_mode = edid_cea_modes[vic];
>>>>>     		unsigned int clock1, clock2;
>>>>> @@ -2921,7 +2925,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
>>>>>     			continue;
>>>>>     
>>>>>     		do {
>>>>> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
>>>>> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
>>>>>     				return vic;
>>>>>     		} while (cea_mode_alternate_timings(vic, &cea_mode));
>>>>>     	}
>>>>> @@ -2938,11 +2942,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m
>>>>>      */
>>>>>     u8 drm_match_cea_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;
>>>> same here, and probably in other CEA match functions.
>>>>> +
>>>>>     	for (vic = 1; vic < ARRAY_SIZE(edid_cea_modes); vic++) {
>>>>>     		struct drm_display_mode cea_mode = edid_cea_modes[vic];
>>>>>     		unsigned int clock1, clock2;
>>>>> @@ -2956,7 +2964,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
>>>>>     			continue;
>>>>>     
>>>>>     		do {
>>>>> -			if (drm_mode_equal_no_clocks_no_stereo(to_match, &cea_mode))
>>>>> +			if (drm_mode_match(to_match, &cea_mode, match_flags))
>>>>>     				return vic;
>>>>>     		} while (cea_mode_alternate_timings(vic, &cea_mode));
>>>>>     	}
>>>>> @@ -3003,6 +3011,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
>>>>>     static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
>>>>>     					      unsigned int clock_tolerance)
>>>>>     {
>>>>> +	unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
>>>>>     	u8 vic;
>>>>>     
>>>>>     	if (!to_match->clock)
>>>>> @@ -3020,7 +3029,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
>>>>>     		    abs(to_match->clock - clock2) > clock_tolerance)
>>>>>     			continue;
>>>>>     
>>>>> -		if (drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
>>>>> +		if (drm_mode_match(to_match, hdmi_mode, match_flags))
>>>>>     			return vic;
>>>>>     	}
>>>>>     
>>>>> @@ -3037,6 +3046,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_
>>>>>      */
>>>>>     static u8 drm_match_hdmi_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)
>>>>> @@ -3052,7 +3062,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
>>>>>     
>>>>>     		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
>>>>>     		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
>>>>> -		    drm_mode_equal_no_clocks_no_stereo(to_match, hdmi_mode))
>>>>> +		    drm_mode_match(to_match, hdmi_mode, match_flags))
>>>>>     			return vic;
>>>>>     	}
>>>>>     	return 0;
>>>> - Shashank

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-17 12:20           ` Sharma, Shashank
@ 2017-11-17 12:49             ` Ville Syrjälä
  2017-11-24  8:56               ` Sharma, Shashank
  0 siblings, 1 reply; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-17 12:49 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: Jose Abreu, Lin, Jia, Akashdeep Sharma, intel-gfx, Emil Velikov,
	dri-devel, Daniel Vetter, Nautiyal Ankit, Jim Bride

On Fri, Nov 17, 2017 at 05:50:11PM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/17/2017 5:05 PM, Ville Syrjälä wrote:
> > On Fri, Nov 17, 2017 at 08:49:49AM +0530, Sharma, Shashank wrote:
> >> Regards
> >>
> >> Shashank
> >>
> >>
> >> On 11/16/2017 9:53 PM, Ville Syrjälä wrote:
> >>> On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
> >>>> Regards
> >>>>
> >>>> Shashank
> >>>>
> >>>>
> >>>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> >>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>>
> >>>>> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
> >>>>> cause us to not send out any VICs in the AVI infoframes. That commit
> >>>>> was since reverted, but if and when we add aspect ratio handing back
> >>>>> we need to be more careful.
> >>>>>
> >>>>> Let's handle this by considering the aspect ratio as a requirement
> >>>>> for cea mode matching only if the passed in mode actually has a
> >>>>> non-zero aspect ratio field. This will keep userspace that doesn't
> >>>>> provide an aspect ratio working as before by matching it to the
> >>>>> first otherwise equal cea mode. And once userspace starts to
> >>>>> provide the aspect ratio it will be considerd a hard requirement
> >>>>> for the match.
> >>>>>
> >>>>> Also change the hdmi mode matching to use drm_mode_match() for
> >>>>> consistency, but we don't match on aspect ratio there since the
> >>>>> spec doesn't list a specific aspect ratio for those modes.
> >>>>>
> >>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>>>> Cc: "Lin, Jia" <lin.a.jia@intel.com>
> >>>>> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> >>>>> Cc: Jim Bride <jim.bride@linux.intel.com>
> >>>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> >>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >>>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> >>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>> ---
> >>>>>     drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
> >>>>>     1 file changed, 14 insertions(+), 4 deletions(-)
> >>>>>
> >>>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> >>>>> index 7220b8f9a7e8..00aa98f3e55d 100644
> >>>>> --- a/drivers/gpu/drm/drm_edid.c
> >>>>> +++ b/drivers/gpu/drm/drm_edid.c
> >>>>> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
> >>>>>     static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
> >>>>>     					     unsigned int clock_tolerance)
> >>>>>     {
> >>>>> +	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;
> >>>> This doesn't look right. This means we are expecting a CEA mode without
> >>>> a pic aspect ratio field,
> >>>> which is invalid.
> >>> No, it's perfectly valid. It's what we currently get from userspace.
> >> Yep, but that's due to missing Aspect ratio handling in the DRM layer.
> >> If that's fixed, as per the list of CEA modes,
> >> each CEA VIC contains an aspect ratio, which is a part of its unique
> >> identity.
> >>
> >> I guess once we have the aspect ratio handling in DRM layer, it
> >> would/should look like this:
> >> - EDID gives you all supported modes, including CEA modes with Aspect ratio
> >> - Userspcae gets the mode information, with aspect ratio (for CEA modes)
> >> If ( Userspace picks one of the CEA modes)
> >>       - sends a modeset
> >>       - we find a matching CEA VIC, found one from modedb
> >>       - we load this VIC = nonzero information in AVI IF VIC field,
> >> else
> >>       - sends a modeset
> >>       - we could not find a matching CEA VIC, as aspect ratio is 0
> >>       - we make VIC field in AVI IF as 0a
> > No. That would break current userspace.
> I guess I forgot to make it clear, that userspace will set the cap, only 
> then we will provide aspect ratio information.
> So this should not break userspace, isn't it ?
> >> This is important, as HDMI compliance test 7-27 inspects if the VIC
> >> field in the AVI IF is accurate.
> > Complicance is secondary to not breaking things that work. Also I find
> > it hard to see what purpose there is in having a complicance test that
> > sets a CEA modes w/o aspect ratio and then expects the infoframe to have
> > VIC 0.
> Again, typically this is how these analyzers force modeset:
> - They send EDID with only one mode, which is the test mode, with aspect 
> ratio.
> - They expect that VIC to be present in AVI IF
> >> - Shashank
> >>>> Ankit is going to publish the aspect ratio patch
> >>>> series again, with proper DRM cap and flags check. Would it be
> >>>> ok if we have a look that handling first ?
> >>> This patch will be needed by that work. Otherwise we're going to stop
> >>> sending a VIC for CEA modes with current userspace.
> >> I guess we should force userspaces to start bothering about aspect ratio
> >> field, right now we
> >> are doing this for Wayland based compositors, may be we should extend it
> >> to X based too.
> > Yes, I've been saying that someone should look into extending the randr
> > protocol with the necessary bits. But that still doesn't allow us to
> > change the current behaviour as old userspace would anyway linger around
> > for a long time.
> I think cap will cove this part

The cap is irrelevant to this discussion. It will not be set by old
userspace, hence it won't change anything for old userspace. Modes
coming from old userspace will still have aspect_ratio=0.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 10/10] video/hdmi: Pass buffer size to infoframe unpack functions
  2017-11-13 17:04 ` [PATCH 10/10] video/hdmi: Pass buffer size to infoframe " Ville Syrjala
@ 2017-11-20 13:36   ` Hans Verkuil
  2017-11-20 14:55       ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Hans Verkuil @ 2017-11-20 13:36 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: intel-gfx, Thierry Reding, Hans Verkuil, linux-media

On 11/13/2017 06:04 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> To make sure the infoframe unpack functions don't end up examining
> stack garbage or oopsing, let's pass in the size of the buffer.
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: linux-media@vger.kernel.org
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/media/i2c/adv7511.c  |  2 +-
>  drivers/media/i2c/adv7604.c  |  2 +-
>  drivers/media/i2c/adv7842.c  |  2 +-
>  drivers/media/i2c/tc358743.c |  2 +-
>  drivers/video/hdmi.c         | 51 ++++++++++++++++++++++++++++++++------------
>  include/linux/hdmi.h         |  2 +-
>  6 files changed, 42 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
> index 2817bafc67bf..dec09c18ea34 100644
> --- a/drivers/media/i2c/adv7511.c
> +++ b/drivers/media/i2c/adv7511.c
> @@ -562,7 +562,7 @@ static void log_infoframe(struct v4l2_subdev *sd, const struct adv7511_cfg_read_
>  	buffer[3] = 0;
>  	buffer[3] = hdmi_infoframe_checksum(buffer, len + 4);
>  
> -	if (hdmi_infoframe_unpack(&frame, buffer) < 0) {
> +	if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
>  		v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc);
>  		return;
>  	}
> diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
> index f289b8aca1da..8500438af0d3 100644
> --- a/drivers/media/i2c/adv7604.c
> +++ b/drivers/media/i2c/adv7604.c
> @@ -2429,7 +2429,7 @@ static int adv76xx_read_infoframe(struct v4l2_subdev *sd, int index,
>  		buffer[i + 3] = infoframe_read(sd,
>  				       adv76xx_cri[index].payload_addr + i);
>  
> -	if (hdmi_infoframe_unpack(frame, buffer) < 0) {
> +	if (hdmi_infoframe_unpack(frame, buffer, sizeof(buffer)) < 0) {
>  		v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__,
>  			 adv76xx_cri[index].desc);
>  		return -ENOENT;
> diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
> index 65f34e7e146f..fd5d5e84dcbf 100644
> --- a/drivers/media/i2c/adv7842.c
> +++ b/drivers/media/i2c/adv7842.c
> @@ -2576,7 +2576,7 @@ static void log_infoframe(struct v4l2_subdev *sd, struct adv7842_cfg_read_infofr
>  	for (i = 0; i < len; i++)
>  		buffer[i + 3] = infoframe_read(sd, cri->payload_addr + i);
>  
> -	if (hdmi_infoframe_unpack(&frame, buffer) < 0) {
> +	if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
>  		v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc);
>  		return;
>  	}
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index e6f5c363ccab..f6a5ebffd9c6 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -453,7 +453,7 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
>  
>  	i2c_rd(sd, PK_AVI_0HEAD, buffer, HDMI_INFOFRAME_SIZE(AVI));
>  
> -	if (hdmi_infoframe_unpack(&frame, buffer) < 0) {
> +	if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
>  		v4l2_err(sd, "%s: unpack of AVI infoframe failed\n", __func__);
>  		return;
>  	}
> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> index 65b915ea4936..b5d491014b0b 100644
> --- a/drivers/video/hdmi.c
> +++ b/drivers/video/hdmi.c
> @@ -1005,8 +1005,9 @@ EXPORT_SYMBOL(hdmi_infoframe_log);
>  
>  /**
>   * hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe
> - * @buffer: source buffer
>   * @frame: HDMI AVI infoframe
> + * @buffer: source buffer
> + * @size: size of buffer
>   *
>   * Unpacks the information contained in binary @buffer into a structured
>   * @frame of the HDMI Auxiliary Video (AVI) information frame.
> @@ -1016,11 +1017,14 @@ EXPORT_SYMBOL(hdmi_infoframe_log);
>   * Returns 0 on success or a negative error code on failure.
>   */
>  static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
> -				     const void *buffer)
> +				     const void *buffer, size_t size)
>  {
>  	const u8 *ptr = buffer;
>  	int ret;
>  
> +	if (size < HDMI_INFOFRAME_SIZE(AVI))
> +		return -EINVAL;
> +
>  	if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
>  	    ptr[1] != 2 ||
>  	    ptr[2] != HDMI_AVI_INFOFRAME_SIZE)
> @@ -1068,8 +1072,9 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
>  
>  /**
>   * hdmi_spd_infoframe_unpack() - unpack binary buffer to a HDMI SPD infoframe
> - * @buffer: source buffer
>   * @frame: HDMI SPD infoframe
> + * @buffer: source buffer
> + * @size: size of buffer
>   *
>   * Unpacks the information contained in binary @buffer into a structured
>   * @frame of the HDMI Source Product Description (SPD) information frame.
> @@ -1079,11 +1084,14 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
>   * Returns 0 on success or a negative error code on failure.
>   */
>  static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
> -				     const void *buffer)
> +				     const void *buffer, size_t size)
>  {
>  	const u8 *ptr = buffer;
>  	int ret;
>  
> +	if (size < HDMI_INFOFRAME_SIZE(SPD))
> +		return -EINVAL;
> +
>  	if (ptr[0] != HDMI_INFOFRAME_TYPE_SPD ||
>  	    ptr[1] != 1 ||
>  	    ptr[2] != HDMI_SPD_INFOFRAME_SIZE) {
> @@ -1106,8 +1114,9 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
>  
>  /**
>   * hdmi_audio_infoframe_unpack() - unpack binary buffer to a HDMI AUDIO infoframe
> - * @buffer: source buffer
>   * @frame: HDMI Audio infoframe
> + * @buffer: source buffer
> + * @size: size of buffer
>   *
>   * Unpacks the information contained in binary @buffer into a structured
>   * @frame of the HDMI Audio information frame.
> @@ -1117,11 +1126,14 @@ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame,
>   * Returns 0 on success or a negative error code on failure.
>   */
>  static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
> -				       const void *buffer)
> +				       const void *buffer, size_t size)
>  {
>  	const u8 *ptr = buffer;
>  	int ret;
>  
> +	if (size < HDMI_INFOFRAME_SIZE(AUDIO))
> +		return -EINVAL;
> +
>  	if (ptr[0] != HDMI_INFOFRAME_TYPE_AUDIO ||
>  	    ptr[1] != 1 ||
>  	    ptr[2] != HDMI_AUDIO_INFOFRAME_SIZE) {
> @@ -1151,8 +1163,9 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
>  
>  /**
>   * hdmi_vendor_infoframe_unpack() - unpack binary buffer to a HDMI vendor infoframe
> - * @buffer: source buffer
>   * @frame: HDMI Vendor infoframe
> + * @buffer: source buffer
> + * @size: size of buffer
>   *
>   * Unpacks the information contained in binary @buffer into a structured
>   * @frame of the HDMI Vendor information frame.
> @@ -1163,7 +1176,7 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
>   */
>  static int
>  hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> -				 const void *buffer)
> +				 const void *buffer, size_t size)
>  {
>  	const u8 *ptr = buffer;
>  	size_t length;
> @@ -1171,6 +1184,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>  	u8 hdmi_video_format;
>  	struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
>  
> +	if (size < HDMI_INFOFRAME_HEADER_SIZE)
> +		return -EINVAL;
> +

This check is not needed since that is already done in hdmi_infoframe_unpack().

>  	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
>  	    ptr[1] != 1 ||
>  	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
> @@ -1178,6 +1194,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>  
>  	length = ptr[2];
>  
> +	if (size < HDMI_INFOFRAME_HEADER_SIZE + length)
> +		return -EINVAL;
> +
>  	if (hdmi_infoframe_checksum(buffer,
>  				    HDMI_INFOFRAME_HEADER_SIZE + length) != 0)
>  		return -EINVAL;
> @@ -1224,8 +1243,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>  
>  /**
>   * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe
> - * @buffer: source buffer
>   * @frame: HDMI infoframe
> + * @buffer: source buffer
> + * @size: size of buffer
>   *
>   * Unpacks the information contained in binary buffer @buffer into a structured
>   * @frame of a HDMI infoframe.
> @@ -1235,23 +1255,26 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
>   * Returns 0 on success or a negative error code on failure.
>   */
>  int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
> -			  const void *buffer)
> +			  const void *buffer, size_t size)
>  {
>  	int ret;
>  	const u8 *ptr = buffer;
>  
> +	if (size < HDMI_INFOFRAME_HEADER_SIZE)
> +		return -EINVAL;
> +
>  	switch (ptr[0]) {
>  	case HDMI_INFOFRAME_TYPE_AVI:
> -		ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer);
> +		ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer, size);
>  		break;
>  	case HDMI_INFOFRAME_TYPE_SPD:
> -		ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer);
> +		ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer, size);
>  		break;
>  	case HDMI_INFOFRAME_TYPE_AUDIO:
> -		ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer);
> +		ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer, size);
>  		break;
>  	case HDMI_INFOFRAME_TYPE_VENDOR:
> -		ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer);
> +		ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer, size);
>  		break;
>  	default:
>  		ret = -EINVAL;
> diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
> index d3816170c062..a577d4ae2570 100644
> --- a/include/linux/hdmi.h
> +++ b/include/linux/hdmi.h
> @@ -333,7 +333,7 @@ union hdmi_infoframe {
>  ssize_t
>  hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size);
>  int hdmi_infoframe_unpack(union hdmi_infoframe *frame,
> -			  const void *buffer);
> +			  const void *buffer, size_t size);
>  void hdmi_infoframe_log(const char *level, struct device *dev,
>  			union hdmi_infoframe *frame);
>  
> 

FYI: I'll be posting two other hdmi.c patches today that we (Cisco) have in our queue
for some time.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 10/10] video/hdmi: Pass buffer size to infoframe unpack functions
  2017-11-20 13:36   ` Hans Verkuil
@ 2017-11-20 14:55       ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-20 14:55 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: dri-devel, intel-gfx, Thierry Reding, Hans Verkuil, linux-media

On Mon, Nov 20, 2017 at 02:36:20PM +0100, Hans Verkuil wrote:
> On 11/13/2017 06:04 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
<snip>
> > @@ -1163,7 +1176,7 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
> >   */
> >  static int
> >  hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> > -				 const void *buffer)
> > +				 const void *buffer, size_t size)
> >  {
> >  	const u8 *ptr = buffer;
> >  	size_t length;
> > @@ -1171,6 +1184,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> >  	u8 hdmi_video_format;
> >  	struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
> >  
> > +	if (size < HDMI_INFOFRAME_HEADER_SIZE)
> > +		return -EINVAL;
> > +
> 
> This check is not needed since that is already done in hdmi_infoframe_unpack().

Hmm. True. Somehow I was expecting that this function would have been
exported on its own, but it's static so clearly I was mistaken.

The pack functions are individually exported, which is where I got
this idea probably.

> 
> >  	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
> >  	    ptr[1] != 1 ||
> >  	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
> > @@ -1178,6 +1194,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> >  
> >  	length = ptr[2];
> >  
> > +	if (size < HDMI_INFOFRAME_HEADER_SIZE + length)
> > +		return -EINVAL;
> > +
> >  	if (hdmi_infoframe_checksum(buffer,
> >  				    HDMI_INFOFRAME_HEADER_SIZE + length) != 0)
> >  		return -EINVAL;

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 10/10] video/hdmi: Pass buffer size to infoframe unpack functions
@ 2017-11-20 14:55       ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-20 14:55 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: intel-gfx, Thierry Reding, Hans Verkuil, dri-devel, linux-media

On Mon, Nov 20, 2017 at 02:36:20PM +0100, Hans Verkuil wrote:
> On 11/13/2017 06:04 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
<snip>
> > @@ -1163,7 +1176,7 @@ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame,
> >   */
> >  static int
> >  hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> > -				 const void *buffer)
> > +				 const void *buffer, size_t size)
> >  {
> >  	const u8 *ptr = buffer;
> >  	size_t length;
> > @@ -1171,6 +1184,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> >  	u8 hdmi_video_format;
> >  	struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
> >  
> > +	if (size < HDMI_INFOFRAME_HEADER_SIZE)
> > +		return -EINVAL;
> > +
> 
> This check is not needed since that is already done in hdmi_infoframe_unpack().

Hmm. True. Somehow I was expecting that this function would have been
exported on its own, but it's static so clearly I was mistaken.

The pack functions are individually exported, which is where I got
this idea probably.

> 
> >  	if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
> >  	    ptr[1] != 1 ||
> >  	    (ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
> > @@ -1178,6 +1194,9 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame,
> >  
> >  	length = ptr[2];
> >  
> > +	if (size < HDMI_INFOFRAME_HEADER_SIZE + length)
> > +		return -EINVAL;
> > +
> >  	if (hdmi_infoframe_checksum(buffer,
> >  				    HDMI_INFOFRAME_HEADER_SIZE + length) != 0)
> >  		return -EINVAL;

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D
  2017-11-17  3:10       ` Sharma, Shashank
@ 2017-11-22 18:28         ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-22 18:28 UTC (permalink / raw)
  To: Sharma, Shashank; +Cc: intel-gfx, Laurent Pinchart, dri-devel

On Fri, Nov 17, 2017 at 08:40:02AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/16/2017 9:51 PM, Ville Syrjälä wrote:
> > On Thu, Nov 16, 2017 at 08:10:55PM +0530, Sharma, Shashank wrote:
> >> Regards
> >>
> >> Shashank
> >>
> >>
> >> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> >>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>
> >>> Appedix F of HDMI 2.0 says that some HDMI sink may fail to switch from
> >>> 3D to 2D mode in a timely fashion if the source simply stops sending the
> >>> HDMI infoframe. The suggested workaround is to keep sending the
> >>> infoframe even when strictly not necessary (ie. no VIC and no S3D).
> >>> HDMI 1.4 does allow for this behaviour, stating that sending the
> >>> infoframe is optional in this case.
> >>>
> >>> The infoframe was first specified in HDMI 1.4, so in theory sinks
> >>> predating that may not appreciate us sending an uknown infoframe
> >>> their way. To avoid regressions let's try to determine if the sink
> >>> supports the infoframe or not. Unfortunately there's no direct way
> >>> to do that, so instead we'll just check if we managed to parse any
> >>> HDMI 1.4 4k or stereo modes from the EDID, and if so we assume the
> >>> sink will accept the infoframe. Also if the EDID contains the HDMI
> >>> 2.0 HDMI Forum VSDB we can assume the sink is prepared to receive
> >>> the infoframe.
> >> I am trying to get some sense from HDMI 2.0 spec section 10.2.1, which
> >> talks about
> >> switch from 3D to 2D.  To me it looks like:
> >> If (sending_to_hdmi2_sinks) {
> >>       - for 3d modes send HF-VSIF
> >>       - for 2d modes && defined in H14b HFVSIF, send H14B-VSIF
> >>         When you switch from 3d->2d {
> >>            - send_HF-VSIF with 3D_valid bit = 0/1
> >>        }
> >> } else { /* HDMI 1.4b sinks from Appendix F */
> >>       -  send H14b-VSIF with HDMI_video_format[2:0 = 0 OR 1]
> >> }
> >>
> >> Should we add a is_hdmi2 check and separate these cases ?
> > We don't support the HDMI forum infoframe. Maybe someone forgot to
> > implement that when adding the rest of HDMI 2.0 support? ;)
> How to make an 'embarrassed smile ' smiley :) ?
> Will start looking into it. Meanwhile
> Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>

Patches 1-2 pushed to drm-misc-next. Thanks for the review.

> >>> v2: Fix the getting has_hdmi_infoframe from display_info
> >>>       Always fail constructing the infoframe if the display
> >>>       possibly can't handle it
> >>>
> >>> Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>> Cc: Andrzej Hajda <a.hajda@samsung.com>
> >>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>> ---
> >>>    drivers/gpu/drm/bridge/sil-sii8620.c      |  3 ++-
> >>>    drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |  4 +++-
> >>>    drivers/gpu/drm/drm_edid.c                | 34 +++++++++++++++++++++++++------
> >>>    drivers/gpu/drm/exynos/exynos_hdmi.c      |  2 +-
> >>>    drivers/gpu/drm/i915/intel_hdmi.c         | 14 +++++++------
> >>>    drivers/gpu/drm/mediatek/mtk_hdmi.c       |  3 ++-
> >>>    drivers/gpu/drm/nouveau/nv50_display.c    |  3 ++-
> >>>    drivers/gpu/drm/rockchip/inno_hdmi.c      |  1 +
> >>>    drivers/gpu/drm/sti/sti_hdmi.c            |  4 +++-
> >>>    drivers/gpu/drm/zte/zx_hdmi.c             |  1 +
> >>>    include/drm/drm_connector.h               |  5 +++++
> >>>    include/drm/drm_edid.h                    |  1 +
> >>>    12 files changed, 57 insertions(+), 18 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
> >>> index b7eb704d0a8a..4417276ba02e 100644
> >>> --- a/drivers/gpu/drm/bridge/sil-sii8620.c
> >>> +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
> >>> @@ -2220,8 +2220,9 @@ static bool sii8620_mode_fixup(struct drm_bridge *bridge,
> >>>    			union hdmi_infoframe frm;
> >>>    			u8 mhl_vic[] = { 0, 95, 94, 93, 98 };
> >>>    
> >>> +			/* FIXME: We need the connector here */
> >>>    			drm_hdmi_vendor_infoframe_from_display_mode(
> >>> -				&frm.vendor.hdmi, adjusted_mode);
> >>> +				&frm.vendor.hdmi, NULL, adjusted_mode);
> >>>    			vic = frm.vendor.hdmi.vic;
> >>>    			if (vic >= ARRAY_SIZE(mhl_vic))
> >>>    				vic = 0;
> >>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> >>> index a64ce7112288..b172139502d6 100644
> >>> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> >>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> >>> @@ -1437,7 +1437,9 @@ static void hdmi_config_vendor_specific_infoframe(struct dw_hdmi *hdmi,
> >>>    	u8 buffer[10];
> >>>    	ssize_t err;
> >>>    
> >>> -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
> >>> +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
> >>> +							  &hdmi->connector,
> >>> +							  mode);
> >>>    	if (err < 0)
> >>>    		/*
> >>>    		 * Going into that statement does not means vendor infoframe
> >>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> >>> index 749d07a01772..9ada0ccf50df 100644
> >>> --- a/drivers/gpu/drm/drm_edid.c
> >>> +++ b/drivers/gpu/drm/drm_edid.c
> >>> @@ -3393,6 +3393,7 @@ static int
> >>>    do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
> >>>    		   const u8 *video_db, u8 video_len)
> >>>    {
> >>> +	struct drm_display_info *info = &connector->display_info;
> >>>    	int modes = 0, offset = 0, i, multi_present = 0, multi_len;
> >>>    	u8 vic_len, hdmi_3d_len = 0;
> >>>    	u16 mask;
> >>> @@ -3520,6 +3521,8 @@ do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
> >>>    	}
> >>>    
> >>>    out:
> >>> +	if (modes > 0)
> >>> +		info->has_hdmi_infoframe = true;
> >>>    	return modes;
> >>>    }
> >>>    
> >>> @@ -4243,6 +4246,8 @@ static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
> >>>    	struct drm_display_info *display = &connector->display_info;
> >>>    	struct drm_hdmi_info *hdmi = &display->hdmi;
> >>>    
> >>> +	display->has_hdmi_infoframe = true;
> >>> +
> >>>    	if (hf_vsdb[6] & 0x80) {
> >>>    		hdmi->scdc.supported = true;
> >>>    		if (hf_vsdb[6] & 0x40)
> >>> @@ -4416,6 +4421,7 @@ static void drm_add_display_info(struct drm_connector *connector,
> >>>    	info->cea_rev = 0;
> >>>    	info->max_tmds_clock = 0;
> >>>    	info->dvi_dual = false;
> >>> +	info->has_hdmi_infoframe = false;
> >>>    
> >>>    	if (edid->revision < 3)
> >>>    		return;
> >>> @@ -4903,6 +4909,7 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
> >>>     * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
> >>>     * data from a DRM display mode
> >>>     * @frame: HDMI vendor infoframe
> >>> + * @connector: the connector
> >> I remember our old discussion where we realized that we will need this
> >> connector for all types of infoframes,
> >> eventually, do you think we should start thinking about creating a
> >> wrapper like drm_any_infoframe_from_display_mode(),
> >> and pass connector and desired type to it ?Or I am getting too ambitious
> >> targeting this series :) ?
> >>>     * @mode: DRM display mode
> >>>     *
> >>>     * Note that there's is a need to send HDMI vendor infoframes only when using a
> >>> @@ -4913,8 +4920,15 @@ s3d_structure_from_display_mode(const struct drm_display_mode *mode)
> >>>     */
> >>>    int
> >>>    drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >>> +					    struct drm_connector *connector,
> >>>    					    const struct drm_display_mode *mode)
> >>>    {
> >>> +	/*
> >>> +	 * FIXME: sil-sii8620 doesn't have a connector around when
> >>> +	 * we need one, so we have to be prepared for a NULL connector.
> >>> +	 */
> >>> +	bool has_hdmi_infoframe = connector ?
> >>> +		connector->display_info.has_hdmi_infoframe : false;
> >>>    	int err;
> >>>    	u32 s3d_flags;
> >>>    	u8 vic;
> >>> @@ -4922,11 +4936,21 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >>>    	if (!frame || !mode)
> >>>    		return -EINVAL;
> >>>    
> >>> +	if (!has_hdmi_infoframe)
> >>> +		return -EINVAL;
> >>> +
> >>>    	vic = drm_match_hdmi_mode(mode);
> >>>    	s3d_flags = mode->flags & DRM_MODE_FLAG_3D_MASK;
> >>>    
> >>> -	if (!vic && !s3d_flags)
> >>> -		return -EINVAL;
> >>> +	/*
> >>> +	 * Even if it's not absolutely necessary to send the infoframe
> >>> +	 * (ie.vic==0 and s3d_struct==0) we will still send it if we
> >>> +	 * know that the sink can handle it. This is based on a
> >>> +	 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
> >>> +	 * have trouble realizing that they shuld switch from 3D to 2D
> >>> +	 * mode if the source simply stops sending the infoframe when
> >>> +	 * it wants to switch from 3D to 2D.
> >>> +	 */
> >>>    
> >>>    	if (vic && s3d_flags)
> >>>    		return -EINVAL;
> >>> @@ -4935,10 +4959,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >>>    	if (err < 0)
> >>>    		return err;
> >>>    
> >>> -	if (vic)
> >>> -		frame->vic = vic;
> >>> -	else
> >>> -		frame->s3d_struct = s3d_structure_from_display_mode(mode);
> >>> +	frame->vic = vic;
> >>> +	frame->s3d_struct = s3d_structure_from_display_mode(mode);
> >>>    
> >>>    	return 0;
> >>>    }
> >>> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
> >>> index 0109ff40b1db..812b2773ed69 100644
> >>> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> >>> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> >>> @@ -795,7 +795,7 @@ static void hdmi_reg_infoframes(struct hdmi_context *hdata)
> >>>    	}
> >>>    
> >>>    	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frm.vendor.hdmi,
> >>> -			&hdata->current_mode);
> >>> +			&hdata->connector, &hdata->current_mode);
> >>>    	if (!ret)
> >>>    		ret = hdmi_vendor_infoframe_pack(&frm.vendor.hdmi, buf,
> >>>    				sizeof(buf));
> >>> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> >>> index 2d95db64cdf2..2ccba4ccf7ad 100644
> >>> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> >>> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> >>> @@ -512,12 +512,14 @@ static void intel_hdmi_set_spd_infoframe(struct drm_encoder *encoder,
> >>>    
> >>>    static void
> >>>    intel_hdmi_set_hdmi_infoframe(struct drm_encoder *encoder,
> >>> -			      const struct intel_crtc_state *crtc_state)
> >>> +			      const struct intel_crtc_state *crtc_state,
> >>> +			      const struct drm_connector_state *conn_state)
> >>>    {
> >>>    	union hdmi_infoframe frame;
> >>>    	int ret;
> >>>    
> >>>    	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> >>> +							  conn_state->connector,
> >>>    							  &crtc_state->base.adjusted_mode);
> >>>    	if (ret < 0)
> >>>    		return;
> >>> @@ -584,7 +586,7 @@ static void g4x_set_infoframes(struct drm_encoder *encoder,
> >>>    
> >>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> >>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> >>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >>>    }
> >>>    
> >>>    static bool hdmi_sink_is_deep_color(const struct drm_connector_state *conn_state)
> >>> @@ -725,7 +727,7 @@ static void ibx_set_infoframes(struct drm_encoder *encoder,
> >>>    
> >>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> >>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> >>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >>>    }
> >>>    
> >>>    static void cpt_set_infoframes(struct drm_encoder *encoder,
> >>> @@ -768,7 +770,7 @@ static void cpt_set_infoframes(struct drm_encoder *encoder,
> >>>    
> >>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> >>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> >>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >>>    }
> >>>    
> >>>    static void vlv_set_infoframes(struct drm_encoder *encoder,
> >>> @@ -821,7 +823,7 @@ static void vlv_set_infoframes(struct drm_encoder *encoder,
> >>>    
> >>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> >>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> >>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >>>    }
> >>>    
> >>>    static void hsw_set_infoframes(struct drm_encoder *encoder,
> >>> @@ -854,7 +856,7 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
> >>>    
> >>>    	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
> >>>    	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
> >>> -	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
> >>> +	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state, conn_state);
> >>>    }
> >>>    
> >>>    void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
> >>> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> >>> index b78791061983..59a11026dceb 100644
> >>> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> >>> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> >>> @@ -1054,7 +1054,8 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi,
> >>>    	u8 buffer[10];
> >>>    	ssize_t err;
> >>>    
> >>> -	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, mode);
> >>> +	err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
> >>> +							  &hdmi->conn, mode);
> >>>    	if (err) {
> >>>    		dev_err(hdmi->dev,
> >>>    			"Failed to get vendor infoframe from mode: %zd\n", err);
> >>> diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
> >>> index b26a506d20ca..9d7b2afd7cfc 100644
> >>> --- a/drivers/gpu/drm/nouveau/nv50_display.c
> >>> +++ b/drivers/gpu/drm/nouveau/nv50_display.c
> >>> @@ -2754,7 +2754,8 @@ nv50_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode)
> >>>    			= hdmi_infoframe_pack(&avi_frame, args.infoframes, 17);
> >>>    	}
> >>>    
> >>> -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi, mode);
> >>> +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&vendor_frame.vendor.hdmi,
> >>> +							  &nv_connector->base, mode);
> >>>    	if (!ret) {
> >>>    		/* We have a Vendor InfoFrame, populate it to the display */
> >>>    		args.pwr.vendor_infoframe_length
> >>> diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
> >>> index ee584d87111f..fab30927a889 100644
> >>> --- a/drivers/gpu/drm/rockchip/inno_hdmi.c
> >>> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
> >>> @@ -282,6 +282,7 @@ static int inno_hdmi_config_video_vsi(struct inno_hdmi *hdmi,
> >>>    	int rc;
> >>>    
> >>>    	rc = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> >>> +							 &hdmi->connector,
> >>>    							 mode);
> >>>    
> >>>    	return inno_hdmi_upload_frame(hdmi, rc, &frame, INFOFRAME_VSI,
> >>> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> >>> index d1902750a85d..c3b292ab17a5 100644
> >>> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> >>> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> >>> @@ -515,7 +515,9 @@ static int hdmi_vendor_infoframe_config(struct sti_hdmi *hdmi)
> >>>    
> >>>    	DRM_DEBUG_DRIVER("\n");
> >>>    
> >>> -	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe, mode);
> >>> +	ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe,
> >>> +							  hdmi->drm_connector,
> >>> +							  mode);
> >>>    	if (ret < 0) {
> >>>    		/*
> >>>    		 * Going into that statement does not means vendor infoframe
> >>> diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
> >>> index b8abb1b496ff..13ea90f7a185 100644
> >>> --- a/drivers/gpu/drm/zte/zx_hdmi.c
> >>> +++ b/drivers/gpu/drm/zte/zx_hdmi.c
> >>> @@ -108,6 +108,7 @@ static int zx_hdmi_config_video_vsi(struct zx_hdmi *hdmi,
> >>>    	int ret;
> >>>    
> >>>    	ret = drm_hdmi_vendor_infoframe_from_display_mode(&frame.vendor.hdmi,
> >>> +							  &hdmi->connector,
> >>>    							  mode);
> >>>    	if (ret) {
> >>>    		DRM_DEV_ERROR(hdmi->dev, "failed to get vendor infoframe: %d\n",
> >>> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> >>> index 2b97d1e28f60..1543212b0449 100644
> >>> --- a/include/drm/drm_connector.h
> >>> +++ b/include/drm/drm_connector.h
> >>> @@ -270,6 +270,11 @@ struct drm_display_info {
> >>>    	bool dvi_dual;
> >>>    
> >>>    	/**
> >>> +	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
> >>> +	 */
> >>> +	bool has_hdmi_infoframe;
> >>> +
> >>> +	/**
> >>>    	 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
> >>>    	 * more stuff redundant with @bus_formats.
> >>>    	 */
> >>> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> >>> index 9e4e23524840..3c8740ad1db6 100644
> >>> --- a/include/drm/drm_edid.h
> >>> +++ b/include/drm/drm_edid.h
> >>> @@ -356,6 +356,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
> >>>    					 bool is_hdmi2_sink);
> >>>    int
> >>>    drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >>> +					    struct drm_connector *connector,
> >>>    					    const struct drm_display_mode *mode);
> >>>    void
> >>>    drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
> >> Otherwise looks good
> >> - Shashank

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes
  2017-11-17 11:38         ` Ville Syrjälä
@ 2017-11-24  8:55           ` Sharma, Shashank
  0 siblings, 0 replies; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-24  8:55 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jose Abreu, Daniel Vetter, intel-gfx, Emil Velikov, dri-devel,
	Nautiyal Ankit

Regards

Shashank


On 11/17/2017 5:08 PM, Ville Syrjälä wrote:
> On Fri, Nov 17, 2017 at 08:53:54AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/16/2017 9:56 PM, Ville Syrjälä wrote:
>>> On Thu, Nov 16, 2017 at 08:31:36PM +0530, Sharma, Shashank wrote:
>>>> Regards
>>>>
>>>> Shashank
>>>>
>>>>
>>>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>>
>>>>> If the user mode would specify an aspect ratio other than 4:3 or 16:9
>>>>> we now silently ignore it. Maybe a better apporoach is to return an
>>>>> error? Let's try that.
>>>>>
>>>>> Also we must be careful that we don't try to send illegal picture
>>>>> aspect in the infoframe as it's only capable of signalling none,
>>>>> 4:3, and 16:9. Currently we're sending these bogus infoframes
>>>>> whenever the cea mode specifies some other aspect ratio.
>>>>>
>>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>>>> Cc: Sean Paul <seanpaul@chromium.org>
>>>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>> ---
>>>>>     drivers/gpu/drm/drm_edid.c | 23 +++++++++++++++++------
>>>>>     1 file changed, 17 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>>>> index 00aa98f3e55d..bafb3ee4ea97 100644
>>>>> --- a/drivers/gpu/drm/drm_edid.c
>>>>> +++ b/drivers/gpu/drm/drm_edid.c
>>>>> @@ -4786,6 +4786,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>>>>>     					 const struct drm_display_mode *mode,
>>>>>     					 bool is_hdmi2_sink)
>>>>>     {
>>>>> +	enum hdmi_picture_aspect picture_aspect;
>>>>>     	int err;
>>>>>     
>>>>>     	if (!frame || !mode)
>>>>> @@ -4828,13 +4829,23 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
>>>>>     	 * Populate picture aspect ratio from either
>>>>>     	 * user input (if specified) or from the CEA mode list.
>>>>>     	 */
>>>>> -	if (mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_4_3 ||
>>>>> -		mode->picture_aspect_ratio == HDMI_PICTURE_ASPECT_16_9)
>>>>> -		frame->picture_aspect = mode->picture_aspect_ratio;
>>>>> -	else if (frame->video_code > 0)
>>>>> -		frame->picture_aspect = drm_get_cea_aspect_ratio(
>>>>> -						frame->video_code);
>>>>> +	picture_aspect = mode->picture_aspect_ratio;
>>>>> +	if (picture_aspect == HDMI_PICTURE_ASPECT_NONE)
>>>>> +		picture_aspect = drm_get_cea_aspect_ratio(frame->video_code);
>>>> This is slightly going in the loop.
>>>> - During the modeset the driver cant specify the aspect ratio
>>>> information, as DRM layer lacks this support.
>>>> - So we fill the VIC field, by comparing the mode with the
>>>> DRM_CEA_MODES[] list. This will pick the first mode
>>>>      available in the list (regardless of its aspect ratio), and fill the
>>>> VIC, as we don't consider aspect ratio while comparing timings.
>>>> - Again, now while sending the aspect ratio, we are picking up the VIC,
>>>> which may not be correct.
>>>>
>>>> So if we have 720x480(4:3) and 720x480(16:9) in the list, as 4:3 is
>>>> first in list, we will always pick 4:3 aspect ratio.
>>> Yes. The user didn't care about the aspect ratio (or rather couldn't
>>> specify one) so we just pick one. Which is exactly what we've been
>>> doing ever since we started sending the VIC in the infoframe.
>> Correct, and we are hoping that this should be better (if not fixed)
>> with the aspect ratio support
>> patches + DRM cap. If the userspace doesn't set the cap, then anyways
>> there is no aspect ratio
>> field available, and VIC would be always 0, as this becomes a Non CEA mode.
>>
>> Or do you think it would be a better idea to send some VIC instead of No
>> VIC, when userspace doesn't
>> set the DRM cap for aspect ratio ?
> Yes. That's the current behaviour.
>
> IIRC some crappy amplifiers etc. with HDMI passthrough don't even work
> correctly unless VIC is specified. Hence we do want to send it whenever
> possible.
Ok, in this case this make sense, and then I kindof agree with what this 
patch is trying to do.
Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
>> - Shashank
>>>> - Shashank
>>>>>     
>>>>> +	/*
>>>>> +	 * The infoframe can't convey anything but none, 4:3
>>>>> +	 * and 16:9, so if the user has asked for anything else
>>>>> +	 * we can only satisfy it by specifying the right VIC.
>>>>> +	 */
>>>>> +	if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
>>>>> +		if (picture_aspect !=
>>>>> +		    drm_get_cea_aspect_ratio(frame->video_code))
>>>>> +			return -EINVAL;
>>>>> +		picture_aspect = HDMI_PICTURE_ASPECT_NONE;
>>>>> +	}
>>>>> +
>>>>> +	frame->picture_aspect = picture_aspect;
>>>>>     	frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
>>>>>     	frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
>>>>>     

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-17 12:49             ` Ville Syrjälä
@ 2017-11-24  8:56               ` Sharma, Shashank
  2017-11-24 13:22                 ` Ville Syrjälä
  0 siblings, 1 reply; 44+ messages in thread
From: Sharma, Shashank @ 2017-11-24  8:56 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Jose Abreu, Lin, Jia, Akashdeep Sharma, intel-gfx, Emil Velikov,
	dri-devel, Daniel Vetter, Nautiyal Ankit, Jim Bride

Regards

Shashank


On 11/17/2017 6:19 PM, Ville Syrjälä wrote:
> On Fri, Nov 17, 2017 at 05:50:11PM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 11/17/2017 5:05 PM, Ville Syrjälä wrote:
>>> On Fri, Nov 17, 2017 at 08:49:49AM +0530, Sharma, Shashank wrote:
>>>> Regards
>>>>
>>>> Shashank
>>>>
>>>>
>>>> On 11/16/2017 9:53 PM, Ville Syrjälä wrote:
>>>>> On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
>>>>>> Regards
>>>>>>
>>>>>> Shashank
>>>>>>
>>>>>>
>>>>>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
>>>>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>>>>
>>>>>>> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
>>>>>>> cause us to not send out any VICs in the AVI infoframes. That commit
>>>>>>> was since reverted, but if and when we add aspect ratio handing back
>>>>>>> we need to be more careful.
>>>>>>>
>>>>>>> Let's handle this by considering the aspect ratio as a requirement
>>>>>>> for cea mode matching only if the passed in mode actually has a
>>>>>>> non-zero aspect ratio field. This will keep userspace that doesn't
>>>>>>> provide an aspect ratio working as before by matching it to the
>>>>>>> first otherwise equal cea mode. And once userspace starts to
>>>>>>> provide the aspect ratio it will be considerd a hard requirement
>>>>>>> for the match.
>>>>>>>
>>>>>>> Also change the hdmi mode matching to use drm_mode_match() for
>>>>>>> consistency, but we don't match on aspect ratio there since the
>>>>>>> spec doesn't list a specific aspect ratio for those modes.
>>>>>>>
>>>>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>>>>>> Cc: "Lin, Jia" <lin.a.jia@intel.com>
>>>>>>> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
>>>>>>> Cc: Jim Bride <jim.bride@linux.intel.com>
>>>>>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>>>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
>>>>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>>>> ---
>>>>>>>      drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
>>>>>>>      1 file changed, 14 insertions(+), 4 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>>>>>>> index 7220b8f9a7e8..00aa98f3e55d 100644
>>>>>>> --- a/drivers/gpu/drm/drm_edid.c
>>>>>>> +++ b/drivers/gpu/drm/drm_edid.c
>>>>>>> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
>>>>>>>      static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
>>>>>>>      					     unsigned int clock_tolerance)
>>>>>>>      {
>>>>>>> +	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;
>>>>>> This doesn't look right. This means we are expecting a CEA mode without
>>>>>> a pic aspect ratio field,
>>>>>> which is invalid.
>>>>> No, it's perfectly valid. It's what we currently get from userspace.
>>>> Yep, but that's due to missing Aspect ratio handling in the DRM layer.
>>>> If that's fixed, as per the list of CEA modes,
>>>> each CEA VIC contains an aspect ratio, which is a part of its unique
>>>> identity.
>>>>
>>>> I guess once we have the aspect ratio handling in DRM layer, it
>>>> would/should look like this:
>>>> - EDID gives you all supported modes, including CEA modes with Aspect ratio
>>>> - Userspcae gets the mode information, with aspect ratio (for CEA modes)
>>>> If ( Userspace picks one of the CEA modes)
>>>>        - sends a modeset
>>>>        - we find a matching CEA VIC, found one from modedb
>>>>        - we load this VIC = nonzero information in AVI IF VIC field,
>>>> else
>>>>        - sends a modeset
>>>>        - we could not find a matching CEA VIC, as aspect ratio is 0
>>>>        - we make VIC field in AVI IF as 0a
>>> No. That would break current userspace.
>> I guess I forgot to make it clear, that userspace will set the cap, only
>> then we will provide aspect ratio information.
>> So this should not break userspace, isn't it ?
>>>> This is important, as HDMI compliance test 7-27 inspects if the VIC
>>>> field in the AVI IF is accurate.
>>> Complicance is secondary to not breaking things that work. Also I find
>>> it hard to see what purpose there is in having a complicance test that
>>> sets a CEA modes w/o aspect ratio and then expects the infoframe to have
>>> VIC 0.
>> Again, typically this is how these analyzers force modeset:
>> - They send EDID with only one mode, which is the test mode, with aspect
>> ratio.
>> - They expect that VIC to be present in AVI IF
>>>> - Shashank
>>>>>> Ankit is going to publish the aspect ratio patch
>>>>>> series again, with proper DRM cap and flags check. Would it be
>>>>>> ok if we have a look that handling first ?
>>>>> This patch will be needed by that work. Otherwise we're going to stop
>>>>> sending a VIC for CEA modes with current userspace.
>>>> I guess we should force userspaces to start bothering about aspect ratio
>>>> field, right now we
>>>> are doing this for Wayland based compositors, may be we should extend it
>>>> to X based too.
>>> Yes, I've been saying that someone should look into extending the randr
>>> protocol with the necessary bits. But that still doesn't allow us to
>>> change the current behaviour as old userspace would anyway linger around
>>> for a long time.
>> I think cap will cove this part
> The cap is irrelevant to this discussion. It will not be set by old
> userspace, hence it won't change anything for old userspace. Modes
> coming from old userspace will still have aspect_ratio=0.
Agree, and in that case, why bother about aspect ratio flags here in 
this series ? Probably let this be taken care in aspect ratio series.
- Shashank

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling
  2017-11-24  8:56               ` Sharma, Shashank
@ 2017-11-24 13:22                 ` Ville Syrjälä
  0 siblings, 0 replies; 44+ messages in thread
From: Ville Syrjälä @ 2017-11-24 13:22 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: Jose Abreu, Lin, Jia, Akashdeep Sharma, intel-gfx, Emil Velikov,
	dri-devel, Daniel Vetter, Nautiyal Ankit, Jim Bride

On Fri, Nov 24, 2017 at 02:26:09PM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 11/17/2017 6:19 PM, Ville Syrjälä wrote:
> > On Fri, Nov 17, 2017 at 05:50:11PM +0530, Sharma, Shashank wrote:
> >> Regards
> >>
> >> Shashank
> >>
> >>
> >> On 11/17/2017 5:05 PM, Ville Syrjälä wrote:
> >>> On Fri, Nov 17, 2017 at 08:49:49AM +0530, Sharma, Shashank wrote:
> >>>> Regards
> >>>>
> >>>> Shashank
> >>>>
> >>>>
> >>>> On 11/16/2017 9:53 PM, Ville Syrjälä wrote:
> >>>>> On Thu, Nov 16, 2017 at 08:21:44PM +0530, Sharma, Shashank wrote:
> >>>>>> Regards
> >>>>>>
> >>>>>> Shashank
> >>>>>>
> >>>>>>
> >>>>>> On 11/13/2017 10:34 PM, Ville Syrjala wrote:
> >>>>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>>>>
> >>>>>>> commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer")
> >>>>>>> cause us to not send out any VICs in the AVI infoframes. That commit
> >>>>>>> was since reverted, but if and when we add aspect ratio handing back
> >>>>>>> we need to be more careful.
> >>>>>>>
> >>>>>>> Let's handle this by considering the aspect ratio as a requirement
> >>>>>>> for cea mode matching only if the passed in mode actually has a
> >>>>>>> non-zero aspect ratio field. This will keep userspace that doesn't
> >>>>>>> provide an aspect ratio working as before by matching it to the
> >>>>>>> first otherwise equal cea mode. And once userspace starts to
> >>>>>>> provide the aspect ratio it will be considerd a hard requirement
> >>>>>>> for the match.
> >>>>>>>
> >>>>>>> Also change the hdmi mode matching to use drm_mode_match() for
> >>>>>>> consistency, but we don't match on aspect ratio there since the
> >>>>>>> spec doesn't list a specific aspect ratio for those modes.
> >>>>>>>
> >>>>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>>>>>> Cc: "Lin, Jia" <lin.a.jia@intel.com>
> >>>>>>> Cc: Akashdeep Sharma <akashdeep.sharma@intel.com>
> >>>>>>> Cc: Jim Bride <jim.bride@linux.intel.com>
> >>>>>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> >>>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >>>>>>> Cc: Emil Velikov <emil.l.velikov@gmail.com>
> >>>>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>>>> ---
> >>>>>>>      drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++----
> >>>>>>>      1 file changed, 14 insertions(+), 4 deletions(-)
> >>>>>>>
> >>>>>>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> >>>>>>> index 7220b8f9a7e8..00aa98f3e55d 100644
> >>>>>>> --- a/drivers/gpu/drm/drm_edid.c
> >>>>>>> +++ b/drivers/gpu/drm/drm_edid.c
> >>>>>>> @@ -2903,11 +2903,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
> >>>>>>>      static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
> >>>>>>>      					     unsigned int clock_tolerance)
> >>>>>>>      {
> >>>>>>> +	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;
> >>>>>> This doesn't look right. This means we are expecting a CEA mode without
> >>>>>> a pic aspect ratio field,
> >>>>>> which is invalid.
> >>>>> No, it's perfectly valid. It's what we currently get from userspace.
> >>>> Yep, but that's due to missing Aspect ratio handling in the DRM layer.
> >>>> If that's fixed, as per the list of CEA modes,
> >>>> each CEA VIC contains an aspect ratio, which is a part of its unique
> >>>> identity.
> >>>>
> >>>> I guess once we have the aspect ratio handling in DRM layer, it
> >>>> would/should look like this:
> >>>> - EDID gives you all supported modes, including CEA modes with Aspect ratio
> >>>> - Userspcae gets the mode information, with aspect ratio (for CEA modes)
> >>>> If ( Userspace picks one of the CEA modes)
> >>>>        - sends a modeset
> >>>>        - we find a matching CEA VIC, found one from modedb
> >>>>        - we load this VIC = nonzero information in AVI IF VIC field,
> >>>> else
> >>>>        - sends a modeset
> >>>>        - we could not find a matching CEA VIC, as aspect ratio is 0
> >>>>        - we make VIC field in AVI IF as 0
> >>> No. That would break current userspace.
> >> I guess I forgot to make it clear, that userspace will set the cap, only
> >> then we will provide aspect ratio information.
> >> So this should not break userspace, isn't it ?
> >>>> This is important, as HDMI compliance test 7-27 inspects if the VIC
> >>>> field in the AVI IF is accurate.
> >>> Complicance is secondary to not breaking things that work. Also I find
> >>> it hard to see what purpose there is in having a complicance test that
> >>> sets a CEA modes w/o aspect ratio and then expects the infoframe to have
> >>> VIC 0.
> >> Again, typically this is how these analyzers force modeset:
> >> - They send EDID with only one mode, which is the test mode, with aspect
> >> ratio.
> >> - They expect that VIC to be present in AVI IF
> >>>> - Shashank
> >>>>>> Ankit is going to publish the aspect ratio patch
> >>>>>> series again, with proper DRM cap and flags check. Would it be
> >>>>>> ok if we have a look that handling first ?
> >>>>> This patch will be needed by that work. Otherwise we're going to stop
> >>>>> sending a VIC for CEA modes with current userspace.
> >>>> I guess we should force userspaces to start bothering about aspect ratio
> >>>> field, right now we
> >>>> are doing this for Wayland based compositors, may be we should extend it
> >>>> to X based too.
> >>> Yes, I've been saying that someone should look into extending the randr
> >>> protocol with the necessary bits. But that still doesn't allow us to
> >>> change the current behaviour as old userspace would anyway linger around
> >>> for a long time.
> >> I think cap will cove this part
> > The cap is irrelevant to this discussion. It will not be set by old
> > userspace, hence it won't change anything for old userspace. Modes
> > coming from old userspace will still have aspect_ratio=0.
> Agree, and in that case, why bother about aspect ratio flags here in 
> this series ? Probably let this be taken care in aspect ratio series.

If someone wants to suck these patches into the aspect ratio series that
fine by me.

I had them here because they were on the same branch where I had the
fix for the aspect ratio in the infoframe. And I was too lazy to
remove them from the series, figuring they're semi-related anyway.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2017-11-24 13:22 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-13 17:04 [PATCH 00/10] drm/edid: Infoframe cleanups and fixes Ville Syrjala
2017-11-13 17:04 ` [PATCH 01/10] video/hdmi: Allow "empty" HDMI infoframes Ville Syrjala
2017-11-13 17:04   ` Ville Syrjala
2017-11-16 14:36   ` Sharma, Shashank
2017-11-16 16:16     ` Ville Syrjälä
2017-11-17  3:05       ` Sharma, Shashank
2017-11-17  3:05         ` Sharma, Shashank
2017-11-13 17:04 ` [PATCH 02/10] drm/edid: Allow HDMI infoframe without VIC or S3D Ville Syrjala
2017-11-16 14:40   ` Sharma, Shashank
2017-11-16 16:21     ` Ville Syrjälä
2017-11-17  3:10       ` Sharma, Shashank
2017-11-22 18:28         ` Ville Syrjälä
2017-11-13 17:04 ` [PATCH 03/10] drm/modes: Introduce drm_mode_match() Ville Syrjala
2017-11-13 17:04 ` [PATCH 04/10] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy Ville Syrjala
2017-11-13 17:04 ` [PATCH 05/10] drm/edid: Fix up edid_cea_modes[] formatting Ville Syrjala
2017-11-13 17:04 ` [PATCH 06/10] drm/edid: Fix cea mode aspect ratio handling Ville Syrjala
2017-11-13 18:13   ` Jose Abreu
2017-11-13 18:53     ` Ville Syrjälä
2017-11-16 14:51   ` Sharma, Shashank
2017-11-16 16:23     ` Ville Syrjälä
2017-11-17  3:19       ` Sharma, Shashank
2017-11-17 11:35         ` Ville Syrjälä
2017-11-17 12:20           ` Sharma, Shashank
2017-11-17 12:49             ` Ville Syrjälä
2017-11-24  8:56               ` Sharma, Shashank
2017-11-24 13:22                 ` Ville Syrjälä
2017-11-13 17:04 ` [PATCH 07/10] drm/edid: Don't send bogus aspect ratios in AVI infoframes Ville Syrjala
2017-11-13 18:30   ` Jose Abreu
2017-11-13 19:00     ` Ville Syrjälä
2017-11-16 15:01   ` Sharma, Shashank
2017-11-16 16:26     ` Ville Syrjälä
2017-11-17  3:23       ` Sharma, Shashank
2017-11-17 11:38         ` Ville Syrjälä
2017-11-24  8:55           ` Sharma, Shashank
2017-11-13 17:04 ` [PATCH 08/10] video/hdmi: Reject illegal picture aspect ratios Ville Syrjala
2017-11-13 18:33   ` Jose Abreu
2017-11-13 18:33     ` Jose Abreu
2017-11-13 17:04 ` [PATCH 09/10] video/hdmi: Constify 'buffer' to the unpack functions Ville Syrjala
2017-11-13 17:04 ` [PATCH 10/10] video/hdmi: Pass buffer size to infoframe " Ville Syrjala
2017-11-20 13:36   ` Hans Verkuil
2017-11-20 14:55     ` Ville Syrjälä
2017-11-20 14:55       ` Ville Syrjälä
2017-11-13 17:52 ` ✓ Fi.CI.BAT: success for drm/edid: Infoframe cleanups and fixes Patchwork
2017-11-13 19:07 ` ✓ Fi.CI.IGT: " Patchwork

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.