ASoC: dwc: Add support for record mode
v2 cover ASoC: dwc: Add support for record mode
This patchset adds support for record mode in I2S PIO pcm and enables 24bit transaction.
With this patchset we now have PIO support for playback and record using only two channels, at sample rate 32k, 44.1k and 48k and sample width 16/24 and 32 bit.
Tested in a x86_64 platform and in ARC AXS101 SDP platform.
Jose Abreu (2):
ASoC: dwc: Add record capability in PIO mode
ASoC: dwc: Enable 24 bit sample size in PIO mode
sound/soc/dwc/designware_i2s.c | 9 +++- sound/soc/dwc/designware_pcm.c | 99 +++++++++++++++++++++++++++++++++--------- sound/soc/dwc/local.h | 9 +++- 3 files changed, 94 insertions(+), 23 deletions(-)
Signature · 12 lines
Cc: Carlos Palminha <[email protected]> Cc: Liam Girdwood <[email protected]> Cc: Mark Brown <[email protected]> Cc: Jaroslav Kysela <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: [email protected] Cc: [email protected] v2: - Added missing cover letter 1.9.1
PATCH v2 1/2 ASoC: dwc: Add record capability in PIO mode
Up until now PIO mode offered only playback support. With this patch we add support for record mode. The PCM was refactored so that we could reuse the existing infrastructure without many changes.
We have support for 16 and 32 bits of sample size using only 2 channels.
Tested in a x86_64 platform and in ARC AXS101 SDP platform.
--- sound/soc/dwc/designware_i2s.c | 9 +++- sound/soc/dwc/designware_pcm.c | 97 +++++++++++++++++++++++++++++++++--------- sound/soc/dwc/local.h | 9 +++- 3 files changed, 92 insertions(+), 23 deletions(-)
sound/soc/dwc/designware_i2s.c +7 -2
@@ -121,9 +121,14 @@ static irqreturn_t i2s_irq_handler(int irq, void *dev_id) irq_valid = true; } -/* Data available. Record mode not supported in PIO mode */ -if (isr[i] &ISR_RXDA ) +/* +* Data available. Retrieve samples from FIFO +* NOTE: Only two channels supported +*/ +if ((isr[i] &ISR_RXDA ) && (i ==0 ) && dev->use_pio) { +dw_pcm_pop_rx (dev); irq_valid = true; + }/* Error Handling: TX */ if (isr[i] &ISR_TXFO ) {
sound/soc/dwc/designware_pcm.c +77 -20
154 lines not on this page · raw message
sound/soc/dwc/local.h +8 -1
@@ -105,20 +105,27 @@ struct dw_i2s_dev {struct i2s_clk_config_data config;int (*i2s_clk_cfg)(struct i2s_clk_config_data *config); -/* data related to PIO transfers (TX) */ +/* data related to PIO transfers */ bool use_pio;struct snd_pcm_substream __rcu *tx_substream; +struct snd_pcm_substream __rcu *rx_substream;unsigned int (*tx_fn)(struct dw_i2s_dev *dev,struct snd_pcm_runtime *runtime,unsigned int tx_ptr,bool *period_elapsed); +unsigned int (*rx_fn)(struct dw_i2s_dev *dev, +struct snd_pcm_runtime *runtime,unsigned int rx_ptr, +bool *period_elapsed);unsigned int tx_ptr; +unsigned int rx_ptr; };#if IS_ENABLED (CONFIG_SND_DESIGNWARE_PCM )void dw_pcm_push_tx (struct dw_i2s_dev *dev); +void dw_pcm_pop_rx (struct dw_i2s_dev *dev);int dw_pcm_register (struct platform_device *pdev);#else void dw_pcm_push_tx (struct dw_i2s_dev *dev) { } +void dw_pcm_pop_rx (struct dw_i2s_dev *dev) { }int dw_pcm_register (struct platform_device *pdev) {return -EINVAL ;
Signature · 1 line
1.9.1
PATCH v2 2/2 ASoC: dwc: Enable 24 bit sample size in PIO mode
In reply to Jose AbreuSample size of 24 bits use in reality 32 bits for storage. We can safelly enable this sample size and treat the data as 32 bits.
Tested in a x86_64 platform and in ARC AXS101 SDP platform.
--- sound/soc/dwc/designware_pcm.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/dwc/designware_pcm.c +2 -0
@@ -80,6 +80,7 @@ .rate_min = 32000, .rate_max = 48000, .formats =SNDRV_PCM_FMTBIT_S16_LE | +SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, .channels_min = 2, .channels_max = 2,
@@ -175,6 +176,7 @@ static int dw_pcm_hw_params(struct snd_pcm_substream *substream, dev->tx_fn = dw_pcm_tx_16; dev->rx_fn = dw_pcm_rx_16;break ; +case SNDRV_PCM_FORMAT_S24_LE :case SNDRV_PCM_FORMAT_S32_LE : dev->tx_fn = dw_pcm_tx_32; dev->rx_fn = dw_pcm_rx_32;
Signature · 1 line
1.9.1