[alsa-devel] problem with copy function

Shahram Shabpareh shabpareh.shahram.7 at gmail.com
Tue Jul 19 09:56:06 CEST 2016


Hi
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?

thanks


More information about the Alsa-devel mailing list