ASoC: samsung: pass DMA channels as pointers
Subsystems (7)
PATCH v2 1/1 ASoC: samsung: pass DMA channels as pointers
ARM64 allmodconfig produces a bunch of warnings when building the samsung ASoC code:
sound/soc/samsung/dmaengine.c: In function 'samsung_asoc_init_dma_data':sound/soc/samsung/dmaengine.c:53:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
playback_data->filter_data = (void *)playback->channel;sound/soc/samsung/dmaengine.c:60:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
capture_data->filter_data = (void *)capture->channel;
We could easily shut up the warning by adding an intermediate cast, but there is a bigger underlying problem: The use of IORESOURCE_DMA to pass data from platform code to device drivers is dubious to start with, as what we really want is a pointer that can be passed into a filter function.
Note that on s3c64xx, the pl08x DMA data is already a pointer, but gets cast to resource_size_t so we can pass it as a resource, and it then gets converted back to a pointer. In contrast, the data we pass for s3c24xx is an index into a device specific table, and we artificially convert that into a pointer for the filter function.
---
v2:
- no longer clash with SPI patch
- don't reference platform data that might be NULL
arch/arm/mach-s3c64xx/dev-audio.c +23 -18
@@ -54,12 +54,12 @@ static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)static struct resource s3c64xx_iis0_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_IIS0 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_I2S0_OUT ), - [2 ] =DEFINE_RES_DMA (DMACH_I2S0_IN ), }; -static struct s3c_audio_pdata i2sv3_pdata = { +static struct s3c_audio_pdata i2s0_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_playback =DMACH_I2S0_OUT , + .dma_capture =DMACH_I2S0_IN , };struct platform_device s3c64xx_device_iis0 = {
@@ -68,15 +68,19 @@ struct platform_device s3c64xx_device_iis0 = { .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), .resource = s3c64xx_iis0_resource, .dev = { - .platform_data = &i2sv3_pdata, + .platform_data = &i2s0_pdata, }, };EXPORT_SYMBOL (s3c64xx_device_iis0);static struct resource s3c64xx_iis1_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_IIS1 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_I2S1_OUT ), - [2 ] =DEFINE_RES_DMA (DMACH_I2S1_IN ), +}; + +static struct s3c_audio_pdata i2s1_pdata = { + .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_playback =DMACH_I2S1_OUT , + .dma_capture =DMACH_I2S1_IN , };struct platform_device s3c64xx_device_iis1 = {
@@ -85,19 +89,19 @@ struct platform_device s3c64xx_device_iis1 = { .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), .resource = s3c64xx_iis1_resource, .dev = { - .platform_data = &i2sv3_pdata, + .platform_data = &i2s1_pdata, }, };EXPORT_SYMBOL (s3c64xx_device_iis1);static struct resource s3c64xx_iisv4_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_IISV4 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_HSI_I2SV40_TX ), - [2 ] =DEFINE_RES_DMA (DMACH_HSI_I2SV40_RX ), };static struct s3c_audio_pdata i2sv4_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_playback =DMACH_HSI_I2SV40_TX , + .dma_capture =DMACH_HSI_I2SV40_RX , .type = { .i2s = { .quirks =QUIRK_PRI_6CHAN ,
@@ -142,12 +146,12 @@ static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)static struct resource s3c64xx_pcm0_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_PCM0 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_PCM0_TX ), - [2 ] =DEFINE_RES_DMA (DMACH_PCM0_RX ), };static struct s3c_audio_pdata s3c_pcm0_pdata = { .cfg_gpio = s3c64xx_pcm_cfg_gpio, + .dma_capture =DMACH_PCM0_RX , + .dma_playback =DMACH_PCM0_TX , };struct platform_device s3c64xx_device_pcm0 = {
@@ -163,12 +167,12 @@ EXPORT_SYMBOL(s3c64xx_device_pcm0);static struct resource s3c64xx_pcm1_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_PCM1 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_PCM1_TX ), - [2 ] =DEFINE_RES_DMA (DMACH_PCM1_RX ), };static struct s3c_audio_pdata s3c_pcm1_pdata = { .cfg_gpio = s3c64xx_pcm_cfg_gpio, + .dma_playback =DMACH_PCM1_TX , + .dma_capture =DMACH_PCM1_RX , };struct platform_device s3c64xx_device_pcm1 = {
@@ -196,13 +200,14 @@ static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)static struct resource s3c64xx_ac97_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_AC97 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_AC97_PCMOUT ), - [2 ] =DEFINE_RES_DMA (DMACH_AC97_PCMIN ), - [3 ] =DEFINE_RES_DMA (DMACH_AC97_MICIN ), - [4 ] =DEFINE_RES_IRQ (IRQ_AC97 ), + [1 ] =DEFINE_RES_IRQ (IRQ_AC97 ), }; -static struct s3c_audio_pdata s3c_ac97_pdata; +static struct s3c_audio_pdata s3c_ac97_pdata = { + .dma_playback =DMACH_AC97_PCMOUT , + .dma_capture =DMACH_AC97_PCMIN , + .dma_capture_mic =DMACH_AC97_MICIN , +};static u64 s3c64xx_ac97_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-s3c64xx/include/mach/dma.h +26 -26
64 lines not on this page · raw message
arch/arm/plat-samsung/devs.c +8 -3
@@ -65,6 +65,7 @@#include <linux/platform_data/usb-ohci-s3c2410.h> #include <plat/usb-phy.h> #include <plat/regs-spi.h> +#include <linux/platform_data/asoc-s3c.h> #include <linux/platform_data/spi-s3c64xx.h> static u64 samsung_device_dma_mask =DMA_BIT_MASK (32 );
@@ -74,9 +75,12 @@ static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);static struct resource s3c_ac97_resource[] = { [0 ] =DEFINE_RES_MEM (S3C2440_PA_AC97 ,S3C2440_SZ_AC97 ), [1 ] =DEFINE_RES_IRQ (IRQ_S3C244X_AC97 ), - [2 ] =DEFINE_RES_DMA_NAMED (DMACH_PCM_OUT ,"PCM out" ), - [3 ] =DEFINE_RES_DMA_NAMED (DMACH_PCM_IN ,"PCM in" ), - [4 ] =DEFINE_RES_DMA_NAMED (DMACH_MIC_IN ,"Mic in" ), +}; + +static struct s3c_audio_pdata s3c_ac97_pdata = { + .dma_playback = (void *)DMACH_PCM_OUT , + .dma_capture = (void *)DMACH_PCM_IN , + .dma_capture_mic = (void *)DMACH_MIC_IN , };struct platform_device s3c_device_ac97 = {
@@ -87,6 +91,7 @@ struct platform_device s3c_device_ac97 = { .dev = { .dma_mask = &samsung_device_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &s3c_ac97_pdata, } };#endif /* CONFIG_CPU_S3C2440 */
include/linux/platform_data/asoc-s3c.h +4 -0
@@ -39,6 +39,10 @@ struct samsung_i2s {*/ struct s3c_audio_pdata {int (*cfg_gpio)(struct platform_device *); +void *dma_playback; +void *dma_capture; +void *dma_play_sec; +void *dma_capture_mic;union {struct samsung_i2s i2s; } type;
sound/soc/samsung/ac97.c +4 -22
@@ -324,7 +324,7 @@ static const struct snd_soc_component_driver s3c_ac97_component = {static int s3c_ac97_probe (struct platform_device *pdev) { -struct resource *mem_res, *dmatx_res, *dmarx_res, *dmamic_res, *irq_res; +struct resource *mem_res, *irq_res;struct s3c_audio_pdata *ac97_pdata;int ret;
@@ -335,24 +335,6 @@ static int s3c_ac97_probe(struct platform_device *pdev) }/* Check for availability of necessary resource */ - dmatx_res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!dmatx_res) { -dev_err (&pdev->dev,"Unable to get AC97-TX dma resource\n" ); -return -ENXIO ; - } - - dmarx_res =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); -if (!dmarx_res) { -dev_err (&pdev->dev,"Unable to get AC97-RX dma resource\n" ); -return -ENXIO ; - } - - dmamic_res =platform_get_resource (pdev,IORESOURCE_DMA ,2 ); -if (!dmamic_res) { -dev_err (&pdev->dev,"Unable to get AC97-MIC dma resource\n" ); -return -ENXIO ; - } - irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );if (!irq_res) {dev_err (&pdev->dev,"AC97 IRQ not provided!\n" );
@@ -364,11 +346,11 @@ static int s3c_ac97_probe(struct platform_device *pdev)if (IS_ERR (s3c_ac97.regs))return PTR_ERR (s3c_ac97.regs); - s3c_ac97_pcm_out.channel = dmatx_res->start; + s3c_ac97_pcm_out.slave = ac97_pdata->dma_playback; s3c_ac97_pcm_out.dma_addr = mem_res->start +S3C_AC97_PCM_DATA ; - s3c_ac97_pcm_in.channel = dmarx_res->start; + s3c_ac97_pcm_in.slave = ac97_pdata->dma_capture; s3c_ac97_pcm_in.dma_addr = mem_res->start +S3C_AC97_PCM_DATA ; - s3c_ac97_mic_in.channel = dmamic_res->start; + s3c_ac97_mic_in.slave = ac97_pdata->dma_capture_mic; s3c_ac97_mic_in.dma_addr = mem_res->start +S3C_AC97_MIC_DATA ;init_completion (&s3c_ac97.done);
sound/soc/samsung/dma.h +1 -1
@@ -15,7 +15,7 @@#include <sound/dmaengine_pcm.h> struct s3c_dma_params { -int channel;/* Channel ID */ +void *slave;/* Channel ID */ dma_addr_t dma_addr;int dma_size;/* Size of the DMA transfer */ char *ch_name;
sound/soc/samsung/dmaengine.c +2 -2
@@ -50,14 +50,14 @@ void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,if (playback) { playback_data = &playback->dma_data; - playback_data->filter_data = (void *)playback->channel; + playback_data->filter_data = playback->slave; playback_data->chan_name = playback->ch_name; playback_data->addr = playback->dma_addr; playback_data->addr_width = playback->dma_size; }if (capture) { capture_data = &capture->dma_data; - capture_data->filter_data = (void *)capture->channel; + capture_data->filter_data = capture->slave; capture_data->chan_name = capture->ch_name; capture_data->addr = capture->dma_addr; capture_data->addr_width = capture->dma_size;
sound/soc/samsung/i2s.c +5 -21
@@ -1257,27 +1257,14 @@ static int samsung_i2s_probe(struct platform_device *pdev) pri_dai->lock = &pri_dai->spinlock;if (!np) { - res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!res) { -dev_err (&pdev->dev, -"Unable to get I2S-TX dma resource\n" ); -return -ENXIO ; - } - pri_dai->dma_playback.channel = res->start; - - res =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); -if (!res) { -dev_err (&pdev->dev, -"Unable to get I2S-RX dma resource\n" ); -return -ENXIO ; - } - pri_dai->dma_capture.channel = res->start; -if (i2s_pdata ==NULL ) {dev_err (&pdev->dev,"Can't work without s3c_audio_pdata\n" );return -EINVAL ; } + pri_dai->dma_playback.slave = i2s_pdata->dma_playback; + pri_dai->dma_capture.slave = i2s_pdata->dma_capture; +if (&i2s_pdata->type) i2s_cfg = &i2s_pdata->type.i2s;
@@ -1338,11 +1325,8 @@ static int samsung_i2s_probe(struct platform_device *pdev) sec_dai->dma_playback.dma_addr = regs_base +I2STXDS ; sec_dai->dma_playback.ch_name ="tx-sec" ; -if (!np) { - res =platform_get_resource (pdev,IORESOURCE_DMA ,2 ); -if (res) - sec_dai->dma_playback.channel = res->start; - } +if (!np) + sec_dai->dma_playback.slave = i2s_pdata->dma_play_sec; sec_dai->dma_playback.dma_size =4 ; sec_dai->addr = pri_dai->addr;
sound/soc/samsung/pcm.c +5 -15
@@ -486,7 +486,7 @@ static const struct snd_soc_component_driver s3c_pcm_component = {static int s3c_pcm_dev_probe (struct platform_device *pdev) {struct s3c_pcm_info *pcm; -struct resource *mem_res, *dmatx_res, *dmarx_res; +struct resource *mem_res;struct s3c_audio_pdata *pcm_pdata;int ret;
@@ -499,18 +499,6 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) pcm_pdata = pdev->dev.platform_data;/* Check for availability of necessary resource */ - dmatx_res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!dmatx_res) { -dev_err (&pdev->dev,"Unable to get PCM-TX dma resource\n" ); -return -ENXIO ; - } - - dmarx_res =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); -if (!dmarx_res) { -dev_err (&pdev->dev,"Unable to get PCM-RX dma resource\n" ); -return -ENXIO ; - } - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem_res) {dev_err (&pdev->dev,"Unable to get register resource\n" );
@@ -568,8 +556,10 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) s3c_pcm_stereo_out[pdev->id].dma_addr = mem_res->start +S3C_PCM_TXFIFO ; - s3c_pcm_stereo_in[pdev->id].channel = dmarx_res->start; - s3c_pcm_stereo_out[pdev->id].channel = dmatx_res->start; +if (pcm_pdata) { + s3c_pcm_stereo_in[pdev->id].slave = pcm_pdata->dma_capture; + s3c_pcm_stereo_out[pdev->id].slave = pcm_pdata->dma_playback; + } pcm->dma_capture = &s3c_pcm_stereo_in[pdev->id]; pcm->dma_playback = &s3c_pcm_stereo_out[pdev->id];
sound/soc/samsung/s3c2412-i2s.c +2 -2
@@ -34,13 +34,13 @@#include "s3c2412-i2s.h" static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { - .channel =DMACH_I2S_OUT , + .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =4 , };static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { - .channel =DMACH_I2S_IN , + .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =4 , };
sound/soc/samsung/s3c24xx-i2s.c +2 -2
@@ -32,13 +32,13 @@#include "s3c24xx-i2s.h" static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { - .channel =DMACH_I2S_OUT , + .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =2 , };static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { - .channel =DMACH_I2S_IN , + .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =2 , };
sound/soc/samsung/spdif.c +2 -8
@@ -359,7 +359,7 @@ static const struct snd_soc_component_driver samsung_spdif_component = {static int spdif_probe (struct platform_device *pdev) {struct s3c_audio_pdata *spdif_pdata; -struct resource *mem_res, *dma_res; +struct resource *mem_res;struct samsung_spdif_info *spdif;int ret;
@@ -367,12 +367,6 @@ static int spdif_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"Entered %s\n" , __func__); - dma_res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!dma_res) { -dev_err (&pdev->dev,"Unable to get dma resource.\n" ); -return -ENXIO ; - } - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem_res) {dev_err (&pdev->dev,"Unable to get register resource.\n" );
@@ -432,7 +426,7 @@ static int spdif_probe(struct platform_device *pdev) spdif_stereo_out.dma_size =2 ; spdif_stereo_out.dma_addr = mem_res->start +DATA_OUTBUF ; - spdif_stereo_out.channel = dma_res->start; + spdif_stereo_out.slave = spdif_pdata ? spdif_pdata->dma_playback :NULL ; spdif->dma_playback = &spdif_stereo_out;
PATCH v2 2/3 ASoC: s3c24xx-i2s: pass DMA channels as platform data
This is a minor cleanup to make the s3c2412-i2s and s3c24xx-i2s drivers independent of the mach/dma.h header file and to allow removing the dependency on the specific dmaengine driver in the next patch.
As a side not, only the s3c24xx-i2s driver seems to still be used, while the definition of the s3c2412-i2s platform device was removed in commit 6d259a25b56d ("ARM: SAMSUNG: use static declaration when it is not used in other files") after it had never been referenced since its introduction in f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support").
Apparently it should have been used by mach-jive.c, but that never happened. My patch at this point leaves the current state unchanged, we can decide whether to fix or delete the jive driver and s3c2412-i2s another time.
---
v2: check for NULL pdata
arch/arm/plat-samsung/devs.c +6 -0
@@ -571,6 +571,11 @@ static struct resource s3c_iis_resource[] = { [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS), }; +static struct s3c_audio_pdata s3c_iis_platdata = { + .dma_playback = (void *)DMACH_I2S_OUT , + .dma_capture = (void *)DMACH_I2S_IN , +}; +struct platform_device s3c_device_iis = { .name ="s3c24xx-iis" , .id =-1 ,
@@ -579,6 +584,7 @@ struct platform_device s3c_device_iis = { .dev = { .dma_mask = &samsung_device_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &s3c_iis_platdata, } };#endif /* CONFIG_PLAT_S3C24XX */
sound/soc/samsung/s3c2412-i2s.c +10 -2
@@ -33,14 +33,14 @@#include "regs-i2s-v2.h" #include "s3c2412-i2s.h" +#include <linux/platform_data/asoc-s3c.h.h> +static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { - .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =4 , };static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { - .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =4 , };
@@ -152,6 +152,12 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev) {int ret =0 ;struct resource *res; +struct s3c_audio_pdata *pdata =dev_get_platdata (&pdev->dev); + +if (!pdata) { +dev_err (&pdev->dev,"missing platform data" ); +return -ENXIO ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); s3c2412_i2s.regs =devm_ioremap_resource (&pdev->dev, res);
@@ -159,7 +165,9 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev)return PTR_ERR (s3c2412_i2s.regs); s3c2412_i2s_pcm_stereo_out.dma_addr = res->start +S3C2412_IISTXD ; + s3c2412_i2s_pcm_stereo_out.slave = pdata->dma_playback; s3c2412_i2s_pcm_stereo_in.dma_addr = res->start +S3C2412_IISRXD ; + s3c2412_i2s_pcm_stereo_in.slave = pdata->dma_capture; ret = s3c_i2sv2_register_component(&pdev->dev, -1, &s3c2412_i2s_component,
sound/soc/samsung/s3c24xx-i2s.c +10 -2
@@ -31,14 +31,14 @@#include "dma.h" #include "s3c24xx-i2s.h" +#include <linux/platform_data/asoc-s3c.h> +static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { - .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =2 , };static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { - .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =2 , };
@@ -454,6 +454,12 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev) {int ret =0 ;struct resource *res; +struct s3c_audio_pdata *pdata =dev_get_platdata (&pdev->dev); + +if (!pdata) { +dev_err (&pdev->dev,"missing platform data" ); +return -ENXIO ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) {
@@ -465,7 +471,9 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev)return PTR_ERR (s3c24xx_i2s.regs); s3c24xx_i2s_pcm_stereo_out.dma_addr = res->start +S3C2410_IISFIFO ; + s3c24xx_i2s_pcm_stereo_out.slave = pdata->dma_playback; s3c24xx_i2s_pcm_stereo_in.dma_addr = res->start +S3C2410_IISFIFO ; + s3c24xx_i2s_pcm_stereo_in.slave = pdata->dma_capture; ret =devm_snd_soc_register_component (&pdev->dev, &s3c24xx_i2s_component, &s3c24xx_i2s_dai,1 );
Re: [PATCHv2 2/3] ASoC: s3c24xx-i2s: pass DMA channels as platform data
Quoted 12 lines · Arnd Bergmann
This is a minor cleanup to make the s3c2412-i2s and s3c24xx-i2s drivers independent of the
mach/dma.hheader file and to allow removing the dependency on the specific dmaengine driver in the next patch.As a side not, only the s3c24xx-i2s driver seems to still be used, while the definition of the s3c2412-i2s platform device was removed in commit
6d259a25b56d("ARM: SAMSUNG: use static declaration when it is not used in other files") after it had never been referenced since its introduction inf0fba2ad1b6b("ASoC: multi-component - ASoC Multi-Component Support").
Quoted 9 lines
Apparently it should have been used by
mach-jive.c, but that never happened. My patch at this point leaves the current state unchanged, we can decide whether to fix or delete the jive driver and s3c2412-i2s another time.Signed-off-by Arnd Bergmann <[email protected]>---
v2: check for NULL pdata
Best regards,
Krzysztof
Re: [PATCHv2 2/3] ASoC: s3c24xx-i2s: pass DMA channels as platform data
In reply to Arnd BergmannQuoted 2 lines · On Tuesday 17 November 2015 16:54:16 Arnd Bergmann wrote:
+#include <
linux/platform_data/asoc-s3c.h.h>
My randconfig test setup has now found the typo above. Resending the fixed version.
Arnd
PATCH v3 2/3 ASoC: s3c24xx-i2s: pass DMA channels as platform data
This is a minor cleanup to make the s3c2412-i2s and s3c24xx-i2s drivers independent of the mach/dma.h header file and to allow removing the dependency on the specific dmaengine driver in the next patch.
As a side not, only the s3c24xx-i2s driver seems to still be used, while the definition of the s3c2412-i2s platform device was removed in commit 6d259a25b56d ("ARM: SAMSUNG: use static declaration when it is not used in other files") after it had never been referenced since its introduction in f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support").
Apparently it should have been used by mach-jive.c, but that never happened. My patch at this point leaves the current state unchanged, we can decide whether to fix or delete the jive driver and s3c2412-i2s another time.
---
v3: fix typo in s3c24xx-i2s.c
v2: check for NULL pdata
arch/arm/plat-samsung/devs.c +6 -0
@@ -571,6 +571,11 @@ static struct resource s3c_iis_resource[] = { [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS), }; +static struct s3c_audio_pdata s3c_iis_platdata = { + .dma_playback = (void *)DMACH_I2S_OUT , + .dma_capture = (void *)DMACH_I2S_IN , +}; +struct platform_device s3c_device_iis = { .name ="s3c24xx-iis" , .id =-1 ,
@@ -579,6 +584,7 @@ struct platform_device s3c_device_iis = { .dev = { .dma_mask = &samsung_device_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &s3c_iis_platdata, } };#endif /* CONFIG_PLAT_S3C24XX */
sound/soc/samsung/s3c2412-i2s.c +10 -2
@@ -33,14 +33,14 @@#include "regs-i2s-v2.h" #include "s3c2412-i2s.h" +#include <linux/platform_data/asoc-s3c.h> +static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { - .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =4 , };static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { - .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =4 , };
@@ -152,6 +152,12 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev) {int ret =0 ;struct resource *res; +struct s3c_audio_pdata *pdata =dev_get_platdata (&pdev->dev); + +if (!pdata) { +dev_err (&pdev->dev,"missing platform data" ); +return -ENXIO ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); s3c2412_i2s.regs =devm_ioremap_resource (&pdev->dev, res);
@@ -159,7 +165,9 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev)return PTR_ERR (s3c2412_i2s.regs); s3c2412_i2s_pcm_stereo_out.dma_addr = res->start +S3C2412_IISTXD ; + s3c2412_i2s_pcm_stereo_out.slave = pdata->dma_playback; s3c2412_i2s_pcm_stereo_in.dma_addr = res->start +S3C2412_IISRXD ; + s3c2412_i2s_pcm_stereo_in.slave = pdata->dma_capture; ret = s3c_i2sv2_register_component(&pdev->dev, -1, &s3c2412_i2s_component,
sound/soc/samsung/s3c24xx-i2s.c +10 -2
@@ -31,14 +31,14 @@#include "dma.h" #include "s3c24xx-i2s.h" +#include <linux/platform_data/asoc-s3c.h> +static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { - .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =2 , };static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { - .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =2 , };
@@ -454,6 +454,12 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev) {int ret =0 ;struct resource *res; +struct s3c_audio_pdata *pdata =dev_get_platdata (&pdev->dev); + +if (!pdata) { +dev_err (&pdev->dev,"missing platform data" ); +return -ENXIO ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) {
@@ -465,7 +471,9 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev)return PTR_ERR (s3c24xx_i2s.regs); s3c24xx_i2s_pcm_stereo_out.dma_addr = res->start +S3C2410_IISFIFO ; + s3c24xx_i2s_pcm_stereo_out.slave = pdata->dma_playback; s3c24xx_i2s_pcm_stereo_in.dma_addr = res->start +S3C2410_IISFIFO ; + s3c24xx_i2s_pcm_stereo_in.slave = pdata->dma_capture; ret =devm_snd_soc_register_component (&pdev->dev, &s3c24xx_i2s_component, &s3c24xx_i2s_dai,1 );
Mark Brown
maintainerApplied "ASoC: s3c24xx-i2s: pass DMA channels as platform data" to the asoc tree
The patch
ASoC: s3c24xx-i2s: pass DMA channels as platform data
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
359fdfa6fde04b3a752df5251b1dcd8866d436faMon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 18 Nov 2015 15:26:00 +0100
Subject: [PATCH] ASoC: s3c24xx-i2s: pass DMA channels as platform data
This is a minor cleanup to make the s3c2412-i2s and s3c24xx-i2s drivers independent of the mach/dma.h header file and to allow removing the dependency on the specific dmaengine driver in the next patch.
As a side not, only the s3c24xx-i2s driver seems to still be used, while the definition of the s3c2412-i2s platform device was removed in commit 6d259a25b56d ("ARM: SAMSUNG: use static declaration when it is not used in other files") after it had never been referenced since its introduction in f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support").
Apparently it should have been used by mach-jive.c, but that never happened. My patch at this point leaves the current state unchanged, we can decide whether to fix or delete the jive driver and s3c2412-i2s another time.
--- arch/arm/plat-samsung/devs.c | 6 ++++++ sound/soc/samsung/s3c2412-i2s.c | 12 ++++++++++-- sound/soc/samsung/s3c24xx-i2s.c | 12 ++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-)
arch/arm/plat-samsung/devs.c +6 -0
@@ -571,6 +571,11 @@ static struct resource s3c_iis_resource[] = { [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS), }; +static struct s3c_audio_pdata s3c_iis_platdata = { + .dma_playback = (void *)DMACH_I2S_OUT , + .dma_capture = (void *)DMACH_I2S_IN , +}; +struct platform_device s3c_device_iis = { .name ="s3c24xx-iis" , .id =-1 ,
@@ -579,6 +584,7 @@ struct platform_device s3c_device_iis = { .dev = { .dma_mask = &samsung_device_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &s3c_iis_platdata, } };#endif /* CONFIG_PLAT_S3C24XX */
sound/soc/samsung/s3c2412-i2s.c +10 -2
@@ -33,14 +33,14 @@#include "regs-i2s-v2.h" #include "s3c2412-i2s.h" +#include <linux/platform_data/asoc-s3c.h> +static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { - .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =4 , };static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { - .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =4 , };
@@ -152,6 +152,12 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev) {int ret =0 ;struct resource *res; +struct s3c_audio_pdata *pdata =dev_get_platdata (&pdev->dev); + +if (!pdata) { +dev_err (&pdev->dev,"missing platform data" ); +return -ENXIO ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); s3c2412_i2s.regs =devm_ioremap_resource (&pdev->dev, res);
@@ -159,7 +165,9 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev)return PTR_ERR (s3c2412_i2s.regs); s3c2412_i2s_pcm_stereo_out.dma_addr = res->start +S3C2412_IISTXD ; + s3c2412_i2s_pcm_stereo_out.slave = pdata->dma_playback; s3c2412_i2s_pcm_stereo_in.dma_addr = res->start +S3C2412_IISRXD ; + s3c2412_i2s_pcm_stereo_in.slave = pdata->dma_capture; ret = s3c_i2sv2_register_component(&pdev->dev, -1, &s3c2412_i2s_component,
sound/soc/samsung/s3c24xx-i2s.c +10 -2
@@ -31,14 +31,14 @@#include "dma.h" #include "s3c24xx-i2s.h" +#include <linux/platform_data/asoc-s3c.h> +static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { - .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =2 , };static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { - .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =2 , };
@@ -454,6 +454,12 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev) {int ret =0 ;struct resource *res; +struct s3c_audio_pdata *pdata =dev_get_platdata (&pdev->dev); + +if (!pdata) { +dev_err (&pdev->dev,"missing platform data" ); +return -ENXIO ; + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!res) {
@@ -465,7 +471,9 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev)return PTR_ERR (s3c24xx_i2s.regs); s3c24xx_i2s_pcm_stereo_out.dma_addr = res->start +S3C2410_IISFIFO ; + s3c24xx_i2s_pcm_stereo_out.slave = pdata->dma_playback; s3c24xx_i2s_pcm_stereo_in.dma_addr = res->start +S3C2410_IISFIFO ; + s3c24xx_i2s_pcm_stereo_in.slave = pdata->dma_capture; ret =devm_snd_soc_register_component (&pdev->dev, &s3c24xx_i2s_component, &s3c24xx_i2s_dai,1 );
Signature · 1 line
2.6.2
PATCH v2 3/3 ASoC: samsung: pass filter function as pointer
In reply to Arnd BergmannAs we are now passing the filter data as pointers to the drivers, we can take the final step and also pass the filter function the same way. I'm keeping this change separate, as there it's less obvious that this is a net win.
Upsides of this are:
- The ASoC drivers are completely independent from the DMA engine implementation, which simplifies the Kconfig logic and in theory allows the same sound drivers to be built in a kernel that supports different kinds of dmaengine drivers.
- Consistency with other subsystems and drivers
On the other hand, we have a few downsides:
- The s3c24xx-dma driver now needs to be built-in for the ac97 platform device to be instantiated on s3c2440.
- samsung_dmaengine_pcm_config cannot be marked 'const' any more because the filter function pointer needs to be set at runtime. This is safe as long we don't have multiple different DMA engines in thet same system at runtime, but is nonetheless ugly.
---
v2: avoid possibly NULL pdata
arch/arm/mach-s3c64xx/dev-audio.c +6 -0
@@ -58,6 +58,7 @@ static struct resource s3c64xx_iis0_resource[] = {static struct s3c_audio_pdata i2s0_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_filter = pl08x_filter_id, .dma_playback =DMACH_I2S0_OUT , .dma_capture =DMACH_I2S0_IN , };
@@ -79,6 +80,7 @@ static struct resource s3c64xx_iis1_resource[] = {static struct s3c_audio_pdata i2s1_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_filter = pl08x_filter_id, .dma_playback =DMACH_I2S1_OUT , .dma_capture =DMACH_I2S1_IN , };
@@ -100,6 +102,7 @@ static struct resource s3c64xx_iisv4_resource[] = {static struct s3c_audio_pdata i2sv4_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_filter = pl08x_filter_id, .dma_playback =DMACH_HSI_I2SV40_TX , .dma_capture =DMACH_HSI_I2SV40_RX , .type = {
@@ -150,6 +153,7 @@ static struct resource s3c64xx_pcm0_resource[] = {static struct s3c_audio_pdata s3c_pcm0_pdata = { .cfg_gpio = s3c64xx_pcm_cfg_gpio, + .dma_filter = pl08x_filter_id, .dma_capture =DMACH_PCM0_RX , .dma_playback =DMACH_PCM0_TX , };
@@ -171,6 +175,7 @@ static struct resource s3c64xx_pcm1_resource[] = {static struct s3c_audio_pdata s3c_pcm1_pdata = { .cfg_gpio = s3c64xx_pcm_cfg_gpio, + .dma_filter = pl08x_filter_id, .dma_playback =DMACH_PCM1_TX , .dma_capture =DMACH_PCM1_RX , };
@@ -205,6 +210,7 @@ static struct resource s3c64xx_ac97_resource[] = {static struct s3c_audio_pdata s3c_ac97_pdata = { .dma_playback =DMACH_AC97_PCMOUT , + .dma_filter = pl08x_filter_id, .dma_capture =DMACH_AC97_PCMIN , .dma_capture_mic =DMACH_AC97_MICIN , };
arch/arm/plat-samsung/devs.c +6 -0
@@ -78,6 +78,9 @@ static struct resource s3c_ac97_resource[] = { };static struct s3c_audio_pdata s3c_ac97_pdata = { +#ifdef CONFIG_S3C24XX_DMAC + .dma_filter = s3c24xx_dma_filter, +#endif .dma_playback = (void *)DMACH_PCM_OUT , .dma_capture = (void *)DMACH_PCM_IN , .dma_capture_mic = (void *)DMACH_MIC_IN ,
@@ -572,6 +575,9 @@ static struct resource s3c_iis_resource[] = { };static struct s3c_audio_pdata s3c_iis_platdata = { +#ifdef CONFIG_S3C24XX_DMAC + .dma_filter = s3c24xx_dma_filter, +#endif .dma_playback = (void *)DMACH_I2S_OUT , .dma_capture = (void *)DMACH_I2S_IN , };
drivers/dma/Kconfig +1 -1
@@ -444,7 +444,7 @@ config STM32_DMA here. config S3C24XX_DMAC - tristate "Samsung S3C24XX DMA support" + bool "Samsung S3C24XX DMA support" depends on ARCH_S3C24XX select DMA_ENGINE select DMA_VIRTUAL_CHANNELS
include/linux/platform_data/asoc-s3c.h +4 -0
@@ -13,6 +13,9 @@*/ #define S3C64XX_AC97_GPD 0#define S3C64XX_AC97_GPE 1 + +#include <linux/dmaengine.h> +extern void s3c64xx_ac97_setup_gpio (int );struct samsung_i2s {
@@ -39,6 +42,7 @@ struct samsung_i2s {*/ struct s3c_audio_pdata {int (*cfg_gpio)(struct platform_device *); +dma_filter_fn dma_filter;void *dma_playback;void *dma_capture;void *dma_play_sec;
sound/soc/samsung/Kconfig +0 -2
@@ -1,8 +1,6 @@ config SND_SOC_SAMSUNG tristate "ASoC support for Samsung" depends on (PLAT_SAMSUNG || ARCH_EXYNOS) - depends on S3C64XX_PL080 || !ARCH_S3C64XX - depends on S3C24XX_DMAC || !ARCH_S3C24XX select SND_SOC_GENERIC_DMAENGINE_PCM help Say Y or M if you want to add support for codecs attached to
sound/soc/samsung/ac97.c +2 -1
@@ -388,7 +388,8 @@ static int s3c_ac97_probe(struct platform_device *pdev)if (ret) goto err5; - ret =samsung_asoc_dma_platform_register (&pdev->dev); + ret =samsung_asoc_dma_platform_register (&pdev->dev, + ac97_pdata->dma_filter);if (ret) {dev_err (&pdev->dev,"failed to get register DMA: %d\n" , ret); goto err5;
sound/soc/samsung/dma.h +3 -1
@@ -13,6 +13,7 @@#define _S3C_AUDIO_H#include <sound/dmaengine_pcm.h> +#include <linux/dmaengine.h> struct s3c_dma_params {void *slave;/* Channel ID */
@@ -25,6 +26,7 @@ struct s3c_dma_params {void samsung_asoc_init_dma_data (struct snd_soc_dai *dai,struct s3c_dma_params *playback,struct s3c_dma_params *capture); -int samsung_asoc_dma_platform_register (struct device *dev); +int samsung_asoc_dma_platform_register (struct device *dev, +dma_filter_fn fn);#endif
sound/soc/samsung/dmaengine.c +5 -11
@@ -28,17 +28,8 @@#include "dma.h" -#ifdef CONFIG_ARCH_S3C64XX -#define filter_fn pl08x_filter_id -#elif defined(CONFIG_ARCH_S3C24XX ) -#define filter_fn s3c24xx_dma_filter -#else -#define filter_fn NULL -#endif - -static const struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = { +static struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = { .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, - .compat_filter_fn = filter_fn, }; void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
@@ -67,8 +58,11 @@ void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, }EXPORT_SYMBOL_GPL (samsung_asoc_init_dma_data); -int samsung_asoc_dma_platform_register (struct device *dev) +int samsung_asoc_dma_platform_register (struct device *dev, +dma_filter_fn filter) { + samsung_dmaengine_pcm_config.compat_filter_fn = filter; + return devm_snd_dmaengine_pcm_register(dev, &samsung_dmaengine_pcm_config, SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME |
sound/soc/samsung/i2s.c +8 -3
@@ -89,6 +89,7 @@ struct i2s_dai {struct s3c_dma_params dma_playback;struct s3c_dma_params dma_capture;struct s3c_dma_params idma_playback; +dma_filter_fn filter;u32 quirks;u32 suspend_i2smod;u32 suspend_i2scon;
@@ -1244,7 +1245,8 @@ static int samsung_i2s_probe(struct platform_device *pdev)if (ret !=0 )return ret; -return samsung_asoc_dma_platform_register (&pdev->dev); +return samsung_asoc_dma_platform_register (&pdev->dev, + sec_dai->filter); } pri_dai =i2s_alloc_dai (pdev, false);
@@ -1264,6 +1266,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) pri_dai->dma_playback.slave = i2s_pdata->dma_playback; pri_dai->dma_capture.slave = i2s_pdata->dma_capture; + pri_dai->filter = i2s_pdata->dma_filter;if (&i2s_pdata->type) i2s_cfg = &i2s_pdata->type.i2s;
@@ -1325,8 +1328,10 @@ static int samsung_i2s_probe(struct platform_device *pdev) sec_dai->dma_playback.dma_addr = regs_base +I2STXDS ; sec_dai->dma_playback.ch_name ="tx-sec" ; -if (!np) +if (!np) { sec_dai->dma_playback.slave = i2s_pdata->dma_play_sec; + sec_dai->filter = i2s_pdata->dma_filter; + } sec_dai->dma_playback.dma_size =4 ; sec_dai->addr = pri_dai->addr;
@@ -1348,7 +1353,7 @@ static int samsung_i2s_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev); - ret =samsung_asoc_dma_platform_register (&pdev->dev); + ret =samsung_asoc_dma_platform_register (&pdev->dev, pri_dai->filter);if (ret !=0 )return ret;
sound/soc/samsung/pcm.c +4 -1
@@ -488,6 +488,7 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev)struct s3c_pcm_info *pcm;struct resource *mem_res;struct s3c_audio_pdata *pcm_pdata; +dma_filter_fn filter;int ret;/* Check for valid device index */
@@ -556,9 +557,11 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) s3c_pcm_stereo_out[pdev->id].dma_addr = mem_res->start +S3C_PCM_TXFIFO ; + filter =NULL ;if (pcm_pdata) { s3c_pcm_stereo_in[pdev->id].slave = pcm_pdata->dma_capture; s3c_pcm_stereo_out[pdev->id].slave = pcm_pdata->dma_playback; + filter = pcm_pdata->dma_filter; } pcm->dma_capture = &s3c_pcm_stereo_in[pdev->id];
@@ -573,7 +576,7 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) goto err5; } - ret =samsung_asoc_dma_platform_register (&pdev->dev); + ret =samsung_asoc_dma_platform_register (&pdev->dev, filter);if (ret) {dev_err (&pdev->dev,"failed to get register DMA: %d\n" , ret); goto err5;
sound/soc/samsung/s3c2412-i2s.c +2 -2
@@ -25,7 +25,6 @@#include <sound/soc.h> #include <sound/pcm_params.h> -#include <mach/dma.h> #include <mach/gpio-samsung.h> #include <plat/gpio-cfg.h>
@@ -177,7 +176,8 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev)return ret; } - ret =samsung_asoc_dma_platform_register (&pdev->dev); + ret =samsung_asoc_dma_platform_register (&pdev->dev, + pdata->dma_filter);if (ret)pr_err ("failed to register the DMA: %d\n" , ret);
sound/soc/samsung/s3c24xx-i2s.c +2 -2
@@ -23,7 +23,6 @@#include <sound/soc.h> #include <sound/pcm_params.h> -#include <mach/dma.h> #include <mach/gpio-samsung.h> #include <plat/gpio-cfg.h> #include "regs-iis.h"
@@ -482,7 +481,8 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev)return ret; } - ret =samsung_asoc_dma_platform_register (&pdev->dev); + ret =samsung_asoc_dma_platform_register (&pdev->dev, + pdata->dma_filter);if (ret)pr_err ("failed to register the dma: %d\n" , ret);
sound/soc/samsung/spdif.c +7 -2
@@ -361,6 +361,7 @@ static int spdif_probe(struct platform_device *pdev)struct s3c_audio_pdata *spdif_pdata;struct resource *mem_res;struct samsung_spdif_info *spdif; +dma_filter_fn filter;int ret; spdif_pdata = pdev->dev.platform_data;
@@ -426,11 +427,15 @@ static int spdif_probe(struct platform_device *pdev) spdif_stereo_out.dma_size =2 ; spdif_stereo_out.dma_addr = mem_res->start +DATA_OUTBUF ; - spdif_stereo_out.slave = spdif_pdata ? spdif_pdata->dma_playback :NULL ; + filter =NULL ; +if (spdif_pdata) { + spdif_stereo_out.slave = spdif_pdata->dma_playback; + filter = spdif_pdata->dma_filter; + } spdif->dma_playback = &spdif_stereo_out; - ret =samsung_asoc_dma_platform_register (&pdev->dev); + ret =samsung_asoc_dma_platform_register (&pdev->dev, filter);if (ret) {dev_err (&pdev->dev,"failed to register DMA: %d\n" , ret); goto err4;
Re: [PATCHv2 3/3] ASoC: samsung: pass filter function as pointer
Quoted 19 lines · Arnd Bergmann
As we are now passing the filter data as pointers to the drivers, we can take the final step and also pass the filter function the same way. I'm keeping this change separate, as there it's less obvious that this is a net win.
Upsides of this are:
- The ASoC drivers are completely independent from the DMA engine implementation, which simplifies the
Kconfiglogic and in theory allows the same sound drivers to be built in a kernel that supports different kinds of dmaengine drivers.- Consistency with other subsystems and drivers
On the other hand, we have a few downsides:
- The s3c24xx-dma driver now needs to be built-in for the ac97 platform device to be instantiated on s3c2440.
Quoted 9 lines
-
samsung_dmaengine_pcm_configcannot be marked 'const' any more because the filter function pointer needs to be set at runtime. This is safe as long we don't have multiple different DMA engines in thet same system at runtime, but is nonetheless ugly.Signed-off-by Arnd Bergmann <[email protected]>---
v2: avoid possibly NULL pdata
Looks good.
I also tested entire patchset on Exynos4412/Trats2 board (custom kernel with audio working) for regressions and it worked fine. However, since this was not a S3C24xx/S3C64xx board, I don't find that testing sufficient for a tag. So only:
Best regards,
Krzysztof
Re: [PATCHv2 3/3] ASoC: samsung: pass filter function as pointer
Quoted 8 lines · On Wednesday 18 November 2015 11:13:18 Krzysztof Kozlowski wrote:
I also tested entire patchset on Exynos4412/Trats2 board (custom kernel with audio working) for regressions and it worked fine. However, since this was not a S3C24xx/S3C64xx board, I don't find that testing sufficient for a tag. So only:
Reviewed-by Krzysztof Kozlowski <[email protected]>
Thanks!
Mark, can you take the three patches through the ASoC tree?
Arnd
Quoted 21 lines · Arnd Bergmann
ARM64 allmodconfig produces a bunch of warnings when building the samsung ASoC code:
sound/soc/samsung/dmaengine.c: In function 'samsung_asoc_init_dma_data':sound/soc/samsung/dmaengine.c:53:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
playback_data->filter_data= (void *)playback->channel;sound/soc/samsung/dmaengine.c:60:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
capture_data->filter_data= (void *)capture->channel;We could easily shut up the warning by adding an intermediate cast, but there is a bigger underlying problem: The use of
IORESOURCE_DMAto pass data from platform code to device drivers is dubious to start with, as what we really want is a pointer that can be passed into a filter function.Note that on s3c64xx, the pl08x DMA data is already a pointer, but gets cast to
resource_size_tso we can pass it as a resource, and it then gets converted back to a pointer. In contrast, the data we pass for s3c24xx is an index into a device specific table, and we artificially convert that into a pointer for the filter function.
Quoted 7 lines
Signed-off-by Arnd Bergmann <[email protected]>---
v2:- no longer clash with SPI patch
- don't reference platform data that might be NULL
Looks good:
Best regards,
Krzysztof
Mark Brown
maintainerApplied "ASoC: samsung: pass DMA channels as pointers" to the asoc tree
In reply to Arnd BergmannThe patch
ASoC: samsung: pass DMA channels as pointers
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
b9a1a743818ea3265abf98f9431623afa8c50c86Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 18 Nov 2015 15:25:23 +0100
Subject: [PATCH] ASoC: samsung: pass DMA channels as pointers
ARM64 allmodconfig produces a bunch of warnings when building the samsung ASoC code:
sound/soc/samsung/dmaengine.c: In function 'samsung_asoc_init_dma_data':sound/soc/samsung/dmaengine.c:53:32: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
playback_data->filter_data = (void *)playback->channel;sound/soc/samsung/dmaengine.c:60:31: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
capture_data->filter_data = (void *)capture->channel;
We could easily shut up the warning by adding an intermediate cast, but there is a bigger underlying problem: The use of IORESOURCE_DMA to pass data from platform code to device drivers is dubious to start with, as what we really want is a pointer that can be passed into a filter function.
Note that on s3c64xx, the pl08x DMA data is already a pointer, but gets cast to resource_size_t so we can pass it as a resource, and it then gets converted back to a pointer. In contrast, the data we pass for s3c24xx is an index into a device specific table, and we artificially convert that into a pointer for the filter function.
--- arch/arm/mach-s3c64xx/dev-audio.c | 41 ++++++++++++++----------- arch/arm/mach-s3c64xx/include/mach/dma.h | 52 ++++++++++++++++---------------- arch/arm/plat-samsung/devs.c | 11 +++++-- include/linux/platform_data/asoc-s3c.h | 4 +++ sound/soc/samsung/ac97.c | 26 +++------------- sound/soc/samsung/dma.h | 2 +- sound/soc/samsung/dmaengine.c | 4 +-- sound/soc/samsung/i2s.c | 26 +++------------- sound/soc/samsung/pcm.c | 20 +++--------- sound/soc/samsung/s3c2412-i2s.c | 4 +-- sound/soc/samsung/s3c24xx-i2s.c | 4 +-- sound/soc/samsung/spdif.c | 10 ++---- 12 files changed, 84 insertions(+), 120 deletions(-)
arch/arm/mach-s3c64xx/dev-audio.c +23 -18
@@ -54,12 +54,12 @@ static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)static struct resource s3c64xx_iis0_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_IIS0 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_I2S0_OUT ), - [2 ] =DEFINE_RES_DMA (DMACH_I2S0_IN ), }; -static struct s3c_audio_pdata i2sv3_pdata = { +static struct s3c_audio_pdata i2s0_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_playback =DMACH_I2S0_OUT , + .dma_capture =DMACH_I2S0_IN , };struct platform_device s3c64xx_device_iis0 = {
@@ -68,15 +68,19 @@ struct platform_device s3c64xx_device_iis0 = { .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), .resource = s3c64xx_iis0_resource, .dev = { - .platform_data = &i2sv3_pdata, + .platform_data = &i2s0_pdata, }, };EXPORT_SYMBOL (s3c64xx_device_iis0);static struct resource s3c64xx_iis1_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_IIS1 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_I2S1_OUT ), - [2 ] =DEFINE_RES_DMA (DMACH_I2S1_IN ), +}; + +static struct s3c_audio_pdata i2s1_pdata = { + .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_playback =DMACH_I2S1_OUT , + .dma_capture =DMACH_I2S1_IN , };struct platform_device s3c64xx_device_iis1 = {
@@ -85,19 +89,19 @@ struct platform_device s3c64xx_device_iis1 = { .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), .resource = s3c64xx_iis1_resource, .dev = { - .platform_data = &i2sv3_pdata, + .platform_data = &i2s1_pdata, }, };EXPORT_SYMBOL (s3c64xx_device_iis1);static struct resource s3c64xx_iisv4_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_IISV4 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_HSI_I2SV40_TX ), - [2 ] =DEFINE_RES_DMA (DMACH_HSI_I2SV40_RX ), };static struct s3c_audio_pdata i2sv4_pdata = { .cfg_gpio = s3c64xx_i2s_cfg_gpio, + .dma_playback =DMACH_HSI_I2SV40_TX , + .dma_capture =DMACH_HSI_I2SV40_RX , .type = { .i2s = { .quirks =QUIRK_PRI_6CHAN ,
@@ -142,12 +146,12 @@ static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev)static struct resource s3c64xx_pcm0_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_PCM0 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_PCM0_TX ), - [2 ] =DEFINE_RES_DMA (DMACH_PCM0_RX ), };static struct s3c_audio_pdata s3c_pcm0_pdata = { .cfg_gpio = s3c64xx_pcm_cfg_gpio, + .dma_capture =DMACH_PCM0_RX , + .dma_playback =DMACH_PCM0_TX , };struct platform_device s3c64xx_device_pcm0 = {
@@ -163,12 +167,12 @@ EXPORT_SYMBOL(s3c64xx_device_pcm0);static struct resource s3c64xx_pcm1_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_PCM1 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_PCM1_TX ), - [2 ] =DEFINE_RES_DMA (DMACH_PCM1_RX ), };static struct s3c_audio_pdata s3c_pcm1_pdata = { .cfg_gpio = s3c64xx_pcm_cfg_gpio, + .dma_playback =DMACH_PCM1_TX , + .dma_capture =DMACH_PCM1_RX , };struct platform_device s3c64xx_device_pcm1 = {
@@ -196,13 +200,14 @@ static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev)static struct resource s3c64xx_ac97_resource[] = { [0 ] =DEFINE_RES_MEM (S3C64XX_PA_AC97 ,SZ_256 ), - [1 ] =DEFINE_RES_DMA (DMACH_AC97_PCMOUT ), - [2 ] =DEFINE_RES_DMA (DMACH_AC97_PCMIN ), - [3 ] =DEFINE_RES_DMA (DMACH_AC97_MICIN ), - [4 ] =DEFINE_RES_IRQ (IRQ_AC97 ), + [1 ] =DEFINE_RES_IRQ (IRQ_AC97 ), }; -static struct s3c_audio_pdata s3c_ac97_pdata; +static struct s3c_audio_pdata s3c_ac97_pdata = { + .dma_playback =DMACH_AC97_PCMOUT , + .dma_capture =DMACH_AC97_PCMIN , + .dma_capture_mic =DMACH_AC97_MICIN , +};static u64 s3c64xx_ac97_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-s3c64xx/include/mach/dma.h +26 -26
64 lines not on this page · raw message
arch/arm/plat-samsung/devs.c +8 -3
@@ -65,6 +65,7 @@#include <linux/platform_data/usb-ohci-s3c2410.h> #include <plat/usb-phy.h> #include <plat/regs-spi.h> +#include <linux/platform_data/asoc-s3c.h> #include <linux/platform_data/spi-s3c64xx.h> static u64 samsung_device_dma_mask =DMA_BIT_MASK (32 );
@@ -74,9 +75,12 @@ static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);static struct resource s3c_ac97_resource[] = { [0 ] =DEFINE_RES_MEM (S3C2440_PA_AC97 ,S3C2440_SZ_AC97 ), [1 ] =DEFINE_RES_IRQ (IRQ_S3C244X_AC97 ), - [2 ] =DEFINE_RES_DMA_NAMED (DMACH_PCM_OUT ,"PCM out" ), - [3 ] =DEFINE_RES_DMA_NAMED (DMACH_PCM_IN ,"PCM in" ), - [4 ] =DEFINE_RES_DMA_NAMED (DMACH_MIC_IN ,"Mic in" ), +}; + +static struct s3c_audio_pdata s3c_ac97_pdata = { + .dma_playback = (void *)DMACH_PCM_OUT , + .dma_capture = (void *)DMACH_PCM_IN , + .dma_capture_mic = (void *)DMACH_MIC_IN , };struct platform_device s3c_device_ac97 = {
@@ -87,6 +91,7 @@ struct platform_device s3c_device_ac97 = { .dev = { .dma_mask = &samsung_device_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &s3c_ac97_pdata, } };#endif /* CONFIG_CPU_S3C2440 */
include/linux/platform_data/asoc-s3c.h +4 -0
@@ -39,6 +39,10 @@ struct samsung_i2s {*/ struct s3c_audio_pdata {int (*cfg_gpio)(struct platform_device *); +void *dma_playback; +void *dma_capture; +void *dma_play_sec; +void *dma_capture_mic;union {struct samsung_i2s i2s; } type;
sound/soc/samsung/ac97.c +4 -22
@@ -324,7 +324,7 @@ static const struct snd_soc_component_driver s3c_ac97_component = {static int s3c_ac97_probe (struct platform_device *pdev) { -struct resource *mem_res, *dmatx_res, *dmarx_res, *dmamic_res, *irq_res; +struct resource *mem_res, *irq_res;struct s3c_audio_pdata *ac97_pdata;int ret;
@@ -335,24 +335,6 @@ static int s3c_ac97_probe(struct platform_device *pdev) }/* Check for availability of necessary resource */ - dmatx_res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!dmatx_res) { -dev_err (&pdev->dev,"Unable to get AC97-TX dma resource\n" ); -return -ENXIO ; - } - - dmarx_res =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); -if (!dmarx_res) { -dev_err (&pdev->dev,"Unable to get AC97-RX dma resource\n" ); -return -ENXIO ; - } - - dmamic_res =platform_get_resource (pdev,IORESOURCE_DMA ,2 ); -if (!dmamic_res) { -dev_err (&pdev->dev,"Unable to get AC97-MIC dma resource\n" ); -return -ENXIO ; - } - irq_res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );if (!irq_res) {dev_err (&pdev->dev,"AC97 IRQ not provided!\n" );
@@ -364,11 +346,11 @@ static int s3c_ac97_probe(struct platform_device *pdev)if (IS_ERR (s3c_ac97.regs))return PTR_ERR (s3c_ac97.regs); - s3c_ac97_pcm_out.channel = dmatx_res->start; + s3c_ac97_pcm_out.slave = ac97_pdata->dma_playback; s3c_ac97_pcm_out.dma_addr = mem_res->start +S3C_AC97_PCM_DATA ; - s3c_ac97_pcm_in.channel = dmarx_res->start; + s3c_ac97_pcm_in.slave = ac97_pdata->dma_capture; s3c_ac97_pcm_in.dma_addr = mem_res->start +S3C_AC97_PCM_DATA ; - s3c_ac97_mic_in.channel = dmamic_res->start; + s3c_ac97_mic_in.slave = ac97_pdata->dma_capture_mic; s3c_ac97_mic_in.dma_addr = mem_res->start +S3C_AC97_MIC_DATA ;init_completion (&s3c_ac97.done);
sound/soc/samsung/dma.h +1 -1
@@ -15,7 +15,7 @@#include <sound/dmaengine_pcm.h> struct s3c_dma_params { -int channel;/* Channel ID */ +void *slave;/* Channel ID */ dma_addr_t dma_addr;int dma_size;/* Size of the DMA transfer */ char *ch_name;
sound/soc/samsung/dmaengine.c +2 -2
@@ -50,14 +50,14 @@ void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,if (playback) { playback_data = &playback->dma_data; - playback_data->filter_data = (void *)playback->channel; + playback_data->filter_data = playback->slave; playback_data->chan_name = playback->ch_name; playback_data->addr = playback->dma_addr; playback_data->addr_width = playback->dma_size; }if (capture) { capture_data = &capture->dma_data; - capture_data->filter_data = (void *)capture->channel; + capture_data->filter_data = capture->slave; capture_data->chan_name = capture->ch_name; capture_data->addr = capture->dma_addr; capture_data->addr_width = capture->dma_size;
sound/soc/samsung/i2s.c +5 -21
@@ -1257,27 +1257,14 @@ static int samsung_i2s_probe(struct platform_device *pdev) pri_dai->lock = &pri_dai->spinlock;if (!np) { - res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!res) { -dev_err (&pdev->dev, -"Unable to get I2S-TX dma resource\n" ); -return -ENXIO ; - } - pri_dai->dma_playback.channel = res->start; - - res =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); -if (!res) { -dev_err (&pdev->dev, -"Unable to get I2S-RX dma resource\n" ); -return -ENXIO ; - } - pri_dai->dma_capture.channel = res->start; -if (i2s_pdata ==NULL ) {dev_err (&pdev->dev,"Can't work without s3c_audio_pdata\n" );return -EINVAL ; } + pri_dai->dma_playback.slave = i2s_pdata->dma_playback; + pri_dai->dma_capture.slave = i2s_pdata->dma_capture; +if (&i2s_pdata->type) i2s_cfg = &i2s_pdata->type.i2s;
@@ -1338,11 +1325,8 @@ static int samsung_i2s_probe(struct platform_device *pdev) sec_dai->dma_playback.dma_addr = regs_base +I2STXDS ; sec_dai->dma_playback.ch_name ="tx-sec" ; -if (!np) { - res =platform_get_resource (pdev,IORESOURCE_DMA ,2 ); -if (res) - sec_dai->dma_playback.channel = res->start; - } +if (!np) + sec_dai->dma_playback.slave = i2s_pdata->dma_play_sec; sec_dai->dma_playback.dma_size =4 ; sec_dai->addr = pri_dai->addr;
sound/soc/samsung/pcm.c +5 -15
@@ -486,7 +486,7 @@ static const struct snd_soc_component_driver s3c_pcm_component = {static int s3c_pcm_dev_probe (struct platform_device *pdev) {struct s3c_pcm_info *pcm; -struct resource *mem_res, *dmatx_res, *dmarx_res; +struct resource *mem_res;struct s3c_audio_pdata *pcm_pdata;int ret;
@@ -499,18 +499,6 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) pcm_pdata = pdev->dev.platform_data;/* Check for availability of necessary resource */ - dmatx_res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!dmatx_res) { -dev_err (&pdev->dev,"Unable to get PCM-TX dma resource\n" ); -return -ENXIO ; - } - - dmarx_res =platform_get_resource (pdev,IORESOURCE_DMA ,1 ); -if (!dmarx_res) { -dev_err (&pdev->dev,"Unable to get PCM-RX dma resource\n" ); -return -ENXIO ; - } - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem_res) {dev_err (&pdev->dev,"Unable to get register resource\n" );
@@ -568,8 +556,10 @@ static int s3c_pcm_dev_probe(struct platform_device *pdev) s3c_pcm_stereo_out[pdev->id].dma_addr = mem_res->start +S3C_PCM_TXFIFO ; - s3c_pcm_stereo_in[pdev->id].channel = dmarx_res->start; - s3c_pcm_stereo_out[pdev->id].channel = dmatx_res->start; +if (pcm_pdata) { + s3c_pcm_stereo_in[pdev->id].slave = pcm_pdata->dma_capture; + s3c_pcm_stereo_out[pdev->id].slave = pcm_pdata->dma_playback; + } pcm->dma_capture = &s3c_pcm_stereo_in[pdev->id]; pcm->dma_playback = &s3c_pcm_stereo_out[pdev->id];
sound/soc/samsung/s3c2412-i2s.c +2 -2
@@ -34,13 +34,13 @@#include "s3c2412-i2s.h" static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { - .channel =DMACH_I2S_OUT , + .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =4 , };static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { - .channel =DMACH_I2S_IN , + .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =4 , };
sound/soc/samsung/s3c24xx-i2s.c +2 -2
@@ -32,13 +32,13 @@#include "s3c24xx-i2s.h" static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { - .channel =DMACH_I2S_OUT , + .slave = (void *)(uintptr_t )DMACH_I2S_OUT , .ch_name ="tx" , .dma_size =2 , };static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { - .channel =DMACH_I2S_IN , + .slave = (void *)(uintptr_t )DMACH_I2S_IN , .ch_name ="rx" , .dma_size =2 , };
sound/soc/samsung/spdif.c +2 -8
@@ -359,7 +359,7 @@ static const struct snd_soc_component_driver samsung_spdif_component = {static int spdif_probe (struct platform_device *pdev) {struct s3c_audio_pdata *spdif_pdata; -struct resource *mem_res, *dma_res; +struct resource *mem_res;struct samsung_spdif_info *spdif;int ret;
@@ -367,12 +367,6 @@ static int spdif_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"Entered %s\n" , __func__); - dma_res =platform_get_resource (pdev,IORESOURCE_DMA ,0 ); -if (!dma_res) { -dev_err (&pdev->dev,"Unable to get dma resource.\n" ); -return -ENXIO ; - } - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem_res) {dev_err (&pdev->dev,"Unable to get register resource.\n" );
@@ -432,7 +426,7 @@ static int spdif_probe(struct platform_device *pdev) spdif_stereo_out.dma_size =2 ; spdif_stereo_out.dma_addr = mem_res->start +DATA_OUTBUF ; - spdif_stereo_out.channel = dma_res->start; + spdif_stereo_out.slave = spdif_pdata ? spdif_pdata->dma_playback :NULL ; spdif->dma_playback = &spdif_stereo_out;
Signature · 1 line
2.6.2