public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* i810_audio mono troubles
@ 2001-12-18  4:57 Greg Pomerantz
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Pomerantz @ 2001-12-18  4:57 UTC (permalink / raw)
  To: linux-kernel

Monaural audio streams on my Sony Vaio PCG-R505TSK play at double speed
under Debian woody / kernel 2.4.16. I've written a quick hack to fix
it, and I was curious if this problem is affecting anybody else, or if
it is specific to my platform. I have been communicating with a number
of people on the linux-sony mailing list who are also having what appear
to be sample-rate related problems with the i810s in Sony Vaios.

Just posting this to make all of theiti810 fans aware of this. My patch
is most likely not the right way to do things, but it does work... I am
particularly curious to hear if I am doing the right thing with
I810_FMT_STEREO.

This patch was made against 2.4.16, but it applies fine (offset -4
lines) against 2.4.17-rc1. My platform is Debian woody, kernel 2.4.16.
My i810 vital statistics:

  Intel 810 + AC97 Audio, version 0.04, 23:16:04 Dec 17 2001
  PCI: Found IRQ 5 for device 00:1f.5
  PCI: Sharing IRQ 5 with 00:1f.3
  PCI: Sharing IRQ 5 with 00:1f.6
  PCI: Setting latency timer of device 00:1f.5 to 64
  i810: Intel ICH2 found at IO 0x1840 and 0x1c00, IRQ 5
  i810_audio: Audio Controller supports 6 channels.
  ac97_codec: AC97 Audio codec, id: 0x4144:0x5348 (Analog Devices AD1881A)
  i810_audio: AC'97 codec 0 Unable to map surround DAC's (or DAC's not present), total channels = 2
  ac97_codec: AC97 Modem codec, id: 0x4358:0x5421 (Unknown)
  i810_audio: timed out waiting for codec 1 analog ready


Take care,

Greg Pomerantz

#text/plain;name=patch-i810-mono-2.4.16 /home/gmp/work/stuff/patch-i810-mono-2.4.16


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

* Re: i810_audio mono troubles
@ 2001-12-18  4:58 Greg Pomerantz
  2001-12-18 16:11 ` Doug Ledford
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Pomerantz @ 2001-12-18  4:58 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: patch-i810-mono-2.4.16 --]
[-- Type: text/plain, Size: 531 bytes --]

+++ drivers/sound/i810_audio.c	Mon Dec 17 23:15:19 2001
@@ -609,6 +609,9 @@
 	
 	new_rate = ac97_set_dac_rate(codec, rate);
 
+	if ((dmabuf->fmt & I810_FMT_STEREO) == 0)
+		new_rate *= 2;
+
 	if(new_rate != rate) {
 		dmabuf->rate = (new_rate * 48000)/clocking;
 	}
@@ -1687,6 +1690,12 @@
 		if (dmabuf->enable & ADC_RUNNING) {
 			stop_adc(state);
 		}
+
+		if (*(int *)arg == 0)
+			dmabuf->fmt &= ~I810_FMT_STEREO;
+		else
+			dmabuf->fmt |= I810_FMT_STEREO;
+
 		return put_user(1, (int *)arg);
 
 	case SNDCTL_DSP_GETBLKSIZE:

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

* Re: i810_audio mono troubles
  2001-12-18  4:58 i810_audio mono troubles Greg Pomerantz
@ 2001-12-18 16:11 ` Doug Ledford
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2001-12-18 16:11 UTC (permalink / raw)
  To: Greg Pomerantz; +Cc: linux-kernel

Greg Pomerantz wrote:

> +++ drivers/sound/i810_audio.c	Mon Dec 17 23:15:19 2001
> @@ -609,6 +609,9 @@
>  	
>  	new_rate = ac97_set_dac_rate(codec, rate);
>  
> +	if ((dmabuf->fmt & I810_FMT_STEREO) == 0)
> +		new_rate *= 2;
> +
>  	if(new_rate != rate) {
>  		dmabuf->rate = (new_rate * 48000)/clocking;
>  	}
> @@ -1687,6 +1690,12 @@
>  		if (dmabuf->enable & ADC_RUNNING) {
>  			stop_adc(state);
>  		}
> +
> +		if (*(int *)arg == 0)
> +			dmabuf->fmt &= ~I810_FMT_STEREO;
> +		else
> +			dmabuf->fmt |= I810_FMT_STEREO;
> +
>  		return put_user(1, (int *)arg);
>  
>  	case SNDCTL_DSP_GETBLKSIZE:


OK, first off, Alan & Co. will shoot this one down because handling 
stereo/mono conversion belongs in user space (the agreed upon way of 
handling things evidently).  Secondly, aside from that point, this is wrong 
anyway.  You are dividing the play rate in half to compensate for the fact 
that the sound is being sent to two channels instead of one.  So, now each 
channel is playing at half speed and slightly out of phase and with much 
reduced high frequency clarity.  Instead, what you should do, is byte double 
the stream (CPU consuming).  You would need to take any input buffer and 
copy every 16bit sample.  A very simple (and non-optimized) stereo converter 
  might look like this:

short *input=&input_buffer, *output=&output_buffer;
int i,j;

for(i=0, j=0;i < input_size;i++, j+=2)
	output[j] = output[j+1] = input[i];



-- 

  Doug Ledford <dledford@redhat.com>  http://people.redhat.com/dledford
       Please check my web site for aic7xxx updates/answers before
                       e-mailing me about problems


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

end of thread, other threads:[~2001-12-18 16:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-18  4:58 i810_audio mono troubles Greg Pomerantz
2001-12-18 16:11 ` Doug Ledford
  -- strict thread matches above, loose matches on Subject: below --
2001-12-18  4:57 Greg Pomerantz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox