You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/10/26 16:09:08 UTC
[incubator-nuttx] 01/04: audio/i2s: add i2s_mclkfrequency method to the I2S lower half
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 6f1fbc29eee746f22e24b57e16e17514fb19b184
Author: Tiago Medicci Serrano <ti...@espressif.com>
AuthorDate: Sun Oct 23 10:18:09 2022 -0300
audio/i2s: add i2s_mclkfrequency method to the I2S lower half
This method allows the codec driver to set a specific mclk
frequency for the I2S lower half. This provides support to change
it on run time according to the supported master clock frequency
of the audio codec, the sample rate and the data width.
---
include/nuttx/audio/i2s.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/include/nuttx/audio/i2s.h b/include/nuttx/audio/i2s.h
index 0aab79abc6..22224b27f7 100644
--- a/include/nuttx/audio/i2s.h
+++ b/include/nuttx/audio/i2s.h
@@ -225,6 +225,29 @@
#define I2S_SEND(d,b,c,a,t) \
((d)->ops->i2s_send ? (d)->ops->i2s_send(d,b,c,a,t) : -ENOTTY)
+/****************************************************************************
+ * Name: I2S_MCLKFREQUENCY
+ *
+ * Description:
+ * Set the master clock frequency. Usually, the MCLK is a multiple of the
+ * sample rate. Most of the audio codecs require setting specific MCLK
+ * frequency according to the sample rate. NOTE: this parameter may not
+ * be implemented on I2S driver. If not implemented, the I2S may set
+ * internally any value to the master clock (or even does not support it).
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * frequency - The I2S master clock's frequency
+ *
+ * Returned Value:
+ * Returns the resulting master clock or a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+#define I2S_MCLKFREQUENCY(d,f) \
+ ((d)->ops->i2s_mclkfrequency ? \
+ (d)->ops->i2s_mclkfrequency(d,f) : -ENOTTY)
+
/****************************************************************************
* Name: I2S_IOCTL
*
@@ -286,6 +309,11 @@ struct i2s_ops_s
FAR void *arg,
uint32_t timeout);
+ /* Master Clock methods */
+
+ CODE uint32_t (*i2s_mclkfrequency)(FAR struct i2s_dev_s *dev,
+ uint32_t frequency);
+
/* Ioctl */
CODE int (*i2s_ioctl)(FAR struct i2s_dev_s *dev,