alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* tlv320aic32x4 Codec ADC and DAC must shutdown to alter clocks
@ 2014-03-12 15:08 Mike Looijmans
  2014-03-12 23:31 ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Looijmans @ 2014-03-12 15:08 UTC (permalink / raw)
  To: Linux-ALSA

My general question: If "my" codec needs to alter the state of the DAPM 
tree, how can the codec ask or inform the DAPM components of this?


This problem occurs on tlv320aic32x4 codecs, but probably applies to 
many others as well.

Using the tlv320aic32x4 a simple loop like this may "crash" the codec:

while true
do
    speaker-test -c 2 -t sine -l 1 -r 48000 > /dev/null
    speaker-test -c 2 -t sine -l 1 -r 44100 > /dev/null
done 


A "crash" means, in this respect that the chip loses some of its 
settings, malfunctions and often it results in NACKs on I2C commands.

I've been trying to properly fix this, but it just won't fit in the 
framework.

The cause is that the DAPM starts the DAC and/or ADC cores while the 
clocks aren't running, and stops the clocks before shutting down the cores.

There is the overall bug of the driver that starts and stops all the 
clocks in the aic32x4_set_bias_level in the wrong order - it should 
start them from source to sink, and stop them in the opposite direction, 
so the PLL must be the first to start and last to stop. Apparently this 
isn't really critical as I've never observed failure as a result of this.

What I cannot fix is that changing the parameters (like clock frequency) 
must stop the DAC core.

The DAPM framework just sets the BIAS to "ON" only once, and does not 
shut down until after a time out. Which is good.
But if the next stream to play needs a different clock setting, the DAC 
must be stopped first, the code must wait until the DAC has powered 
down, and then the clocks can be stopped and altered. When all settings 
are done, the DAC can be restarted.

Starting the DAC is the DAPM's task, it's this line that does the job:

SND_SOC_DAPM_DAC("Left DAC", "Left Playback", AIC32X4_DACSETUP, 7, 0),

I can detect the change in the hw_params, and on the first stream to 
play, this is called while still in STANDBY or lower levels. However, 
when the codec is already in ON bias level, how do I tell DAPM that I 
had to shut down the DAC in order to change the parameters? Just 
toggling the related bits will keep the DAC powered down. A routine to 
store and restore the power state is possible, but very ineffective. 
Especially since the "I must shutdown" conclusion can also be in the 
clock setting routine. That would result in multiple down-up cycles.


-- 
Mike Looijmans

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-29 10:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 15:08 tlv320aic32x4 Codec ADC and DAC must shutdown to alter clocks Mike Looijmans
2014-03-12 23:31 ` Mark Brown
2014-03-13  7:09   ` Mike Looijmans
2014-03-13 14:04     ` Mark Brown
2014-03-14  9:47       ` Mike Looijmans
2014-03-28 14:13         ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).