blob: a87b76c6f9ed6ca73cb8b42c2b54b5e12135f367 [file] [log] [blame]
Simon Glassce6d99a2018-12-10 10:37:33 -07001/* 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
Tom Rini752ed082024-04-27 08:10:58 -060010#include <linux/types.h>
11
Simon Glass401d1c42020-10-30 21:38:53 -060012struct udevice;
13
Simon Glassce6d99a2018-12-10 10:37:33 -070014/*
15 * An audio codec turns digital data into sound with various parameters to
16 * control its operation.
17 */
18
19/* Operations for sound */
20struct 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)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010047 * Return: 0 if OK, -ve on error
Simon Glassce6d99a2018-12-10 10:37:33 -070048 */
49int 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__ */