Skip to contentSkip to conversation

omap alsa tsc2101 driver

PATCH lamikr 3 participants 13 messages Feb 5, 2006 – Feb 8, 2006

Subsystems (4)
lore
Share & tools
lore

lamikr

author
#0 lore raw

Hi

I have not seen anyone working with the tsc2101 Alsa driver, so attached are the tsc2101 alsa driver sources I have been working for a while. The patch should apply to the omap-driver head. Unfortunately it is still non-functional at least with my omap 1510 based iPAQ h6340.

I can hear small start of the song but then nothing happens. I have tried to debug the code and I can see that the the driver is able to get one callback to sound_dma_irq_handler with DSCR_END_BLOCK set, but after it does not continue with a next period of code.

Here is some info from the driver
- all code is located in /sound/arm/omap as I have wanted to mix it to existing aic23 code until this one works
- based on to aic23 Alsa and tsc2101 OSS drivers. DMA code and driver base taken from the aic, but hardware initialization taken from the tsc2101 oss driver. (dma has only small changes like 16 bit mono to capture params instead of 32 bit ones supported in the aic23)
- mixer code for DGC, headset and handset
- debug is mostly printed by using DPRINTK() function and can be enabled by uncommenting "#define DEBUG 1" from the omap-alsa.h
- This is platform driver, so you need to register it to your board-code in arch/arm/mach-omap1/board-* in a following way:

        static struct platform_device h6300_mcbsp1_device = {
                    .name        = "omap_tsc2101_mcbsp",
                    .id        = 1,
            };

        static struct platform_device *h6300_devices[] __initdata = {
                ...  
                &h6300_mcbsp1_device,
        };

I have only tested this with omap1510 based iPAQ h6300, so I would appreciate if somebody else could test this with other devices having tsc2101 chipset to find out whether this is just my hw specific problem. (Fixes would ofcource also be nice :-)

For testing the driver I have plugged headset and listened the result of following commands
- aplay song.wav (44100 hz 16 bit little endion format)
- "speaker-test -r 8000", "-r 44100", etc...

I have also tryed to change the audio_get_dma_pos() method to be like in the sa11xx-uda1341.c driver. With implementation
based on to that, the speaker-test is able to produce somekind of periodic "wuff <silence> wuff <silence> wuff..." sound. (that method version is commented out in the omap-alsa-tsc2101.c)

In addition to sources, attached is the log from one play attempt.

Mika

root@h6300:~# aplay free_breakbeat.wav
Playing WAVE 'free_breakbeat.wav' : Signed 16 bit Little Endian, Rate
44100 Hz, Stereo
aplay: pcm_write:1146: write error: Input/output error
root@h6300:~# dmesg
XXX Alsa debug f:omap_alsa_tsc2101_init, l:1157
XXX Alsa debug f:snd_omap_alsa_tsc2101_probe, l:1077
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_pcm, l:845
XXX Alsa debug f:omap_alsa_tsc2101_audio_init, l:350
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
[snd_omap_init_mixer]: start
[setRecordSource]: start
[setRecordSource]: end(0)
[snd_omap_init_mixer]: end(0)
OMAP_ALSA_TSC2101 audio support initialized
<omap_alsa_tsc2101_clock_on>: clock use count = 0
<omap_alsa_tsc2101_clock_on>: old clock rate = 12000000
omap_alsa_tsc2101_clock_on(), no need to change clock rate, rate already
12000000 Hz.
<omap_alsa_tsc2101_clock_on>: MCLK = 12000000 [12000000], usecount = 1,
clk_enable retval = 0
<snd_card_omap_alsa_tsc2101_open>: runtime->hw =
snd_omap_alsa_tsc2101_playback
<snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(),
size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:686
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:248
<omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL
<snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started,  offset = 0, dma_size = 8192, s->period =
0, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042022400, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:229
XXX Alsa debug f:audio_ifc_start, l:222
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0,
s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status =
32, data = c0b0608c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling
audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<audio_process_dma>: started,  offset = 8192, dma_size = 8192, s->period
= 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042014208
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042014208, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period =
1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size
= 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr
= 0, dma_ptr = -1042014208
<sound_dma_irq_handler>: done
ALSA
/home/lamikr/own/h6300/git/linux-omap-h6300-2.6/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?)
<snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:488
[omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0)
[omap_clear_alsa_sound_dma]: start
[omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:785
<omap_alsa_tsc2101_clock_off>: clock use count = 1
<omap_alsa_tsc2101_clock_off>: clock rate = 12000000
<omap_alsa_tsc2101_clock_off>: clock disabled
<omap_alsa_tsc2101_clock_off>: audio codec off
sound/arm/Kconfig +10 -0
diff -Naur linux-omap-2.6/sound/arm/Kconfig linux-omap-h6300-2.6/sound/arm/Kconfig
@@ -45,4 +45,14 @@
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-omap-aic23.
 
+config SND_OMAP_ALSA_TSC2101
+	tristate "TSC2101 driver for OMAP boards which has TSC2101 chip."
+	depends ARCH_OMAP1
+	select SND_PCM
+	help
+	  Say Y here if you have a OMAP platform board (iPAQ H63xx for example)
+	  and want to use its TSC2101 audio chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-omap-alsa-tsc2101.
 endmenu
sound/arm/Makefile +2 -0
diff -Naur linux-omap-2.6/sound/arm/Makefile linux-omap-h6300-2.6/sound/arm/Makefile
@@ -16,3 +16,5 @@
 
 obj-$(CONFIG_SND_OMAP_AIC23) += snd-omap-aic23.o
 snd-omap-aic23-objs := omap-aic23.o omap-alsa-dma.o omap-alsa-mixer.o
+
+obj-$(CONFIG_SND) += omap/
sound/arm/omap/Makefile +8 -0
diff -Naur linux-omap-2.6/sound/arm/omap/Makefile linux-omap-h6300-2.6/sound/arm/omap/Makefile
@@ -0,0 +1,8 @@
+#
+# Makefile for ALSA
+#
+
+snd-omap-alsa-tsc2101-objs := omap-alsa-tsc2101.o omap-alsa-tsc2101-dma.o omap-alsa-tsc2101-mixer.o
+
+# Toplevel Module Dependency
+obj-$(CONFIG_SND_OMAP_ALSA_TSC2101)   += snd-omap-alsa-tsc2101.o
sound/arm/omap/omap-alsa.h +88 -0

88 lines not on this page · raw message

sound/arm/omap/omap-alsa-tsc2101.c +1170 -0

1,170 lines not on this page · raw message

sound/arm/omap/omap-alsa-tsc2101-dma.c +530 -0

530 lines not on this page · raw message

sound/arm/omap/omap-alsa-tsc2101-dma.h +61 -0

61 lines not on this page · raw message

sound/arm/omap/omap-alsa-tsc2101.h +75 -0

75 lines not on this page · raw message

sound/arm/omap/omap-alsa-tsc2101-mixer.c +645 -0

645 lines not on this page · raw message

sound/arm/omap/omap-alsa-tsc2101-mixer.h +67 -0

67 lines not on this page · raw message

#1 lore raw

Hi Mika,

I have been working in this ALSA driver as well, and I have a functional patch that plays songs but lacks the mixer support yet. What do you think of join the drivers to make it work faster? I am developing it generically in order to take advantage of existing common code as dma and alsa generic.

Daniel

Quoted 157 lines · lamikr

Hi

I have not seen anyone working with the tsc2101 Alsa driver, so attached are the tsc2101 alsa driver sources I have been working for a while. The patch should apply to the omap-driver head. Unfortunately it is still non-functional at least with my omap 1510 based iPAQ h6340.

I can hear small start of the song but then nothing happens. I have tried to debug the code and I can see that the the driver is able to get one callback to sound_dma_irq_handler with DSCR_END_BLOCK set, but after it does not continue with a next period of code.

Here is some info from the driver
- all code is located in /sound/arm/omap as I have wanted to mix it to existing aic23 code until this one works
- based on to aic23 Alsa and tsc2101 OSS drivers. DMA code and driver base taken from the aic, but hardware initialization taken from the tsc2101 oss driver. (dma has only small changes like 16 bit mono to capture params instead of 32 bit ones supported in the aic23)
- mixer code for DGC, headset and handset
- debug is mostly printed by using DPRINTK() function and can be enabled by uncommenting "#define DEBUG 1" from the omap-alsa.h
- This is platform driver, so you need to register it to your board-code in arch/arm/mach-omap1/board-* in a following way:

        static struct platform_device h6300_mcbsp1_device = {
                    .name        = "omap_tsc2101_mcbsp",
                    .id        = 1,
            };

        static struct platform_device *h6300_devices[] __initdata = {
                ...
                &h6300_mcbsp1_device,
        };

I have only tested this with omap1510 based iPAQ h6300, so I would appreciate if somebody else could test this with other devices having tsc2101 chipset to find out whether this is just my hw specific problem. (Fixes would ofcource also be nice :-)

For testing the driver I have plugged headset and listened the result of following commands
- aplay song.wav (44100 hz 16 bit little endion format)
- "speaker-test -r 8000", "-r 44100", etc...

I have also tryed to change the audio_get_dma_pos() method to be like in the sa11xx-uda1341.c driver. With implementation
based on to that, the speaker-test is able to produce somekind of periodic "wuff <silence> wuff <silence> wuff..." sound. (that method version is commented out in the omap-alsa-tsc2101.c)

In addition to sources, attached is the log from one play attempt.

Mika

root@h6300:~# aplay free_breakbeat.wav
Playing WAVE 'free_breakbeat.wav' : Signed 16 bit Little Endian, Rate
44100 Hz, Stereo
aplay: pcm_write:1146: write error: Input/output error
root@h6300:~# dmesg
XXX Alsa debug f:omap_alsa_tsc2101_init, l:1157
XXX Alsa debug f:snd_omap_alsa_tsc2101_probe, l:1077
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_pcm, l:845
XXX Alsa debug f:omap_alsa_tsc2101_audio_init, l:350
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
[snd_omap_init_mixer]: start
[setRecordSource]: start
[setRecordSource]: end(0)
[snd_omap_init_mixer]: end(0)
OMAP_ALSA_TSC2101 audio support initialized
<omap_alsa_tsc2101_clock_on>: clock use count = 0
<omap_alsa_tsc2101_clock_on>: old clock rate = 12000000
omap_alsa_tsc2101_clock_on(), no need to change clock rate, rate already
12000000 Hz.
<omap_alsa_tsc2101_clock_on>: MCLK = 12000000 [12000000], usecount = 1,
clk_enable retval = 0
<snd_card_omap_alsa_tsc2101_open>: runtime->hw =
snd_omap_alsa_tsc2101_playback
<snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(),
size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:686
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:248
<omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL
<snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started,  offset = 0, dma_size = 8192, s->period =
0, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042022400, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:229
XXX Alsa debug f:audio_ifc_start, l:222
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0,
s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status =
32, data = c0b0608c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling
audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<audio_process_dma>: started,  offset = 8192, dma_size = 8192, s->period
= 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042014208
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042014208, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period =
1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size
= 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr
= 0, dma_ptr = -1042014208
<sound_dma_irq_handler>: done
ALSA
/home/lamikr/own/h6300/git/linux-omap-h6300-2.6/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?)
<snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:488
[omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0)
[omap_clear_alsa_sound_dma]: start
[omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:785
<omap_alsa_tsc2101_clock_off>: clock use count = 1
<omap_alsa_tsc2101_clock_off>: clock rate = 12000000
<omap_alsa_tsc2101_clock_off>: clock disabled
<omap_alsa_tsc2101_clock_off>: audio codec off
Quoted 8 lines

_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

--
INdT - Manaus - Brazil

author
#2 lore raw

Hi Petrini

That sounds good for me, I am happy from anything that works and can try to continue from that :-)
Can you give more info from your driver like is it already using DMA, is it using headset or normal speakers for playing, etc?
In addition do you have sources available somewhere so I could check whether your code works also with my device?

It should be possible to take the existing mixer part from my code to your driver. As I have not yet been able to play songs properly, I have sofar only been able to test the volume and mute/unmute settings from the Mixers Digital Gain Control (DGC) properly.
Headset and handset parts seems to act ok, but only time will tell whether they really work. But if I can get your driver to play with my device, I could continue from that.

I think there will also be a need for a somekind of "temp/work" repository for helping to synchronize the our (and possible others) work, but I think we can resolve that later.

Mika

Quoted 187 lines · Daniel Petrini

Hi Mika,

I have been working in this ALSA driver as well, and I have a functional patch that plays songs but lacks the mixer support yet. What do you think of join the drivers to make it work faster? I am developing it generically in order to take advantage of existing common code as dma and alsa generic.

Daniel

Quoted 157 lines · lamikr

Hi

I have not seen anyone working with the tsc2101 Alsa driver, so attached are the tsc2101 alsa driver sources I have been working for a while. The patch should apply to the omap-driver head. Unfortunately it is still non-functional at least with my omap 1510 based iPAQ h6340.

I can hear small start of the song but then nothing happens. I have tried to debug the code and I can see that the the driver is able to get one callback to sound_dma_irq_handler with DSCR_END_BLOCK set, but after it does not continue with a next period of code.

Here is some info from the driver
- all code is located in /sound/arm/omap as I have wanted to mix it to existing aic23 code until this one works
- based on to aic23 Alsa and tsc2101 OSS drivers. DMA code and driver base taken from the aic, but hardware initialization taken from the tsc2101 oss driver. (dma has only small changes like 16 bit mono to capture params instead of 32 bit ones supported in the aic23)
- mixer code for DGC, headset and handset
- debug is mostly printed by using DPRINTK() function and can be enabled by uncommenting "#define DEBUG 1" from the omap-alsa.h
- This is platform driver, so you need to register it to your board-code in arch/arm/mach-omap1/board-* in a following way:

       static struct platform_device h6300_mcbsp1_device = {
                   .name        = "omap_tsc2101_mcbsp",
                   .id        = 1,
           };

       static struct platform_device *h6300_devices[] __initdata = {
               ...
               &h6300_mcbsp1_device,
       };

I have only tested this with omap1510 based iPAQ h6300, so I would appreciate if somebody else could test this with other devices having tsc2101 chipset to find out whether this is just my hw specific problem. (Fixes would ofcource also be nice :-)

For testing the driver I have plugged headset and listened the result of following commands
- aplay song.wav (44100 hz 16 bit little endion format)
- "speaker-test -r 8000", "-r 44100", etc...

I have also tryed to change the audio_get_dma_pos() method to be like in the sa11xx-uda1341.c driver. With implementation
based on to that, the speaker-test is able to produce somekind of periodic "wuff <silence> wuff <silence> wuff..." sound. (that method version is commented out in the omap-alsa-tsc2101.c)

In addition to sources, attached is the log from one play attempt.

Mika

root@h6300:~# aplay free_breakbeat.wav
Playing WAVE 'free_breakbeat.wav' : Signed 16 bit Little Endian, Rate
44100 Hz, Stereo
aplay: pcm_write:1146: write error: Input/output error
root@h6300:~# dmesg
XXX Alsa debug f:omap_alsa_tsc2101_init, l:1157
XXX Alsa debug f:snd_omap_alsa_tsc2101_probe, l:1077
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_pcm, l:845
XXX Alsa debug f:omap_alsa_tsc2101_audio_init, l:350
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
[snd_omap_init_mixer]: start
[setRecordSource]: start
[setRecordSource]: end(0)
[snd_omap_init_mixer]: end(0)
OMAP_ALSA_TSC2101 audio support initialized
<omap_alsa_tsc2101_clock_on>: clock use count = 0
<omap_alsa_tsc2101_clock_on>: old clock rate = 12000000
omap_alsa_tsc2101_clock_on(), no need to change clock rate, rate already
12000000 Hz.
<omap_alsa_tsc2101_clock_on>: MCLK = 12000000 [12000000], usecount = 1,
clk_enable retval = 0
<snd_card_omap_alsa_tsc2101_open>: runtime->hw =
snd_omap_alsa_tsc2101_playback
<snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(),
size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:686
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:248
<omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL
<snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started,  offset = 0, dma_size = 8192, s->period =
0, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042022400, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:229
XXX Alsa debug f:audio_ifc_start, l:222
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0,
s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status =
32, data = c0b0608c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling
audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<audio_process_dma>: started,  offset = 8192, dma_size = 8192, s->period
= 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042014208
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042014208, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period =
1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size
= 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr
= 0, dma_ptr = -1042014208
<sound_dma_irq_handler>: done
ALSA
/home/lamikr/own/h6300/git/linux-omap-h6300-2.6/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?)
<snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:488
[omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0)
[omap_clear_alsa_sound_dma]: start
[omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:785
<omap_alsa_tsc2101_clock_off>: clock use count = 1
<omap_alsa_tsc2101_clock_off>: clock rate = 12000000
<omap_alsa_tsc2101_clock_off>: clock disabled
<omap_alsa_tsc2101_clock_off>: audio codec off
Quoted 10 lines

_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

--
INdT - Manaus - Brazil

#3 lore raw

Hi Mika,

Quoted 4 lines · lamikr

Hi Petrini

That sounds good for me, I am happy from anything that works and can try to continue from that :-)

Great!

Quoted 4 lines

Can you give more info from your driver like is it already using DMA, is it using headset or normal speakers for playing, etc?
In addition do you have sources available somewhere so I could check whether your code works also with my device?

Yes, I am sending it right now (I have just updated my tree). Please note that it is really work in progress code, with remaining debug printks and so on. I will clean up soon.
Try to make it work w/ your device, you will have to change the board* file accordingly H2 or osk in this patch.

Quoted 8 lines

It should be possible to take the existing mixer part from my code to your driver. As I have not yet been able to play songs properly, I have sofar only been able to test the volume and mute/unmute settings from the Mixers Digital Gain Control (DGC) properly.
Headset and handset parts seems to act ok, but only time will tell whether they really work. But if I can get your driver to play with my device, I could continue from that.

Let me know if you can play sounds with this patch so that I will prepare it to receive your mixer then you can debug it

Quoted 3 lines

I think there will also be a need for a somekind of "temp/work" repository for helping to synchronize the our (and possible others) work, but I think we can resolve that later.

Yeah, maybe we can try to keep sending pathes privetely in order to don't mess the list to much, unless we got a server somewhere.

Please let me know if this patch works for you.
The idea was to change omap-alsa-aic23.c to omap-alsa.c and use separate codec files for board dependent functions and data. Dma and mcbsp functions should remain untouched.

Quoted 2 lines

Mika

Daniel

Quoted 184 lines
Quoted 182 lines · Daniel Petrini

Hi Mika,

I have been working in this ALSA driver as well, and I have a functional patch that plays songs but lacks the mixer support yet. What do you think of join the drivers to make it work faster? I am developing it generically in order to take advantage of existing common code as dma and alsa generic.

Daniel

Quoted 167 lines · lamikr

Hi

I have not seen anyone working with the tsc2101 Alsa driver, so attached are the tsc2101 alsa driver sources I have been working for a while. The patch should apply to the omap-driver head. Unfortunately it is still non-functional at least with my omap 1510 based iPAQ h6340.

I can hear small start of the song but then nothing happens. I have tried to debug the code and I can see that the the driver is able to get one callback to sound_dma_irq_handler with DSCR_END_BLOCK set, but after it does not continue with a next period of code.

Here is some info from the driver
- all code is located in /sound/arm/omap as I have wanted to mix it to existing aic23 code until this one works
- based on to aic23 Alsa and tsc2101 OSS drivers. DMA code and driver base taken from the aic, but hardware initialization taken from the tsc2101 oss driver. (dma has only small changes like 16 bit mono to capture params instead of 32 bit ones supported in the aic23)
- mixer code for DGC, headset and handset
- debug is mostly printed by using DPRINTK() function and can be enabled by uncommenting "#define DEBUG 1" from the omap-alsa.h
- This is platform driver, so you need to register it to your board-code in arch/arm/mach-omap1/board-* in a following way:

       static struct platform_device h6300_mcbsp1_device = {
                   .name        = "omap_tsc2101_mcbsp",
                   .id        = 1,
           };

       static struct platform_device *h6300_devices[] __initdata = {
               ...
               &h6300_mcbsp1_device,
       };

I have only tested this with omap1510 based iPAQ h6300, so I would appreciate if somebody else could test this with other devices having tsc2101 chipset to find out whether this is just my hw specific problem. (Fixes would ofcource also be nice :-)

For testing the driver I have plugged headset and listened the result of following commands
- aplay song.wav (44100 hz 16 bit little endion format)
- "speaker-test -r 8000", "-r 44100", etc...

I have also tryed to change the audio_get_dma_pos() method to be like in the sa11xx-uda1341.c driver. With implementation
based on to that, the speaker-test is able to produce somekind of periodic "wuff <silence> wuff <silence> wuff..." sound. (that method version is commented out in the omap-alsa-tsc2101.c)

In addition to sources, attached is the log from one play attempt.

Mika

root@h6300:~# aplay free_breakbeat.wav
Playing WAVE 'free_breakbeat.wav' : Signed 16 bit Little Endian, Rate
44100 Hz, Stereo
aplay: pcm_write:1146: write error: Input/output error
root@h6300:~# dmesg
XXX Alsa debug f:omap_alsa_tsc2101_init, l:1157
XXX Alsa debug f:snd_omap_alsa_tsc2101_probe, l:1077
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_pcm, l:845
XXX Alsa debug f:omap_alsa_tsc2101_audio_init, l:350
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
XXX Alsa debug f:audio_dma_request, l:385
[omap_request_alsa_sound_dma]: start
[omap_request_alsa_sound_dma]: end(0)
[snd_omap_init_mixer]: start
[setRecordSource]: start
[setRecordSource]: end(0)
[snd_omap_init_mixer]: end(0)
OMAP_ALSA_TSC2101 audio support initialized
<omap_alsa_tsc2101_clock_on>: clock use count = 0
<omap_alsa_tsc2101_clock_on>: old clock rate = 12000000
omap_alsa_tsc2101_clock_on(), no need to change clock rate, rate already
12000000 Hz.
<omap_alsa_tsc2101_clock_on>: MCLK = 12000000 [12000000], usecount = 1,
clk_enable retval = 0
<snd_card_omap_alsa_tsc2101_open>: runtime->hw =
snd_omap_alsa_tsc2101_playback
<snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(),
size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:686
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:248
<omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL
<snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started,  offset = 0, dma_size = 8192, s->period =
0, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042022400, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:229
XXX Alsa debug f:audio_ifc_start, l:222
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0,
s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042022400
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status =
32, data = c0b0608c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling
audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0,
s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size
= 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537,
dma_ptr = -1042023937
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537
<audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0
<audio_process_dma>: started,  offset = 8192, dma_size = 8192, s->period
= 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size =
32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr =
0, dma_ptr = -1042014208
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr =
-1042014208, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period =
1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size
= 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr
= 0, dma_ptr = -1042014208
<sound_dma_irq_handler>: done
ALSA
/home/lamikr/own/h6300/git/linux-omap-h6300-2.6/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?)
<snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:488
[omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0)
[omap_clear_alsa_sound_dma]: start
[omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:785
<omap_alsa_tsc2101_clock_off>: clock use count = 1
<omap_alsa_tsc2101_clock_off>: clock rate = 12000000
<omap_alsa_tsc2101_clock_off>: clock disabled
<omap_alsa_tsc2101_clock_off>: audio codec off

_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

Quoted 7 lines
Quoted 5 lines

--
INdT - Manaus - Brazil

--
INdT - Manaus - Brazil

arch/arm/mach-omap1/board-h2.c +37 -0
index 4cc6a31..ead9ac9 100644
@@ -41,6 +41,7 @@
 #include <asm/arch/usb.h>
 #include <asm/arch/keypad.h>
 #include <asm/arch/common.h>
+#include <asm/arch/mcbsp.h>
 
 extern int omap_gpio_init(void);
 
@@ -271,12 +272,48 @@ static struct platform_device h2_irda_de
 	.resource	= h2_irda_resources,
 };
 
+static struct omap_mcbsp_config mcbsp1_config = {
+	.mcbsp_regs = { 
+		.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
+		.spcr1 = RINTM(3) | RRST,
+		.rcr2  = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
+			 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
+		.rcr1  = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
+		.xcr2  = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
+			 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
+		.xcr1  = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
+		.srgr1 = FWID(15),
+		.srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
+
+		.pcr0  = CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
+		//.pcr0 = CLKXP | CLKRP,	/* mcbsp: slave */
+	},
+	.codec_configure_dev	= tsc2101_configure,
+	.codec_set_samplerate	= tsc2101_set_samplerate,
+	.codec_clock_setup	= tsc2101_clock_setup,
+	.codec_clock_on		= tsc2101_clock_on,
+	.codec_clock_off	= tsc2101_clock_off,
+	.codec_write		= audio_tsc2101_write,
+	.codec_read		= audio_tsc2101_read,
+	.init_audio_controls 	= tsc2101_init_audio_controls,
+
+};
+
+static struct platform_device h2_mcbsp1_device = {
+	.name 		= "omap_mcbsp",
+	.id		= 1,
+	.dev = {
+		.platform_data = &mcbsp1_config,
+	},
+};
+
 static struct platform_device *h2_devices[] __initdata = {
 	&h2_nor_device,
 	&h2_nand_device,
 	&h2_smc91x_device,
 	&h2_irda_device,
 	&h2_kp_device,
+	&h2_mcbsp1_device,
 };
 
 static void __init h2_init_smc91x(void)
arch/arm/mach-omap1/board-osk.c +38 -2
index 9d6098b..fb716df 100644
@@ -148,10 +148,46 @@ static struct platform_device osk5912_cf
 	.num_resources	= ARRAY_SIZE(osk5912_cf_resources),
 	.resource	= osk5912_cf_resources,
 };
+static struct platform_device h2_smc91x_device = {
+	.name		= "smc91x",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(h2_smc91x_resources),
+	.resource	= h2_smc91x_resources,
+};
+
+static struct omap_mcbsp_config mcbsp1_config = {
+	.mcbsp_regs = { 
+		.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
+		.spcr1 = RINTM(3) | RRST,
+		.rcr2  = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
+			 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
+		.rcr1  = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
+		.xcr2  = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
+			 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
+		.xcr1  = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
+		.srgr1 = FWID(15),
+		.srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
 
-static struct platform_device osk5912_mcbsp1_device = {
-	.name		= "omap_mcbsp",
+		.pcr0  = CLKXM | CLKRM | FSXP | FSRP | CLKXP | CLKRP,
+		//.pcr0 = CLKXP | CLKRP,	/* mcbsp: slave */
+	},
+	.codec_configure_dev	= tsc2101_configure,
+	.codec_set_samplerate	= tsc2101_set_samplerate,
+	.codec_clock_setup	= tsc2101_clock_setup,
+	.codec_clock_on		= tsc2101_clock_on,
+	.codec_clock_off	= tsc2101_clock_off,
+	.codec_write		= audio_tsc2101_write,
+	.codec_read		= audio_tsc2101_read,
+	.init_audio_controls 	= tsc2101_init_audio_controls,
+
+};
+
+static struct platform_device h2_mcbsp1_device = {
+	.name 		= "omap_mcbsp",
 	.id		= 1,
+	.dev = {
+		.platform_data = &mcbsp1_config,
+	},
 };
 
 static struct resource osk5912_kp_resources[] = {
include/asm-arm/arch-omap/mcbsp.h +35 -0
index d97e031..1b2c95c 100644
@@ -312,4 +312,39 @@ void omap_mcbsp_set_spi_mode(unsigned in
 int omap_mcbsp_pollread(unsigned int id, u16 * buf);
 int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
 
+/* Codecs -  must leave soon */
+//#include "../../../sound/arm/alsa-omap.h"
+struct codec_controls;
+/* for alsa driver must leave */
+struct omap_mcbsp_config {
+	struct	omap_mcbsp_reg_cfg	 mcbsp_regs;
+	void	(*codec_configure_dev)(void);
+	void	(*codec_set_samplerate)(long, unsigned int *);
+	void	(*codec_clock_setup)(void);
+	int	(*codec_clock_on)(void);
+	int 	(*codec_clock_off)(void);
+	void 	(*codec_write)(u8 address, u16 data);
+	void	(*codec_read) (u8 address);
+	void 	(*init_audio_controls) (struct codec_controls *);
+	
+
+};
+
+
+inline void aic23_configure(void);
+void aic23_set_samplerate(long rate, unsigned int rates[]);
+void aic23_clock_setup(void);
+int aic23_clock_on(void);
+int aic23_clock_off(void);
+void audio_aic23_write(u8, u16);
+void aic23_init_audio_controls(struct codec_controls * controls);
+
+inline void tsc2101_configure(void);
+void tsc2101_set_samplerate(long rate, unsigned int rates[]);
+void tsc2101_clock_setup(void);
+int tsc2101_clock_on(void);
+int tsc2101_clock_off(void);
+void audio_tsc2101_write(u8, u16);
+u16 audio_tsc2101_read(u8);
+void tsc2101_init_audio_controls(struct codec_controls * controls);
 #endif
sound/arm/Kconfig +14 -0
index cf07154..f2e7577 100644
@@ -7,6 +7,7 @@ config SND_SA11XX_UDA1341
 	tristate "SA11xx UDA1341TS driver (iPaq H3600)"
 	depends on ARCH_SA1100 && SND && L3
 	select SND_PCM
+	select SND_GENERIC_DRIVER
 	help
 	  Say Y here if you have a Compaq iPaq H3x00 handheld computer
 	  and want to use its Philips UDA 1341 audio chip.
@@ -45,4 +46,17 @@ config SND_OMAP_AIC23
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-omap-aic23.
 
+config SND_OMAP_TSC2101
+	tristate "OMAP TSC2101 alsa driver (H2)"
+	depends on ARCH_OMAP && SND
+	select SND_PCM
+        select OMAP_TSC2101
+        select OMAP_UWIRE if ARCH_OMAP
+	help
+	  Say Y here if you have a H2 platform board
+	  and want to use its TSC2101 audio chip.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-omap-alsa-tsc2101.
+
 endmenu
sound/arm/Makefile +5 -2
index 019a9f0..1215b88 100644
@@ -14,5 +14,8 @@ snd-pxa2xx-pcm-objs		:= pxa2xx-pcm.o
 obj-$(CONFIG_SND_PXA2XX_AC97)	+= snd-pxa2xx-ac97.o
 snd-pxa2xx-ac97-objs		:= pxa2xx-ac97.o
 
-obj-$(CONFIG_SND_OMAP_AIC23) += snd-omap-aic23.o
-snd-omap-aic23-objs := omap-aic23.o omap-alsa-dma.o omap-alsa-mixer.o
+obj-$(CONFIG_SND_OMAP_AIC23) += snd-omap-alsa-aic23.o
+snd-omap-alsa-aic23-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-mixer.o omap-alsa-aic23.o 
+
+obj-$(CONFIG_SND_OMAP_TSC2101) += snd-omap-alsa-tsc2101.o
+snd-omap-alsa-tsc2101-objs := omap-alsa.o omap-alsa-dma.o omap-alsa-mixer.o omap-alsa-tsc2101.o 
sound/arm/omap-aic23.h +9 -4
index c8ab42c..ff7385c 100644
@@ -44,6 +44,7 @@
 #include <asm/arch/dma.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <asm/arch/mcbsp.h>
 
 #define DEFAULT_OUTPUT_VOLUME         0x60
 #define DEFAULT_INPUT_VOLUME          0x00	/* 0 ==> mute line in */
@@ -93,7 +94,7 @@ struct audio_stream {
 /*
  * Alsa card structure for aic23
  */
-struct snd_card_omap_aic23 {
+struct snd_card_omap_codec {
 	snd_card_t *card;
 	snd_pcm_t *pcm;
 	long samplerate;
@@ -103,17 +104,21 @@ struct snd_card_omap_aic23 {
 /*********** Function Prototypes *************************/
 
 void audio_dma_callback(void *);
-int snd_omap_mixer(struct snd_card_omap_aic23 *);
-void snd_omap_init_mixer(void);
+int snd_omap_mixer(struct snd_card_omap_codec *);
+void snd_omap_init_mixer(struct omap_mcbsp_config *);
 /* Clock functions */
 int omap_aic23_clock_on(void);
 int omap_aic23_clock_off(void);
+ /* ADDED functions - H2/LDM port */
+void omap_codec_set_samplerate(struct snd_card_omap_codec * , long rate, unsigned int rates[]);
+inline void codec_configure(void);
 
 #ifdef CONFIG_PM
 void snd_omap_suspend_mixer(void);
 void snd_omap_resume_mixer(void);
 #endif
 
+#if 0
 /* Codec AIC23 */
 #if defined(CONFIG_SENSORS_TLV320AIC23) || defined (CONFIG_SENSORS_TLV320AIC23_MODULE)
 
@@ -126,5 +131,5 @@ static __inline__ void audio_aic23_write
 }
 
 #endif /* CONFIG_SENSORS_TLV320AIC23 */
-
+#endif
 #endif
sound/arm/omap-alsa-aic23.c new file +255 -0

255 lines not on this page · raw message

sound/arm/omap-alsa-mixer.c +75 -36

259 lines not on this page · raw message

sound/arm/omap-alsa-mixer.h new file +72 -0

72 lines not on this page · raw message

sound/arm/omap-alsa-tsc2101.c new file +471 -0

471 lines not on this page · raw message

sound/arm/omap-alsa.c new file +757 -0

757 lines not on this page · raw message

sound/arm/omap-alsa.h new file +16 -0
new file mode 100644
index 0000000..7867736
@@ -0,0 +1,16 @@
+
+/*
+ * struct that contais codec audio control values and registers address
+ *  to handle them (used by mixer)
+ */
+struct codec_controls {
+	u16	left_vol_output;
+	u16	right_vol_output;
+	u16	left_line_input;
+	u16	right_line_input;
+	u8	left_vol_address;
+	u8	right_vol_address;
+	u8	left_line_address;
+	u8	right_line_address;
+	u16 	mic_input;
+} ;
author
#4 lore raw
Quoted 8 lines

Yes, I am sending it right now (I have just updated my tree). Please note that it is really work in progress code, with remaining debug printks and so on. I will clean up soon.
Try to make it work w/ your device, you will have to change the board* file accordingly H2 or osk in this patch.

Yes, I made the changes. I kind of liked from the idea to codec aic/tsc2101 specific
functions in the board, but the side-effect is that I was not able to build the driver anymore
as a module. (I got unresolved function errors in the end of build). But when selecting to
build the driver in to image, it compiled just fine.

Quoted 4 lines

Let me know if you can play sounds with this patch so that I will prepare it to receive your mixer then you can debug it

But unfortunately your version seemed to work in a similar way for me than my one,--> I was able to hear only the beginning of song. The only code difference for our h6300 board compared to h2/osk is the mcbsp settings and they could be wrong.
But could they be wrong when with the OSS driver "cat song.wav > /dev/dsp" works just fine with the same mcbsp settings...

Following questions comes to my mind:
Are you able to play all kind of wav/mp3 songs with your driver by using aplay?
Any changes you could also test the playback with my driver version, it could help me to identify the problem
if I know/not know whether that version works with h2 or osk.

I have found at least one difference in my and your driver versions is that in set_samplerate function
you do not change all mcbsp registers by calling omap_mcbsp_config(). Instead you will only update
srgr1 and srgr2 by calling

    OMAP_MCBSP_WRITE(OMAP1610_MCBSP1_BASE, SRGR2, srgr2);
    OMAP_MCBSP_WRITE(OMAP1610_MCBSP1_BASE, SRGR1, srgr1);

Below is the debug from my attempt with your driver...

Mika

root@h6300:~# aplay 01_the_grudge.mp3
Playing raw data '01_the_grudge.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono
root@h6300:~# dmesg
=417792)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (bad gzip magic numbers);
looks like an initrd
Freeing initrd memory: 2048K
NET: Registered protocol family 16
MUX: initialized UART3_TX
MUX: initialized UART3_RX
MUX: initialized F18_1610_KBC0
MUX: initialized D20_1610_KBC1
MUX: initialized D19_1610_KBC2
MUX: initialized E18_1610_KBC3
MUX: initialized C21_1610_KBC4
MUX: initialized G18_1610_KBR0
MUX: initialized F19_1610_KBR1
MUX: initialized H14_1610_KBR2
MUX: initialized E20_1610_KBR3
MUX: initialized E19_1610_KBR4
MUX: initialized N19_1610_KBR5
DMA support for OMAP15xx initialized
Initializing OMAP McBSP system
USB: hmc 0
MUX: initialized N14_1510_UWIRE_CS0
MUX: initialized P15_1510_UWIRE_CS3
usbcore: registered new driver usbfs
usbcore: registered new driver hub
Power Management for TI OMAP.
NetWinder Floating Point Emulator V0.97 (extended precision)
OMAP DSP driver initialization
omapdsp: mapping in ARM MMU, v=0xe0fff000, p=0x10ab4000, sz=0x1000
JFFS version 1.0, (C) 1999, 2000  Axis Communications AB
JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
Allocated 270656 bytes for deflate workspace
Allocated 46912 bytes for inflate workspace
Registering JFFS2 compressor "zlib"
Compressor "zlib", prio 60
Registering JFFS2 compressor "rtime"
Compressor "zlib", prio 60
Compressor "rtime", prio 50
Registering JFFS2 compressor "rubinmips"
Compressor "zlib", prio 60
Compressor "rtime", prio 50
Compressor "rubinmips", prio 10
Registering JFFS2 compressor "dynrubin"
Compressor "zlib", prio 60
Compressor "rtime", prio 50
Compressor "dynrubin", prio 20
Compressor "rubinmips", prio 10
JFFS2: default compression mode: priority
Initializing Cryptographic API
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
omapfb: configured for panel h6300
lcd_h6300.c: h6300_panel_init() done
omapfb-lcdc: init
lcd_h6300.c: h6300_panel_enable() done
Console: switching to colour frame buffer device 60x53
omapfb: initialized vram=153600 pixclock 21000 kHz hfreq 77.8 kHz vfreq
229.7 HzOMAP RTC Driver
omap_rtc: RTC already running.
Non-volatile memory driver v1.2
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xfffb0000 (irq = 46) is a ST16654
serial8250.0: ttyS1 at MMIO 0xfffb0800 (irq = 47) is a ST16654
serial8250.0: ttyS2 at MMIO 0xfffb9800 (irq = 15) is a ST16654
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize
loop: loaded (max 8 devices)
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
NET: Registered protocol family 24
STRIP: Version 1.3A-STUART.CHESHIRE (unlimited channels)
usbmon: debugfs is not available
ohci_hcd: 2005 April 22 USB 1.1 'Open' Host Controller (OHCI) Driver (OMAP)
ohci_hcd: block sizes: ed 64 td 64
usbcore: registered new driver cdc_acm
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/class/cdc-acm.c:
v0.25:USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new driver asix
usbcore: registered new driver cdc_ether
usbcore: registered new driver net1080
usbcore: registered new driver zaurus
usbcore: registered new driver usbserial
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/usb-serial.c:
USB Serial support registered for generic
usbcore: registered new driver usbserial_generic
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/usb-serial.c:
USB Serial Driver core
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/usb-serial.c:
USB Serial support registered for PocketPC PDA
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/ipaq.c:
USB PocketPC PDA driver v0.5
usbcore: registered new driver ipaq
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/usb-serial.c:
USB Serial support registered for Handspring Visor / Palm OS
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/usb-serial.c:
USB Serial support registered for Sony Clie 3.5
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/usb-serial.c:
USB Serial support registered for Sony Clie 5.0
usbcore: registered new driver visor
/home/lamikr/own/h6300/eclipsewk/h6300_dev/drivers/usb/serial/visor.c:
USB HandSpring Visor / Palm OS driver
udc: OMAP UDC driver, version: 4 October 2004 (iso)
udc: OMAP UDC rev 2.7
udc: hmc mode 0, (unknown) transceiver
udc: fifo mode 3, 648 bytes not used
usb0: Ethernet Gadget, version: May Day 2005
usb0: using omap_udc, OUT ep2out-bulk IN ep1in-bulk STATUS ep3in-int
usb0: MAC b2:e5:68:a6:39:c9
usb0: HOST MAC b2:58:90:b3:b8:66
ts: Compaq touchscreen protocol output
Advanced Linux Sound Architecture Driver Version 1.0.11rc2 (Wed Jan 04
08:57:20 2006 UTC).
WR: ad:0x5 data:0x0
WR: ad:0x3 data:0xc010
udc: USB reset done, gadget ether
WR: ad:0x3 data:0xc010
WR: ad:0x1d data:0x0
WR: ad:0x2 data:0x0
WR: ad:0x20 data:0x75d1
usb0: full speed config #1: 100 mA, Ethernet Gadget, using CDC Ethernet
WR: ad:0x21 data:0xf0
WR: ad:0x22 data:0x0
WR: ad:0x1 data:0x1900
WR: ad:0x1e data:0x1900
WR: ad:0x2 data:0x3e3e
WR: ad:0x0 data:0x4100
WR: ad:0x6 data:0x2904
WR: ad:0x1b data:0x811c
WR: ad:0x1c data:0x5240

TESTE 2

OSK audio support initialized
ALSA device list:
#0: OMAP OSK with AIC23
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes) TCP established hash table entries: 4096 (order: 2, 16384 bytes) TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096) TCP reno registered
TCP bic registered
Initializing IPsec netlink socket
NET: Registered protocol family 1
NET: Registered protocol family 10
lo: Disabled Privacy Extensions
IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
mmcblk0: mmc0:0001 SDR256 250816KiB
mmcblk0: p1 p2
Bridge firewalling registered
IP-Config: Complete:

      device=usb0, addr=192.168.2.2, mask=255.0.0.0, gw=192.168.2.1,
     host=h6300, domain=, nis-domain=(none),
     bootserver=192.168.2.1, rootserver=192.168.2.1, rootpath=

Looking up port of RPC 100003/2 on 192.168.2.1 Looking up port of RPC 100005/1 on 192.168.2.1
VFS: Mounted root (nfs filesystem).
Freeing init memory: 120K
usb0: no IPv6 routers present
MUX: initialized M14_1510_GPIO2
input: omap_ts as /class/input/input0
OMAP touchscreen driver initialized
i2c_omap i2c_omap.1: bus 0 rev1.0 at 100 kHz pca9535_attach() started
pca9535_attach() ok
OMAP Keypad Driver
omap-keypad: Spurious key event 0-5
omap-keypad: Spurious key event 1-5
omap-keypad: Spurious key event 2-5
omap-keypad: Spurious key event 3-5
omap-keypad: Spurious key event 4-5
omap-keypad: Spurious key event 5-5
omap-keypad: Spurious key event 6-5
omap-keypad: Spurious key event 7-5
input: omap-keypad as /class/input/input1
Bluetooth: Core ver 2.8
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Bluetooth: HCI UART driver ver 2.2
Bluetooth: HCI H4 protocol initialized
Bluetooth: HCI BCSP protocol initialized
Bluetooth: L2CAP ver 2.8
Bluetooth: L2CAP socket layer initialized
h6300 Bluetooth Driver init()
h6300_bt_led.c h6300_clear_led() done h6300_bt_brf6100.c h6300_bt_probe() done
NET: Registered protocol family 23
Bluetooth: HIDP (Human Interface Emulation) ver 1.1
Bluetooth: RFCOMM socket layer initialized
Bluetooth: RFCOMM TTY layer initialized
Bluetooth: RFCOMM ver 1.6
WR: ad:0x0 data:0x413f
WR: ad:0x6 data:0x804
WR: ad:0x1b data:0x8120
WR: ad:0x1c data:0x1e00

#5 lore raw

Hi,

Quoted 8 lines · lamikr
Quoted 8 lines

Yes, I am sending it right now (I have just updated my tree). Please note that it is really work in progress code, with remaining debug printks and so on. I will clean up soon.
Try to make it work w/ your device, you will have to change the board* file accordingly H2 or osk in this patch.

Quoted 7 lines

Yes, I made the changes. I kind of liked from the idea to codec aic/tsc2101 specific
functions in the board, but the side-effect is that I was not able to build the driver anymore
as a module. (I got unresolved function errors in the end of build). But when selecting to
build the driver in to image, it compiled just fine.

That will be fixed. The idea to have separeted file for alsa generic and codecs is that you can work or improve diferent parts of the driver indenpendently. And of course reuse code.

Quoted 8 lines
Quoted 4 lines

Let me know if you can play sounds with this patch so that I will prepare it to receive your mixer then you can debug it

But unfortunately your version seemed to work in a similar way for me than my one,--> I was able to hear only the beginning of song. The only code difference for our h6300 board compared to h2/osk is the mcbsp settings and they could be wrong.

Humm, Maybe the problems dwells in this function:
omap_get_dma_src_addr_counter
(called in alsa-omap driver core file) Please try to analyse its
behavior for omap1510, the idea is to get the current position of a dma transfer. Maybe the registers are diferent in 1510 which has different dma engine.

Quoted 6 lines

But could they be wrong when with the OSS driver "cat song.wav > /dev/dsp" works just fine with the same mcbsp settings...

Following questions comes to my mind:
Are you able to play all kind of wav/mp3 songs with your driver by using aplay?

Yeah. I can play them. In most of the frequencies although I use madplay for mp3.

Quoted 2 lines

Any changes you could also test the playback with my driver version, it could help me to identify the problem

I compiled but I can not play yet, I think that my alsa programs are old in my rootfs. I compile them as modules or integrated without success. I will update my rfs.
It says: alsactl: load_state:1236: No soundcards found... After I make it run I give you a feedback.

Quoted 9 lines

if I know/not know whether that version works with h2 or osk. I have found at least one difference in my and your driver versions is that in set_samplerate function
you do not change all mcbsp registers by calling omap_mcbsp_config(). Instead you will only update
srgr1 and srgr2 by calling

    OMAP_MCBSP_WRITE(OMAP1610_MCBSP1_BASE, SRGR2, srgr2);
    OMAP_MCBSP_WRITE(OMAP1610_MCBSP1_BASE, SRGR1, srgr1);

This means no difference. It is just to avoid callings to mcbsp function explicitly.

Quoted 6 lines

Below is the debug from my attempt with your driver...

Mika

root@h6300:~# aplay 01_the_grudge.mp3
Playing raw data '01_the_grudge.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono

The support for 8Khz is not ok yet although I think that you have tested for other frequencies. I can see in the remaining of the debug that it seems ok. Maybe the problem is in that function pointed above.

Daniel
--
INdT - Manaus - Brazil

author
#6 lore raw
Quoted 24 lines · Daniel Petrini

Hi,

Quoted 9 lines · lamikr
Quoted 9 lines

Yes, I am sending it right now (I have just updated my tree). Please note that it is really work in progress code, with remaining debug printks and so on. I will clean up soon.
Try to make it work w/ your device, you will have to change the board* file accordingly H2 or osk in this patch.

Quoted 9 lines

Yes, I made the changes. I kind of liked from the idea to codec aic/tsc2101 specific
functions in the board, but the side-effect is that I was not able to build the driver anymore
as a module. (I got unresolved function errors in the end of build). But when selecting to
build the driver in to image, it compiled just fine.

Quoted 5 lines

That will be fixed. The idea to have separeted file for alsa generic and codecs is that you can work or improve diferent parts of the driver indenpendently. And of course reuse code.

Yes, that seems to be very doable. In my driver I just planned to take the tsc2101 code
totally separately until I can get it somehow working.

Quoted 8 lines

Humm, Maybe the problems dwells in this function:
omap_get_dma_src_addr_counter
(called in alsa-omap driver core file) Please try to analyse its behavior for omap1510, the idea is to get the current position of a dma transfer. Maybe the registers are diferent in 1510 which has different dma engine.

Thanks for the idea, I will try to investigate it later on today. I just checked
that the OSS code is not relying to omap_get_dma_src_addr_counter() function at all
so that might explain the reason why the oss version works for me.

Quoted 5 lines
Quoted 4 lines

Any changes you could also test the playback with my driver version, it could help me to identify the problem

Quoted 7 lines

I compiled but I can not play yet, I think that my alsa programs are old in my rootfs. I compile them as modules or integrated without success. I will update my rfs.
It says: alsactl: load_state:1236: No soundcards found... After I make it run I give you a feedback.

Hmm, did you remember to change the board code, to register the driver? I use here:

static struct platform_device h6300_mcbsp1_device = {
    .name        = "omap_tsc2101_mcbsp",
    .id        = 1,
};
static struct platform_device *h6300_devices[] __initdata = {
    &h6300_mcbsp1_device,
};

If the driver loads correctly, you should be able to use alsamixer with recent alsa utils.
The version I have tested here is from alsa 1.0.9. In addition you can turn the debug on from omap-alsa.h

Quoted 4 lines
Quoted 4 lines

Below is the debug from my attempt with your driver...

Mika

Quoted 10 lines
Quoted 4 lines
root@h6300:~# aplay 01_the_grudge.mp3
Playing raw data '01_the_grudge.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono

The support for 8Khz is not ok yet although I think that you have tested for other frequencies. I can see in the remaining of the debug that it seems ok. Maybe the problem is in that function pointed above.

With speaker-test I have used many frequencies but from wav-files I only tested
"Signed 16 bit Little Indian with 44100 hz". The madplay I have here requires me to modprobe
snd-pcm-oss OSS compatibility module.

Mika

#7 lore raw

Hi Mika,

Quoted 7 lines · lamikr
Quoted 5 lines · Daniel Petrini

Hi,

On 2/7/06, lamikr <[email protected]> wrote:

(...)

Quoted 9 lines
Quoted 9 lines

Humm, Maybe the problems dwells in this function:
omap_get_dma_src_addr_counter
(called in alsa-omap driver core file) Please try to analyse its behavior for omap1510, the idea is to get the current position of a dma transfer. Maybe the registers are diferent in 1510 which has different dma engine.

Quoted 5 lines

Thanks for the idea, I will try to investigate it later on today. I just checked
that the OSS code is not relying to omap_get_dma_src_addr_counter() function at all
so that might explain the reason why the oss version works for me.

I guess that the answer might come from there.

Quoted 14 lines
Quoted 5 lines
Quoted 4 lines

Any changes you could also test the playback with my driver version, it could help me to identify the problem

Quoted 7 lines

I compiled but I can not play yet, I think that my alsa programs are old in my rootfs. I compile them as modules or integrated without success. I will update my rfs.
It says: alsactl: load_state:1236: No soundcards found... After I make it run I give you a feedback.

Hmm, did you remember to change the board code, to register the driver? I use here:

Quoted 9 lines
static struct platform_device h6300_mcbsp1_device = {
    .name        = "omap_tsc2101_mcbsp",
    .id        = 1,
};
static struct platform_device *h6300_devices[] __initdata = {
    &h6300_mcbsp1_device,
};

ok. It has worked with that. The song played fine in H2.

Cheers,

Daniel
--
INdT - Manaus - Brazil

author
#8 lore raw

Daniel

Thanks for help and info! So now I at least know that it is propably something h6300 specific. That makes it hard for me to help with the alsa driver... One more thing, could you enable debug (omap-alsa.h) and send the dmesg output of "aplay reggae80e.wav" for me?
I just downloaded that wav myself from

http://www.breakbeatsonly.co.uk/demos/december03/reggae80e.wav

and got following log.

<setMixerVolumeAsHeadsetGainControlVolume>: mixer volume = 20 <setMixerVolumeAsHeadsetGainControlVolume>: to registry = 6400 <setMixerVolumeAsHandsetGainControlVolume>: mixer volume = 20 <setMixerVolumeAsHandsetGainControlVolume>: to registry = 6400 <setMixerVolumeAsDacGainControlVolume>: mixer volume left = 93, right = 93 <setMixerVolumeAsDacGainControlVolume>: to registry: left = 6, right = 6, total = 1542
[snd_omap_init_mixer]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_pcm, l:888
XXX Alsa debug f:omap_alsa_tsc2101_audio_init, l:367
XXX Alsa debug f:audio_dma_request, l:393 [omap_request_alsa_sound_dma]: start [omap_request_alsa_sound_dma]: end(0)
XXX Alsa debug f:audio_dma_request, l:393 [omap_request_alsa_sound_dma]: start [omap_request_alsa_sound_dma]: end(0)
OMAP_ALSA_TSC2101 audio support initialized <snd_card_omap_alsa_tsc2101_open>: runtime->hw = snd_omap_alsa_tsc2101_playback <snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(), size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:729
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:263 <omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL <snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started, offset = 0, dma_size = 8192, s->period = 0, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024983040
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr = -1024983040, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:244
XXX Alsa debug f:audio_ifc_start, l:237
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0, s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024983040
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status = 32, data = c0b4bd4c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed [audio_get_dma_pos]: start
audio_get_dma_pos(), offset = 0, srcPos = -1024983040, dmaAddr = -1024983040 [audio_get_dma_pos]: end(0)
<audio_process_dma>: started, offset = 8192, dma_size = 8192, s->period = 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024974848
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr = -1024974848, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period = 1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024974848
<sound_dma_irq_handler>: done
[audio_get_dma_pos]: start
audio_get_dma_pos(), offset = 2048, srcPos = -1024974848, dmaAddr = -1024983040
[audio_get_dma_pos]: end(2048)
[audio_get_dma_pos]: start
audio_get_dma_pos(), offset = 2048, srcPos = -1024974848, dmaAddr = -1024983040
[audio_get_dma_pos]: end(2048)
ALSA /home/lamikr/own/h6300/eclipsewk/h6300_dev/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?) <snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:531 [omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0)
[omap_clear_alsa_sound_dma]: start
[omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:828 <snd_card_omap_alsa_tsc2101_open>: runtime->hw = snd_omap_alsa_tsc2101_playback <snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(), size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:729
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:263 <omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL <snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started, offset = 0, dma_size = 8192, s->period = 0, s->periods = 0, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024983040
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr = -1024983040, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:244
XXX Alsa debug f:audio_ifc_start, l:237
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0, s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024983040
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status = 32, data = c0b4bd4c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed [audio_get_dma_pos]: start
audio_get_dma_pos(), offset = 0, srcPos = -1024983040, dmaAddr = -1024983040 [audio_get_dma_pos]: end(0)
<audio_process_dma>: started, offset = 8192, dma_size = 8192, s->period = 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024974848
[omap_start_alsa_sound_dma]: start
<omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr = -1024974848, dma_size = 8192
[audio_set_dma_params_play]: start
[audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period = 1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024974848
<sound_dma_irq_handler>: done
[audio_get_dma_pos]: start
audio_get_dma_pos(), offset = 2048, srcPos = -1024974848, dmaAddr = -1024983040
[audio_get_dma_pos]: end(2048)
[audio_get_dma_pos]: start
audio_get_dma_pos(), offset = 2048, srcPos = -1024974848, dmaAddr = -1024983040
[audio_get_dma_pos]: end(2048)
ALSA /home/lamikr/own/h6300/eclipsewk/h6300_dev/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?) <snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:531 [omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0)
[omap_clear_alsa_sound_dma]: start
[omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:828

Mika

Quoted 11 lines

ok. It has worked with that. The song played fine in H2.

Cheers,

Daniel
--
INdT - Manaus - Brazil

author
#9 lore raw
In reply to Daniel Petrini

Sorry, I send wrong log by myself. Here is the correct one...

<setMixerVolumeAsHeadsetGainControlVolume>: mixer volume = 20 <setMixerVolumeAsHeadsetGainControlVolume>: to registry = 6400 <setMixerVolumeAsHandsetGainControlVolume>: mixer volume = 20 <setMixerVolumeAsHandsetGainControlVolume>: to registry = 6400 <setMixerVolumeAsDacGainControlVolume>: mixer volume left = 93, right = 93 <setMixerVolumeAsDacGainControlVolume>: to registry: left = 6, right = 6, total = 1542
[snd_omap_init_mixer]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_pcm, l:853
XXX Alsa debug f:omap_alsa_tsc2101_audio_init, l:367
XXX Alsa debug f:audio_dma_request, l:393 [omap_request_alsa_sound_dma]: start [omap_request_alsa_sound_dma]: end(0)
XXX Alsa debug f:audio_dma_request, l:393 [omap_request_alsa_sound_dma]: start [omap_request_alsa_sound_dma]: end(0)
OMAP_ALSA_TSC2101 audio support initialized <snd_card_omap_alsa_tsc2101_open>: runtime->hw = snd_omap_alsa_tsc2101_playback <snd_omap_alsa_tsc2101_hw_params>: snd_omap_alsa_tsc2101_hw_params(), size = 131072
XXX Alsa debug f:snd_omap_alsa_tsc2101_prepare, l:694
XXX Alsa debug f:omap_alsa_tsc2101_set_samplerate, l:263 <omap_alsa_tsc2101_set_samplerate>: selected 44.1khz PLL <snd_omap_alsa_tsc2101_trigger>: cmd = 1
<audio_process_dma>: started, offset = 0, dma_size = 8192, s->period = 0, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024065536
[omap_start_alsa_sound_dma]: start <omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr = -1024065536, dma_size = 8192
[audio_set_dma_params_play]: start [audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
XXX Alsa debug f:audio_ifc_stop, l:244
XXX Alsa debug f:audio_ifc_start, l:237 [audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 0, dma_size = 8192, s->period = 0, s->periods = 1, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024065536
<sound_dma_irq_handler>: started, lch = 0, status = 0x20, dma_status = 32, data = c0b4b80c
<sound_dma_irq_handler>: status = DCSR_END_BLOCK, calling audio_dma_callback()
<audio_dma_callback>: s->active, calling snd_pcm_period_elapsed <audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 0, s->period = 1, s->periods = 1, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = -1537, dma_ptr = -1024067073
<audio_get_dma_pos>: offsetFrame= 0, countFrame = 1537 <audio_get_dma_pos>: warning, resetted offset to 0, old offset val = 0 <audio_process_dma>: started, offset = 8192, dma_size = 8192, s->period = 1, s->periods = 0, s->dma_q_head = 0, s->offset = 0, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024057344
[omap_start_alsa_sound_dma]: start <omap_start_alsa_sound_dma>: stream_id = playback, dma_ptr = -1024057344, dma_size = 8192
[audio_set_dma_params_play]: start [audio_set_dma_params_play]: end(0)
[audio_start_dma_chain]: start
[audio_start_dma_chain]: end(0)
[omap_start_alsa_sound_dma]: end(0)
<audio_process_dma>: done, offset = 8192, dma_size = 8192, s->period = 1, s->periods = 1, s->dma_q_head = 0, s->offset = 8192, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, dma_ptr = -1024057344
<sound_dma_irq_handler>: done
<audio_get_dma_pos>: count = 6150, s->dma_q_head = 0, s->offset = 8192, s->period = 2, s->periods = 1, rt->buffer_size = 32768, rt->period_size = 2048, rt->frame_bits = 32, runtime->dma_addr = 0, offset = 511, dma_ptr = -1024065025
<audio_get_dma_pos>: offsetFrame= 2048, countFrame = 1537
ALSA /home/lamikr/own/h6300/eclipsewk/h6300_dev/sound/core/pcm_lib.c:2231:
playback write error (DMA or IRQ trouble?) <snd_omap_alsa_tsc2101_trigger>: cmd = 0
XXX Alsa debug f:audio_stop_dma, l:496 [omap_alsa_audio_stop_dma]: start
[omap_alsa_audio_stop_dma]: end(0) [omap_clear_alsa_sound_dma]: start [omap_clear_alsa_sound_dma]: end(0)
XXX Alsa debug f:snd_card_omap_alsa_tsc2101_close, l:793

author
#10 lore raw
In reply to Daniel Petrini

I got my driver version working also with h6300/1510! But the solution is not perfect and I do not yet understand why it helped.
I did not made any changes to audio_dma_get_pos() method. Instead I just added dma_close to audio_process_dma() method
before each dma_start call and that forces the DMA to somehow trigger irq_handler more oftern.

*diff -Naur h6300_dev_old/sound/arm/omap/omap-alsa-tsc2101.c h6300_dev_working/sound/arm/omap/omap-alsa-tsc2101.c*
*--- h6300_dev_old/sound/arm/omap/omap-alsa-tsc2101.c 2006-02-06 15:36:21.000000000 +0200*
*+++ h6300_dev_working/sound/arm/omap/omap-alsa-tsc2101.c 2006-02-08 14:37:27.000000000 +0200*
@@ -508,6 +508,7 @@
int period;
unsigned int dma_size;
unsigned int offset;
+ unsigned long flags;
int ret;

runtime = substream->runtime;
@@ -528,6 +529,11 @@
runtime->frame_bits,
runtime->dma_addr,
(dma_addr_t)runtime->dma_area + offset);
+#ifdef CONFIG_MACH_OMAP_H6300
+ spin_lock_irqsave(&s->dma_lock, flags);
+ omap_alsa_audio_stop_dma(s);
+ spin_unlock_irqrestore(&s->dma_lock, flags);
+#endif
ret = omap_start_alsa_sound_dma(s,
(dma_addr_t)runtime->dma_area + offset, dma_size);

Now I need to figure out why this fixed the problem and what would be a smarter solution for this.
In addition I can hear that 41000 hz sound is still not played with full speed. (Maybe 1/2 speed is more correct...)

Mika

#11 lore raw
In reply to lamikr
Quoted 2 lines · lamikr
root@h6300:~# aplay 01_the_grudge.mp3
Playing raw data '01_the_grudge.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono

AFAIK, aplay is not able to play MP3 files directly. try to convert the file to WAV or use madplay.

Regards,
--
Anderson Lizardo
Embedded Linux Lab - 10LE
Nokia Institute of Technology - INdT
Manaus - Brazil

author
#12 lore raw
Quoted 8 lines
Quoted 4 lines

Playing raw data '01_the_grudge.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono

AFAIK, aplay is not able to play MP3 files directly. try to convert the file to WAV or use madplay.

That was actually a good point I have not realized earlier! I have however also tested with the "Signed 16 bit little endian wavs using 44100 hz" with same results.

Mika