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