Add Freescale ASRC driver
Subsystems (5)
Nicolin Chen
reviewerv2 cover Add Freescale ASRC driver
This series of patches add Freescale ASRC module driver support along with the extra request in imx-sdma structure required by SDMA Device to Device script.
The previous version has been in the maillist for nearly six months without any comment and reply. So I decide to drop the SDMA part's change since this series focus on ASRC support (Later, we can send SDMA part separately.) so that ASRC driver may get upstream first.
Changelog
v2:
* PATCH-1: Dropped the change to SDMA driver.
* PATCH-2: Dropped useless member in private data structures.
* PATCH-2: Refined some comments in fsl_asrc_dma.c driver.
* PATCH-2: Refined commit comments.
Nicolin Chen (2):
ARM: imx: Add the secondary request into the structure for imx-sdma
ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
.../devicetree/bindings/sound/fsl,asrc.txt | 62 ++ include/linux/platform_data/dma-imx.h | 1 + sound/soc/fsl/Kconfig | 9 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_asrc.c | 1031 ++++++++++++++++++++ sound/soc/fsl/fsl_asrc.h | 461 +++++++++ sound/soc/fsl/fsl_asrc_dma.c | 384 ++++++++ 7 files changed, 1950 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/fsl,asrc.txt create mode 100644 sound/soc/fsl/fsl_asrc.c create mode 100644 sound/soc/fsl/fsl_asrc.h create mode 100644 sound/soc/fsl/fsl_asrc_dma.c
Signature · 1 line
1.8.4
Nicolin Chen
reviewerPATCH v2 1/2 ARM: imx: Add the secondary request into the structure for imx-sdma
SDMA supports device to device (per_2_per) scripts to handle DMA transfering between two peripheral devices. The per_2_per script, however, needs two dma requests from two sides while the current structure only defined one request.
So this patch just simply adds the secondary request so as to let SDMA and its user to add its implementation later.
[ Both change in the SDMA driver and its users like Freescale ASRC ASoC driver
should be taken along with this change in order to truly support per_2_per sciprts. However, we here make an expediency by adding this first so that we can add either side later since this patch won't break any function and meanwhile it can make merge window more smoothly: we don't need to apply the change inside dmaengine branch via ASoC tree any more. -- Nicolin ]
--- include/linux/platform_data/dma-imx.h | 1 + 1 file changed, 1 insertion(+)
include/linux/platform_data/dma-imx.h +1 -0
@@ -51,6 +51,7 @@ enum imx_dma_prio {struct imx_dma_data {int dma_request;/* DMA request line */ +int dma_request2;/* secondary DMA request line */ enum sdma_peripheral_type peripheral_type;int priority; };
Signature · 1 line
1.8.4
Re: [PATCH v2 1/2] ARM: imx: Add the secondary request into the structure for imx-sdma
Quoted 7 lines · Nicolin Chen
SDMA supports device to device (
per_2_per) scripts to handle DMA transfering between two peripheral devices. Theper_2_perscript, however, needs two dma requests from two sides while the current structure only defined one request.So this patch just simply adds the secondary request so as to let SDMA and its user to add its implementation later.
Quoted 8 lines
[ Both change in the SDMA driver and its users like Freescale ASRC ASoC driver
should be taken along with this change in order to truly supportper_2_persciprts. However, we here make an expediency by adding this first so that we can add either side later since this patch won't break any function and meanwhile it can make merge window more smoothly: we don't need to apply the change inside dmaengine branch via ASoC tree any more. -- Nicolin ]Signed-off-by Nicolin Chen <[email protected]>
Nicolin Chen
reviewerPATCH v2 2/2 ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
In reply to Nicolin ChenThe Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a signal associated with an input clock into a signal associated with a different output clock. The driver currently works as a Front End of DPCM with other Back Ends DAI links such as ESAI<->CS42888 and SSI<->WM8962 and SAI. It converts the original sample rate to a common rate supported by Back Ends for playback while converts the common rate of Back Ends to a desired rate for capture. It has 3 pairs to support three different substreams within totally 10 channels.
--- .../devicetree/bindings/sound/fsl,asrc.txt | 62 ++ sound/soc/fsl/Kconfig | 9 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/fsl_asrc.c | 1031 ++++++++++++++++++++ sound/soc/fsl/fsl_asrc.h | 461 +++++++++ sound/soc/fsl/fsl_asrc_dma.c | 384 ++++++++ 6 files changed, 1949 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/fsl,asrc.txt create mode 100644 sound/soc/fsl/fsl_asrc.c create mode 100644 sound/soc/fsl/fsl_asrc.h create mode 100644 sound/soc/fsl/fsl_asrc_dma.c
Documentation/devicetree/bindings/sound/fsl,asrc.txt new file +62 -0
@@ -0,0 +1,62 @@ +Freescale Asynchronous Sample Rate Converter (ASRC) Controller + +The Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a +signal associated with an input clock into a signal associated with a different +output clock. The driver currently works as a Front End of DPCM with other Back +Ends Audio controller such as ESAI, SSI and SAI. It has three pairs to support +three substreams within totally 10 channels. + +Required properties: + + - compatible : Compatible list, must contain "fsl,imx35-asrc" or + "fsl,imx53-asrc". + + - reg : Offset and length of the register set for the device. + + - interrupts : Contains the spdif interrupt. + + - dmas : Generic dma devicetree binding as described in + Documentation/devicetree/bindings/dma/dma.txt. + + - dma-names : Six dmas have to be defined: "rxa", "rxb", "rxc", "txa", "txb", + and "txc". + + - clocks : Contains an entry for each entry in clock-names. + + - clock-names : Includes the following entries: + "mem" Peripheral access clock to access registers. + "ipg" Peripheral clock to driver module. + "asrck_<0-f>" Clock sources for input and output clock. + + - big-endian : If this property is absent, the native endian mode will + be in use as default, or the big endian mode will be in use + for all the device registers. + + - fsl,asrc-rate : Defines a mutual sample rate used by Back End DAI link. + + - fsl,asrc-width : Defines a mutual sample width used by Back End DAI link. + +Example: + +asrc: asrc@02034000 { + compatible = "fsl,imx53-asrc"; + reg = <0x02034000 0x4000>; + interrupts = <0 50 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks 107>, <&clks 107>, <&clks 0>, + <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, + <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, + <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, + <&clks 107>, <&clks 0>, <&clks 0>; + clock-names = "mem", "ipg", "asrck0", + "asrck_1", "asrck_2", "asrck_3", "asrck_4", + "asrck_5", "asrck_6", "asrck_7", "asrck_8", + "asrck_9", "asrck_a", "asrck_b", "asrck_c", + "asrck_d", "asrck_e", "asrck_f"; + dmas = <&sdma 17 23 1>, <&sdma 18 23 1>, <&sdma 19 23 1>, + <&sdma 20 23 1>, <&sdma 21 23 1>, <&sdma 22 23 1>; + dma-names = "rxa", "rxb", "rxc", + "txa", "txb", "txc"; + fsl,asrc-rate = <48000>; + fsl,asrc-width = <16>; + status = "okay"; +};
sound/soc/fsl/Kconfig +9 -0
@@ -2,6 +2,15 @@ menu "SoC Audio for Freescale CPUs" comment "Common SoC Audio options for Freescale CPUs:" +config SND_SOC_FSL_ASRC + tristate "Asynchronous Sample Rate Converter (ASRC) module support" + select REGMAP_MMIO + help + Say Y if you want to add Asynchronous Sample Rate Converter (ASRC) + support for the Freescale CPUs. + This option is only useful for out-of-tree drivers since + in-tree drivers select it automatically. + config SND_SOC_FSL_SAI tristate "Synchronous Audio Interface (SAI) module support" select REGMAP_MMIO
sound/soc/fsl/Makefile +2 -0
@@ -11,6 +11,7 @@ snd-soc-p1022-rdk-objs := p1022_rdk.o obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o # Freescale SSI/DMA/SAI/SPDIF Support +snd-soc-fsl-asrc-objs := fsl_asrc.o fsl_asrc_dma.o snd-soc-fsl-sai-objs := fsl_sai.o snd-soc-fsl-ssi-y := fsl_ssi.o snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o
@@ -18,6 +19,7 @@ snd-soc-fsl-spdif-objs := fsl_spdif.o snd-soc-fsl-esai-objs := fsl_esai.o snd-soc-fsl-utils-objs := fsl_utils.o snd-soc-fsl-dma-objs := fsl_dma.o +obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o
sound/soc/fsl/fsl_asrc.c new file +1031 -0
1,031 lines not on this page · raw message
sound/soc/fsl/fsl_asrc.h new file +461 -0
461 lines not on this page · raw message
sound/soc/fsl/fsl_asrc_dma.c new file +384 -0
384 lines not on this page · raw message
Signature · 1 line
1.8.4
Re: [PATCH v2 2/2] ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
Quoted 10 lines · Nicolin Chen
The Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a signal associated with an input clock into a signal associated with a different output clock. The driver currently works as a Front End of DPCM with other Back Ends DAI links such as ESAI<->CS42888 and SSI<->WM8962 and SAI. It converts the original sample rate to a common rate supported by Back Ends for playback while converts the common rate of Back Ends to a desired rate for capture. It has 3 pairs to support three different substreams within totally 10 channels.
Signed-off-by Nicolin Chen <[email protected]>---
[...]
Quoted 3 lines
sound/soc/fsl/fsl_asrc.c new file +0
-0@@ -0,0 +1,1031 @@
[...]
sound/soc/fsl/fsl_asrc.c line 1021
Quoted 5 lines
sound/soc/fsl/fsl_asrc.c new file +5
-0+static struct platform_driver fsl_asrc_driver = { + .probe = fsl_asrc_probe, + .driver = { + .name ="fsl-asrc" , + .owner =THIS_MODULE ,
Not necessary, this will be set by module_platform_driver (or the expansion of platform_driver_register, respectively).
Quoted 5 lines
sound/soc/fsl/fsl_asrc.c new file +5
-0+ .of_match_table = fsl_asrc_ids, + .pm = &fsl_asrc_pm, + }, +}; +module_platform_driver (fsl_asrc_driver);
[...]
Quoted 3 lines
sound/soc/fsl/fsl_asrc_dma.c new file +0
-0@@ -0,0 +1,384 @@
[...]
sound/soc/fsl/fsl_asrc_dma.c line 339
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c new file +10
-0+static int fsl_asrc_dma_pcm_new (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_card *card = rtd->card->snd_card; +struct snd_pcm_substream *substream; +struct snd_pcm *pcm = rtd->pcm; +u64 dma_mask =DMA_BIT_MASK (32 ); +int ret, i; + +if (!card->dev->dma_mask) + card->dev->dma_mask = &dma_mask;
dma_mask will go out of scope after fsl_asrc_dma_pcm_new returns, resulting in a stray pointer in card->dev->dma_mask.
Quoted 47 lines
sound/soc/fsl/fsl_asrc_dma.c new file +45
-0+if (!card->dev->coherent_dma_mask) + card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); + +for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_LAST ; i++) { + substream = pcm->streams[i].substream; + + ret =snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV , pcm->card->dev, +FSL_ASRC_DMABUF_SIZE , &substream->dma_buffer); +if (ret) { +dev_err (card->dev,"failed to allocate DMA buffer\n" ); + goto err; + } + } + +return 0 ; + +err: +if (--i ==0 ) +snd_dma_free_pages (&pcm->streams[i].substream->dma_buffer); + +return ret; +} + +static void fsl_asrc_dma_pcm_free (struct snd_pcm *pcm) +{ +struct snd_pcm_substream *substream; +int i; + +for (i =SNDRV_PCM_STREAM_PLAYBACK ; i <=SNDRV_PCM_STREAM_LAST ; i++) { + substream = pcm->streams[i].substream; +if (!substream) +continue ; + +snd_dma_free_pages (&substream->dma_buffer); + substream->dma_buffer.area =NULL ; + substream->dma_buffer.addr =0 ; + } +} + +struct snd_soc_platform_driver fsl_asrc_platform = { + .ops = &fsl_asrc_dma_pcm_ops, + .pcm_new = fsl_asrc_dma_pcm_new, + .pcm_free = fsl_asrc_dma_pcm_free, +}; +EXPORT_SYMBOL_GPL (fsl_asrc_platform);Signature · 1 line
1.8.4
--
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
Re: [PATCH v2 2/2] ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers
Hi Tobias,
Quoted 43 lines · Tobias Klauser
Quoted 10 lines · Nicolin Chen
The Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a signal associated with an input clock into a signal associated with a different output clock. The driver currently works as a Front End of DPCM with other Back Ends DAI links such as ESAI<->CS42888 and SSI<->WM8962 and SAI. It converts the original sample rate to a common rate supported by Back Ends for playback while converts the common rate of Back Ends to a desired rate for capture. It has 3 pairs to support three different substreams within totally 10 channels.
Signed-off-by Nicolin Chen <[email protected]>---
[...]
Quoted 3 lines
sound/soc/fsl/fsl_asrc.c new file +0
-0@@ -0,0 +1,1031 @@[...]
sound/soc/fsl/fsl_asrc.c line 1021
Quoted 5 lines
sound/soc/fsl/fsl_asrc.c new file +5
-0+static struct platform_driver fsl_asrc_driver = { + .probe = fsl_asrc_probe, + .driver = { + .name ="fsl-asrc" , + .owner =THIS_MODULE ,Not necessary, this will be set by
module_platform_driver(or the expansion ofplatform_driver_register, respectively).Quoted 5 lines
sound/soc/fsl/fsl_asrc.c new file +5
-0+ .of_match_table = fsl_asrc_ids, + .pm = &fsl_asrc_pm, + }, +}; +module_platform_driver (fsl_asrc_driver);[...]
Quoted 3 lines
sound/soc/fsl/fsl_asrc_dma.c new file +0
-0@@ -0,0 +1,384 @@[...]
Quoted 13 lines
sound/soc/fsl/fsl_asrc_dma.c line 339
Quoted 10 lines
sound/soc/fsl/fsl_asrc_dma.c new file +10
-0+static int fsl_asrc_dma_pcm_new (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_card *card = rtd->card->snd_card; +struct snd_pcm_substream *substream; +struct snd_pcm *pcm = rtd->pcm; +u64 dma_mask =DMA_BIT_MASK (32 ); +int ret, i; + +if (!card->dev->dma_mask) + card->dev->dma_mask = &dma_mask;
dma_maskwill go out of scope afterfsl_asrc_dma_pcm_newreturns, resulting in a stray pointer incard->dev->dma_mask.
Will fix them in v3.
Thank you
Nicolin