[alsa-devel] [PATCH] ASoC: ak4613: call dummy write for PW_MGMT1/3 when Playback
Takashi Sakamoto
o-takashi at sakamocchi.jp
Tue Nov 14 09:27:42 CET 2017
On Nov 14 2017 15:31, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
>
> Power Down Release Command (PMVR, PMDAC, RSTN, PMDA1-PMDA6)
> which are located on PW_MGMT1 / PW_MGMT3 register must be
> write again after at least 5 LRCK cycle or later from the first
> command. Otherwise, Playback volume will be 0dB.
> This patch adds dummy write when Playback Start timing.
> ...
> +
> + delay = 6000000 / priv->rate;
> + priv->component = &codec->component;
> + schedule_delayed_work(&priv->dummy_write_work,
> + usecs_to_jiffies(delay));
In my understanding, kernel's service of delayed work relies on kernel's
timer service. Resolution of the service is quite coarse in this
purpose, at least for several phases of word select clock. In the worst
case when task scheduling is too delay, many audio samples are not
presented by the DAC in the beginning of playback. I can easily imagine
that users get confused.
For this purpose, hrtimer kernel service is better. However, in design
of ALSA PCM core, .trigger callback can be done in any IRQ context,
basically. This means that we can't call task scheduler in the callback
as long as issuing the command in the callback. This is a reason that
you use workqueue for this purpose.
In your patch description, 5 word select phases after 'the first
command'. According to "Digital Attenuator" section per page 44 of
AK4613 English datasheet (AsahiKASEI 2015, MS1052-E-05)[1], your 'the
first command' seems to be the previous command issueing of 'power-down
release command'. In my understanding, in ak4613 codec driver, issueing
of the previous command is done in 'ak4613_set_bias_level()'. If there's
a guarantee for DAPM stuffs to call this function on any non-IRQ
context, it's better to call the subsequent commands in the function
with interval of sleep functionality with finer resolution (e.g.
usleep_range()) but I don't know exactly that any components has
guarantee to receive word select clock when the function is called.
[1] http://www.akm.com/akm/en/file/datasheet/AK4613VQ.pdf
Regards
Takashi Sakamoto
More information about the Alsa-devel
mailing list