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 | |
| 7 | #ifndef __AUDIO_CODEC_H__ |
| 8 | #define __AUDIO_CODEC_H__ |
| 9 | |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | struct udevice; |
| 11 | |
Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 12 | /* |
| 13 | * An audio codec turns digital data into sound with various parameters to |
| 14 | * control its operation. |
| 15 | */ |
| 16 | |
| 17 | /* Operations for sound */ |
| 18 | struct audio_codec_ops { |
| 19 | /** |
| 20 | * set_params() - Set audio codec parameters |
| 21 | * |
| 22 | * @dev: Sound device |
| 23 | * @inteface: Interface number to use on codec |
| 24 | * @rate: Sampling rate in Hz |
| 25 | * @mclk_freq: Codec clock frequency in Hz |
| 26 | * @bits_per_sample: Must be 16 or 24 |
| 27 | * @channels: Number of channels to use (1=mono, 2=stereo) |
| 28 | * @return 0 if OK, -ve on error |
| 29 | */ |
| 30 | int (*set_params)(struct udevice *dev, int interface, int rate, |
| 31 | int mclk_freq, int bits_per_sample, uint channels); |
| 32 | }; |
| 33 | |
| 34 | #define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops) |
| 35 | |
| 36 | /** |
| 37 | * audio_codec_set_params() - Set audio codec parameters |
| 38 | * |
| 39 | * @dev: Sound device |
| 40 | * @inteface: Interface number to use on codec |
| 41 | * @rate: Sampling rate in Hz |
| 42 | * @mclk_freq: Codec clock frequency in Hz |
| 43 | * @bits_per_sample: Must be 16 or 24 |
| 44 | * @channels: Number of channels to use (1=mono, 2=stereo) |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 45 | * Return: 0 if OK, -ve on error |
Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 46 | */ |
| 47 | int audio_codec_set_params(struct udevice *dev, int interface, int rate, |
| 48 | int mclk_freq, int bits_per_sample, uint channels); |
| 49 | |
| 50 | #endif /* __AUDIO_CODEC_H__ */ |