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