[alsa-devel] How to control the route in smartphone

Liam Girdwood lg at opensource.wolfsonmicro.com
Tue Sep 4 19:46:36 CEST 2007


On Tue, 2007-09-04 at 15:14 +0800, Leijin Tang wrote:
> Hi all,
> 
>      When the audio codec is used in the smartphone, we get the problem how to define and control the route in the alsa driver. The scenario is only in the phone device. The application need switch the routes based on the different scenes. 

This is something I've been looking into for the last year and sadly
have not had any development time to commit to it. It's also something
the openmoko guys are looking at too. Atm there is no ALSA API or config
file format for changing/defining scenarios.

Fwiw, the OpenZaurus machines do ALSA scenario atm using an alsactl dump
for each scenario. This is changed by user space when the device
scenario is changed. (google for zaurusd for info)   

> 
> Example: the coedec is wm9713L.
> 
> the in port: LINEL,LINER,MONOIN,MIC1,MIC2, ac97_in 
> 
> the out port: HEADSET, SPEAKER, RECEIVER, ac97_out 
> 
> When the phone is coming, we need chose the route LINE to receiver. After the calling and playing the mp3, we should switch the route ac97_in to speaker on.
> 
> This scenario doesn’t appear in the PC. So how to carry out the function in the alsa architecture is so difficulty. The router names how to define, the alsa-lib how to do the control.There has no design to the phone device in the alsa by now. 
> 
> Does anybody have some ideas? We can do some discussion and resolve the issue. 
> 

Ideally, we should be able to specify scenarios in a text file. This
file could either list the sources and sinks within each scenario (for
an autorouter to set - (I have some autorouter code)) or list a series
of kcontrol settings for each scenario or both.

e.g. (for autorouter)

Scenario "Headphone Playback" {
  Source "Left DAC"
  Source "Right DAC"
  Sink "Left Out1"
  Sink "Right Out1"
  Volume "Out1 Playback Volume"
  Mute "Out1 Playback Switch"
}

e.g. (for kcontrol series)

Scenario "Headphone Playback" {
  Control "Out1 Left Mixer Playback Switch" Value "true"
  Control "Out1 Right Mixer Playback Switch" Value "true"
  Volume "Out1 Playback Volume"
  Mute "Out1 Playback Switch"
}


Note: These are just example formats, they need some thought.

The scenarios should also be able to re alias volumes, mutes etc as well
as altering internal codec routes. This is because the changing route
often changes the alsa controls for volume, mute etc as well. This way
"master volume" will always be "master volume" to user apps regardless
of the actual scenario.

We should probably also add some new function calls to alsa-lib in order
get/set scenario e.g.

snd_scenario_get()  - gets the current scenario
snd_scenario_set()  - sets the scenario
snd_scenario_list() - lists all the available scenarios supported by
sound card.

Finally, I also would define a set of standard scenarios. This would
allow application software to become far more portable between devices.
i.e. the app would just need to ask for "Voice Call Handset" instead of
knowing the scenario name for each machine. Custom scenarios should also
be permitted.

This is just a brain dump atm, I'll try and clarify it a bit to make
more sense later. I also have to post a similar mail to the ohm-devel
list so I'll cross post if no one minds.

Liam



More information about the Alsa-devel mailing list