Add I2S audio support for ARC AXS10x boards
Subsystems (4)
v7 cover Add I2S audio support for ARC AXS10x boards
ARC AXS10x platforms consist of a mainboard with several peripherals. One of those peripherals is an HDMI output port controlled by the ADV7511 transmitter.
This patch set adds I2S audio for the AXS10x platform.
NOTE:
Although the mainline I2S driver uses ALSA DMA engine, this controller can be built without DMA support so it was necessary to add this custom platform driver so that HDMI audio works in AXS boards.
Changes v6 -> v7:
* Discard the use of memcpy
* Report IRQ_HANDLED only when there is an IRQ
* Use interrupts to check if PIO mode is in use
* Unmask interrupts only when in PIO mode
* Remove empty functions
Changes v5 -> v6:
* Use SNDRV_DMA_TYPE_CONTINUOUS
Changes v4 -> v5:
* Resolve undefined references when compiling as module
* Dropped adv7511 audio patches
* Use DMA properties in I2S to check which mode to use: PIO or DMA (as suggested by Lars-Peter Clausen)
Changes v3 -> v4:
* Reintroduced custom PCM driver (see note below)
* Use DT boolean to switch between ALSA DMA engine PCM or custom PCM
* Use fifo depth to program I2S FCR
* Update I2S documentation
Changes v2 -> v3:
* Removed pll_config functions (as suggested by Alexey Brodkin)
* Removed HDMI start at adv7511_core (as suggested by Archit Taneja)
* Use NOP functions for adv7511_audio (as suggested by Archit Taneja)
* Added adv7511_audio_exit() function (as suggested by Archit Taneja)
* Moved adv7511 to its own folder (as suggested by Archit Taneja)
* Separated file rename of adv7511_core (as suggested by Emil Velikov)
* Compile adv7511 as module if ALSA SoC is compiled as module
* Load adv7511 audio only if declared in device tree (as suggested by Laurent Pinchart)
* Dropped custom platform driver, using now ALSA DMA engine
* Dropped IRQ handler for I2S
Changes v1 -> v2:
* DT bindings moved to separate patch (as suggested by Alexey Brodkin)
* Removed defconfigs entries (as suggested by Alexey Brodkin)
Jose Abreu (4):
ASoC: dwc: Add helper functions to disable/enable irqs
ASoC: dwc: Do not use devm_clk_get() if using platform data
ASoC: dwc: Add PIO PCM extension
ASoC: dwc: Add irq parameter to DOCUMENTATION
.../devicetree/bindings/sound/designware-i2s.txt | 4 + sound/soc/dwc/Kconfig | 9 + sound/soc/dwc/Makefile | 5 +- sound/soc/dwc/designware_i2s.c | 229 ++++++++++----------- sound/soc/dwc/designware_pcm.c | 220 ++++++++++++++++++++ sound/soc/dwc/local.h | 122 +++++++++++ 6 files changed, 467 insertions(+), 122 deletions(-) create mode 100644 sound/soc/dwc/designware_pcm.c create mode 100644 sound/soc/dwc/local.h
Signature · 7 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v7 1/4 ASoC: dwc: Add helper functions to disable/enable irqs
Helper functions to disable and enable the I2S interrupts were added. Only the interrupts of the used channels are enabled.
Also, there is no need to enable irqs at dw_i2s_config(), they are already enabled at startup.
---
This patch was only introduced in v7.
sound/soc/dwc/designware_i2s.c | 68 +++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 27 deletions(-)
sound/soc/dwc/designware_i2s.c +41 -27
@@ -145,26 +145,54 @@ static inline void i2s_clear_irqs(struct dw_i2s_dev *dev, u32 stream) } } -static void i2s_start (struct dw_i2s_dev *dev, -struct snd_pcm_substream *substream) +static inline void i2s_disable_irqs (struct dw_i2s_dev *dev,u32 stream, +int chan_nr) { -struct i2s_clk_config_data *config = &dev->config;u32 i, irq; -i2s_write_reg (dev->i2s_base,IER ,1 ); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -for (i =0 ; i < (config->chan_nr /2 ); i++) { +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +for (i =0 ; i < (chan_nr /2 ); i++) { + irq =i2s_read_reg (dev->i2s_base,IMR (i)); +i2s_write_reg (dev->i2s_base,IMR (i), irq |0x30 ); + } + }else { +for (i =0 ; i < (chan_nr /2 ); i++) { + irq =i2s_read_reg (dev->i2s_base,IMR (i)); +i2s_write_reg (dev->i2s_base,IMR (i), irq |0x03 ); + } + } +} + +static inline void i2s_enable_irqs (struct dw_i2s_dev *dev,u32 stream, +int chan_nr) +{ +u32 i, irq; + +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +for (i =0 ; i < (chan_nr /2 ); i++) { irq =i2s_read_reg (dev->i2s_base,IMR (i));i2s_write_reg (dev->i2s_base,IMR (i), irq & ~0x30 ); } -i2s_write_reg (dev->i2s_base,ITER ,1 ); }else { -for (i =0 ; i < (config->chan_nr /2 ); i++) { +for (i =0 ; i < (chan_nr /2 ); i++) { irq =i2s_read_reg (dev->i2s_base,IMR (i));i2s_write_reg (dev->i2s_base,IMR (i), irq & ~0x03 ); } -i2s_write_reg (dev->i2s_base,IRER ,1 ); } +} + +static void i2s_start (struct dw_i2s_dev *dev, +struct snd_pcm_substream *substream) +{ +struct i2s_clk_config_data *config = &dev->config; + +i2s_write_reg (dev->i2s_base,IER ,1 ); +i2s_enable_irqs (dev, substream->stream, config->chan_nr); + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +i2s_write_reg (dev->i2s_base,ITER ,1 ); +else +i2s_write_reg (dev->i2s_base,IRER ,1 );i2s_write_reg (dev->i2s_base,CER ,1 ); }
@@ -172,24 +200,14 @@ static void i2s_start(struct dw_i2s_dev *dev,static void i2s_stop (struct dw_i2s_dev *dev,struct snd_pcm_substream *substream) { -u32 i =0 , irq;i2s_clear_irqs (dev, substream->stream); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )i2s_write_reg (dev->i2s_base,ITER ,0 ); - -for (i =0 ; i <4 ; i++) { - irq =i2s_read_reg (dev->i2s_base,IMR (i)); -i2s_write_reg (dev->i2s_base,IMR (i), irq |0x30 ); - } - }else { +else i2s_write_reg (dev->i2s_base,IRER ,0 ); -for (i =0 ; i <4 ; i++) { - irq =i2s_read_reg (dev->i2s_base,IMR (i)); -i2s_write_reg (dev->i2s_base,IMR (i), irq |0x03 ); - } - } +i2s_disable_irqs (dev, substream->stream,8 );if (!dev->active) {i2s_write_reg (dev->i2s_base,CER ,0 );
@@ -223,7 +241,7 @@ static int dw_i2s_startup(struct snd_pcm_substream *substream,static void dw_i2s_config (struct dw_i2s_dev *dev,int stream) { -u32 ch_reg, irq; +u32 ch_reg;struct i2s_clk_config_data *config = &dev->config;
@@ -235,16 +253,12 @@ static void dw_i2s_config(struct dw_i2s_dev *dev, int stream) dev->xfer_resolution);i2s_write_reg (dev->i2s_base,TFCR (ch_reg), dev->fifo_th -1 ); - irq =i2s_read_reg (dev->i2s_base,IMR (ch_reg)); -i2s_write_reg (dev->i2s_base,IMR (ch_reg), irq & ~0x30 );i2s_write_reg (dev->i2s_base,TER (ch_reg),1 ); }else {i2s_write_reg (dev->i2s_base,RCR (ch_reg), dev->xfer_resolution);i2s_write_reg (dev->i2s_base,RFCR (ch_reg), dev->fifo_th -1 ); - irq =i2s_read_reg (dev->i2s_base,IMR (ch_reg)); -i2s_write_reg (dev->i2s_base,IMR (ch_reg), irq & ~0x03 );i2s_write_reg (dev->i2s_base,RER (ch_reg),1 ); }
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: dwc: Add helper functions to disable/enable irqs" to the asoc tree
The patch
ASoC: dwc: Add helper functions to disable/enable irqs
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
df4e7be1832a1ca9fccfb2ed8771a17da6f7fa57Mon Sep 17 00:00:00 2001
From: Jose Abreu <[email protected]>
Date: Mon, 23 May 2016 11:02:22 +0100
Subject: [PATCH] ASoC: dwc: Add helper functions to disable/enable irqs
Helper functions to disable and enable the I2S interrupts were added. Only the interrupts of the used channels are enabled.
Also, there is no need to enable irqs at dw_i2s_config(), they are already enabled at startup.
--- sound/soc/dwc/designware_i2s.c | 68 +++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 27 deletions(-)
sound/soc/dwc/designware_i2s.c +41 -27
@@ -145,26 +145,54 @@ static inline void i2s_clear_irqs(struct dw_i2s_dev *dev, u32 stream) } } -static void i2s_start (struct dw_i2s_dev *dev, -struct snd_pcm_substream *substream) +static inline void i2s_disable_irqs (struct dw_i2s_dev *dev,u32 stream, +int chan_nr) { -struct i2s_clk_config_data *config = &dev->config;u32 i, irq; -i2s_write_reg (dev->i2s_base,IER ,1 ); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { -for (i =0 ; i < (config->chan_nr /2 ); i++) { +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +for (i =0 ; i < (chan_nr /2 ); i++) { + irq =i2s_read_reg (dev->i2s_base,IMR (i)); +i2s_write_reg (dev->i2s_base,IMR (i), irq |0x30 ); + } + }else { +for (i =0 ; i < (chan_nr /2 ); i++) { + irq =i2s_read_reg (dev->i2s_base,IMR (i)); +i2s_write_reg (dev->i2s_base,IMR (i), irq |0x03 ); + } + } +} + +static inline void i2s_enable_irqs (struct dw_i2s_dev *dev,u32 stream, +int chan_nr) +{ +u32 i, irq; + +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +for (i =0 ; i < (chan_nr /2 ); i++) { irq =i2s_read_reg (dev->i2s_base,IMR (i));i2s_write_reg (dev->i2s_base,IMR (i), irq & ~0x30 ); } -i2s_write_reg (dev->i2s_base,ITER ,1 ); }else { -for (i =0 ; i < (config->chan_nr /2 ); i++) { +for (i =0 ; i < (chan_nr /2 ); i++) { irq =i2s_read_reg (dev->i2s_base,IMR (i));i2s_write_reg (dev->i2s_base,IMR (i), irq & ~0x03 ); } -i2s_write_reg (dev->i2s_base,IRER ,1 ); } +} + +static void i2s_start (struct dw_i2s_dev *dev, +struct snd_pcm_substream *substream) +{ +struct i2s_clk_config_data *config = &dev->config; + +i2s_write_reg (dev->i2s_base,IER ,1 ); +i2s_enable_irqs (dev, substream->stream, config->chan_nr); + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +i2s_write_reg (dev->i2s_base,ITER ,1 ); +else +i2s_write_reg (dev->i2s_base,IRER ,1 );i2s_write_reg (dev->i2s_base,CER ,1 ); }
@@ -172,24 +200,14 @@ static void i2s_start(struct dw_i2s_dev *dev,static void i2s_stop (struct dw_i2s_dev *dev,struct snd_pcm_substream *substream) { -u32 i =0 , irq;i2s_clear_irqs (dev, substream->stream); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )i2s_write_reg (dev->i2s_base,ITER ,0 ); - -for (i =0 ; i <4 ; i++) { - irq =i2s_read_reg (dev->i2s_base,IMR (i)); -i2s_write_reg (dev->i2s_base,IMR (i), irq |0x30 ); - } - }else { +else i2s_write_reg (dev->i2s_base,IRER ,0 ); -for (i =0 ; i <4 ; i++) { - irq =i2s_read_reg (dev->i2s_base,IMR (i)); -i2s_write_reg (dev->i2s_base,IMR (i), irq |0x03 ); - } - } +i2s_disable_irqs (dev, substream->stream,8 );if (!dev->active) {i2s_write_reg (dev->i2s_base,CER ,0 );
@@ -223,7 +241,7 @@ static int dw_i2s_startup(struct snd_pcm_substream *substream,static void dw_i2s_config (struct dw_i2s_dev *dev,int stream) { -u32 ch_reg, irq; +u32 ch_reg;struct i2s_clk_config_data *config = &dev->config;
@@ -235,16 +253,12 @@ static void dw_i2s_config(struct dw_i2s_dev *dev, int stream) dev->xfer_resolution);i2s_write_reg (dev->i2s_base,TFCR (ch_reg), dev->fifo_th -1 ); - irq =i2s_read_reg (dev->i2s_base,IMR (ch_reg)); -i2s_write_reg (dev->i2s_base,IMR (ch_reg), irq & ~0x30 );i2s_write_reg (dev->i2s_base,TER (ch_reg),1 ); }else {i2s_write_reg (dev->i2s_base,RCR (ch_reg), dev->xfer_resolution);i2s_write_reg (dev->i2s_base,RFCR (ch_reg), dev->fifo_th -1 ); - irq =i2s_read_reg (dev->i2s_base,IMR (ch_reg)); -i2s_write_reg (dev->i2s_base,IMR (ch_reg), irq & ~0x03 );i2s_write_reg (dev->i2s_base,RER (ch_reg),1 ); }
Signature · 1 line
2.8.1
PATCH v7 2/4 ASoC: dwc: Do not use devm_clk_get() if using platform data
In reply to Jose AbreuWhen using platform data the devm_clk_get() function is called causing a probe failure if the clock is not declared. As we can pass the clock handler by platform data call only devm_clk_get() when platform data is not used.
---
This patch was only introduced in v7.
sound/soc/dwc/designware_i2s.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
sound/soc/dwc/designware_i2s.c +8 -7
@@ -690,15 +690,16 @@ static int dw_i2s_probe(struct platform_device *pdev)dev_err (&pdev->dev,"no clock configure method\n" );return -ENODEV ; } - } - dev->clk =devm_clk_get (&pdev->dev, clk_id); + }else { + dev->clk =devm_clk_get (&pdev->dev, clk_id); -if (IS_ERR (dev->clk)) -return PTR_ERR (dev->clk); +if (IS_ERR (dev->clk)) +return PTR_ERR (dev->clk); - ret =clk_prepare_enable (dev->clk); -if (ret <0 ) -return ret; + ret =clk_prepare_enable (dev->clk); +if (ret <0 ) +return ret; + } }dev_set_drvdata (&pdev->dev, dev);
Signature · 1 line
1.9.1
Mark Brown
maintainerRe: [PATCH 2/4 v7] ASoC: dwc: Do not use devm_clk_get() if using platform data
Quoted 5 lines · Jose Abreu
When using platform data the
devm_clk_get()function is called causing a probe failure if the clock is not declared. As we can pass the clock handler by platform data call onlydevm_clk_get()when platform data is not used.
No, this is broken - if the device needs a clock the device needs a clock and clock names should be static rather than passed in via platform data (indeed NULL is a perfectly valid clock name). The system integation should map in a clock as needed, if it's just a fixed crystal or something then just register a fixed clock and connect it up.
PATCH v7 3/4 ASoC: dwc: Add PIO PCM extension
In reply to Jose AbreuA PCM extension was added to I2S driver so that audio samples are transferred using PIO mode.
The PCM supports two channels @ 16 or 32 bits with rates 32k, 44.1k and 48k.
Although the mainline I2S driver uses ALSA DMA engine the I2S controller can be built without DMA support, therefore this is the reason why this extension was added.
The selection between the use of DMA engine or PIO mode is detected by declaring or not the interrupt parameters in the DT and using Kconfig.
---
Changes v6 -> v7:
* Discard the use of memcpy
* Report IRQ_HANDLED only when there is an IRQ
* Use interrupts to check if PIO mode is in use
* Unmask interrupts only when in PIO mode
* Remove empty functions
Changes v5 -> v6:
* Use SNDRV_DMA_TYPE_CONTINUOUS
Changes v4 -> v5:
* Resolve undefined references when compiling as module
* Use DMA properties in I2S to check which mode to use: PIO or DMA (as suggested by Lars-Peter Clausen)
Changes v3 -> v4:
* Reintroduced custom PCM driver
* Use DT boolean to switch between ALSA DMA engine PCM or custom PCM
Changes v2 -> v3:
* Removed pll_config functions (as suggested by Alexey Brodkin)
* Dropped custom platform driver, using now ALSA DMA engine
* Dropped IRQ handler for I2S
No changes v1 -> v2.
sound/soc/dwc/Kconfig | 9 ++ sound/soc/dwc/Makefile | 5 +- sound/soc/dwc/designware_i2s.c | 148 ++++++++++++--------------- sound/soc/dwc/designware_pcm.c | 220 +++++++++++++++++++++++++++++++++++++++++ sound/soc/dwc/local.h | 122 +++++++++++++++++++++++ 5 files changed, 415 insertions(+), 89 deletions(-) create mode 100644 sound/soc/dwc/designware_pcm.c create mode 100644 sound/soc/dwc/local.h
sound/soc/dwc/Kconfig +9 -0
@@ -7,4 +7,13 @@ config SND_DESIGNWARE_I2S Synopsys desigwnware I2S device. The device supports upto maximum of 8 channels each for play and record. +config SND_DESIGNWARE_PCM + bool "PCM PIO extension for I2S driver" + depends on SND_DESIGNWARE_I2S + help + Say Y or N if you want to add a custom ALSA extension that registers + a PCM and uses PIO to transfer data. + + This functionality is specially suited for I2S devices that don't have + DMA support.
sound/soc/dwc/Makefile +3 -2
@@ -1,3 +1,4 @@ # SYNOPSYS Platform Support -obj-$(CONFIG_SND_DESIGNWARE_I2S) += designware_i2s.o - +obj-$(CONFIG_SND_DESIGNWARE_I2S) += dwc_i2s.o +dwc_i2s-y := designware_i2s.o +dwc_i2s-$(CONFIG_SND_DESIGNWARE_PCM) += designware_pcm.o
sound/soc/dwc/designware_i2s.c +61 -87
191 lines not on this page · raw message
sound/soc/dwc/designware_pcm.c new file +220 -0
220 lines not on this page · raw message
sound/soc/dwc/local.h new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
1.9.1
Mark Brown
maintainerRe: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
sound/soc/dwc/Kconfig config SND_DESIGNWARE_I2S · line 11
Quoted 2 lines · Jose Abreu
sound/soc/dwc/Kconfig +2
-0+config SND_DESIGNWARE_PCM + bool "PCM PIO extension for I2S driver"
Why can't this be built as a module?
Review
Quoted 2 lines
(quoted diff) +2
-0+ + return irq_valid ? IRQ_HANDLED : IRQ_NONE;
Please write a normal if statement, the ternery operator doesn't help legibility.
sound/soc/dwc/designware_i2s.c static inline void i2s_enable_irqs(struct dw_i2s_dev *dev, u32 stream, · line 146
Quoted 13 lines
static void i2s_start(struct
dw_i2s_dev*dev,sound/soc/dwc/designware_i2s.c +3
-1struct snd_pcm_substream *substream) {struct i2s_clk_config_data *config = &dev->config;i2s_write_reg (dev->i2s_base,IER ,1 ); -i2s_enable_irqs (dev, substream->stream, config->chan_nr); + +if (dev->use_pio) +i2s_enable_irqs (dev, substream->stream, config->chan_nr);if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )i2s_write_reg (dev->i2s_base,ITER ,1 );
That seems wrong, or at least something that should be separate? Previously we needed interrupts for DMA operation but now we enable interrupts only if we don't use DMA. It feels like we want to make the change for DMA separately if only to make it clear for bisection, are we 100% sure that masking the interrupt won't also mask the DMA request signals?
sound/soc/dwc/designware_i2s.c static int dw_i2s_probe(struct platform_device *pdev) · line 632
Quoted 12 lines
sound/soc/dwc/designware_i2s.c +12
-0+ irq =platform_get_irq (pdev,0 ); +if (irq >=0 ) { +dev_dbg (&pdev->dev,"using PIO mode\n" ); + dev->use_pio = true; + + ret =devm_request_irq (&pdev->dev, irq, i2s_irq_handler,0 , + pdev->name, dev); +if (ret <0 ) { +dev_err (&pdev->dev,"failed to request irq\n" ); +return ret; + } + }
This also seems wrong. We're forcing PIO if an interrupt is provided rather than based on DMA being configured which means that if the interrupt is wired up and happens to be described in DT we'll get worse performance. People should be able to just describe the system without worrying about this, and we might find some other use for the interrupts in future. Indeed right now it would probably be reasonable to use the error interrupts all the time if they're available.
Re: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
Hi Mark,
Thanks for your comments.
Quoted 5 lines · Mark Brown
sound/soc/dwc/Kconfig config SND_DESIGNWARE_I2S · line 11
Quoted 2 lines · Jose Abreu
sound/soc/dwc/Kconfig +2
-0+config SND_DESIGNWARE_PCM + bool "PCM PIO extension for I2S driver"Why can't this be built as a module?
I can change but my intention was to make this PCM a kind of extension to the driver instead of adding a new module to the system.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ + return irq_valid ? IRQ_HANDLED : IRQ_NONE;Please write a normal if statement, the ternery operator doesn't help legibility.
Ok.
Quoted 12 lines
Quoted 12 lines
static void i2s_start(struct
dw_i2s_dev*dev,sound/soc/dwc/designware_i2s.c +3
-1struct snd_pcm_substream *substream) {struct i2s_clk_config_data *config = &dev->config;i2s_write_reg (dev->i2s_base,IER ,1 ); -i2s_enable_irqs (dev, substream->stream, config->chan_nr); + +if (dev->use_pio) +i2s_enable_irqs (dev, substream->stream, config->chan_nr);
Quoted 8 lines
sound/soc/dwc/designware_i2s.c static inline void i2s_enable_irqs(struct dw_i2s_dev *dev, u32 stream, · line 146
Quoted 2 lines
sound/soc/dwc/designware_i2s.c +0
-0if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )i2s_write_reg (dev->i2s_base,ITER ,1 );That seems wrong, or at least something that should be separate? Previously we needed interrupts for DMA operation but now we enable interrupts only if we don't use DMA. It feels like we want to make the change for DMA separately if only to make it clear for bisection, are we 100% sure that masking the interrupt won't also mask the DMA request signals?
Indeed I thought about this and the interrupts must also be enabled when in DMA mode. Although there is no interrupt handler in the original driver (without this patches) in some setups the interrupt line may be connected to the DMA controller. I will drop this change and always enable interrupts. Please note that I don't have a setup with DMA support so I can only test using the PIO mode.
Quoted 11 lines
Quoted 11 lines
sound/soc/dwc/designware_i2s.c +11
-0+ irq =platform_get_irq (pdev,0 ); +if (irq >=0 ) { +dev_dbg (&pdev->dev,"using PIO mode\n" ); + dev->use_pio = true; + + ret =devm_request_irq (&pdev->dev, irq, i2s_irq_handler,0 , + pdev->name, dev); +if (ret <0 ) { +dev_err (&pdev->dev,"failed to request irq\n" ); +return ret; + }
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }This also seems wrong. We're forcing PIO if an interrupt is provided rather than based on DMA being configured which means that if the interrupt is wired up and happens to be described in DT we'll get worse performance. People should be able to just describe the system without worrying about this, and we might find some other use for the interrupts in future. Indeed right now it would probably be reasonable to use the error interrupts all the time if they're available.
How should I then determine which mode to use?
- Check if DMA parameters are declared in DT, or
- Check if snd_dmaengine_pcm_register() fails, or
- Assume PIO mode will be used when compiling with PIO PCM, or
- Something else ?
Best regards,
Jose Miguel Abreu
Mark Brown
maintainerRe: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
Quoted 1 line · Jose Abreu
On 24-05-2016 17:41, Mark Brown wrote:
Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.
Quoted 10 lines
Quoted 9 lines
sound/soc/dwc/designware_i2s.c static inline void i2s_enable_irqs(struct dw_i2s_dev *dev, u32 stream, · line 146
Quoted 2 lines
sound/soc/dwc/designware_i2s.c +0
-0if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )i2s_write_reg (dev->i2s_base,ITER ,1 );That seems wrong, or at least something that should be separate? Previously we needed interrupts for DMA operation but now we enable interrupts only if we don't use DMA. It feels like we want to make the change for DMA separately if only to make it clear for bisection, are we 100% sure that masking the interrupt won't also mask the DMA request signals?
Quoted 5 lines
Indeed I thought about this and the interrupts must also be enabled when in DMA mode. Although there is no interrupt handler in the original driver (without this patches) in some setups the interrupt line may be connected to the DMA controller. I will drop this change and always enable interrupts. Please note that I don't have a setup with DMA support so I can only test using the PIO mode.
Presumably you can talk to your hardware colleagues and get them to make you a FPGA with a DMA IP available?
Quoted 9 lines
Quoted 3 lines
This also seems wrong. We're forcing PIO if an interrupt is provided rather than based on DMA being configured which means that if the interrupt is wired up and happens to be described in DT we'll get worse
How should I then determine which mode to use?
- Check if DMA parameters are declared in DT, or
- Check ifsnd_dmaengine_pcm_register()fails, or
- Assume PIO mode will be used when compiling with PIO PCM, or
- Something else ?
You could either unconditionally register the PIO driver and only actually start using it if the driver is instantiated or you could check to see if the registration function works (handling deferred probe - if the DMA driver just didn't load yet you should wait for it).
Re: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
Hi Mark,
Quoted 14 lines · Mark Brown
Quoted 1 line · Jose Abreu
On 24-05-2016 17:41, Mark Brown wrote:
Please fix your mail client to word wrap within paragraphs at something substantially less than 80 columns. Doing this makes your messages much easier to read and reply to.
Quoted 8 lines
Quoted 8 lines
sound/soc/dwc/designware_i2s.c static inline void i2s_enable_irqs(struct dw_i2s_dev *dev, u32 stream, · line 146
Quoted 2 lines
sound/soc/dwc/designware_i2s.c +0
-0if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )i2s_write_reg (dev->i2s_base,ITER ,1 );That seems wrong, or at least something that should be separate? Previously we needed interrupts for DMA operation but now we enable interrupts only if we don't use DMA. It feels like we want to make the change for DMA separately if only to make it clear for bisection, are we 100% sure that masking the interrupt won't also mask the DMA request signals?
Quoted 7 lines
Quoted 5 lines
Indeed I thought about this and the interrupts must also be enabled when in DMA mode. Although there is no interrupt handler in the original driver (without this patches) in some setups the interrupt line may be connected to the DMA controller. I will drop this change and always enable interrupts. Please note that I don't have a setup with DMA support so I can only test using the PIO mode.
Presumably you can talk to your hardware colleagues and get them to make you a FPGA with a DMA IP available?
Its already in the todo list.
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
This also seems wrong. We're forcing PIO if an interrupt is provided rather than based on DMA being configured which means that if the interrupt is wired up and happens to be described in DT we'll get worse
How should I then determine which mode to use?
- Check if DMA parameters are declared in DT, or
- Check ifsnd_dmaengine_pcm_register()fails, or
- Assume PIO mode will be used when compiling with PIO PCM, or
- Something else ?
Quoted 4 lines
You could either unconditionally register the PIO driver and only actually start using it if the driver is instantiated or you could check to see if the registration function works (handling deferred probe - if the DMA driver just didn't load yet you should wait for it).
I think I will take the second option. Something like this:
"
ret = snd_dmaengine_pcm_register(...)
if (ret == -EPROBE_DEFER)
return ret;
else
pio_register(...);"?
Best regards,
Jose Miguel Abreu
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerRe: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
Quoted 8 lines · Jose Abreu
I think I will take the second option. Something like this:
"ret = snd_dmaengine_pcm_register(...) if (ret == -EPROBE_DEFER) return ret; else pio_register(...);"?
Sure. You should print a diagnostic if you fail to get the DMA, for any real system it's going to be a bug.
Re: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
Hi Mark,
Quoted 10 lines · Mark Brown
Quoted 8 lines · Jose Abreu
I think I will take the second option. Something like this:
"ret = snd_dmaengine_pcm_register(...) if (ret == -EPROBE_DEFER) return ret; else pio_register(...);"?
Quoted 2 lines
Sure. You should print a diagnostic if you fail to get the DMA, for any real system it's going to be a bug.
Ok, will do that. I noticed the last I2S patch that you merged ("ASoC: dwc: Add helper functions to disable/enable irqs") is not in for-next yet. Should I base my work on 'topic/dwc' branch?
Best regards,
Jose Miguel Abreu
Mark Brown
maintainerRe: [PATCH 3/4 v7] ASoC: dwc: Add PIO PCM extension
Quoted 3 lines · Jose Abreu
Ok, will do that. I noticed the last I2S patch that you merged ("ASoC: dwc: Add helper functions to disable/enable irqs") is not in for-next yet. Should I base my work on 'topic/dwc' branch?
We are in the merge window. No new non-bugfix patches will be merged until the merge window ends, most likely sometime this weekend.
PATCH v7 4/4 ASoC: dwc: Add irq parameter to DOCUMENTATION
In reply to Jose AbreuA parameter description for the interruptions of the I2S controller was added. This interrupt parameter should only be set when I2S does not have DMA support.
---
Changes v6 -> v7:
* interrupts is now optional property
No changes v5 -> v6.
Changes v4 -> v5:
* interrupts is now required property
* Drop 'snps-use-dmaengine' property
This patch was only introduced in v4.
Documentation/devicetree/bindings/sound/designware-i2s.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/sound/designware-i2s.txt +4 -0
@@ -12,6 +12,10 @@ Required properties: one for receive. - dma-names : "tx" for the transmit channel, "rx" for the receive channel. +Optional properties: + - interrupts: The interrupt line number for the I2S controller. Add this + parameter if the I2S controller that you are using does not support DMA. + For more details on the 'dma', 'dma-names', 'clock' and 'clock-names' properties please check: * resource-names.txt
Signature · 1 line
1.9.1
Re: [PATCH 4/4 v7] ASoC: dwc: Add irq parameter to DOCUMENTATION
Quoted 23 lines · Jose Abreu
A parameter description for the interruptions of the I2S controller was added. This interrupt parameter should only be set when I2S does not have DMA support.
Signed-off-by Jose Abreu <[email protected]>Cc Carlos Palminha <[email protected]>Cc Mark Brown <[email protected]>Cc Liam Girdwood <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Rob Herring <[email protected]>Cc Alexey Brodkin <[email protected]>---
Changes v6 -> v7:
* interrupts is now optional propertyNo changes v5 -> v6.
Quoted 8 lines
Changes v4 -> v5:
* interrupts is now required property
* Drop 'snps-use-dmaengine' propertyThis patch was only introduced in v4.
Documentation/devicetree/bindings/sound/designware-i2s.txt | 4 ++++ 1 file changed, 4 insertions(+)
Mark Brown
maintainerApplied "ASoC: dwc: Add irq parameter to DOCUMENTATION" to the asoc tree
In reply to Jose AbreuThe patch
ASoC: dwc: Add irq parameter to DOCUMENTATION
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
5aa1418defb0e88fb7f70c5b112d531cfcede851Mon Sep 17 00:00:00 2001
From: Jose Abreu <[email protected]>
Date: Thu, 9 Jun 2016 12:47:06 +0100
Subject: [PATCH] ASoC: dwc: Add irq parameter to DOCUMENTATION
A parameter description for the interruptions of the I2S controller was added.
--- Documentation/devicetree/bindings/sound/designware-i2s.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/sound/designware-i2s.txt +4 -0
@@ -12,6 +12,10 @@ Required properties: one for receive. - dma-names : "tx" for the transmit channel, "rx" for the receive channel. +Optional properties: + - interrupts: The interrupt line number for the I2S controller. Add this + parameter if the I2S controller that you are using does not support DMA. + For more details on the 'dma', 'dma-names', 'clock' and 'clock-names' properties please check: * resource-names.txt
Signature · 1 line
2.8.1