Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 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 | |
Tom Rini | d22d069 | 2024-04-27 08:10:58 -0600 | [diff] [blame] | 10 | #include <linux/types.h> |
| 11 | |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 12 | struct udevice; |
| 13 | |
Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 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) |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 47 | * Return: 0 if OK, -ve on error |
Simon Glass | ed96cde | 2018-12-10 10:37:33 -0700 | [diff] [blame] | 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__ */ |