Skip to contentSkip to conversation

tests/chamelium/kms_chamelium_audio: Add suspend/resume audio tests

PATCH In review Jeevan B 2 participants 2 messages May 11

lore
Share & tools
lore

Jeevan B

author
#0 lore raw

PATCH 1/1 tests/chamelium/kms_chamelium_audio: Add suspend/resume audio tests

Add test to validate audio works before and after suspend/resume on HDMI/DP connector.

v2: Perform a single suspend/resume for all audio combinations.
Re-enable chamelium after suspend and separate pre-suspend and post-resume validation paths for clearer failure diagnostics.

---
 tests/chamelium/kms_chamelium_audio.c | 133 ++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
tests/chamelium/kms_chamelium_audio.c +133 -0
index df8d27c0c..2fd8322e0 100644
@@ -52,6 +52,12 @@
  * SUBTEST: hdmi-audio-edid
  * Description: Plug a connector with an EDID suitable for audio, check ALSA's
  *              EDID-Like Data reports the correct audio parameters
+ *
+ * SUBTEST: dp-audio-after-suspend
+ * Description: Verify audio works before and after system suspend/resume
+ *
+ * SUBTEST: hdmi-audio-after-suspend
+ * Description: Verify audio works before and after system suspend/resume
  */
 
 /* Playback parameters control the audio signal we synthesize and send */
@@ -695,6 +701,46 @@ static bool check_audio_configuration(struct alsa *alsa,
 	return true;
 }
 
+static bool run_audio_tests(chamelium_data_t *data,
+			    struct alsa *alsa,
+			    struct chamelium_port *port,
+			    const char *audio_device)
+{
+	bool run = false;
+	int ret, i, j;
+	int channels, sampling_rate;
+	snd_pcm_format_t format;
+
+	for (i = 0; i < test_sampling_rates_count; i++) {
+		for (j = 0; j < test_formats_count; j++) {
+			ret = alsa_open_output(alsa, audio_device);
+			igt_assert_f(ret >= 0,
+				     "Failed to open ALSA output\n");
+
+			format = test_formats[j];
+			channels = PLAYBACK_CHANNELS;
+			sampling_rate = test_sampling_rates[i];
+
+			if (!check_audio_configuration(alsa, format,
+						       channels,
+						       sampling_rate)) {
+				alsa_close_output(alsa);
+				continue;
+			}
+
+			run = true;
+
+			igt_assert(run_audio_test_once(data, alsa, port,
+						       format, channels,
+						       sampling_rate));
+
+			alsa_close_output(alsa);
+		}
+	}
+
+	return run;
+}
+
 static const char test_display_audio_desc[] =
 	"Playback various audio signals with various audio formats/rates, "
 	"capture them and check they are correct";
@@ -789,6 +835,83 @@ static void test_display_audio(chamelium_data_t *data,
 	free(alsa);
 }
 
+static const char test_display_audio_suspend_resume_desc[] =
+	"Verify audio works before and after system suspend/resume";
+static void test_display_audio_suspend_resume(
+				chamelium_data_t *data,
+				struct chamelium_port *port,
+				const char *audio_device,
+				enum igt_custom_edid_type edid)
+{
+	struct alsa *alsa;
+	igt_output_t *output;
+	igt_plane_t *primary;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	drmModeConnector *connector;
+	int fb_id;
+
+	igt_require(alsa_has_exclusive_access());
+
+	igt_require(chamelium_has_audio_support(data->chamelium,
+						port));
+
+	alsa = alsa_init();
+	igt_assert(alsa);
+
+	igt_modeset_disable_all_outputs(&data->display);
+
+	chamelium_reset_state(&data->display, data->chamelium,
+			      port, data->ports,
+			      data->port_count);
+
+	output = chamelium_prepare_output(data, port, edid);
+
+	connector = chamelium_port_get_connector(data->chamelium,
+						 port, false);
+
+	primary = igt_output_get_plane_type(output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_assert(primary);
+
+	igt_assert(connector->count_modes > 0);
+
+	mode = &connector->modes[0];
+
+	fb_id = igt_create_color_pattern_fb(data->drm_fd,
+					    mode->hdisplay,
+					    mode->vdisplay,
+					    DRM_FORMAT_XRGB8888,
+					    DRM_FORMAT_MOD_LINEAR,
+					    0, 0, 0, &fb);
+
+	igt_assert(fb_id > 0);
+
+	chamelium_enable_output(data, port, output,
+				mode, &fb);
+
+	igt_assert(run_audio_tests(data, alsa, port,
+				   audio_device));
+
+	igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
+				      SUSPEND_TEST_NONE);
+
+	chamelium_enable_output(data, port, output,
+				mode, &fb);
+
+	igt_display_commit2(&data->display,
+			    COMMIT_ATOMIC);
+
+	igt_assert(run_audio_tests(data, alsa, port,
+				   audio_device));
+
+	igt_remove_fb(data->drm_fd, &fb);
+
+	drmModeFreeConnector(connector);
+
+	free(alsa);
+}
+
 static const char test_display_audio_edid_desc[] =
 	"Plug a connector with an EDID suitable for audio, check ALSA's "
 	"EDID-Like Data reports the correct audio parameters";
@@ -866,6 +989,11 @@ int igt_main()
 	connector_subtest("dp-audio-edid", DisplayPort, &data, test_display_audio_edid,
 			  IGT_CUSTOM_EDID_DP_AUDIO);
 
+	igt_describe(test_display_audio_suspend_resume_desc);
+	connector_subtest("dp-audio-after-suspend", DisplayPort, &data,
+			  test_display_audio_suspend_resume,
+			  "HDMI", IGT_CUSTOM_EDID_DP_AUDIO);
+
 	igt_describe("HDMI tests");
 
 	igt_describe(test_display_audio_desc);
@@ -876,6 +1004,11 @@ int igt_main()
 	connector_subtest("hdmi-audio-edid", HDMIA, &data, test_display_audio_edid,
 			  IGT_CUSTOM_EDID_HDMI_AUDIO);
 
+	igt_describe(test_display_audio_suspend_resume_desc);
+	connector_subtest("hdmi-audio-after-suspend", HDMIA, &data,
+			  test_display_audio_suspend_resume,
+			  "HDMI", IGT_CUSTOM_EDID_HDMI_AUDIO);
+
 	igt_fixture() {
 		igt_display_fini(&data.display);
 		drm_close_driver(data.drm_fd);
Signature · 1 line
2.43.0
#1 lore raw

Hello Jeevan ,

Quoted 68 lines

-----Original Message-----
From: B, Jeevan <[email protected]>
Sent: 11 May 2026 09:49
To: [email protected]
Cc: Borah, Chaitanya Kumar <[email protected]>; Bilal, Mohammed <[email protected]>; B, Jeevan <[email protected]>
Subject: [PATCH i-g-t] tests/chamelium/kms_chamelium_audio: Add suspend/resume audio tests

Add test to validate audio works before and after suspend/resume on HDMI/DP connector.

v2: Perform a single suspend/resume for all audio combinations.
Re-enable chamelium after suspend and separate pre-suspend and post-resume validation paths for clearer failure diagnostics.

---
 tests/chamelium/kms_chamelium_audio.c | 133
++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
tests/chamelium/kms_chamelium_audio.c +8 -0
index df8d27c0c..2fd8322e0 100644
@@ -52,6 +52,12 @@
  * SUBTEST: hdmi-audio-edid
  * Description: Plug a connector with an EDID suitable for audio, check ALSA's
  *              EDID-Like Data reports the correct audio parameters
+ *
+ * SUBTEST: dp-audio-after-suspend
+ * Description: Verify audio works before and after system
+ suspend/resume
+ *
+ * SUBTEST: hdmi-audio-after-suspend
+ * Description: Verify audio works before and after system
+ suspend/resume
  */
 
 /* Playback parameters control the audio signal we synthesize and send */ @@ -

695,6 +701,46 @@ static bool check_audio_configuration(struct alsa *alsa,

tests/chamelium/kms_chamelium_audio.c +22 -0
 	return true;
 }
 
+static bool run_audio_tests(chamelium_data_t *data,
+			    struct alsa *alsa,
+			    struct chamelium_port *port,
+			    const char *audio_device)
+{
+	bool run = false;
+	int ret, i, j;
+	int channels, sampling_rate;
+	snd_pcm_format_t format;
+
+	for (i = 0; i < test_sampling_rates_count; i++) {
+		for (j = 0; j < test_formats_count; j++) {
+			ret = alsa_open_output(alsa, audio_device);
+			igt_assert_f(ret >= 0,
+				     "Failed to open ALSA output\n");
+
+			format = test_formats[j];
+			channels = PLAYBACK_CHANNELS;
+			sampling_rate = test_sampling_rates[i];
+
+			if (!check_audio_configuration(alsa, format,
+						       channels,

tests/chamelium/kms_chamelium_audio.c static bool check_audio_configuration(struct alsa *alsa, · line 735

Quoted 10 lines
tests/chamelium/kms_chamelium_audio.c +10 -0
+						       sampling_rate)) {
+				alsa_close_output(alsa);
+				continue;
+			}
+
+			run = true;
+
+			igt_assert(run_audio_test_once(data, alsa, port,
+						       format, channels,
+						       sampling_rate));

[1] I have a doubt: if igt_assert aborts here on the first failure, are we able to determine whether the abort happened before or after suspend?

Quoted 71 lines
tests/chamelium/kms_chamelium_audio.c +8 -0
+
+			alsa_close_output(alsa);
+		}
+	}
+
+	return run;
+}
+
 static const char test_display_audio_desc[] =
 	"Playback various audio signals with various audio formats/rates, "
 	"capture them and check they are correct"; @@ -789,6 +835,83 @@

static void test_display_audio(chamelium_data_t *data,

tests/chamelium/kms_chamelium_audio.c +56 -0
 	free(alsa);
 }
 
+static const char test_display_audio_suspend_resume_desc[] =
+	"Verify audio works before and after system suspend/resume"; static
+void test_display_audio_suspend_resume(
+				chamelium_data_t *data,
+				struct chamelium_port *port,
+				const char *audio_device,
+				enum igt_custom_edid_type edid)
+{
+	struct alsa *alsa;
+	igt_output_t *output;
+	igt_plane_t *primary;
+	struct igt_fb fb;
+	drmModeModeInfo *mode;
+	drmModeConnector *connector;
+	int fb_id;
+
+	igt_require(alsa_has_exclusive_access());
+
+	igt_require(chamelium_has_audio_support(data->chamelium,
+						port));
+
+	alsa = alsa_init();
+	igt_assert(alsa);
+
+	igt_modeset_disable_all_outputs(&data->display);
+
+	chamelium_reset_state(&data->display, data->chamelium,
+			      port, data->ports,
+			      data->port_count);
+
+	output = chamelium_prepare_output(data, port, edid);
+
+	connector = chamelium_port_get_connector(data->chamelium,
+						 port, false);
+
+	primary = igt_output_get_plane_type(output,
+					    DRM_PLANE_TYPE_PRIMARY);
+	igt_assert(primary);
+
+	igt_assert(connector->count_modes > 0);
+
+	mode = &connector->modes[0];
+
+	fb_id = igt_create_color_pattern_fb(data->drm_fd,
+					    mode->hdisplay,
+					    mode->vdisplay,
+					    DRM_FORMAT_XRGB8888,
+					    DRM_FORMAT_MOD_LINEAR,
+					    0, 0, 0, &fb);
+
+	igt_assert(fb_id > 0);
+
+	chamelium_enable_output(data, port, output,
+				mode, &fb);
+
+	igt_assert(run_audio_tests(data, alsa, port,

tests/chamelium/kms_chamelium_audio.c static void test_display_audio(chamelium_data_t *data, · line 903

Quoted 10 lines
tests/chamelium/kms_chamelium_audio.c +10 -0
+				   audio_device));
+
+	igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
+				      SUSPEND_TEST_NONE);
+
+	chamelium_enable_output(data, port, output,
+				mode, &fb);
+
+	igt_display_commit2(&data->display,
+			    COMMIT_ATOMIC);

[2] chamelium_enable_output() internally calls igt_display_commit2() already Is it necessary to have another commit here ?

Regards,
Mohammed Bilal

Quoted 42 lines
tests/chamelium/kms_chamelium_audio.c +12 -0
+
+	igt_assert(run_audio_tests(data, alsa, port,
+				   audio_device));
+
+	igt_remove_fb(data->drm_fd, &fb);
+
+	drmModeFreeConnector(connector);
+
+	free(alsa);
+}
+
 static const char test_display_audio_edid_desc[] =
 	"Plug a connector with an EDID suitable for audio, check ALSA's "
 	"EDID-Like Data reports the correct audio parameters"; @@ -866,6
+989,11 @@ int igt_main()
 	connector_subtest("dp-audio-edid", DisplayPort, &data,

test_display_audio_edid,

tests/chamelium/kms_chamelium_audio.c +10 -0
 			  IGT_CUSTOM_EDID_DP_AUDIO);
 
+	igt_describe(test_display_audio_suspend_resume_desc);
+	connector_subtest("dp-audio-after-suspend", DisplayPort, &data,
+			  test_display_audio_suspend_resume,
+			  "HDMI", IGT_CUSTOM_EDID_DP_AUDIO);
+
 	igt_describe("HDMI tests");
 
 	igt_describe(test_display_audio_desc);
@@ -876,6 +1004,11 @@ int igt_main()
 	connector_subtest("hdmi-audio-edid", HDMIA, &data,
 test_display_audio_edid,
 			  IGT_CUSTOM_EDID_HDMI_AUDIO);
 
+	igt_describe(test_display_audio_suspend_resume_desc);
+	connector_subtest("hdmi-audio-after-suspend", HDMIA, &data,
+			  test_display_audio_suspend_resume,
+			  "HDMI", IGT_CUSTOM_EDID_HDMI_AUDIO);
+
 	igt_fixture() {
 		igt_display_fini(&data.display);

drm_close_driver(data.drm_fd);
--
2.43.0