[igt-dev] [RFC PATCH 3/3] tests/kms_chamelium: add InfoFrame checks to audio tests

Simon Ser simon.ser at intel.com
Tue Jul 16 11:58:14 UTC 2019


If the DUT sends an InfoFrame, check that its values are correct. Per the HDMI
and DP specs, most of the fields can be set to "refer to stream header" because
some information is duplicated. The DP spec also says that InfoFrames are
optional if mono or stereo audio is used (because there's no channel speaker
allocation).

Signed-off-by: Simon Ser <simon.ser at intel.com>
---
 tests/kms_chamelium.c | 50 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 321fb16b73bd..e754c4734736 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -29,6 +29,7 @@
 #include "igt_vc4.h"
 #include "igt_edid.h"
 #include "igt_eld.h"
+#include "igt_infoframe.h"
 
 #include <fcntl.h>
 #include <pthread.h>
@@ -1014,6 +1015,53 @@ static void audio_state_stop(struct audio_state *state, bool success)
 		  success ? "ALL GREEN" : "FAILED");
 }
 
+static void check_audio_infoframe(struct audio_state *state)
+{
+	struct chamelium_infoframe *infoframe;
+	struct infoframe_audio infoframe_audio;
+	struct infoframe_audio expected = {0};
+	bool ok;
+
+	expected.coding_type = INFOFRAME_AUDIO_CT_PCM;
+	expected.channel_count = state->playback.channels;
+	expected.sampling_freq = state->playback.rate;
+	expected.sample_size = snd_pcm_format_width(state->playback.format);
+
+	infoframe = chamelium_get_last_infoframe(state->chamelium, state->port,
+						 CHAMELIUM_INFOFRAME_AUDIO);
+	if (infoframe == NULL && state->playback.channels <= 2) {
+		/* Audio InfoFrames are optional for mono and stereo audio */
+		igt_debug("Skipping audio InfoFrame check: "
+			  "no InfoFrame received\n");
+		return;
+	}
+	igt_assert_f(infoframe != NULL, "no audio InfoFrame received\n");
+
+	ok = infoframe_audio_parse(&infoframe_audio, infoframe->version,
+				   infoframe->payload, infoframe->payload_size);
+	chamelium_infoframe_destroy(infoframe);
+	igt_assert_f(ok, "failed to parse audio InfoFrame\n");
+
+	igt_debug("Checking audio InfoFrame:\n");
+	igt_debug("coding_type: got %d, expected %d\n",
+		  infoframe_audio.coding_type, expected.coding_type);
+	igt_debug("channel_count: got %d, expected %d\n",
+		  infoframe_audio.channel_count, expected.channel_count);
+	igt_debug("sampling_freq: got %d, expected %d\n",
+		  infoframe_audio.sampling_freq, expected.sampling_freq);
+	igt_debug("sample_size: got %d, expected %d\n",
+		  infoframe_audio.sample_size, expected.sample_size);
+
+	if (infoframe_audio.coding_type != INFOFRAME_AUDIO_CT_UNSPECIFIED)
+		igt_assert(infoframe_audio.coding_type == expected.coding_type);
+	if (infoframe_audio.channel_count >= 0)
+		igt_assert(infoframe_audio.channel_count == expected.channel_count);
+	if (infoframe_audio.sampling_freq >= 0)
+		igt_assert(infoframe_audio.sampling_freq == expected.sampling_freq);
+	if (infoframe_audio.sample_size >= 0)
+		igt_assert(infoframe_audio.sample_size == expected.sample_size);
+}
+
 static int
 audio_output_frequencies_callback(void *data, void *buffer, int samples)
 {
@@ -1139,6 +1187,8 @@ static bool test_audio_frequencies(struct audio_state *state)
 	free(channel);
 	audio_signal_fini(state->signal);
 
+	check_audio_infoframe(state);
+
 	return success;
 }
 
-- 
2.22.0



More information about the igt-dev mailing list