Skip to content

Commit d00b4a9

Browse files
committed
[nrf fromlist] tests: drivers: i2s: Add test for 8ch, 32bit, 48k TDM
Add test case where TDM is tested with 8 channels, 32 bit word size and 48k sample rate. Add Kconfig that enables test skip if the driver supports 8 channels but fails in this configuration. Upstream PR #: 95249 Signed-off-by: Sebastian Głąb <[email protected]>
1 parent b48a1f2 commit d00b4a9

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

tests/drivers/i2s/i2s_additional/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ config I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED
7575
When set to 'y', test will check that i2s_configure() returns -EINVAL.
7676
When set to 'n', test will do the transmission.
7777

78+
config I2S_TEST_EIGHT_CHANNELS_32b_48k_UNSUPPORTED
79+
bool "Skip test with 8 channels, 32 bit word size and 48k sample rate"
80+
help
81+
Skip test that is challenging due to high data throughput.
82+
This Kconfig has no effect if I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED=y.
83+
When set to 'y', test will be skipped.
84+
When set to 'n', test will do the transmission.
85+
7886
config I2S_TEST_DATA_FORMAT_I2S_UNSUPPORTED
7987
bool "I2S_FMT_DATA_FORMAT_I2S is not supported by the driver"
8088
help
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&audiopll {
8+
status = "okay";
9+
frequency = <NRFS_AUDIOPLL_FREQ_AUDIO_48K>;
10+
};
11+
12+
&tdm130 {
13+
mck-frequency = <12288000>;
14+
mck-clock-source = "ACLK";
15+
sck-clock-source = "ACLK";
16+
};

tests/drivers/i2s/i2s_additional/src/main.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(i2s_add, LOG_LEVEL_INF);
1919
#define NUMBER_OF_CHANNELS 2
2020
#define FRAME_CLK_FREQ 44100
2121

22-
#define NUM_BLOCKS 20
22+
#define NUM_BLOCKS 4
2323
#define TIMEOUT 1000
2424

2525
#define SAMPLES_COUNT 64
@@ -519,9 +519,9 @@ ZTEST(i2s_additional, test_02b_four_channels)
519519
#endif /* CONFIG_I2S_TEST_FOUR_CHANNELS_UNSUPPORTED */
520520
}
521521

522-
/** @brief Test I2S transfer with eight channels.
522+
/** @brief Test I2S transfer with eight channels, 16 bit and 44.1 kHz.
523523
*/
524-
ZTEST(i2s_additional, test_02c_eight_channels)
524+
ZTEST(i2s_additional, test_02c_eight_channels_default)
525525
{
526526
struct i2s_config i2s_cfg = default_i2s_cfg;
527527

@@ -549,6 +549,43 @@ ZTEST(i2s_additional, test_02c_eight_channels)
549549
#endif /* CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED */
550550
}
551551

552+
/** @brief Test I2S transfer with eight channels, 32 bit and 48 kHz.
553+
*/
554+
ZTEST(i2s_additional, test_02d_eight_channels_high_throughput)
555+
{
556+
struct i2s_config i2s_cfg = default_i2s_cfg;
557+
558+
i2s_cfg.channels = 8;
559+
i2s_cfg.word_size = 32;
560+
i2s_cfg.frame_clk_freq = 48000;
561+
562+
#if defined(CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED)
563+
int ret;
564+
565+
ret = i2s_configure(dev_i2s, I2S_DIR_TX, &i2s_cfg);
566+
zassert_equal(ret, -EINVAL, "Unexpected result %d", ret);
567+
#else /* CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED */
568+
569+
#if defined(CONFIG_I2S_TEST_EIGHT_CHANNELS_32b_48k_UNSUPPORTED)
570+
/* Skip this test if driver supports 8ch but fails in this configuration. */
571+
ztest_test_skip();
572+
#endif
573+
574+
/* Select format that supports eight channels. */
575+
#if !defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_LONG_UNSUPPORTED)
576+
i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_LONG;
577+
TC_PRINT("Selected format is I2S_FMT_DATA_FORMAT_PCM_LONG\n");
578+
#elif !defined(CONFIG_I2S_TEST_DATA_FORMAT_PCM_SHORT_UNSUPPORTED)
579+
i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_SHORT;
580+
TC_PRINT("Selected format is I2S_FMT_DATA_FORMAT_PCM_SHORT\n");
581+
#else
582+
#error "Don't know what format supports eight channels."
583+
#endif
584+
585+
i2s_dir_both_transfer_long(&i2s_cfg);
586+
#endif /* CONFIG_I2S_TEST_EIGHT_CHANNELS_UNSUPPORTED */
587+
}
588+
552589
/** @brief Test I2S transfer with format I2S_FMT_DATA_FORMAT_I2S
553590
*/
554591
ZTEST(i2s_additional, test_03a_format_i2s)

tests/drivers/i2s/i2s_additional/testcase.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ tests:
2626
drivers.i2s.additional.gpio_loopback.54h:
2727
harness_config:
2828
fixture: i2s_loopback
29+
extra_configs:
30+
- CONFIG_I2S_TEST_EIGHT_CHANNELS_32b_48k_UNSUPPORTED=y
31+
platform_allow:
32+
- nrf54h20dk/nrf54h20/cpuapp
33+
integration_platforms:
34+
- nrf54h20dk/nrf54h20/cpuapp
35+
36+
drivers.i2s.additional.gpio_loopback.54h.aclk:
37+
harness_config:
38+
fixture: i2s_loopback
39+
extra_args: EXTRA_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_aclk.overlay"
2940
platform_allow:
3041
- nrf54h20dk/nrf54h20/cpuapp
3142
integration_platforms:

0 commit comments

Comments
 (0)