summaryrefslogtreecommitdiff
path: root/test/dm/audio.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-12-14 14:18:47 -0500
committerTom Rini <trini@konsulko.com>2018-12-14 14:18:47 -0500
commit8fc26fce41592175ae004514e431e68a9dd60671 (patch)
tree9d4f5d9b057a749742e9dcead3cfa41c4ddae5ea /test/dm/audio.c
parentd117d8f19b0625f88309e47a8a32c2faa384dddc (diff)
parentf987177db9c988142032ed8142a093cce2378a90 (diff)
Merge tag 'dm-pull-14dec18' of git://git.denx.de/u-boot-dm
Complete conversion of sound to driver model
Diffstat (limited to 'test/dm/audio.c')
-rw-r--r--test/dm/audio.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/dm/audio.c b/test/dm/audio.c
new file mode 100644
index 0000000000..77c3a3625b
--- /dev/null
+++ b/test/dm/audio.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 <audio_codec.h>
+#include <dm.h>
+#include <dm/test.h>
+#include <test/ut.h>
+#include <asm/test.h>
+
+/* Basic test of the audio codec uclass */
+static int dm_test_audio(struct unit_test_state *uts)
+{
+ int interface, rate, mclk_freq, bits_per_sample;
+ struct udevice *dev;
+ uint channels;
+
+ /* check probe success */
+ ut_assertok(uclass_first_device_err(UCLASS_AUDIO_CODEC, &dev));
+ ut_assertok(audio_codec_set_params(dev, 1, 2, 3, 4, 5));
+ sandbox_get_codec_params(dev, &interface, &rate, &mclk_freq,
+ &bits_per_sample, &channels);
+ ut_asserteq(1, interface);
+ ut_asserteq(2, rate);
+ ut_asserteq(3, mclk_freq);
+ ut_asserteq(4, bits_per_sample);
+ ut_asserteq(5, channels);
+
+ return 0;
+}
+DM_TEST(dm_test_audio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);