On Thu, Nov 15, 2018 at 01:55:06AM +0200, Dimitris Papavasiliou wrote:
On 11/15/2018 01:02 AM, Mark Brown wrote:
I've no idea what you're proposing, sorry.
I mentioned it in the message you replied to initially, so you can consult that for more details if you want, but I'll give a summary below:
That was rather a long mail and I got a bit lost about what the proposal was.
As far as I could determine experimentally, switching clocks when the DAC is not suspended seems to result in a spike at the input of the DAC, the level of which doesn't depend on the digital volume setting (so that it's always very loud). I tried various
This is fairly normal; the DAC is partly digital.
Avoiding the spike instead of relying on muting seems preferable, but, since the power state of the PCM5122 is manipulated by the CODEC driver, in response to requests to set the bias level, I'm concerned about potential race conditions.
Given that there's no substantial delays in the power up/down paths of the driver you probably want to set idle_bias_off and possibly also configuring ignore_pmdown_time to force immediate poweroff. That should get the device powered down rapidly, though bouncing the power on and off all the time isn't great. If you do need ignore_pmdown_time then it's probably better to add a higher level interface that allows the machine driver to cancel all power down timers.
if (no_switch_needed) return;
snd_soc_dapm_mutex_lock(dapm); force = (snd_soc_dapm_get_bias_level(dapm) != SND_SOC_BIAS_OFF);
if (force) snd_soc_dapm_force_bias_level(dapm, SND_SOC_BIAS_OFF);
/* Switch the clock here. */
...
if (force) snd_soc_dapm_sync_unlocked(dapm);
snd_soc_dapm_mutex_unlock(dapm);
This is not a good idea, fiddling around with DAPM internals from drivers is going to be very fragile as things change in future.