diff options
author | Simon Glass <sjg@chromium.org> | 2019-02-16 20:24:54 -0700 |
---|---|---|
committer | Bin Meng <bmeng.cn@gmail.com> | 2019-02-20 15:27:08 +0800 |
commit | 2850266965ade165f913a66f679a0449faf21180 (patch) | |
tree | f173b23f448ab8db19adaf8ee75228baf281a42b /test/dm | |
parent | e65f9ef9f21058a7e4f54e11da1af49a8c1b0579 (diff) |
sound: Add uclass operations for beeping
Some audio codecs such as Intel HDA do not need to use digital data to
play sounds, but instead have a way to emit beeps. Add this interface as
an option. If the beep interface is not supported, then the sound uclass
falls back to the I2S interface.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/sound.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/dm/sound.c b/test/dm/sound.c index 7d0b36e7a5..3767abbd1c 100644 --- a/test/dm/sound.c +++ b/test/dm/sound.c @@ -32,3 +32,24 @@ static int dm_test_sound(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_sound, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test of the 'start beep' operations */ +static int dm_test_sound_beep(struct unit_test_state *uts) +{ + struct udevice *dev; + + /* check probe success */ + ut_assertok(uclass_first_device_err(UCLASS_SOUND, &dev)); + ut_asserteq(-ENOSYS, sound_start_beep(dev, 100)); + ut_asserteq(0, sandbox_get_beep_frequency(dev)); + + sandbox_set_allow_beep(dev, true); + ut_asserteq(0, sound_start_beep(dev, 100)); + ut_asserteq(100, sandbox_get_beep_frequency(dev)); + + ut_asserteq(0, sound_stop_beep(dev)); + ut_asserteq(0, sandbox_get_beep_frequency(dev)); + + return 0; +} +DM_TEST(dm_test_sound_beep, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |