public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2] lib/igt_kms: generate an EDID suitable for DP audio
Date: Thu,  6 Jun 2019 13:45:44 +0300	[thread overview]
Message-ID: <20190606104544.18693-1-simon.ser@intel.com> (raw)

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.

v2:
- Replace {HDMI,DP}_AUDIO_EDID_LENGTH with AUDIO_EDID_LENGTH (Arek)
- Don't hardcode EDIDs array length (Arek)

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
 lib/igt_kms.c           | 46 +++++++++++++++++++++++++++++++++--------
 lib/igt_kms.h           |  3 ++-
 tests/kms_chamelium.c   | 10 ++++++---
 tests/kms_hdmi_inject.c |  2 +-
 4 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index d7d711a72d27..011b064579a8 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 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];
@@ -233,7 +235,33 @@ const unsigned char *igt_kms_get_hdmi_audio_edid(void)
 {
 	int channels;
 	uint8_t sampling_rates, sample_sizes;
-	static unsigned char raw_edid[HDMI_AUDIO_EDID_LENGTH] = {0};
+	static unsigned char raw_edid[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, 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[AUDIO_EDID_LENGTH] = {0};
 	struct cea_sad sad = {0};
 	struct cea_speaker_alloc speaker_alloc = {0};

@@ -250,7 +278,7 @@ 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, false, &sad, &speaker_alloc);

 	return raw_edid;
 }
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4ac28131b6d9..5df9f18c0bd1 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -757,10 +757,11 @@ struct cea_sad;
 struct cea_speaker_alloc;

 #define EDID_LENGTH 128
-#define HDMI_AUDIO_EDID_LENGTH (2 * EDID_LENGTH)
+#define 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..3beea0c623bd 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -39,7 +39,9 @@ enum test_edid {
 	TEST_EDID_BASE,
 	TEST_EDID_ALT,
 	TEST_EDID_HDMI_AUDIO,
+	TEST_EDID_DP_AUDIO,
 };
+#define TEST_EDID_COUNT 5

 typedef struct {
 	struct chamelium *chamelium;
@@ -49,7 +51,7 @@ typedef struct {

 	int drm_fd;

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

 #define HOTPLUG_TIMEOUT 20 /* seconds */
@@ -1997,6 +1999,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 */
 }
@@ -2031,7 +2035,7 @@ igt_main
 						 &data.port_count);

 		data.edids[TEST_EDID_CHAMELIUM_DEFAULT] = CHAMELIUM_DEFAULT_EDID;
-		for (i = 1; i < sizeof(data.edids) / sizeof(data.edids[0]); ++i) {
+		for (i = 1; i < TEST_EDID_COUNT; ++i) {
 			data.edids[i] = chamelium_new_edid(data.chamelium,
 							   get_edid(i));
 		}
@@ -2113,7 +2117,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 {
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index 47f5ef2c558a..6b7e100f2027 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -219,7 +219,7 @@ hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
 	struct kmstest_connector_config config;

 	edid = igt_kms_get_hdmi_audio_edid();
-	length = HDMI_AUDIO_EDID_LENGTH;
+	length = AUDIO_EDID_LENGTH;

 	kmstest_force_edid(drm_fd, connector, edid, length);

--
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-06-06 10:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 10:45 Simon Ser [this message]
2019-06-06 12:43 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/igt_kms: generate an EDID suitable for DP audio (rev2) Patchwork
2019-06-06 13:07 ` [igt-dev] [PATCH i-g-t v2] lib/igt_kms: generate an EDID suitable for DP audio Arkadiusz Hiler
2019-06-08 15:17 ` [igt-dev] ✓ Fi.CI.IGT: success for lib/igt_kms: generate an EDID suitable for DP audio (rev2) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190606104544.18693-1-simon.ser@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox