Simon Glass | ce6d99a | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2018 Google LLC |
| 4 | * Written by Simon Glass <sjg@chromium.org> |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <audio_codec.h> |
| 9 | #include <dm.h> |
| 10 | #include <dm/test.h> |
Simon Glass | 0e1fad4 | 2020-07-19 10:15:37 -0600 | [diff] [blame^] | 11 | #include <test/test.h> |
Simon Glass | ce6d99a | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 12 | #include <test/ut.h> |
| 13 | #include <asm/test.h> |
| 14 | |
| 15 | /* Basic test of the audio codec uclass */ |
| 16 | static int dm_test_audio(struct unit_test_state *uts) |
| 17 | { |
| 18 | int interface, rate, mclk_freq, bits_per_sample; |
| 19 | struct udevice *dev; |
| 20 | uint channels; |
| 21 | |
| 22 | /* check probe success */ |
| 23 | ut_assertok(uclass_first_device_err(UCLASS_AUDIO_CODEC, &dev)); |
| 24 | ut_assertok(audio_codec_set_params(dev, 1, 2, 3, 4, 5)); |
| 25 | sandbox_get_codec_params(dev, &interface, &rate, &mclk_freq, |
| 26 | &bits_per_sample, &channels); |
| 27 | ut_asserteq(1, interface); |
| 28 | ut_asserteq(2, rate); |
| 29 | ut_asserteq(3, mclk_freq); |
| 30 | ut_asserteq(4, bits_per_sample); |
| 31 | ut_asserteq(5, channels); |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | DM_TEST(dm_test_audio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |