Skip to contentSkip to conversation

Add an HDMI aspect ratio test

PATCH In review Simon Ser 3 participants 8 messages Jul 22, 2019 – Aug 16, 2019 Library code

lore
Share & tools
lore

Simon Ser

author
#0 lore raw

cover Add an HDMI aspect ratio test

This series add an HDMI aspect ratio test.

DisplayPort has been left out for now, see the second commit.

Simon Ser (2):
lib/igt_infoframe: add support for AVI InfoFrames tests/kms_chamelium: add an aspect ratio test

 lib/igt_infoframe.c   |  30 ++++++++
 lib/igt_infoframe.h   |  48 ++++++++++++
 tests/kms_chamelium.c | 169 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 246 insertions(+), 1 deletion(-)

--
2.22.0

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

author
#1 lore raw

PATCH 1/2 lib/igt_infoframe: add support for AVI InfoFrames

This commit adds partial support for AVI InfoFrames. Only bytes 1 and 2 of the InfoFrame payload are parsed.

These bytes contain (among other things) information about the aspect ratio of the frames.

---
 lib/igt_infoframe.c | 30 ++++++++++++++++++++++++++++
 lib/igt_infoframe.h | 48 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
lib/igt_infoframe.c +30 -0
index 7e4fb45881a6..d8a2e609573c 100644
@@ -27,6 +27,7 @@
 
 #include <string.h>
 
+#include "igt_core.h"
 #include "igt_infoframe.h"
 
 /**
@@ -61,6 +62,35 @@ static const int sample_sizes[] = {
 
 static const size_t sample_sizes_len = sizeof(sample_sizes) / sizeof(sample_sizes[0]);
 
+bool infoframe_avi_parse(struct infoframe_avi *infoframe, int version,
+			 const uint8_t *buf, size_t buf_size)
+{
+	memset(infoframe, 0, sizeof(*infoframe));
+
+	switch (version) {
+	case 2:
+	case 3:
+	case 4:
+		break; /* supported */
+	default:
+		igt_debug("Unsuppported AVI InfoFrame version: %d\n", version);
+		return false;
+	}
+
+	if (buf_size < 13)
+		return false;
+
+	infoframe->rgb_ycbcr = buf[0] >> 5;
+	infoframe->scan = buf[0] & 0x3;
+
+	infoframe->colorimetry = buf[1] >> 7;
+	infoframe->picture_aspect_ratio = (buf[1] >> 4) & 0x3;
+	infoframe->active_aspect_ratio = buf[1] & 0xF;
+	infoframe->vic = buf[3];
+
+	return true;
+}
+
 bool infoframe_audio_parse(struct infoframe_audio *infoframe, int version,
 			   const uint8_t *buf, size_t buf_size)
 {
lib/igt_infoframe.h +48 -0

60 lines not on this page · raw message

Signature · 6 lines
2.22.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
author
#4 lore raw

PATCH 2/2 tests/kms_chamelium: add an aspect ratio test

In reply to Simon Ser

This test generates an EDID with support for modes tied to a specific aspect ratio. It then plugs a connector with this EDID and iterates the list of modes to find the one with the expected aspect ratio flag. The connector is then enabled and the Chamelium board is used to capture the AVI InfoFrame. The InfoFrame fields are then checked.

To advertise support for a mode with a specific aspect ratio, sinks add Video Identification Codes in the CEA extension. The VIC chosen by the source is contained in the AVI InfoFrame. The InfoFrame also contains a picture aspect ratio field, but it's only able to indicate whether the aspect ratio is 16:9 or 4:3.

For now the test is only enabled for HDMI. I've tried to make it work on DP too, but after reading the kernel code it seems like we don't support AVI InfoFrames on DP.

---
 tests/kms_chamelium.c | 169 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 168 insertions(+), 1 deletion(-)
tests/kms_chamelium.c +168 -1
index 913a4cd8506d..4b41e2cad9d0 100644
@@ -41,8 +41,9 @@ enum test_edid {
 	TEST_EDID_ALT,
 	TEST_EDID_HDMI_AUDIO,
 	TEST_EDID_DP_AUDIO,
+	TEST_EDID_ASPECT_RATIO,
 };
-#define TEST_EDID_COUNT 4
+#define TEST_EDID_COUNT 5
 
 typedef struct {
 	struct chamelium *chamelium;
@@ -862,6 +863,167 @@ static void test_mode_timings(data_t *data, struct chamelium_port *port)
 	drmModeFreeConnector(connector);
 }
 
+/* Set of Video Identification Codes advertised in the EDID */
+static const uint8_t edid_ar_svds[] = {
+	16, /* 1080p @ 60Hz, 16:9 */
+};
+
+struct vic_mode {
+	int hactive, vactive;
+	int vrefresh; /* Hz */
+	uint32_t picture_ar;
+};
+
+/* Maps Video Identification Codes to a mode */
+static const struct vic_mode vic_modes[] = {
+	[16] = {
+		.hactive = 1920,
+		.vactive = 1080,
+		.vrefresh = 60,
+		.picture_ar = DRM_MODE_PICTURE_ASPECT_16_9,
+	},
+};
+
+/* Maps aspect ratios to their mode flag */
+static const uint32_t mode_ar_flags[] = {
+	[DRM_MODE_PICTURE_ASPECT_16_9] = DRM_MODE_FLAG_PIC_AR_16_9,
+};
+
+static enum infoframe_avi_picture_aspect_ratio
+get_infoframe_avi_picture_ar(uint32_t aspect_ratio)
+{
+	/* The AVI picture aspect ratio field only supports 4:3 and 16:9 */
+	switch (aspect_ratio) {
+	case DRM_MODE_PICTURE_ASPECT_4_3:
+		return INFOFRAME_AVI_PIC_AR_4_3;
+	case DRM_MODE_PICTURE_ASPECT_16_9:
+		return INFOFRAME_AVI_PIC_AR_16_9;
+	default:
+		return INFOFRAME_AVI_PIC_AR_UNSPECIFIED;
+	}
+}
+
+static bool vic_mode_matches_drm(const struct vic_mode *vic_mode,
+				 drmModeModeInfo *drm_mode)
+{
+	uint32_t ar_flag = mode_ar_flags[vic_mode->picture_ar];
+
+	return vic_mode->hactive == drm_mode->hdisplay &&
+	       vic_mode->vactive == drm_mode->vdisplay &&
+	       vic_mode->vrefresh == drm_mode->vrefresh &&
+	       ar_flag == (drm_mode->flags & DRM_MODE_FLAG_PIC_AR_MASK);
+}
+
+static const struct edid *get_aspect_ratio_edid(void)
+{
+	static unsigned char raw_edid[2 * EDID_BLOCK_SIZE] = {0};
+	struct edid *edid;
+	struct edid_ext *edid_ext;
+	struct edid_cea *edid_cea;
+	char *cea_data;
+	struct edid_cea_data_block *block;
+	size_t cea_data_size = 0, vsdb_size;
+	const struct cea_vsdb *vsdb;
+
+	edid = (struct edid *) raw_edid;
+	memcpy(edid, igt_kms_get_base_edid(), sizeof(struct edid));
+	edid->extensions_len = 1;
+	edid_ext = &edid->extensions[0];
+	edid_cea = &edid_ext->data.cea;
+	cea_data = edid_cea->data;
+
+	/* The HDMI VSDB advertises support for InfoFrames */
+	block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
+	vsdb = cea_vsdb_get_hdmi_default(&vsdb_size);
+	cea_data_size += edid_cea_data_block_set_vsdb(block, vsdb,
+						      vsdb_size);
+
+	/* Short Video Descriptor */
+	block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
+	cea_data_size += edid_cea_data_block_set_svd(block, edid_ar_svds,
+						     sizeof(edid_ar_svds));
+
+	assert(cea_data_size <= sizeof(edid_cea->data));
+
+	edid_ext_set_cea(edid_ext, cea_data_size, 0, 0);
+
+	edid_update_checksum(edid);
+
+	return edid;
+}
+
+static void test_display_aspect_ratio(data_t *data, struct chamelium_port *port)
+{
+	igt_output_t *output;
+	igt_plane_t *primary;
+	drmModeConnector *connector;
+	drmModeModeInfo *mode;
+	int fb_id, i;
+	struct igt_fb fb;
+	bool found, ok;
+	struct chamelium_infoframe *infoframe;
+	struct infoframe_avi infoframe_avi;
+	uint8_t vic = 16; /* TODO: test more VICs */
+
+	igt_require(chamelium_supports_get_last_infoframe(data->chamelium));
+
+	reset_state(data, port);
+
+	output = prepare_output(data, port, TEST_EDID_ASPECT_RATIO);
+	connector = chamelium_port_get_connector(data->chamelium, port, false);
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	igt_assert(primary);
+
+	const struct vic_mode *vic_mode = &vic_modes[vic];
+	uint32_t aspect_ratio = vic_mode->picture_ar;
+
+	found = false;
+	igt_assert(connector->count_modes > 0);
+	for (i = 0; i < connector->count_modes; i++) {
+		mode = &connector->modes[i];
+
+		if (vic_mode_matches_drm(vic_mode, mode)) {
+			found = true;
+			break;
+		}
+	}
+	igt_assert_f(found,
+		     "Failed to find mode with the correct aspect ratio\n");
+
+	fb_id = igt_create_color_pattern_fb(data->drm_fd,
+					    mode->hdisplay, mode->vdisplay,
+					    DRM_FORMAT_XRGB8888,
+					    LOCAL_DRM_FORMAT_MOD_NONE,
+					    0, 0, 0, &fb);
+	igt_assert(fb_id > 0);
+
+	enable_output(data, port, output, mode, &fb);
+
+	infoframe = chamelium_get_last_infoframe(data->chamelium, port,
+						 CHAMELIUM_INFOFRAME_AVI);
+	igt_assert_f(infoframe, "AVI InfoFrame not received\n");
+
+	ok = infoframe_avi_parse(&infoframe_avi, infoframe->version,
+				 infoframe->payload, infoframe->payload_size);
+	igt_assert_f(ok, "Failed to parse AVI InfoFrame\n");
+
+	enum infoframe_avi_picture_aspect_ratio frame_ar =
+		get_infoframe_avi_picture_ar(aspect_ratio);
+
+	igt_debug("Checking AVI InfoFrame\n");
+	igt_debug("Picture aspect ratio: got %d, expected %d\n",
+		  infoframe_avi.picture_aspect_ratio, frame_ar);
+	igt_debug("Video Identification Code (VIC): got %d, expected %d\n",
+		  infoframe_avi.vic, vic);
+
+	igt_assert(infoframe_avi.picture_aspect_ratio == frame_ar);
+	igt_assert(infoframe_avi.vic == vic);
+
+	chamelium_infoframe_destroy(infoframe);
+	igt_remove_fb(data->drm_fd, &fb);
+	drmModeFreeConnector(connector);
+}
+
 
 /* Playback parameters control the audio signal we synthesize and send */
 #define PLAYBACK_CHANNELS 2
@@ -2208,6 +2370,8 @@ static const struct edid *get_edid(enum test_edid edid)
 		return igt_kms_get_hdmi_audio_edid();
 	case TEST_EDID_DP_AUDIO:
 		return igt_kms_get_dp_audio_edid();
+	case TEST_EDID_ASPECT_RATIO:
+		return get_aspect_ratio_edid();
 	}
 	assert(0); /* unreachable */
 }
@@ -2487,6 +2651,9 @@ igt_main
 		connector_subtest("hdmi-audio-edid", HDMIA)
 			test_display_audio_edid(&data, port,
 						TEST_EDID_HDMI_AUDIO);
+
+		connector_subtest("hdmi-aspect-ratio", HDMIA)
+			test_display_aspect_ratio(&data, port);
 	}
 
 	igt_subtest_group {
Signature · 6 lines
2.22.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#6 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for Add an HDMI aspect ratio test (rev2)

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: Add an HDMI aspect ratio test (rev2)
URL : https://patchwork.freedesktop.org/series/64018/
State : success

== Summary ==

CI Bug Log - changes from IGT_5136 -> IGTPW_3353
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/64018/revisions/2/mbox/

Known issues
------------

Here are the changes found in IGTPW_3353 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_mmap_gtt@basic-write-gtt:
- fi-icl-u3: [PASS][1] -> [DMESG-WARN][2] ([fdo#107724])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/fi-icl-u3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/fi-icl-u3/igt@[email protected]

* igt@i915_selftest@live_requests:
- fi-byt-j1900: [PASS][3] -> [INCOMPLETE][4] ([fdo#102657])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/fi-byt-j1900/igt@i915_selftest@live_requests.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/fi-byt-j1900/igt@i915_selftest@live_requests.html

#### Possible fixes ####

* igt@gem_basic@create-close:
- fi-icl-u3: [DMESG-WARN][5] ([fdo#107724]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/fi-icl-u3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/fi-icl-u3/igt@[email protected]

* igt@gem_ctx_switch@legacy-render:
- fi-bxt-dsi: [INCOMPLETE][7] ([fdo#103927]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/fi-bxt-dsi/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/fi-bxt-dsi/igt@[email protected]

* igt@gem_exec_suspend@basic-s4-devices:
- fi-blb-e6850: [INCOMPLETE][9] ([fdo#107718]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/fi-blb-e6850/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/fi-blb-e6850/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102657]: https://bugs.freedesktop.org/show_bug.cgi?id=102657
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#111144]: https://bugs.freedesktop.org/show_bug.cgi?id=111144

Participating hosts (52 -> 46)
------------------------------

Additional (1): fi-bsw-n3050
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus

Build changes
-------------

* IGT: IGT_5136 -> IGTPW_3353

CI_DRM_6711: 66992026e64fe4405ca25b1e978a98c7e132673b @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3353: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/
IGT_5136: 6083d852b741e75d4842ac45a19964b176d198aa @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Testlist changes ==

+igt@kms_chamelium@hdmi-aspect-ratio

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 1/2
#2 lore raw

Re: [igt-dev] [PATCH i-g-t 1/2] lib/igt_infoframe: add support for AVI InfoFrames

In reply to Simon Ser
Quoted 40 lines · Simon Ser

This commit adds partial support for AVI InfoFrames. Only bytes 1 and 2 of the InfoFrame payload are parsed.

These bytes contain (among other things) information about the aspect ratio of the frames.

---
 lib/igt_infoframe.c | 30 ++++++++++++++++++++++++++++
 lib/igt_infoframe.h | 48 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
lib/igt_infoframe.c +13 -0
index 7e4fb45881a6..d8a2e609573c 100644
@@ -27,6 +27,7 @@
 
 #include <string.h>
 
+#include "igt_core.h"
 #include "igt_infoframe.h"
 
 /**
@@ -61,6 +62,35 @@ static const int sample_sizes[] = {
 
 static const size_t sample_sizes_len = sizeof(sample_sizes) / sizeof(sample_sizes[0]);
 
+bool infoframe_avi_parse(struct infoframe_avi *infoframe, int version,
+			 const uint8_t *buf, size_t buf_size)
+{
+	memset(infoframe, 0, sizeof(*infoframe));
+
+	switch (version) {
+	case 2:
+	case 3:
+	case 4:
+		break; /* supported */
+	default:
+		igt_debug("Unsuppported AVI InfoFrame version: %d\n", version);

lib/igt_infoframe.c static const int sample_sizes[] = { · line 86

Quoted 10 lines
lib/igt_infoframe.c +10 -0
+		return false;
+	}
+
+	if (buf_size < 13)
+		return false;
+
+	infoframe->rgb_ycbcr = buf[0] >> 5;
+	infoframe->scan = buf[0] & 0x3;
+
+	infoframe->colorimetry = buf[1] >> 7;

Shouldn't it be >> 6? It's 2 last bits.

Quoted 37 lines
lib/igt_infoframe.c +7 -0
+	infoframe->picture_aspect_ratio = (buf[1] >> 4) & 0x3;
+	infoframe->active_aspect_ratio = buf[1] & 0xF;
+	infoframe->vic = buf[3];
+
+	return true;
+}
+
 bool infoframe_audio_parse(struct infoframe_audio *infoframe, int version,
 			   const uint8_t *buf, size_t buf_size)
 {
lib/igt_infoframe.h +19 -0
index 35daa3ea169d..056cdad6072a 100644
@@ -32,6 +32,52 @@
 #include <stddef.h>
 #include <stdint.h>
 
+enum infoframe_avi_rgb_ycbcr {
+	INFOFRAME_AVI_RGB = 0,
+	INFOFRAME_AVI_YCBCR422 = 1,
+	INFOFRAME_AVI_YCBCR444 = 2,
+	INFOFRAME_AVI_YCBCR420 = 3,
+	INFOFRAME_AVI_IDO_DEFINED = 7,
+};
+
+enum infoframe_avi_scan {
+	INFOFRAME_AVI_SCAN_UNSPECIFIED = 0,
+	INFOFRAME_AVI_OVERSCAN = 1,
+	INFOFRAME_AVI_UNDERSCAN = 2,
+};
+
+enum infoframe_avi_colorimetry {
+	INFOFRAME_AVI_COLORIMETRY_UNSPECIFIED = 0,
+	INFOFRAME_AVI_SMPTE_170M = 1,
+	INFOFRAME_AVI_ITUR_BT709 = 2,
+	INFOFRAME_AVI_COLORIMETRY_EXTENDED = 3,

lib/igt_infoframe.h line 63

Quoted 10 lines
lib/igt_infoframe.h +10 -0
+};
+
+enum infoframe_avi_picture_aspect_ratio {
+	INFOFRAME_AVI_PIC_AR_UNSPECIFIED = 0,
+	INFOFRAME_AVI_PIC_AR_4_3 = 1,
+	INFOFRAME_AVI_PIC_AR_16_9 = 2,
+};
+
+enum infoframe_avi_active_aspect_ratio {
+	INFOFRAME_AVI_ACT_AR_PIC = 0, /* same as picture aspect ratio */

Shouldn't this be 8? I believe it is 0b1000.

With the above addressed

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

author
#3 lore raw

Re: [igt-dev] [PATCH i-g-t 1/2] lib/igt_infoframe: add support for AVI InfoFrames

Quoted 45 lines · Arkadiusz Hiler
Quoted 44 lines · Simon Ser

This commit adds partial support for AVI InfoFrames. Only bytes 1 and 2 of the InfoFrame payload are parsed.

These bytes contain (among other things) information about the aspect ratio of the frames.

---
 lib/igt_infoframe.c | 30 ++++++++++++++++++++++++++++
 lib/igt_infoframe.h | 48 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
lib/igt_infoframe.c +17 -0
index 7e4fb45881a6..d8a2e609573c 100644
@@ -27,6 +27,7 @@
 
 #include <string.h>
 
+#include "igt_core.h"
 #include "igt_infoframe.h"
 
 /**
@@ -61,6 +62,35 @@ static const int sample_sizes[] = {
 
 static const size_t sample_sizes_len = sizeof(sample_sizes) / sizeof(sample_sizes[0]);
 
+bool infoframe_avi_parse(struct infoframe_avi *infoframe, int version,
+			 const uint8_t *buf, size_t buf_size)
+{
+	memset(infoframe, 0, sizeof(*infoframe));
+
+	switch (version) {
+	case 2:
+	case 3:
+	case 4:
+		break; /* supported */
+	default:
+		igt_debug("Unsuppported AVI InfoFrame version: %d\n", version);
+		return false;
+	}
+
+	if (buf_size < 13)
Quoted 8 lines

lib/igt_infoframe.c static const int sample_sizes[] = { · line 86

Quoted 6 lines
lib/igt_infoframe.c +6 -0
+		return false;
+
+	infoframe->rgb_ycbcr = buf[0] >> 5;
+	infoframe->scan = buf[0] & 0x3;
+
+	infoframe->colorimetry = buf[1] >> 7;

Shouldn't it be >> 6? It's 2 last bits.

Indeed, good catch!

Quoted 41 lines
Quoted 41 lines
lib/igt_infoframe.c +7 -0
+	infoframe->picture_aspect_ratio = (buf[1] >> 4) & 0x3;
+	infoframe->active_aspect_ratio = buf[1] & 0xF;
+	infoframe->vic = buf[3];
+
+	return true;
+}
+
 bool infoframe_audio_parse(struct infoframe_audio *infoframe, int version,
 			   const uint8_t *buf, size_t buf_size)
 {
lib/igt_infoframe.h +23 -0
index 35daa3ea169d..056cdad6072a 100644
@@ -32,6 +32,52 @@
 #include <stddef.h>
 #include <stdint.h>
 
+enum infoframe_avi_rgb_ycbcr {
+	INFOFRAME_AVI_RGB = 0,
+	INFOFRAME_AVI_YCBCR422 = 1,
+	INFOFRAME_AVI_YCBCR444 = 2,
+	INFOFRAME_AVI_YCBCR420 = 3,
+	INFOFRAME_AVI_IDO_DEFINED = 7,
+};
+
+enum infoframe_avi_scan {
+	INFOFRAME_AVI_SCAN_UNSPECIFIED = 0,
+	INFOFRAME_AVI_OVERSCAN = 1,
+	INFOFRAME_AVI_UNDERSCAN = 2,
+};
+
+enum infoframe_avi_colorimetry {
+	INFOFRAME_AVI_COLORIMETRY_UNSPECIFIED = 0,
+	INFOFRAME_AVI_SMPTE_170M = 1,
+	INFOFRAME_AVI_ITUR_BT709 = 2,
+	INFOFRAME_AVI_COLORIMETRY_EXTENDED = 3,
+};
+
+enum infoframe_avi_picture_aspect_ratio {
+	INFOFRAME_AVI_PIC_AR_UNSPECIFIED = 0,
Quoted 8 lines

lib/igt_infoframe.h line 63

Quoted 6 lines
lib/igt_infoframe.h +6 -0
+	INFOFRAME_AVI_PIC_AR_4_3 = 1,
+	INFOFRAME_AVI_PIC_AR_16_9 = 2,
+};
+
+enum infoframe_avi_active_aspect_ratio {
+	INFOFRAME_AVI_ACT_AR_PIC = 0, /* same as picture aspect ratio */

Shouldn't this be 8? I believe it is 0b1000.

Eh, you're right!

Quoted 2 lines

With the above addressed

Thanks for the review
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 2/2
#5 lore raw

Re: [igt-dev] [PATCH i-g-t 2/2] tests/kms_chamelium: add an aspect ratio test

In reply to Simon Ser
Quoted 176 lines · Simon Ser

This test generates an EDID with support for modes tied to a specific aspect ratio. It then plugs a connector with this EDID and iterates the list of modes to find the one with the expected aspect ratio flag. The connector is then enabled and the Chamelium board is used to capture the AVI InfoFrame. The InfoFrame fields are then checked.

To advertise support for a mode with a specific aspect ratio, sinks add Video Identification Codes in the CEA extension. The VIC chosen by the source is contained in the AVI InfoFrame. The InfoFrame also contains a picture aspect ratio field, but it's only able to indicate whether the aspect ratio is 16:9 or 4:3.

For now the test is only enabled for HDMI. I've tried to make it work on DP too, but after reading the kernel code it seems like we don't support AVI InfoFrames on DP.

---
 tests/kms_chamelium.c | 169 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 168 insertions(+), 1 deletion(-)
tests/kms_chamelium.c +138 -1
index 913a4cd8506d..4b41e2cad9d0 100644
@@ -41,8 +41,9 @@ enum test_edid {
 	TEST_EDID_ALT,
 	TEST_EDID_HDMI_AUDIO,
 	TEST_EDID_DP_AUDIO,
+	TEST_EDID_ASPECT_RATIO,
 };
-#define TEST_EDID_COUNT 4
+#define TEST_EDID_COUNT 5
 
 typedef struct {
 	struct chamelium *chamelium;
@@ -862,6 +863,167 @@ static void test_mode_timings(data_t *data, struct chamelium_port *port)
 	drmModeFreeConnector(connector);
 }
 
+/* Set of Video Identification Codes advertised in the EDID */
+static const uint8_t edid_ar_svds[] = {
+	16, /* 1080p @ 60Hz, 16:9 */
+};
+
+struct vic_mode {
+	int hactive, vactive;
+	int vrefresh; /* Hz */
+	uint32_t picture_ar;
+};
+
+/* Maps Video Identification Codes to a mode */
+static const struct vic_mode vic_modes[] = {
+	[16] = {
+		.hactive = 1920,
+		.vactive = 1080,
+		.vrefresh = 60,
+		.picture_ar = DRM_MODE_PICTURE_ASPECT_16_9,
+	},
+};
+
+/* Maps aspect ratios to their mode flag */
+static const uint32_t mode_ar_flags[] = {
+	[DRM_MODE_PICTURE_ASPECT_16_9] = DRM_MODE_FLAG_PIC_AR_16_9,
+};
+
+static enum infoframe_avi_picture_aspect_ratio
+get_infoframe_avi_picture_ar(uint32_t aspect_ratio)
+{
+	/* The AVI picture aspect ratio field only supports 4:3 and 16:9 */
+	switch (aspect_ratio) {
+	case DRM_MODE_PICTURE_ASPECT_4_3:
+		return INFOFRAME_AVI_PIC_AR_4_3;
+	case DRM_MODE_PICTURE_ASPECT_16_9:
+		return INFOFRAME_AVI_PIC_AR_16_9;
+	default:
+		return INFOFRAME_AVI_PIC_AR_UNSPECIFIED;
+	}
+}
+
+static bool vic_mode_matches_drm(const struct vic_mode *vic_mode,
+				 drmModeModeInfo *drm_mode)
+{
+	uint32_t ar_flag = mode_ar_flags[vic_mode->picture_ar];
+
+	return vic_mode->hactive == drm_mode->hdisplay &&
+	       vic_mode->vactive == drm_mode->vdisplay &&
+	       vic_mode->vrefresh == drm_mode->vrefresh &&
+	       ar_flag == (drm_mode->flags & DRM_MODE_FLAG_PIC_AR_MASK);
+}
+
+static const struct edid *get_aspect_ratio_edid(void)
+{
+	static unsigned char raw_edid[2 * EDID_BLOCK_SIZE] = {0};
+	struct edid *edid;
+	struct edid_ext *edid_ext;
+	struct edid_cea *edid_cea;
+	char *cea_data;
+	struct edid_cea_data_block *block;
+	size_t cea_data_size = 0, vsdb_size;
+	const struct cea_vsdb *vsdb;
+
+	edid = (struct edid *) raw_edid;
+	memcpy(edid, igt_kms_get_base_edid(), sizeof(struct edid));
+	edid->extensions_len = 1;
+	edid_ext = &edid->extensions[0];
+	edid_cea = &edid_ext->data.cea;
+	cea_data = edid_cea->data;
+
+	/* The HDMI VSDB advertises support for InfoFrames */
+	block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
+	vsdb = cea_vsdb_get_hdmi_default(&vsdb_size);
+	cea_data_size += edid_cea_data_block_set_vsdb(block, vsdb,
+						      vsdb_size);
+
+	/* Short Video Descriptor */
+	block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
+	cea_data_size += edid_cea_data_block_set_svd(block, edid_ar_svds,
+						     sizeof(edid_ar_svds));
+
+	assert(cea_data_size <= sizeof(edid_cea->data));
+
+	edid_ext_set_cea(edid_ext, cea_data_size, 0, 0);
+
+	edid_update_checksum(edid);
+
+	return edid;
+}
+
+static void test_display_aspect_ratio(data_t *data, struct chamelium_port *port)
+{
+	igt_output_t *output;
+	igt_plane_t *primary;
+	drmModeConnector *connector;
+	drmModeModeInfo *mode;
+	int fb_id, i;
+	struct igt_fb fb;
+	bool found, ok;
+	struct chamelium_infoframe *infoframe;
+	struct infoframe_avi infoframe_avi;
+	uint8_t vic = 16; /* TODO: test more VICs */
+
+	igt_require(chamelium_supports_get_last_infoframe(data->chamelium));
+
+	reset_state(data, port);
+
+	output = prepare_output(data, port, TEST_EDID_ASPECT_RATIO);
+	connector = chamelium_port_get_connector(data->chamelium, port, false);
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	igt_assert(primary);
+
+	const struct vic_mode *vic_mode = &vic_modes[vic];
+	uint32_t aspect_ratio = vic_mode->picture_ar;
+
+	found = false;
+	igt_assert(connector->count_modes > 0);
+	for (i = 0; i < connector->count_modes; i++) {
+		mode = &connector->modes[i];
+
+		if (vic_mode_matches_drm(vic_mode, mode)) {
+			found = true;
+			break;
+		}
+	}
+	igt_assert_f(found,
+		     "Failed to find mode with the correct aspect ratio\n");
+
+	fb_id = igt_create_color_pattern_fb(data->drm_fd,
+					    mode->hdisplay, mode->vdisplay,
+					    DRM_FORMAT_XRGB8888,
+					    LOCAL_DRM_FORMAT_MOD_NONE,
+					    0, 0, 0, &fb);
+	igt_assert(fb_id > 0);
+
+	enable_output(data, port, output, mode, &fb);
+

tests/kms_chamelium.c static void test_mode_timings(data_t *data, struct chamelium_port *port) · line 1011

Quoted 10 lines
tests/kms_chamelium.c +10 -0
+	infoframe = chamelium_get_last_infoframe(data->chamelium, port,
+						 CHAMELIUM_INFOFRAME_AVI);
+	igt_assert_f(infoframe, "AVI InfoFrame not received\n");
+
+	ok = infoframe_avi_parse(&infoframe_avi, infoframe->version,
+				 infoframe->payload, infoframe->payload_size);
+	igt_assert_f(ok, "Failed to parse AVI InfoFrame\n");
+
+	enum infoframe_avi_picture_aspect_ratio frame_ar =
+		get_infoframe_avi_picture_ar(aspect_ratio);

I think we will get complaints about mixed code and declarations.

Other than that

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

#7 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for Add an HDMI aspect ratio test (rev2)

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: Add an HDMI aspect ratio test (rev2)
URL : https://patchwork.freedesktop.org/series/64018/
State : success

== Summary ==

CI Bug Log - changes from IGT_5136_full -> IGTPW_3353_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/64018/revisions/2/mbox/

New tests
---------

New tests have been introduced between IGT_5136_full and IGTPW_3353_full:

### New IGT tests (1) ###

* igt@kms_chamelium@hdmi-aspect-ratio:
- Statuses : 6 skip(s)
- Exec time: [0.0] s

Known issues
------------

Here are the changes found in IGTPW_3353_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@rcs0-s3:
- shard-apl: [PASS][1] -> [DMESG-WARN][2] ([fdo#108566]) +4 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-apl2/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-apl6/igt@[email protected]

* igt@gem_ctx_shared@q-smoketest-bsd:
- shard-iclb: [PASS][3] -> [INCOMPLETE][4] ([fdo#107713]) +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb7/igt@[email protected]

* igt@gem_exec_schedule@fifo-bsd:
- shard-iclb: [PASS][5] -> [SKIP][6] ([fdo#111325]) +3 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb7/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb2/igt@[email protected]

* igt@kms_cursor_legacy@cursor-vs-flip-atomic-transitions:
- shard-hsw: [PASS][7] -> [FAIL][8] ([fdo#103355])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-hsw4/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-hsw4/igt@[email protected]

* igt@kms_flip@absolute-wf_vblank:
- shard-glk: [PASS][9] -> [INCOMPLETE][10] ([fdo#103359] / [k.org#198133])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-glk3/igt@kms_flip@absolute-wf_vblank.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-glk2/igt@kms_flip@absolute-wf_vblank.html

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt:
- shard-iclb: [PASS][11] -> [FAIL][12] ([fdo#103167]) +5 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb6/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-shrfb-plflip-blt.html

* igt@kms_psr@psr2_sprite_mmap_gtt:
- shard-iclb: [PASS][13] -> [SKIP][14] ([fdo#109441]) +3 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb3/igt@kms_psr@psr2_sprite_mmap_gtt.html

* igt@prime_busy@hang-bsd2:
- shard-iclb: [PASS][15] -> [SKIP][16] ([fdo#109276]) +14 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb6/igt@[email protected]

#### Possible fixes ####

* igt@gem_ctx_shared@exec-single-timeline-bsd:
- shard-iclb: [SKIP][17] ([fdo#110841]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb2/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb5/igt@[email protected]

* igt@gem_ctx_switch@legacy-bsd2-heavy:
- shard-iclb: [SKIP][19] ([fdo#109276]) -> [PASS][20] +17 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb3/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb1/igt@[email protected]

* igt@gem_eio@reset-stress:
- shard-iclb: [FAIL][21] ([fdo#109661]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb4/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb6/igt@[email protected]
- shard-snb: [FAIL][23] ([fdo#109661]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-snb5/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-snb6/igt@[email protected]

* igt@gem_exec_schedule@deep-bsd:
- shard-iclb: [SKIP][25] ([fdo#111325]) -> [PASS][26] +6 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb4/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb6/igt@[email protected]

* igt@i915_pm_rpm@i2c:
- shard-hsw: [FAIL][27] ([fdo#104097]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-hsw4/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-hsw1/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-suspend:
- shard-apl: [DMESG-WARN][29] ([fdo#108566]) -> [PASS][30] +5 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-apl3/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-apl1/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-stridechange:
- shard-iclb: [FAIL][31] ([fdo#103167]) -> [PASS][32] +5 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb7/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb1/igt@[email protected]

* igt@kms_hdmi_inject@inject-audio:
- shard-iclb: [DMESG-WARN][33] ([fdo#109593]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb1/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb3/igt@[email protected]

* igt@kms_plane_lowres@pipe-a-tiling-x:
- shard-iclb: [FAIL][35] ([fdo#103166]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb6/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb8/igt@[email protected]

* igt@kms_psr@psr2_sprite_plane_move:
- shard-iclb: [SKIP][37] ([fdo#109441]) -> [PASS][38] +3 similar issues
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb5/igt@kms_psr@psr2_sprite_plane_move.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb2/igt@kms_psr@psr2_sprite_plane_move.html

#### Warnings ####

* igt@gem_mocs_settings@mocs-rc6-bsd2:
- shard-iclb: [FAIL][39] ([fdo#111330]) -> [SKIP][40] ([fdo#109276])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb4/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb8/igt@[email protected]

* igt@kms_dp_dsc@basic-dsc-enable-edp:
- shard-iclb: [DMESG-WARN][41] ([fdo#107724]) -> [SKIP][42] ([fdo#109349])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5136/shard-iclb2/igt@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/shard-iclb8/igt@[email protected]

[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103355]: https://bugs.freedesktop.org/show_bug.cgi?id=103355
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#104097]: https://bugs.freedesktop.org/show_bug.cgi?id=104097
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109349]: https://bugs.freedesktop.org/show_bug.cgi?id=109349
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109593]: https://bugs.freedesktop.org/show_bug.cgi?id=109593
[fdo#109661]: https://bugs.freedesktop.org/show_bug.cgi?id=109661
[fdo#110841]: https://bugs.freedesktop.org/show_bug.cgi?id=110841
[fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
[fdo#111330]: https://bugs.freedesktop.org/show_bug.cgi?id=111330
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133

Participating hosts (7 -> 6)
------------------------------

Missing (1): shard-skl

Build changes
-------------

* IGT: IGT_5136 -> IGTPW_3353

CI_DRM_6711: 66992026e64fe4405ca25b1e978a98c7e132673b @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3353: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/
IGT_5136: 6083d852b741e75d4842ac45a19964b176d198aa @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3353/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev