All of lore.kernel.org
 help / color / mirror / Atom feed
* Alsa driver data transfer problem: the MSB is changed to 1
@ 2006-09-28  8:43 YongLi
  2006-09-28 12:59 ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: YongLi @ 2006-09-28  8:43 UTC (permalink / raw)
  To: alsa-devel

Hello All,

I am desiging a TI sound card driver on my ARM board using Linux 2.6.18.

The ARM SOC uses IIS and IIC to control this soud codec chip. 

I found a stranger problem reltaed to the sound PCM data: The data transfered by DMA is different from the data I write to the sound device!

If I perform this command:

cat test.txt > /dev/dsp

using the printk to trace the data flow, I found the snd_pcm_oss_write function write all the data in test.txt to 
substream->runtime->oss.buffer. However, In the snd_pcm_plug_write_transfer function, the channel changes and the data is different:

original data(text.txt):
[00]=30
[01]=31
[02]=32
[03]=33
[04]=34
[05]=35
[06]=36
[07]=37
[08]=38
[09]=39
[10]=0a

The modified data:
[00]=00
[01]=b0
[02]=00
[03]=b0
[04]=00
[05]=b1
[06]=00
[07]=b1
[08]=00
[09]=b2
[10]=00
[11]=b2
[12]=00
[13]=b3
[14]=00
[15]=b3

It seems that all the 8th bit are changed to 1. I am not sure if it is correct.

Thank you!

Tyler Li

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Alsa driver data transfer problem: the MSB is changed to 1
  2006-09-28  8:43 Alsa driver data transfer problem: the MSB is changed to 1 YongLi
@ 2006-09-28 12:59 ` Takashi Iwai
  2006-09-29  1:33   ` YongLi
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2006-09-28 12:59 UTC (permalink / raw)
  To: YongLi; +Cc: alsa-devel

At Thu, 28 Sep 2006 16:43:06 +0800,
YongLi wrote:
> 
> Hello All,
> 
> I am desiging a TI sound card driver on my ARM board using Linux 2.6.18.
> 
> The ARM SOC uses IIS and IIC to control this soud codec chip. 
> 
> I found a stranger problem reltaed to the sound PCM data: The data transfered by DMA is different from the data I write to the sound device!
> 
> If I perform this command:
> 
> cat test.txt > /dev/dsp
> 
> using the printk to trace the data flow, I found the snd_pcm_oss_write function write all the data in test.txt to 
> substream->runtime->oss.buffer. However, In the snd_pcm_plug_write_transfer function, the channel changes and the data is different:
> 
> original data(text.txt):
> [00]=30
> [01]=31
> [02]=32
> [03]=33
> [04]=34
> [05]=35
> [06]=36
> [07]=37
> [08]=38
> [09]=39
> [10]=0a
> 
> The modified data:
> [00]=00
> [01]=b0
> [02]=00
> [03]=b0
> [04]=00
> [05]=b1
> [06]=00
> [07]=b1
> [08]=00
> [09]=b2
> [10]=00
> [11]=b2
> [12]=00
> [13]=b3
> [14]=00
> [15]=b3
> 
> It seems that all the 8th bit are changed to 1. I am not sure if it is correct.

The OSS-emulation code converts format, rate, channels, etc,
automatically for the parameters that hardware accepts.
So, "cat /dev/dsp" doesn't always pass the raw data as it is.

Check the PCM status on /proc/asound/card0/pcm0p/sub0/* (enabled when
built with CONFIG_SND_VERBOSE_PROCFS).


Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Alsa driver data transfer problem: the MSB is changed to 1
  2006-09-28 12:59 ` Takashi Iwai
@ 2006-09-29  1:33   ` YongLi
  2006-09-29 10:21     ` Takashi Iwai
  2006-09-29 12:14     ` James Courtier-Dutton
  0 siblings, 2 replies; 5+ messages in thread
From: YongLi @ 2006-09-29  1:33 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel


----- Original Message ----- 
From: "Takashi Iwai" <tiwai@suse.de>
To: "YongLi" <sdshliyong@163.com>
Cc: <alsa-devel@lists.sourceforge.net>
Sent: Thursday, September 28, 2006 8:59 PM
Subject: Re: [Alsa-devel] Alsa driver data transfer problem: the MSB is changed to 1


> At Thu, 28 Sep 2006 16:43:06 +0800,
> YongLi wrote:
>> 
>> Hello All,
>> 
>> I am desiging a TI sound card driver on my ARM board using Linux 2.6.18.
>> 
>> The ARM SOC uses IIS and IIC to control this soud codec chip. 
>> 
>> I found a stranger problem reltaed to the sound PCM data: The data transfered by DMA is different from the data I write to the sound device!
>> 
>> If I perform this command:
>> 
>> cat test.txt > /dev/dsp
>> 
>> using the printk to trace the data flow, I found the snd_pcm_oss_write function write all the data in test.txt to 
>> substream->runtime->oss.buffer. However, In the snd_pcm_plug_write_transfer function, the channel changes and the data is different:
>> 
>> original data(text.txt):
>> [00]=30
>> [01]=31
>> [02]=32
>> [03]=33
>> [04]=34
>> [05]=35
>> [06]=36
>> [07]=37
>> [08]=38
>> [09]=39
>> [10]=0a
>> 
>> The modified data:
>> [00]=00
>> [01]=b0
>> [02]=00
>> [03]=b0
>> [04]=00
>> [05]=b1
>> [06]=00
>> [07]=b1
>> [08]=00
>> [09]=b2
>> [10]=00
>> [11]=b2
>> [12]=00
>> [13]=b3
>> [14]=00
>> [15]=b3
>> 
>> It seems that all the 8th bit are changed to 1. I am not sure if it is correct.
> 
> The OSS-emulation code converts format, rate, channels, etc,
> automatically for the parameters that hardware accepts.
> So, "cat /dev/dsp" doesn't always pass the raw data as it is.
> 
> Check the PCM status on /proc/asound/card0/pcm0p/sub0/* (enabled when
> built with CONFIG_SND_VERBOSE_PROCFS).
> 
> 
> Takashi
>

Thank you for your email!

I am using linux 2.6.16 and did not found the CONFIG_SND_VERBOSE_PROCFS option, it seems that the kernel supports this option automatically.

Regarding the /proc/asound/card0/pcm0p/sub0/status file, after I cat something to /dev/dsp, the status file content is:
state: RUNNING
trigger_time: 1706.262101000
tstamp      : 1958.720932000
delay       : 16018
avail       : 366
avail_max   : 3437
-----
hw_ptr      : 7872878
appl_ptr    : 7888896

I want to know why the OSS-emulation code converts the data automatically, in which source file? If I use mplayer to play some wav or mp3 music, does this convert affect the sound?

Thank you again!

Tyler Li

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Alsa driver data transfer problem: the MSB is changed to 1
  2006-09-29  1:33   ` YongLi
@ 2006-09-29 10:21     ` Takashi Iwai
  2006-09-29 12:14     ` James Courtier-Dutton
  1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2006-09-29 10:21 UTC (permalink / raw)
  To: YongLi; +Cc: alsa-devel

At Fri, 29 Sep 2006 09:33:15 +0800,
YongLi wrote:
> 
> 
> ----- Original Message ----- 
> From: "Takashi Iwai" <tiwai@suse.de>
> To: "YongLi" <sdshliyong@163.com>
> Cc: <alsa-devel@lists.sourceforge.net>
> Sent: Thursday, September 28, 2006 8:59 PM
> Subject: Re: [Alsa-devel] Alsa driver data transfer problem: the MSB is changed to 1
> 
> 
> > At Thu, 28 Sep 2006 16:43:06 +0800,
> > YongLi wrote:
> >> 
> >> Hello All,
> >> 
> >> I am desiging a TI sound card driver on my ARM board using Linux 2.6.18.
> >> 
> >> The ARM SOC uses IIS and IIC to control this soud codec chip. 
> >> 
> >> I found a stranger problem reltaed to the sound PCM data: The data transfered by DMA is different from the data I write to the sound device!
> >> 
> >> If I perform this command:
> >> 
> >> cat test.txt > /dev/dsp
> >> 
> >> using the printk to trace the data flow, I found the snd_pcm_oss_write function write all the data in test.txt to 
> >> substream->runtime->oss.buffer. However, In the snd_pcm_plug_write_transfer function, the channel changes and the data is different:
> >> 
> >> original data(text.txt):
> >> [00]=30
> >> [01]=31
> >> [02]=32
> >> [03]=33
> >> [04]=34
> >> [05]=35
> >> [06]=36
> >> [07]=37
> >> [08]=38
> >> [09]=39
> >> [10]=0a
> >> 
> >> The modified data:
> >> [00]=00
> >> [01]=b0
> >> [02]=00
> >> [03]=b0
> >> [04]=00
> >> [05]=b1
> >> [06]=00
> >> [07]=b1
> >> [08]=00
> >> [09]=b2
> >> [10]=00
> >> [11]=b2
> >> [12]=00
> >> [13]=b3
> >> [14]=00
> >> [15]=b3
> >> 
> >> It seems that all the 8th bit are changed to 1. I am not sure if it is correct.
> > 
> > The OSS-emulation code converts format, rate, channels, etc,
> > automatically for the parameters that hardware accepts.
> > So, "cat /dev/dsp" doesn't always pass the raw data as it is.
> > 
> > Check the PCM status on /proc/asound/card0/pcm0p/sub0/* (enabled when
> > built with CONFIG_SND_VERBOSE_PROCFS).
> > 
> > 
> > Takashi
> >
> 
> Thank you for your email!
> 
> I am using linux 2.6.16 and did not found the
> CONFIG_SND_VERBOSE_PROCFS option, it seems that the kernel supports
> this option automatically. 
> 
> Regarding the /proc/asound/card0/pcm0p/sub0/status file, after I cat
> something to /dev/dsp, the status file content is:
> state: RUNNING
> trigger_time: 1706.262101000
> tstamp      : 1958.720932000
> delay       : 16018
> avail       : 366
> avail_max   : 3437
> -----
> hw_ptr      : 7872878
> appl_ptr    : 7888896

Look at hw_params file.  It shows the hardware parameters.
If the parameter doesn't match with what you specified in the apps,
the conversion is done.

> I want to know why the OSS-emulation code converts the data
> automatically, in which source file?

core/oss/*.c

> If I use mplayer to play some
> wav or mp3 music, does this convert affect the sound? 

No matter what OSS apps, the conversion occurs when the apps pass
hardware parameters that are not supported by the device.


Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

* Re: Alsa driver data transfer problem: the MSB is changed to 1
  2006-09-29  1:33   ` YongLi
  2006-09-29 10:21     ` Takashi Iwai
@ 2006-09-29 12:14     ` James Courtier-Dutton
  1 sibling, 0 replies; 5+ messages in thread
From: James Courtier-Dutton @ 2006-09-29 12:14 UTC (permalink / raw)
  To: YongLi; +Cc: Takashi Iwai, alsa-devel

On 29/09/06, YongLi <sdshliyong@163.com> wrote:
> If I perform this command:
>
> cat test.txt > /dev/dsp
>

That command does not specifiy to /dev/dsp what format the file is.
I.e 8 bit audio or 16bit audio. The OSS api specifies a default
assumed value. Now, if the sound card itself cannot handle the assumed
value, it will automatically adjust the format so that some sound
plays.

As I said before, use aplay instead of cat.

James

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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

end of thread, other threads:[~2006-09-29 12:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-28  8:43 Alsa driver data transfer problem: the MSB is changed to 1 YongLi
2006-09-28 12:59 ` Takashi Iwai
2006-09-29  1:33   ` YongLi
2006-09-29 10:21     ` Takashi Iwai
2006-09-29 12:14     ` James Courtier-Dutton

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.