[igt-dev] [PATCH i-g-t] lib/igt_kms: generate an EDID suitable for DP audio

Simon Ser simon.ser at intel.com
Tue Jun 4 12:19:23 UTC 2019


Prior to this commit, we were using the Chamelium's default EDID for DP audio.
This relies on the fact that this EDID supports audio and has correct audio
paremeters for our testing.

Generating our own EDID is less error-prone and will allow us to test different
audio parameters.

Signed-off-by: Simon Ser <simon.ser at intel.com>
---
 lib/igt_kms.c         | 44 +++++++++++++++++++++++++++++++++++--------
 lib/igt_kms.h         |  2 ++
 tests/kms_chamelium.c |  7 +++++--
 3 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index d7d711a72d27..55c48a3776f2 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -183,9 +183,9 @@ const unsigned char *igt_kms_get_alt_edid(void)
 }

 static void
-generate_hdmi_audio_edid(unsigned char raw_edid[static HDMI_AUDIO_EDID_LENGTH],
-			 struct cea_sad *sad,
-			 struct cea_speaker_alloc *speaker_alloc)
+generate_audio_edid(unsigned char raw_edid[static HDMI_AUDIO_EDID_LENGTH],
+		    bool with_vsd, struct cea_sad *sad,
+		    struct cea_speaker_alloc *speaker_alloc)
 {
 	struct edid *edid;
 	struct edid_ext *edid_ext;
@@ -210,10 +210,12 @@ generate_hdmi_audio_edid(unsigned char raw_edid[static HDMI_AUDIO_EDID_LENGTH],
 	cea_data_size += edid_cea_data_block_set_sad(block, sad, 1);

 	/* A Vendor Specific Data block is needed for HDMI audio */
-	block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
-	vsd = cea_vsd_get_hdmi_default(&vsd_size);
-	cea_data_size += edid_cea_data_block_set_vsd(block, vsd,
-						     vsd_size);
+	if (with_vsd) {
+		block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
+		vsd = cea_vsd_get_hdmi_default(&vsd_size);
+		cea_data_size += edid_cea_data_block_set_vsd(block, vsd,
+							     vsd_size);
+	}

 	/* Speaker Allocation Data block */
 	block = (struct edid_cea_data_block *) &cea_data[cea_data_size];
@@ -250,7 +252,33 @@ const unsigned char *igt_kms_get_hdmi_audio_edid(void)
 	/* Initialize the Speaker Allocation Data */
 	speaker_alloc.speakers = CEA_SPEAKER_FRONT_LEFT_RIGHT_CENTER;

-	generate_hdmi_audio_edid(raw_edid, &sad, &speaker_alloc);
+	generate_audio_edid(raw_edid, true, &sad, &speaker_alloc);
+
+	return raw_edid;
+}
+
+const unsigned char *igt_kms_get_dp_audio_edid(void)
+{
+	int channels;
+	uint8_t sampling_rates, sample_sizes;
+	static unsigned char raw_edid[DP_AUDIO_EDID_LENGTH] = {0};
+	struct cea_sad sad = {0};
+	struct cea_speaker_alloc speaker_alloc = {0};
+
+	/* Initialize the Short Audio Descriptor for PCM */
+	channels = 2;
+	sampling_rates = CEA_SAD_SAMPLING_RATE_32KHZ |
+			 CEA_SAD_SAMPLING_RATE_44KHZ |
+			 CEA_SAD_SAMPLING_RATE_48KHZ;
+	sample_sizes = CEA_SAD_SAMPLE_SIZE_16 |
+		       CEA_SAD_SAMPLE_SIZE_20 |
+		       CEA_SAD_SAMPLE_SIZE_24;
+	cea_sad_init_pcm(&sad, channels, sampling_rates, sample_sizes);
+
+	/* Initialize the Speaker Allocation Data */
+	speaker_alloc.speakers = CEA_SPEAKER_FRONT_LEFT_RIGHT_CENTER;
+
+	generate_audio_edid(raw_edid, false, &sad, &speaker_alloc);

 	return raw_edid;
 }
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4ac28131b6d9..125d743fe7f5 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -758,9 +758,11 @@ struct cea_speaker_alloc;

 #define EDID_LENGTH 128
 #define HDMI_AUDIO_EDID_LENGTH (2 * EDID_LENGTH)
+#define DP_AUDIO_EDID_LENGTH (2 * EDID_LENGTH)
 const unsigned char *igt_kms_get_base_edid(void);
 const unsigned char *igt_kms_get_alt_edid(void);
 const unsigned char *igt_kms_get_hdmi_audio_edid(void);
+const unsigned char *igt_kms_get_dp_audio_edid(void);

 struct udev_monitor *igt_watch_hotplug(void);
 bool igt_hotplug_detected(struct udev_monitor *mon,
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 52e3f0953621..18fa3be60617 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -39,6 +39,7 @@ enum test_edid {
 	TEST_EDID_BASE,
 	TEST_EDID_ALT,
 	TEST_EDID_HDMI_AUDIO,
+	TEST_EDID_DP_AUDIO,
 };

 typedef struct {
@@ -49,7 +50,7 @@ typedef struct {

 	int drm_fd;

-	int edids[4];
+	int edids[5];
 } data_t;

 #define HOTPLUG_TIMEOUT 20 /* seconds */
@@ -1997,6 +1998,8 @@ static const unsigned char *get_edid(enum test_edid edid)
 		return igt_kms_get_alt_edid();
 	case TEST_EDID_HDMI_AUDIO:
 		return igt_kms_get_hdmi_audio_edid();
+	case TEST_EDID_DP_AUDIO:
+		return igt_kms_get_dp_audio_edid();
 	}
 	assert(0); /* unreachable */
 }
@@ -2113,7 +2116,7 @@ igt_main
 		 * Use the Chamelium's default EDID for DP audio. */
 		connector_subtest("dp-audio", DisplayPort)
 			test_display_audio(&data, port, "HDMI",
-					   TEST_EDID_CHAMELIUM_DEFAULT);
+					   TEST_EDID_DP_AUDIO);
 	}

 	igt_subtest_group {
--
2.21.0



More information about the igt-dev mailing list