Re: problem with copy function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Jul 19 2016 16:56, Shahram Shabpareh wrote:
> I have a board with ti am3358 processor. it has a sound port called McASP
> and I've used IDT821034 as codec. The Linux kernel source package that is
> included by board company is 3.2.0 and I wrote a basic driver for IDT821034
> codec and changed the code of davinci-mcasp.c . Now the basic functionality
> of system is ok and i have signals on oscilloscope. Another thing is i have
> to setup a specific configuration for this system. the target system must
> have 32 tdm slots in each frame and 32 PCM channels and each slot is 8
> bits. this is also done in kernel source code. currently the problem is i
> want that data of channel 1 be mapped to slot 1, channel 2 be mapped to
> slot 2, .... and channel 32 be mapped to slot 32. but when i run aplay to
> send to only channel 1, data will be send to all slots! i want that all
> slots be 0 except slot 1. How can i do that?
> 
> I searched in source tree and found the function that i need to override
> this behaviour is copy that is defined in snd_pcm_ops structure. I defined
> a function called davinci_pcm_copy in davinci-pcm.c file and added the
> function to structure like below:
> 
> static struct snd_pcm_ops davinci_pcm_ops = {
>     ....
>     .copy = davinci_pcm_copy,
> };
> 
> the problem is, this copy function is not called at all by kernel pcm
> subsystem.
> 
> Again i searched the kernel code and found that copy function has a calling
> path as below:
> 
> alsa-lib -> snd_pcm_playback_ioctl -> snd_pcm_playback_ioctl1 ->
> snd_pcm_lib_write -> snd_pcm_lib_write1 -> snd_pcm_lib_write_transfer ->
> copy
> 
> but my calling path is:
> 
> alsa-lib -> snd_pcm_playback_ioctl -> snd_pcm_playback_ioctl1 ->
> snd_pcm_common_ioctl1 -> snd_pcm_sync_ptr
> 
> I created a wav file from a mp3 file with this command:
> 
> ffmpeg -i file.mp3 -ac 1 -ar 8000 -ab 64k -f u8 file.wav
> 
> and played with this command:
> 
> aplay -vv -c 1 file.wav
> 
> Strange thing is when i run this aplay command in my PC the first calling
> path is executed but when i run the same aplay with same file in my board
> the second calling path is executed. Is it related to software and hardware
> params of sound devices? if yes, what should i do to copy function being
> called in my board?

Would you check output of aplay command in a point of 'access' way? Like:

$ aplay -v -D hw:0,0 -f S16_LE -r 44100 -c 2 /dev/urandom
...
Hardware PCM card 0 'HDA Intel PCH' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
...

In this case, the process executes ioctl(2) with
SNDRV_PCM_IOCTL_WRITEI_FRAMES, thus the .copy() in kernel is probably
executed.

But in this case:
$ aplay -v -D plughw:0,0 /dev/urandom
...
Slave: Hardware PCM card 0 'HDA Intel PCH' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : MMAP_INTERLEAVED
...

The process run with mmap(2)ed page frame, thus PCM frames are not
transferred by ioctl(2).

Before going to the details, please check it.


Regards

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux