Simon Glass | ed96cde | 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 | |
Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 7 | #include <audio_codec.h> |
| 8 | #include <dm.h> |
| 9 | #include <dm/test.h> |
Simon Glass | 75c4d41 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 10 | #include <test/test.h> |
Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 11 | #include <test/ut.h> |
| 12 | #include <asm/test.h> |
| 13 | |
| 14 | /* Basic test of the audio codec uclass */ |
| 15 | static int dm_test_audio(struct unit_test_state *uts) |
| 16 | { |
| 17 | int interface, rate, mclk_freq, bits_per_sample; |
| 18 | struct udevice *dev; |
| 19 | uint channels; |
| 20 | |
| 21 | /* check probe success */ |
| 22 | ut_assertok(uclass_first_device_err(UCLASS_AUDIO_CODEC, &dev)); |
| 23 | ut_assertok(audio_codec_set_params(dev, 1, 2, 3, 4, 5)); |
| 24 | sandbox_get_codec_params(dev, &interface, &rate, &mclk_freq, |
| 25 | &bits_per_sample, &channels); |
| 26 | ut_asserteq(1, interface); |
| 27 | ut_asserteq(2, rate); |
| 28 | ut_asserteq(3, mclk_freq); |
| 29 | ut_asserteq(4, bits_per_sample); |
| 30 | ut_asserteq(5, channels); |
| 31 | |
| 32 | return 0; |
| 33 | } |
Simon Glass | 1a92f83 | 2024-08-22 07:57:48 -0600 | [diff] [blame] | 34 | DM_TEST(dm_test_audio, UTF_SCAN_PDATA | UTF_SCAN_FDT); |