summaryrefslogtreecommitdiff
path: root/include/audio_codec.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-12-10 20:37:33 +0300
committerSimon Glass <sjg@chromium.org>2018-12-14 02:32:49 +0300
commitce6d99a056ebc9ad329521ca3660f6cb298a7666 (patch)
treee297e74248dba6d54656e7899a4bd0e134c1dd9d /include/audio_codec.h
parent45863db5a97360b6843a0488621342819e9a6e62 (diff)
downloadu-boot-ce6d99a056ebc9ad329521ca3660f6cb298a7666.tar.xz
dm: sound: Create a uclass for audio codecs
An audio codec provides a way to convert digital data to sound and vice versa. Add a simple uclass which just supports setting the parameters for the codec. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/audio_codec.h')
-rw-r--r--include/audio_codec.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/audio_codec.h b/include/audio_codec.h
new file mode 100644
index 0000000000..2587099546
--- /dev/null
+++ b/include/audio_codec.h
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2018 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __AUDIO_CODEC_H__
+#define __AUDIO_CODEC_H__
+
+/*
+ * An audio codec turns digital data into sound with various parameters to
+ * control its operation.
+ */
+
+/* Operations for sound */
+struct audio_codec_ops {
+ /**
+ * set_params() - Set audio codec parameters
+ *
+ * @dev: Sound device
+ * @inteface: Interface number to use on codec
+ * @rate: Sampling rate in Hz
+ * @mclk_freq: Codec clock frequency in Hz
+ * @bits_per_sample: Must be 16 or 24
+ * @channels: Number of channels to use (1=mono, 2=stereo)
+ * @return 0 if OK, -ve on error
+ */
+ int (*set_params)(struct udevice *dev, int interface, int rate,
+ int mclk_freq, int bits_per_sample, uint channels);
+};
+
+#define audio_codec_get_ops(dev) ((struct audio_codec_ops *)(dev)->driver->ops)
+
+/**
+ * audio_codec_set_params() - Set audio codec parameters
+ *
+ * @dev: Sound device
+ * @inteface: Interface number to use on codec
+ * @rate: Sampling rate in Hz
+ * @mclk_freq: Codec clock frequency in Hz
+ * @bits_per_sample: Must be 16 or 24
+ * @channels: Number of channels to use (1=mono, 2=stereo)
+ * @return 0 if OK, -ve on error
+ */
+int audio_codec_set_params(struct udevice *dev, int interface, int rate,
+ int mclk_freq, int bits_per_sample, uint channels);
+
+#endif /* __AUDIO_CODEC_H__ */