On Tue, Nov 14, 2017 at 05:27:42PM +0900, Takashi Sakamoto wrote:
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.
Yes, the delayed work might be delayed a lot more than expected under load (or possibly for other reasons).
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.
The problem with set_bias_level() for this might be that the clocks aren't all running until audio is triggered... it's tricky to find a good place to put this that's in line. I'm thinking we might want to add a post trigger callback for cases like this, digital_mute() kind of has that job right now (since it exists mainly to cover up things like controllers that output nonsense during startup) but it'd be a bit of an abuse to just use it as-is. Probably easiest though.