LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] at73c213: Monaural support
@ 2008-03-07 10:02 Atsushi Nemoto
  2008-03-07 12:13 ` Hans-Christian Egtvedt
  0 siblings, 1 reply; 4+ messages in thread
From: Atsushi Nemoto @ 2008-03-07 10:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Hans-Christian Egtvedt, Haavard Skinnemoen, Andrew Victor

This patch add support for monaural playback to at73c213 driver.  The
sound will be apear on L-channel.  Tested on AT91SAM9260-EK.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 89d6e9c..a7839cc 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -118,7 +118,7 @@ static struct snd_pcm_hardware snd_at73c213_playback_hw = {
 	.rates		= SNDRV_PCM_RATE_CONTINUOUS,
 	.rate_min	= 8000,  /* Replaced by chip->bitrate later. */
 	.rate_max	= 50000, /* Replaced by chip->bitrate later. */
-	.channels_min	= 2,
+	.channels_min	= 1,
 	.channels_max	= 2,
 	.buffer_bytes_max = 64 * 1024 - 1,
 	.period_bytes_min = 512,
@@ -228,6 +228,14 @@ static int snd_at73c213_pcm_close(struct snd_pcm_substream *substream)
 static int snd_at73c213_pcm_hw_params(struct snd_pcm_substream *substream,
 				 struct snd_pcm_hw_params *hw_params)
 {
+	struct snd_at73c213 *chip = snd_pcm_substream_chip(substream);
+	int channels = params_channels(hw_params);
+	int val;
+
+	val = ssc_readl(chip->ssc->regs, TFMR);
+	val = SSC_BFINS(TFMR_DATNB, channels - 1, val);
+	ssc_writel(chip->ssc->regs, TFMR, val);
+
 	return snd_pcm_lib_malloc_pages(substream,
 					params_buffer_bytes(hw_params));
 }
@@ -249,10 +257,12 @@ static int snd_at73c213_pcm_prepare(struct snd_pcm_substream *substream)
 
 	ssc_writel(chip->ssc->regs, PDC_TPR,
 			(long)runtime->dma_addr);
-	ssc_writel(chip->ssc->regs, PDC_TCR, runtime->period_size * 2);
+	ssc_writel(chip->ssc->regs, PDC_TCR,
+			runtime->period_size * runtime->channels);
 	ssc_writel(chip->ssc->regs, PDC_TNPR,
 			(long)runtime->dma_addr + block_size);
-	ssc_writel(chip->ssc->regs, PDC_TNCR, runtime->period_size * 2);
+	ssc_writel(chip->ssc->regs, PDC_TNCR,
+			runtime->period_size * runtime->channels);
 
 	return 0;
 }
@@ -375,7 +385,8 @@ static irqreturn_t snd_at73c213_interrupt(int irq, void *dev_id)
 
 		ssc_writel(chip->ssc->regs, PDC_TNPR,
 				(long)runtime->dma_addr + offset);
-		ssc_writel(chip->ssc->regs, PDC_TNCR, runtime->period_size * 2);
+		ssc_writel(chip->ssc->regs, PDC_TNCR,
+				runtime->period_size * runtime->channels);
 		retval = IRQ_HANDLED;
 	}
 

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

* Re: [PATCH] at73c213: Monaural support
  2008-03-07 10:02 [PATCH] at73c213: Monaural support Atsushi Nemoto
@ 2008-03-07 12:13 ` Hans-Christian Egtvedt
  2008-03-07 15:25   ` Atsushi Nemoto
  0 siblings, 1 reply; 4+ messages in thread
From: Hans-Christian Egtvedt @ 2008-03-07 12:13 UTC (permalink / raw)
  To: Atsushi Nemoto
  Cc: linux-kernel, Hans-Christian Egtvedt, Haavard Skinnemoen, Andrew Victor

Atsushi Nemoto wrote:
> This patch add support for monaural playback to at73c213 driver.  The
> sound will be apear on L-channel.  Tested on AT91SAM9260-EK.
> 

This works fine for me on AT32AP7000 on STK1000 as well.

Although, I had to use 32 * 1024 buffer_bytes_max and 16 * 1024
period_bytes_max. Higher buffer_bytes_max resulted in glitching sound
when only using one channel. Nothing to do with this patch.

> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

Acked-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>

> ---
> diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
> index 89d6e9c..a7839cc 100644
> --- a/sound/spi/at73c213.c
> +++ b/sound/spi/at73c213.c
> @@ -118,7 +118,7 @@ static struct snd_pcm_hardware snd_at73c213_playback_hw = {
>  	.rates		= SNDRV_PCM_RATE_CONTINUOUS,
>  	.rate_min	= 8000,  /* Replaced by chip->bitrate later. */
>  	.rate_max	= 50000, /* Replaced by chip->bitrate later. */
> -	.channels_min	= 2,
> +	.channels_min	= 1,
>  	.channels_max	= 2,
>  	.buffer_bytes_max = 64 * 1024 - 1,
>  	.period_bytes_min = 512,
> @@ -228,6 +228,14 @@ static int snd_at73c213_pcm_close(struct snd_pcm_substream *substream)
>  static int snd_at73c213_pcm_hw_params(struct snd_pcm_substream *substream,
>  				 struct snd_pcm_hw_params *hw_params)
>  {
> +	struct snd_at73c213 *chip = snd_pcm_substream_chip(substream);
> +	int channels = params_channels(hw_params);
> +	int val;
> +
> +	val = ssc_readl(chip->ssc->regs, TFMR);
> +	val = SSC_BFINS(TFMR_DATNB, channels - 1, val);
> +	ssc_writel(chip->ssc->regs, TFMR, val);
> +
>  	return snd_pcm_lib_malloc_pages(substream,
>  					params_buffer_bytes(hw_params));
>  }
> @@ -249,10 +257,12 @@ static int snd_at73c213_pcm_prepare(struct snd_pcm_substream *substream)
>  
>  	ssc_writel(chip->ssc->regs, PDC_TPR,
>  			(long)runtime->dma_addr);
> -	ssc_writel(chip->ssc->regs, PDC_TCR, runtime->period_size * 2);
> +	ssc_writel(chip->ssc->regs, PDC_TCR,
> +			runtime->period_size * runtime->channels);
>  	ssc_writel(chip->ssc->regs, PDC_TNPR,
>  			(long)runtime->dma_addr + block_size);
> -	ssc_writel(chip->ssc->regs, PDC_TNCR, runtime->period_size * 2);
> +	ssc_writel(chip->ssc->regs, PDC_TNCR,
> +			runtime->period_size * runtime->channels);
>  
>  	return 0;
>  }
> @@ -375,7 +385,8 @@ static irqreturn_t snd_at73c213_interrupt(int irq, void *dev_id)
>  
>  		ssc_writel(chip->ssc->regs, PDC_TNPR,
>  				(long)runtime->dma_addr + offset);
> -		ssc_writel(chip->ssc->regs, PDC_TNCR, runtime->period_size * 2);
> +		ssc_writel(chip->ssc->regs, PDC_TNCR,
> +				runtime->period_size * runtime->channels);
>  		retval = IRQ_HANDLED;
>  	}
>  


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

* Re: [PATCH] at73c213: Monaural support
  2008-03-07 12:13 ` Hans-Christian Egtvedt
@ 2008-03-07 15:25   ` Atsushi Nemoto
  2008-03-07 15:28     ` Hans-Christian Egtvedt
  0 siblings, 1 reply; 4+ messages in thread
From: Atsushi Nemoto @ 2008-03-07 15:25 UTC (permalink / raw)
  To: hans-christian.egtvedt; +Cc: linux-kernel, hcegtvedt, hskinnemoen, avictor.za

On Fri, 07 Mar 2008 13:13:57 +0100, Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> wrote:
> This works fine for me on AT32AP7000 on STK1000 as well.

Thanks, good news.

> Although, I had to use 32 * 1024 buffer_bytes_max and 16 * 1024
> period_bytes_max. Higher buffer_bytes_max resulted in glitching sound
> when only using one channel. Nothing to do with this patch.

Hmm, it sounds strange.  But I still do not understand sound buffer
management well...

---
Atsushi Nemoto

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

* Re: [PATCH] at73c213: Monaural support
  2008-03-07 15:25   ` Atsushi Nemoto
@ 2008-03-07 15:28     ` Hans-Christian Egtvedt
  0 siblings, 0 replies; 4+ messages in thread
From: Hans-Christian Egtvedt @ 2008-03-07 15:28 UTC (permalink / raw)
  To: Atsushi Nemoto
  Cc: linux-kernel, hans-christian.egtvedt, hskinnemoen, avictor.za

Atsushi Nemoto wrote:
> On Fri, 07 Mar 2008 13:13:57 +0100, Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com> wrote:

>> Although, I had to use 32 * 1024 buffer_bytes_max and 16 * 1024
>> period_bytes_max. Higher buffer_bytes_max resulted in glitching sound
>> when only using one channel. Nothing to do with this patch.
> 
> Hmm, it sounds strange.  But I still do not understand sound buffer
> management well...
> 

Me neither, alsa is a bit big and tons of layer hiding where stuff is 
actually done. Still unsure what to do about the buffer and period size, 
but I think setting them to 32k and 16k will work for most people.

-- 
HC, which just got a new email address

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

end of thread, other threads:[~2008-03-07 15:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07 10:02 [PATCH] at73c213: Monaural support Atsushi Nemoto
2008-03-07 12:13 ` Hans-Christian Egtvedt
2008-03-07 15:25   ` Atsushi Nemoto
2008-03-07 15:28     ` Hans-Christian Egtvedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).