audio_codec.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. struct udevice;
  9. /*
  10. * An audio codec turns digital data into sound with various parameters to
  11. * control its operation.
  12. */
  13. /* Operations for sound */
  14. struct audio_codec_ops {
  15. /**
  16. * set_params() - Set audio codec parameters
  17. *
  18. * @dev: Sound device
  19. * @inteface: Interface number to use on codec
  20. * @rate: Sampling rate in Hz
  21. * @mclk_freq: Codec clock frequency in Hz
  22. * @bits_per_sample: Must be 16 or 24
  23. * @channels: Number of channels to use (1=mono, 2=stereo)
  24. * @return 0 if OK, -ve on error
  25. */
  26. int (*set_params)(struct udevice *dev, int interface, int rate,
  27. int mclk_freq, int bits_per_sample, uint channels);
  28. };
  29. #define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops)
  30. /**
  31. * audio_codec_set_params() - Set audio codec parameters
  32. *
  33. * @dev: Sound device
  34. * @inteface: Interface number to use on codec
  35. * @rate: Sampling rate in Hz
  36. * @mclk_freq: Codec clock frequency in Hz
  37. * @bits_per_sample: Must be 16 or 24
  38. * @channels: Number of channels to use (1=mono, 2=stereo)
  39. * @return 0 if OK, -ve on error
  40. */
  41. int audio_codec_set_params(struct udevice *dev, int interface, int rate,
  42. int mclk_freq, int bits_per_sample, uint channels);
  43. #endif /* __AUDIO_CODEC_H__ */