All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] ASoC: OMAP: data_type and sync_mode configurable in audio dma
@ 2010-02-19  0:32 Candelaria Villareal, Jorge
  2010-02-19 10:35 ` Liam Girdwood
  0 siblings, 1 reply; 4+ messages in thread
From: Candelaria Villareal, Jorge @ 2010-02-19  0:32 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org
  Cc: broonie@opensource.wolfsonmicro.com, Liam Girdwood

From: Misael Lopez Cruz <x0052729@ti.com>

Allow client drivers to set the data_type (16, 32) and the
sync_mode (element, packet, etc) of the audio dma transferences.

McBSP dai driver configures it for a data type of 16 bits and
element sync mode.

Signed-off-by: Misael Lopez Cruz <x0052729@ti.com>
Signed-off-by: Jorge Eduardo Candelaria <jorge.candelaria@ti.com>
---
 sound/soc/omap/omap-mcbsp.c |    2 ++
 sound/soc/omap/omap-pcm.c   |   15 ++++++++-------
 sound/soc/omap/omap-pcm.h   |    4 +++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 6bbbd2a..d297256 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -287,6 +287,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
 	omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma;
 	omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port;
 	omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode;
+	omap_mcbsp_dai_dma_params[id][substream->stream].data_type =
+							OMAP_DMA_DATA_TYPE_S16;
 	cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream];
 
 	if (mcbsp_data->configured) {
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 9db2770..825db38 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -37,7 +37,8 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
 				  SNDRV_PCM_INFO_INTERLEAVED |
 				  SNDRV_PCM_INFO_PAUSE |
 				  SNDRV_PCM_INFO_RESUME,
-	.formats		= SNDRV_PCM_FMTBIT_S16_LE,
+	.formats		= SNDRV_PCM_FMTBIT_S16_LE |
+				  SNDRV_PCM_FMTBIT_S32_LE,
 	.period_bytes_min	= 32,
 	.period_bytes_max	= 64 * 1024,
 	.periods_min		= 2,
@@ -149,6 +150,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 	struct omap_runtime_data *prtd = runtime->private_data;
 	struct omap_pcm_dma_data *dma_data = prtd->dma_data;
 	struct omap_dma_channel_params dma_params;
+	int bytes;
 
 	/* return if this is a bufferless transfer e.g.
 	 * codec <--> BT codec or GSM modem -- lg FIXME */
@@ -156,11 +158,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 		return 0;
 
 	memset(&dma_params, 0, sizeof(dma_params));
-	/*
-	 * Note: Regardless of interface data formats supported by OMAP McBSP
-	 * or EAC blocks, internal representation is always fixed 16-bit/sample
-	 */
-	dma_params.data_type			= OMAP_DMA_DATA_TYPE_S16;
+	dma_params.data_type			= dma_data->data_type;
 	dma_params.trigger			= dma_data->dma_req;
 	dma_params.sync_mode			= dma_data->sync_mode;
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -170,6 +168,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 		dma_params.src_start		= runtime->dma_addr;
 		dma_params.dst_start		= dma_data->port_addr;
 		dma_params.dst_port		= OMAP_DMA_PORT_MPUI;
+		dma_params.dst_fi		= dma_data->packet_size;
 	} else {
 		dma_params.src_amode		= OMAP_DMA_AMODE_CONSTANT;
 		dma_params.dst_amode		= OMAP_DMA_AMODE_POST_INC;
@@ -177,6 +176,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 		dma_params.src_start		= dma_data->port_addr;
 		dma_params.dst_start		= runtime->dma_addr;
 		dma_params.src_port		= OMAP_DMA_PORT_MPUI;
+		dma_params.src_fi		= dma_data->packet_size;
 	}
 	/*
 	 * Set DMA transfer frame size equal to ALSA period size and frame
@@ -184,7 +184,8 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
 	 * we can transfer the whole ALSA buffer with single DMA transfer but
 	 * still can get an interrupt at each period bounary
 	 */
-	dma_params.elem_count	= snd_pcm_lib_period_bytes(substream) / 2;
+	bytes = snd_pcm_lib_period_bytes(substream);
+	dma_params.elem_count	= bytes >> dma_data->data_type;
 	dma_params.frame_count	= runtime->periods;
 	omap_set_dma_params(prtd->dma_ch, &dma_params);
 
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index 38a821d..b19975d 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -29,8 +29,10 @@ struct omap_pcm_dma_data {
 	char		*name;		/* stream identifier */
 	int		dma_req;	/* DMA request line */
 	unsigned long	port_addr;	/* transmit/receive register */
-	int		sync_mode;	/* DMA sync mode */
 	void (*set_threshold)(struct snd_pcm_substream *substream);
+	int		data_type;	/* data type 8,16,32 */
+	int		sync_mode;	/* DMA sync mode */
+	int		packet_size;	/* packet size only in PACKET mode */
 };
 
 extern struct snd_soc_platform omap_soc_platform;
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/3] ASoC: OMAP: data_type and sync_mode configurable in audio dma
  2010-02-19  0:32 [PATCH v3 1/3] ASoC: OMAP: data_type and sync_mode configurable in audio dma Candelaria Villareal, Jorge
@ 2010-02-19 10:35 ` Liam Girdwood
  2010-02-19 14:03   ` Jarkko Nikula
  0 siblings, 1 reply; 4+ messages in thread
From: Liam Girdwood @ 2010-02-19 10:35 UTC (permalink / raw)
  To: Candelaria Villareal, Jorge
  Cc: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com

On Thu, 2010-02-18 at 18:32 -0600, Candelaria Villareal, Jorge wrote:
> From: Misael Lopez Cruz <x0052729@ti.com>
> 
> Allow client drivers to set the data_type (16, 32) and the
> sync_mode (element, packet, etc) of the audio dma transferences.
> 
> McBSP dai driver configures it for a data type of 16 bits and
> element sync mode.
> 
> Signed-off-by: Misael Lopez Cruz <x0052729@ti.com>
> Signed-off-by: Jorge Eduardo Candelaria <jorge.candelaria@ti.com>

This looks fine, but I've just one minor comment below.

> ---
>  sound/soc/omap/omap-mcbsp.c |    2 ++
>  sound/soc/omap/omap-pcm.c   |   15 ++++++++-------
>  sound/soc/omap/omap-pcm.h   |    4 +++-
>  3 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
> index 6bbbd2a..d297256 100644
> --- a/sound/soc/omap/omap-mcbsp.c
> +++ b/sound/soc/omap/omap-mcbsp.c
> @@ -287,6 +287,8 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
>  	omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma;
>  	omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port;
>  	omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode;
> +	omap_mcbsp_dai_dma_params[id][substream->stream].data_type =
> +							OMAP_DMA_DATA_TYPE_S16;
>  	cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream];
>  
>  	if (mcbsp_data->configured) {
> diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
> index 9db2770..825db38 100644
> --- a/sound/soc/omap/omap-pcm.c
> +++ b/sound/soc/omap/omap-pcm.c
> @@ -37,7 +37,8 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
>  				  SNDRV_PCM_INFO_INTERLEAVED |
>  				  SNDRV_PCM_INFO_PAUSE |
>  				  SNDRV_PCM_INFO_RESUME,
> -	.formats		= SNDRV_PCM_FMTBIT_S16_LE,
> +	.formats		= SNDRV_PCM_FMTBIT_S16_LE |
> +				  SNDRV_PCM_FMTBIT_S32_LE,
>  	.period_bytes_min	= 32,
>  	.period_bytes_max	= 64 * 1024,
>  	.periods_min		= 2,
> @@ -149,6 +150,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
>  	struct omap_runtime_data *prtd = runtime->private_data;
>  	struct omap_pcm_dma_data *dma_data = prtd->dma_data;
>  	struct omap_dma_channel_params dma_params;
> +	int bytes;
>  
>  	/* return if this is a bufferless transfer e.g.
>  	 * codec <--> BT codec or GSM modem -- lg FIXME */
> @@ -156,11 +158,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
>  		return 0;
>  
>  	memset(&dma_params, 0, sizeof(dma_params));
> -	/*
> -	 * Note: Regardless of interface data formats supported by OMAP McBSP
> -	 * or EAC blocks, internal representation is always fixed 16-bit/sample
> -	 */

Perhaps this should be rewritten to reflect mcbsp and mcpdm users rather
than deleted.

> -	dma_params.data_type			= OMAP_DMA_DATA_TYPE_S16;
> +	dma_params.data_type			= dma_data->data_type;
>  	dma_params.trigger			= dma_data->dma_req;
>  	dma_params.sync_mode			= dma_data->sync_mode;
>  	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
> @@ -170,6 +168,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
>  		dma_params.src_start		= runtime->dma_addr;
>  		dma_params.dst_start		= dma_data->port_addr;
>  		dma_params.dst_port		= OMAP_DMA_PORT_MPUI;
> +		dma_params.dst_fi		= dma_data->packet_size;
>  	} else {
>  		dma_params.src_amode		= OMAP_DMA_AMODE_CONSTANT;
>  		dma_params.dst_amode		= OMAP_DMA_AMODE_POST_INC;
> @@ -177,6 +176,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
>  		dma_params.src_start		= dma_data->port_addr;
>  		dma_params.dst_start		= runtime->dma_addr;
>  		dma_params.src_port		= OMAP_DMA_PORT_MPUI;
> +		dma_params.src_fi		= dma_data->packet_size;
>  	}
>  	/*
>  	 * Set DMA transfer frame size equal to ALSA period size and frame
> @@ -184,7 +184,8 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
>  	 * we can transfer the whole ALSA buffer with single DMA transfer but
>  	 * still can get an interrupt at each period bounary
>  	 */
> -	dma_params.elem_count	= snd_pcm_lib_period_bytes(substream) / 2;
> +	bytes = snd_pcm_lib_period_bytes(substream);
> +	dma_params.elem_count	= bytes >> dma_data->data_type;
>  	dma_params.frame_count	= runtime->periods;
>  	omap_set_dma_params(prtd->dma_ch, &dma_params);
>  
> diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
> index 38a821d..b19975d 100644
> --- a/sound/soc/omap/omap-pcm.h
> +++ b/sound/soc/omap/omap-pcm.h
> @@ -29,8 +29,10 @@ struct omap_pcm_dma_data {
>  	char		*name;		/* stream identifier */
>  	int		dma_req;	/* DMA request line */
>  	unsigned long	port_addr;	/* transmit/receive register */
> -	int		sync_mode;	/* DMA sync mode */
>  	void (*set_threshold)(struct snd_pcm_substream *substream);
> +	int		data_type;	/* data type 8,16,32 */
> +	int		sync_mode;	/* DMA sync mode */
> +	int		packet_size;	/* packet size only in PACKET mode */
>  };
>  
>  extern struct snd_soc_platform omap_soc_platform;

Liam

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/3] ASoC: OMAP: data_type and sync_mode configurable in audio dma
  2010-02-19 10:35 ` Liam Girdwood
@ 2010-02-19 14:03   ` Jarkko Nikula
  2010-02-19 14:16     ` Liam Girdwood
  0 siblings, 1 reply; 4+ messages in thread
From: Jarkko Nikula @ 2010-02-19 14:03 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: Candelaria Villareal, Jorge, broonie@opensource.wolfsonmicro.com,
	alsa-devel@alsa-project.org

On Fri, 19 Feb 2010 10:35:25 +0000
Liam Girdwood <lrg@slimlogic.co.uk> wrote:

> > @@ -156,11 +158,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
> >  		return 0;
> >  
> >  	memset(&dma_params, 0, sizeof(dma_params));
> > -	/*
> > -	 * Note: Regardless of interface data formats supported by OMAP McBSP
> > -	 * or EAC blocks, internal representation is always fixed 16-bit/sample
> > -	 */
> 
> Perhaps this should be rewritten to reflect mcbsp and mcpdm users rather
> than deleted.
> 
I'm fine with the deletion. AFAIK there is no public specs for the EAC
(at least not for the OMAP2420) so I see this comment only confusing
(I wrote it) and a person who would write DAI driver for the EAC most
probably has accesses to the specs.


-- 
Jarkko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 1/3] ASoC: OMAP: data_type and sync_mode configurable in audio dma
  2010-02-19 14:03   ` Jarkko Nikula
@ 2010-02-19 14:16     ` Liam Girdwood
  0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-02-19 14:16 UTC (permalink / raw)
  To: Jarkko Nikula, Candelaria Villareal, Jorge
  Cc: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com

On Fri, 2010-02-19 at 16:03 +0200, Jarkko Nikula wrote:
> On Fri, 19 Feb 2010 10:35:25 +0000
> Liam Girdwood <lrg@slimlogic.co.uk> wrote:
> 
> > > @@ -156,11 +158,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
> > >  		return 0;
> > >  
> > >  	memset(&dma_params, 0, sizeof(dma_params));
> > > -	/*
> > > -	 * Note: Regardless of interface data formats supported by OMAP McBSP
> > > -	 * or EAC blocks, internal representation is always fixed 16-bit/sample
> > > -	 */
> > 
> > Perhaps this should be rewritten to reflect mcbsp and mcpdm users rather
> > than deleted.
> > 
> I'm fine with the deletion. AFAIK there is no public specs for the EAC
> (at least not for the OMAP2420) so I see this comment only confusing
> (I wrote it) and a person who would write DAI driver for the EAC most
> probably has accesses to the specs.
> 

Ok, that's fine. 

Jorge, now it's only patch 2/3 requiring a little work.

Liam 

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-19 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-19  0:32 [PATCH v3 1/3] ASoC: OMAP: data_type and sync_mode configurable in audio dma Candelaria Villareal, Jorge
2010-02-19 10:35 ` Liam Girdwood
2010-02-19 14:03   ` Jarkko Nikula
2010-02-19 14:16     ` Liam Girdwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.