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 64abc7205259cd5badfeb114041ade0be3cbdfa4 Author: Tiago Medicci Serrano <[email protected]> AuthorDate: Tue Oct 25 14:34:35 2022 -0300 drivers/audio/cs4344: add txchannels method and fix supported data width --- drivers/audio/cs4344.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/audio/cs4344.c b/drivers/audio/cs4344.c index 57278239c8..516af188dc 100644 --- a/drivers/audio/cs4344.c +++ b/drivers/audio/cs4344.c @@ -55,6 +55,7 @@ ****************************************************************************/ static int cs4344_setmclkfrequency(FAR struct cs4344_dev_s *priv); +static void cs4344_settxchannels(FAR struct cs4344_dev_s *priv); static void cs4344_setdatawidth(FAR struct cs4344_dev_s *priv); static void cs4344_setbitrate(FAR struct cs4344_dev_s *priv); @@ -287,11 +288,26 @@ static int cs4344_setmclkfrequency(FAR struct cs4344_dev_s *priv) return ret > 0 ? OK : ret; } +/**************************************************************************** + * Name: cs4344_settxchannels + * + * Description: + * Set the number of channels + * + ****************************************************************************/ + +static void cs4344_settxchannels(FAR struct cs4344_dev_s *priv) +{ + DEBUGASSERT(priv); + + I2S_TXCHANNELS(priv->i2s, priv->nchannels); +} + /**************************************************************************** * Name: cs4344_setdatawidth * * Description: - * Set the 8- or 16-bit data modes + * Set the 16 or 24-bit data modes * ****************************************************************************/ @@ -301,13 +317,13 @@ static void cs4344_setdatawidth(FAR struct cs4344_dev_s *priv) { /* Reset default default setting */ - priv->i2s->ops->i2s_txdatawidth(priv->i2s, 16); + I2S_TXDATAWIDTH(priv->i2s, 16); } else { - /* This should select 8-bit with no companding */ + /* This should select 24-bit with no companding */ - priv->i2s->ops->i2s_txdatawidth(priv->i2s, 8); + I2S_TXDATAWIDTH(priv->i2s, 24); } } @@ -320,7 +336,7 @@ static void cs4344_setbitrate(FAR struct cs4344_dev_s *priv) { DEBUGASSERT(priv); - priv->i2s->ops->i2s_txsamplerate(priv->i2s, priv->samprate); + I2S_TXSAMPLERATE(priv->i2s, priv->samprate); audinfo("sample rate=%u nchannels=%u bpsamp=%u\n", priv->samprate, priv->nchannels, priv->bpsamp); @@ -553,7 +569,7 @@ cs4344_configure(FAR struct audio_lowerhalf_s *dev, break; } - if (caps->ac_controls.b[2] != 8 && caps->ac_controls.b[2] != 16) + if (caps->ac_controls.b[2] != 16 && caps->ac_controls.b[2] != 24) { auderr("ERROR: Unsupported bits per sample: %d\n", caps->ac_controls.b[2]); @@ -589,6 +605,7 @@ cs4344_configure(FAR struct audio_lowerhalf_s *dev, } } + cs4344_settxchannels(priv); cs4344_setdatawidth(priv); cs4344_setbitrate(priv); }
