Tinyalsa configuration

14,689 views
Skip to first unread message

Ed Embedd

unread,
Oct 9, 2012, 5:51:44 AM10/9/12
to android-...@googlegroups.com
Good morning,

I'm trying to figure out how to set up tinyalsa on my TI embedded platform with Android ICS, I found no documentation about tinyalsa or tinyHAL and this is very frustrating when you are trying to get things done.
I will be glad if someone can help me to find some documentation or can give me some hints to make tinyplay work.

when I execute tinyplay I have this output:

"Unable to open PCM device (cannot set hw params: Invalid argument)"

I think it could be a bad tinymix setting, but i don't know where/how to find the correct params.

Thanks for your attention, have a nice day.

Ed

Glenn Kasten

unread,
Oct 9, 2012, 10:38:32 AM10/9/12
to android-...@googlegroups.com
For documentation on the API, see comments in external/tinyalsa/include/tinyalsa/asoundlib.h

I've heard of tinyHAL at Wolfson open source, but I'm not familiar with the details. 

For sample Android audio HAL implementations that use tinyalsa,
see device/asus/grouper/audio/ (JB) or device/samsung/tuna/audio/ (ICS or JB).

Here's my cheat sheet for the example apps:

Play
tinyplay file.wav -D card -d device -p period_size defaults to 1024 -n  period_count defaults to 4
file.wav should be a WAV PCM typically 44100 Hz stereo 16-bit signed

Capture:
tinycap file.wav -D card -d device -c channels=2 -r rate=44100 -b bits=16 -period_size=104 -n number of periods e.g. 4

List mixer controls:
tinymix with no options

Prabagaran Thangavel

unread,
Oct 9, 2012, 11:18:25 AM10/9/12
to android-...@googlegroups.com
Some hint :

1. Check the Sampling Frequency. Tinyplay supports only 44.1 KHZ raw PCM file.
2. Make sure that tinymix settings are proper. In TI Omap and ABE is used the backend opening will be failed if the backend widgets are not enabled properly using tinymix.

Basically tinyplay does

1) opens the file /dev/sndpcmC{Cardnumber}D{Devicenumber}c{capture/playback}.
2) sets the hardware parameters of the opened device.
3) Opens the wav file and does writes the pcm buffers of size specified in params using pcm_write.

Let me know if you need any help regarding the ALSA source code. I will try to help.

Thanks and Regards,
Prabagaran.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/raLLde4vzR4J.

To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Ed Embedd

unread,
Oct 9, 2012, 11:23:05 AM10/9/12
to android-...@googlegroups.com
Thank you Glenn,

I have some other few question:

1)if android audio is already working (system sound work and music player work correctly) I still need to configure tinymix to be able to use tinyplay or tinycap?
2)if the first answer is yes, do you know what kind of documentation (processor datasheet? Audio backend? ...) i need to configure the right audio path through tinymix?

I'm not an audio expert so thanks in advance for your help and your patience

Ed

2012/10/9 Glenn Kasten <gka...@android.com>

--
You received this message because you are subscribed to the Google Groups "android-platform" group.

Ed Embedd

unread,
Oct 9, 2012, 11:37:34 AM10/9/12
to android-...@googlegroups.com
Hi Prabagaran Thangavel,



2012/10/9 Prabagaran Thangavel <prabag...@gmail.com>

Some hint :

1. Check the Sampling Frequency. Tinyplay supports only 44.1 KHZ raw PCM file.
2. Make sure that tinymix settings are proper. In TI Omap and ABE is used the backend opening will be failed if the backend widgets are not enabled properly using tinymix.


1) I checked the frequency because I read about this limitation on TI forum
2)This, I think, is my key problem. I'm not sure at what kind of documentation I have to look to setup properly the device. Now I'm studying my processor datasheet ( Sitara am3358 ) to find some ABE diagram

I really appreciate your help

Thanks,

Ed.

Glenn Kasten

unread,
Oct 10, 2012, 10:55:52 AM10/10/12
to android-...@googlegroups.com
1. If mediaserver has already started up and you have played audio successfully via AudioFlinger, then the mixer controls are usually already set up correctly. So if you kill mediaserver after playing audio with AudioFlinger, and then run tinyplay, it will usually work.  But if you run tinyplay before mediaserver has ever run, then the mixer controls might only have their default (often incorrect) values. For example, I've seen speaker work OK but not wired headphones.

2. You need all the relevant documentation that describes the mixer controls, or you may need to read the source code, usually in the kernel sound/soc/ -- look for the string constants in the driver(s) for your device. I've found mixer controls to be a black art -- usually poorly documented and they require a lot of trial and error to get them right.

priya.bala...@wipro.com

unread,
Oct 10, 2012, 11:32:00 PM10/10/12
to android-...@googlegroups.com

And, some hardware do not support 44.1KHz sampling frequency, like the one in Galaxy nexus.

In that case, using tinyplay with a 48KHz stereo wav file will work

--

You received this message because you are subscribed to the Google Groups "android-platform" group.

Gabriel M. Beddingfield

unread,
Oct 13, 2012, 9:15:19 AM10/13/12
to android-...@googlegroups.com, Ed Embedd
On 10/09/2012 04:51 AM, Ed Embedd wrote:
> Good morning,
>
> I'm trying to figure out how to set up tinyalsa on my TI embedded
> platform with Android ICS, I found no documentation about tinyalsa or
> tinyHAL and this is very frustrating when you are trying to get things done.
> I will be glad if someone can help me to find some documentation or can
> give me some hints to make tinyplay work.

tinyalsa - unfortunately, the code is the documentation.

tinyhal - This is a minimilist implementation of an audio hal, and
requires an XML file to configure it. I think it's the tiny_hw.xml file
in the tinyhal-crespo project.[1]

> when I execute tinyplay I have this output:
>
> *"Unable to open PCM device (cannot set hw params: Invalid argument)"*

tinyplay does not do any resampling or format conversions. Therefore if
the WAV file thaty you play does not EXACTLY match the hardware
capabilities of your device (sample rate, number of channels, number of
bits per sample, period size, period count)... then this is the error
that you get.

> I think it could be a bad tinymix setting, but i don't know where/how to
> find the correct params.

I recommend that you switch to using audio-tool.[2] It can do
everything tinyplay/tinycap/tinymix can do... and It includes a 'tone'
command that will play waveforms (sine, triangle, etc) at any frequency
and hardware settings that you want. To compile it you need a compiler
that will statically link libc... like the CodeSourcery compiler.

-gabriel

[1]
http://opensource.wolfsonmicro.com/cgi-bin/gitweb.cgi?p=tinyhal-crespo.git;a=summary
[2] http://gitorious.org/omap-audio/omap-audio-tool

Ed Embedd

unread,
Oct 15, 2012, 4:51:18 AM10/15/12
to Gabriel M. Beddingfield, android-...@googlegroups.com
Thank you guys,

I tried all of your hints but I didn't succeed so I compiled tinyalsa for my linuxbox (ubuntu 12.04) and I tried to play something with tinyplay, all goes fine.
So I think that on the board the problem could be the android audioflinger that keeps always the control of the devices. I tried to remove audiomanager but didn't work.




12/10/13 Gabriel M. Beddingfield <gabr...@gmail.com>

Gabriel Beddingfield

unread,
Oct 15, 2012, 9:16:59 AM10/15/12
to Ed Embedd, android-...@googlegroups.com
Hi Ed,

On Mon, Oct 15, 2012 at 3:51 AM, Ed Embedd <ed.e...@gmail.com> wrote:
> Thank you guys,
>
> I tried all of your hints but I didn't succeed so I compiled tinyalsa for my
> linuxbox (ubuntu 12.04) and I tried to play something with tinyplay, all
> goes fine.

SoC audio configs are generally a little more complex than an
equivalent desktop config. In addition, the default behavior for
/any/ audio device in Linux is "everything is off." All volumes to
zero. All audio routes and switches "off."

Therefore, distributions like Ubuntu have special programs that try to
configure the audio for you -- to /enable/ things by default. This
makes it easier to set up your computer.

But Android is an embedded platform where the hardware is well-known
before-hand. Therefore, there are generally no programs that will
make using audio "easy." Meanwhile, SoC audio routings are generally
more complex... so you need to have insight into how to route it.

For example, for a pandaboard (OMAP4) you have to set several mixer
settings (about 5 or 6) in order to get basic audio playback over
hw:0,0. That's why 'audio-tool' has a 'config' subcommand -- it will
config several basic routings for you.

> So I think that on the board the problem could be the android audioflinger
> that keeps always the control of the devices. I tried to remove audiomanager
> but didn't work.

Nope... audioflinger does not hold the device open. After playing a
sound or something... it holds it open for about 3 seconds and then
closes it.

If the problem was that audioflinger kept the device open then you
would get a different error. (I think, "You don't have permission" or
something like that.)

-gabriel

Ed Embedd

unread,
Oct 25, 2012, 6:42:08 AM10/25/12
to android-...@googlegroups.com, Ed Embedd

Thank you Gabriel, but I'm going to be a little bit confused.
As I said some posts above, my board can reproduce audio under android (system sounds and audio player works), so, as Glenn said, my mixer settings should be ok,
unfortunately I cant find am3358 Asoc block diagram, so I can't verify if the tinymix setting are really ok. 
Now, after your answer, I'm not sure anymore that my mixer settings are right despite android audio being ok. 

Ed Embedd

unread,
Oct 25, 2012, 6:50:06 AM10/25/12
to android-...@googlegroups.com, Ed Embedd
I made other tests,
I tried to set tinymix manually, I changed several settings and I tried to launch tinyplay... same result. so with the same modified setting, I tried to play some music with android audio player and it worked, i re-checked tinymix during and after the execution of the song and it never changed so, to me, seems that tinymix is quite unuseful.
Someone know more about this?  


Il giorno lunedì 15 ottobre 2012 15:17:15 UTC+2, Gabriel Beddingfield ha scritto:

Murasoli Selvan

unread,
Sep 12, 2013, 6:17:54 AM9/12/13
to android-...@googlegroups.com
Good points and really helped me to understand tinyplay.

thanks  a lot sir.

Murasoli K
Reply all
Reply to author
Forward
0 new messages