Prepare v2025.01
[u-boot.git] / include / audio_codec.h
bloba87b76c6f9ed6ca73cb8b42c2b54b5e12135f367
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Copyright 2018 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
7 #ifndef __AUDIO_CODEC_H__
8 #define __AUDIO_CODEC_H__
10 #include <linux/types.h>
12 struct udevice;
15 * An audio codec turns digital data into sound with various parameters to
16 * control its operation.
19 /* Operations for sound */
20 struct audio_codec_ops {
21 /**
22 * set_params() - Set audio codec parameters
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
32 int (*set_params)(struct udevice *dev, int interface, int rate,
33 int mclk_freq, int bits_per_sample, uint channels);
36 #define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops)
38 /**
39 * audio_codec_set_params() - Set audio codec parameters
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
49 int audio_codec_set_params(struct udevice *dev, int interface, int rate,
50 int mclk_freq, int bits_per_sample, uint channels);
52 #endif /* __AUDIO_CODEC_H__ */