Skip to contentSkip to conversation

Add aspect ratio parsing

PATCH Superseded Shashank Sharma 2 participants 7 messages Dec 17, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Add aspect ratio parsing

Currently DRM framework doesn't parse aspect ratio of a videomode while converting it from a umode->kmode or viceversa. This causes modeset of CEA modes with incorrect aspect ratio.

While running HDMI complaince, tests (like 7-27) expect the DUT to apply the mode as per the VIC, but as driver does not consider the aspect ratio part while searching a mode from modedb, we end up setting mode with a wrong VIC, causing the test to fail.

What this patch set does:
Patch 1-2
- Adds aspect ratio flags in the DRM layer, in form of flags.
- Adds parsing of aspect ratio, during conversion of a umode->kmode and viceversa.
- Adds aspect ratio check while finding a mode, during modeset.

Patch 3-5
- Adds some new aspect ratio defined in CEA-861-F specs to support HDMI 2.0 displays, in DRM and I915 layer.

V2: needed a rebase

Shashank Sharma (5):
drm: add picture aspect ratio flags
drm: Add aspect ratio parsing in DRM layer
video: Add new aspect ratios for HDMI 2.0
drm: Add flags for new aspect ratios
drm/i915: Add support for new aspect ratios

 drivers/gpu/drm/drm_modes.c       | 46 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_hdmi.c |  6 +++++
 drivers/gpu/drm/i915/intel_sdvo.c |  6 +++++
 drivers/video/hdmi.c              |  4 ++++
 include/linux/hdmi.h              |  2 ++
 include/uapi/drm/drm_mode.h       | 24 +++++++++++++++-----
 6 files changed, 83 insertions(+), 5 deletions(-)
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v2 1/5 drm: add picture aspect ratio flags

This patch adds drm flag bits for aspect ratio information

Currently drm flag bits don't have field for mode's picture aspect ratio. This field will help the driver to pick mode with right aspect ratio, and help in setting right VIC field in avi infoframes.

---
 include/uapi/drm/drm_mode.h | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
include/uapi/drm/drm_mode.h +13 -5
index 50adb46..3389bd1 100644
@@ -73,6 +73,19 @@
 #define  DRM_MODE_FLAG_3D_TOP_AND_BOTTOM	(7<<14)
 #define  DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF	(8<<14)
 
+/* Picture aspect ratio options */
+#define DRM_MODE_PICTURE_ASPECT_NONE		0
+#define DRM_MODE_PICTURE_ASPECT_4_3		1
+#define DRM_MODE_PICTURE_ASPECT_16_9		2
+
+/* Aspect ratio flag bitmask (4 bits 21:19) */
+#define	 DRM_MODE_FLAG_PARMASK		(0x0F<<19)
+#define  DRM_MODE_FLAG_PARNONE \
+		(DRM_MODE_PICTURE_ASPECT_NONE << 19)
+#define  DRM_MODE_FLAG_PAR4_3 \
+		(DRM_MODE_PICTURE_ASPECT_4_3 << 19)
+#define  DRM_MODE_FLAG_PAR16_9 \
+		(DRM_MODE_PICTURE_ASPECT_16_9 << 19)
 
 /* DPMS flags */
 /* bit compatible with the xorg definitions. */
@@ -88,11 +101,6 @@
 #define DRM_MODE_SCALE_CENTER		2 /* Centered, no scaling */
 #define DRM_MODE_SCALE_ASPECT		3 /* Full screen, preserve aspect */
 
-/* Picture aspect ratio options */
-#define DRM_MODE_PICTURE_ASPECT_NONE	0
-#define DRM_MODE_PICTURE_ASPECT_4_3	1
-#define DRM_MODE_PICTURE_ASPECT_16_9	2
-
 /* Dithering mode options */
 #define DRM_MODE_DITHERING_OFF	0
 #define DRM_MODE_DITHERING_ON	1
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH v2 2/5 drm: Add aspect ratio parsing in DRM layer

In reply to Shashank Sharma

Current DRM layer functions dont parse aspect ratio information while converting a user mode->kernel mode or viceversa. This causes modeset to pick mode with wrong aspect ratio, eventually cauing failures in HDMI compliance test cases, due to wrong VIC.

This patch adds aspect ratio information in DRM's mode conversion and mode comparision functions, to make sure kernel picks mode with right aspect ratio (as per the VIC).

---
 drivers/gpu/drm/drm_modes.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/gpu/drm/drm_modes.c +34 -0
index 20775c0..7824a63 100644
@@ -939,6 +939,9 @@ bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1, const struct
 	    (mode2->flags & DRM_MODE_FLAG_3D_MASK))
 		return false;
 
+	if (mode1->picture_aspect_ratio != mode2->picture_aspect_ratio)
+		return false;
+
 	return drm_mode_equal_no_clocks_no_stereo(mode1, mode2);
 }
 EXPORT_SYMBOL(drm_mode_equal_no_clocks);
@@ -967,6 +970,7 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
 	    mode1->vsync_end == mode2->vsync_end &&
 	    mode1->vtotal == mode2->vtotal &&
 	    mode1->vscan == mode2->vscan &&
+	    mode1->picture_aspect_ratio == mode2->picture_aspect_ratio &&
 	    (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
 	     (mode2->flags & ~DRM_MODE_FLAG_3D_MASK))
 		return true;
@@ -1470,6 +1474,22 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
 	out->vrefresh = in->vrefresh;
 	out->flags = in->flags;
 	out->type = in->type;
+	out->flags &= ~DRM_MODE_FLAG_PARMASK;
+
+	switch (in->picture_aspect_ratio) {
+	case HDMI_PICTURE_ASPECT_4_3:
+		out->flags |= DRM_MODE_FLAG_PAR4_3;
+		break;
+	case HDMI_PICTURE_ASPECT_16_9:
+		out->flags |= DRM_MODE_FLAG_PAR16_9;
+		break;
+	case HDMI_PICTURE_ASPECT_NONE:
+	case HDMI_PICTURE_ASPECT_RESERVED:
+	default:
+		out->flags |= DRM_MODE_FLAG_PARNONE;
+		break;
+	}
+
 	strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
 	out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
 }
@@ -1515,6 +1535,20 @@ int drm_mode_convert_umode(struct drm_display_mode *out,
 	strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
 	out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
 
+	/* Clearing picture aspect ratio bits from out flags */
+	out->flags &= ~DRM_MODE_FLAG_PARMASK;
+
+	switch (in->flags & DRM_MODE_FLAG_PARMASK) {
+	case DRM_MODE_FLAG_PAR4_3:
+		out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_4_3;
+		break;
+	case DRM_MODE_FLAG_PAR16_9:
+		out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9;
+		break;
+	default:
+		out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
+	}
+
 	out->status = drm_mode_validate_basic(out);
 	if (out->status != MODE_OK)
 		goto out;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH v2 3/5 video: Add new aspect ratios for HDMI 2.0

In reply to Shashank Sharma

HDMI 2.0/CEA-861-F introduces two new aspect ratios:
- 64:27
- 256:135

This patch adds enumeration for the new aspect ratios in the existing aspect ratio list.

---
 drivers/video/hdmi.c | 4 ++++
 include/linux/hdmi.h | 2 ++
 2 files changed, 6 insertions(+)
drivers/video/hdmi.c +4 -0
index 1626892..1cf907e 100644
@@ -533,6 +533,10 @@ hdmi_picture_aspect_get_name(enum hdmi_picture_aspect picture_aspect)
 		return "4:3";
 	case HDMI_PICTURE_ASPECT_16_9:
 		return "16:9";
+	case HDMI_PICTURE_ASPECT_64_27:
+		return "64:27";
+	case HDMI_PICTURE_ASPECT_256_135:
+		return "256:135";
 	case HDMI_PICTURE_ASPECT_RESERVED:
 		return "Reserved";
 	}
include/linux/hdmi.h +2 -0
index e974420..edbb4fc 100644
@@ -78,6 +78,8 @@ enum hdmi_picture_aspect {
 	HDMI_PICTURE_ASPECT_NONE,
 	HDMI_PICTURE_ASPECT_4_3,
 	HDMI_PICTURE_ASPECT_16_9,
+	HDMI_PICTURE_ASPECT_64_27,
+	HDMI_PICTURE_ASPECT_256_135,
 	HDMI_PICTURE_ASPECT_RESERVED,
 };
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH v2 4/5 drm: Add flags for new aspect ratios

In reply to Shashank Sharma

HDMI 2.0/CEA-861-F introduces two new aspect ratios:
- 64:27
- 256:135

This patch adds DRM flags for the new aspect ratios in the existing aspect ratio flags.

---
 include/uapi/drm/drm_mode.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/uapi/drm/drm_mode.h +6 -0
index 3389bd1..b482d73 100644
@@ -77,6 +77,8 @@
 #define DRM_MODE_PICTURE_ASPECT_NONE		0
 #define DRM_MODE_PICTURE_ASPECT_4_3		1
 #define DRM_MODE_PICTURE_ASPECT_16_9		2
+#define DRM_MODE_PICTURE_ASPECT_64_27		3
+#define DRM_MODE_PICTURE_ASPECT_256_135	4
 
 /* Aspect ratio flag bitmask (4 bits 21:19) */
 #define	 DRM_MODE_FLAG_PARMASK		(0x0F<<19)
@@ -86,6 +88,10 @@
 		(DRM_MODE_PICTURE_ASPECT_4_3 << 19)
 #define  DRM_MODE_FLAG_PAR16_9 \
 		(DRM_MODE_PICTURE_ASPECT_16_9 << 19)
+#define  DRM_MODE_FLAG_PAR64_27 \
+		(DRM_MODE_PICTURE_ASPECT_64_27 << 19)
+#define  DRM_MODE_FLAG_PAR256_135 \
+		(DRM_MODE_PICTURE_ASPECT_256_135 << 19)
 
 /* DPMS flags */
 /* bit compatible with the xorg definitions. */
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

PATCH v2 5/5 drm/i915: Add support for new aspect ratios

In reply to Shashank Sharma

HDMI 2.0/CEA-861-F introduces two new aspect ratios:
- 64:27
- 256:135

This patch adds support for these aspect ratios in I915 driver, at various places.

---
 drivers/gpu/drm/drm_modes.c       | 12 ++++++++++++
 drivers/gpu/drm/i915/intel_hdmi.c |  6 ++++++
 drivers/gpu/drm/i915/intel_sdvo.c |  6 ++++++
 3 files changed, 24 insertions(+)
drivers/gpu/drm/drm_modes.c +12 -0
index 7824a63..7e27854 100644
@@ -1483,6 +1483,12 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
 	case HDMI_PICTURE_ASPECT_16_9:
 		out->flags |= DRM_MODE_FLAG_PAR16_9;
 		break;
+	case HDMI_PICTURE_ASPECT_64_27:
+		out->flags |= DRM_MODE_FLAG_PAR64_27;
+		break;
+	case DRM_MODE_PICTURE_ASPECT_256_135:
+		out->flags |= DRM_MODE_FLAG_PAR256_135;
+		break;
 	case HDMI_PICTURE_ASPECT_NONE:
 	case HDMI_PICTURE_ASPECT_RESERVED:
 	default:
@@ -1545,6 +1551,12 @@ int drm_mode_convert_umode(struct drm_display_mode *out,
 	case DRM_MODE_FLAG_PAR16_9:
 		out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9;
 		break;
+	case DRM_MODE_FLAG_PAR64_27:
+		out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_64_27;
+		break;
+	case DRM_MODE_FLAG_PAR256_135:
+		out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_256_135;
+		break;
 	default:
 		out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
 	}
drivers/gpu/drm/i915/intel_hdmi.c +6 -0
index 6825543..6d5c3ad 100644
@@ -1533,6 +1533,12 @@ intel_hdmi_set_property(struct drm_connector *connector,
 		case DRM_MODE_PICTURE_ASPECT_16_9:
 			intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_16_9;
 			break;
+		case DRM_MODE_PICTURE_ASPECT_64_27:
+			intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_64_27;
+			break;
+		case DRM_MODE_PICTURE_ASPECT_256_135:
+			intel_hdmi->aspect_ratio = HDMI_PICTURE_ASPECT_256_135;
+			break;
 		default:
 			return -EINVAL;
 		}
drivers/gpu/drm/i915/intel_sdvo.c +6 -0
index 2e1da06..83f30d6 100644
@@ -2069,6 +2069,12 @@ intel_sdvo_set_property(struct drm_connector *connector,
 		case DRM_MODE_PICTURE_ASPECT_16_9:
 			intel_sdvo->aspect_ratio = HDMI_PICTURE_ASPECT_16_9;
 			break;
+		case DRM_MODE_PICTURE_ASPECT_64_27:
+			intel_sdvo->aspect_ratio = HDMI_PICTURE_ASPECT_64_27;
+			break;
+		case DRM_MODE_PICTURE_ASPECT_256_135:
+			intel_sdvo->aspect_ratio = HDMI_PICTURE_ASPECT_256_135;
+			break;
 		default:
 			return -EINVAL;
 		}
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

✗ warning: Fi.CI.BAT

In reply to Shashank Sharma
== Summary ==

== Summary ==

Built on 8463389e40c3815b2e9b052f34145b1d728975be drm-intel-nightly: 2015y-12m-17d-14h-39m-21s UTC integration manifest

Test igt@kms_pipe_crc_basic@read-crc-pipe-c-frame-sequence on bdw-nuci7 dmesg-warn -> pass Test igt@kms_flip@basic-flip-vs-dpms on bsw-nuc-2 pass -> dmesg-warn
Test igt@kms_force_connector_basic@prune-stale-modes on snb-x220t pass -> skip Test igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a on snb-x220t pass -> dmesg-warn Test igt@kms_pipe_crc_basic@read-crc-pipe-a on snb-x220t dmesg-warn -> pass Test igt@kms_pipe_crc_basic@read-crc-pipe-c on bdw-nuci7 pass -> dmesg-warn Test igt@kms_pipe_crc_basic@read-crc-pipe-c on skl-i5k-2 dmesg-warn -> pass Test igt@kms_pipe_crc_basic@read-crc-pipe-b on snb-dellxps dmesg-warn -> pass Test igt@kms_setmode@basic-clone-single-crtc on snb-dellxps pass -> dmesg-warn Test igt@kms_flip@basic-flip-vs-modeset on hsw-gt2 pass -> dmesg-warn
Test igt@kms_flip@basic-flip-vs-modeset on bsw-nuc-2 pass -> dmesg-warn

bdw-nuci7        total:135  pass:124  dwarn:2   dfail:0   fail:0   skip:9  
bsw-nuc-2        total:135  pass:113  dwarn:2   dfail:0   fail:0   skip:20 
hsw-brixbox      total:135  pass:127  dwarn:1   dfail:0   fail:0   skip:7  
hsw-gt2          total:135  pass:129  dwarn:2   dfail:0   fail:0   skip:4  
ilk-hp8440p      total:135  pass:100  dwarn:0   dfail:0   fail:2   skip:33 
ivb-t430s        total:135  pass:128  dwarn:1   dfail:1   fail:1   skip:4  
skl-i5k-2        total:135  pass:123  dwarn:4   dfail:0   fail:0   skip:8  
skl-i7k-2        total:135  pass:123  dwarn:4   dfail:0   fail:0   skip:8  
snb-dellxps      total:135  pass:121  dwarn:2   dfail:0   fail:0   skip:12 
snb-x220t        total:135  pass:120  dwarn:2   dfail:0   fail:1   skip:12 

Results at /archive/results/CI_IGT_test/Patchwork_702/

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx