diff options
author | Simon Glass <sjg@chromium.org> | 2018-12-10 10:37:36 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-12-13 16:32:49 -0700 |
commit | d4901898654b664c41d8a03afc0e0fbf531b5812 (patch) | |
tree | e757add0074c0f4c193a97157abaa70e7e56ec2e /test/dm | |
parent | e625b68b04a400ba377ec0a5b958bde0bc6244ff (diff) | |
download | u-boot-d4901898654b664c41d8a03afc0e0fbf531b5812.zip u-boot-d4901898654b664c41d8a03afc0e0fbf531b5812.tar.gz u-boot-d4901898654b664c41d8a03afc0e0fbf531b5812.tar.bz2 |
dm: sound: Create a uclass for sound
The sound driver pulls together the audio codec and i2s drivers in order
to actually make sounds. It supports setup() and play() methods. The
sound_find_codec_i2s() function allows locating the linked codec and i2s
devices. They can be referred to from uclass-private data.
Add a uclass and a test for sound.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/Makefile | 1 | ||||
-rw-r--r-- | test/dm/sound.c | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile index 28ede9a..73f5dcf 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -55,6 +55,7 @@ obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o obj-$(CONFIG_CPU) += cpu.o +obj-$(CONFIG_DM_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o obj-$(CONFIG_DMA) += dma.o diff --git a/test/dm/sound.c b/test/dm/sound.c new file mode 100644 index 0000000..7d0b36e --- /dev/null +++ b/test/dm/sound.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 Google LLC + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <common.h> +#include <dm.h> +#include <sound.h> +#include <dm/test.h> +#include <test/ut.h> +#include <asm/test.h> + +/* Basic test of the sound codec uclass */ +static int dm_test_sound(struct unit_test_state *uts) +{ + struct sound_uc_priv *uc_priv; + struct udevice *dev; + + /* check probe success */ + ut_assertok(uclass_first_device_err(UCLASS_SOUND, &dev)); + uc_priv = dev_get_uclass_priv(dev); + ut_asserteq_str("audio-codec", uc_priv->codec->name); + ut_asserteq_str("i2s", uc_priv->i2s->name); + ut_asserteq(0, sandbox_get_setup_called(dev)); + + ut_assertok(sound_beep(dev, 1, 100)); + ut_asserteq(4560, sandbox_get_sound_sum(dev)); + ut_assertok(sound_beep(dev, 1, 100)); + ut_asserteq(9120, sandbox_get_sound_sum(dev)); + + return 0; +} +DM_TEST(dm_test_sound, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |