audio.c 922 B

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