blob: a81a315157651d5413f83ad6e5a9399d64271f47 [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
Simon Glass401d1c42020-10-30 21:38:53 -060010struct udevice;
11
Simon Glassce6d99a2018-12-10 10:37:33 -070012/*
13 * An audio codec turns digital data into sound with various parameters to
14 * control its operation.
15 */
16
17/* Operations for sound */
18struct 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 Schuchardt185f8122022-01-19 18:05:50 +010045 * Return: 0 if OK, -ve on error
Simon Glassce6d99a2018-12-10 10:37:33 -070046 */
47int 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__ */