audio_codec.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2018 Google LLC
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #ifndef __AUDIO_CODEC_H__
  7. #define __AUDIO_CODEC_H__
  8. /*
  9. * An audio codec turns digital data into sound with various parameters to
  10. * control its operation.
  11. */
  12. /* Operations for sound */
  13. struct audio_codec_ops {
  14. /**
  15. * set_params() - Set audio codec parameters
  16. *
  17. * @dev: Sound device
  18. * @inteface: Interface number to use on codec
  19. * @rate: Sampling rate in Hz
  20. * @mclk_freq: Codec clock frequency in Hz
  21. * @bits_per_sample: Must be 16 or 24
  22. * @channels: Number of channels to use (1=mono, 2=stereo)
  23. * @return 0 if OK, -ve on error
  24. */
  25. int (*set_params)(struct udevice *dev, int interface, int rate,
  26. int mclk_freq, int bits_per_sample, uint channels);
  27. };
  28. #define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops)
  29. /**
  30. * audio_codec_set_params() - Set audio codec parameters
  31. *
  32. * @dev: Sound device
  33. * @inteface: Interface number to use on codec
  34. * @rate: Sampling rate in Hz
  35. * @mclk_freq: Codec clock frequency in Hz
  36. * @bits_per_sample: Must be 16 or 24
  37. * @channels: Number of channels to use (1=mono, 2=stereo)
  38. * @return 0 if OK, -ve on error
  39. */
  40. int audio_codec_set_params(struct udevice *dev, int interface, int rate,
  41. int mclk_freq, int bits_per_sample, uint channels);
  42. #endif /* __AUDIO_CODEC_H__ */