From 7f6e856ff292a40a605fd12408a72f16f72c5a05 Mon Sep 17 00:00:00 2001 From: Xingyu Wu Date: Thu, 25 Aug 2022 10:36:50 +0800 Subject: [PATCH] sound:dwc:i2s:Support 16bit playback and capture Add 16bit playing and record but unsupport 8k rate. Signed-off-by: Xingyu Wu --- sound/soc/dwc/dwc-i2s.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c index 88042dd..d21ffc6 100755 --- a/sound/soc/dwc/dwc-i2s.c +++ b/sound/soc/dwc/dwc-i2s.c @@ -255,6 +255,15 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream, switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: + if (params_rate(params) == 8000) { + dev_err(dev->dev, "I2S: unsupported 8000 rate with S16_LE, Stereo.\n"); + return -EINVAL; + } + + if (txrx == SNDRV_PCM_STREAM_PLAYBACK) + dev->play_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; + else + dev->capture_dma_data.dt.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; config->data_width = 16; dev->ccr = 0x00; dev->xfer_resolution = 0x02; @@ -1018,6 +1027,9 @@ static int dw_configure_dai(struct dw_i2s_dev *dev, dw_i2s_dai->playback.channels_max = 1 << (COMP1_TX_CHANNELS(comp1) + 1); dw_i2s_dai->playback.formats = formats[idx]; + for (;idx > 0; idx--) + dw_i2s_dai->playback.formats |= formats[idx - 1]; + dw_i2s_dai->playback.rates = rates; } @@ -1032,6 +1044,9 @@ static int dw_configure_dai(struct dw_i2s_dev *dev, dw_i2s_dai->capture.channels_max = 1 << (COMP1_RX_CHANNELS(comp1) + 1); dw_i2s_dai->capture.formats = formats[idx]; + for (;idx > 0; idx--) + dw_i2s_dai->capture.formats |= formats[idx - 1]; + dw_i2s_dai->capture.rates = rates; } -- 2.7.4