On Tue, Mar 27, 2018 at 06:57:44PM -0300, Ezequiel Garcia wrote:
On a second look, I don't think digital mute helps here. And I don't think the problem is fixable at the CPU DAI level.
The noise has been reported on bcm2835-i2s and rockchip-i2s, which made me think most SoCs were unable to guarantee the clocks could be stopped properly.
As the commit explains, the root of the noise is that this amplifier specifies that the LRCLK cannot be disabled with the BCLK being enabled.
I don't see any mechanism at the SoC level to guarantee that the LRCLK and BCLK clocks will be shutdown in order.
Honestly I'm surprised that there's a big issue here - most of the SoCs I've seen shut everything down at pretty much the same time. It sounds like this CODEC is *extremely* fragile somehow and probably can't really tolerate having the clocks stopped at all.
Well, from the above description, it seems this noise arises from a limitation of the amplifier, so it doesn't seem too bad to apply a small delay and make it configurable.
The default value (no delay) will work for most users, and the delay parameter would be turned on by those having noise issues with this driver.
That is what patch v2 does, let me know if you still think it's horrible, or if you think I am still missing anything.
I'm still not super sure why you need to assert SD_MODE with an extra delay here (for the benefit of the archives that's shutdown mode which powers the chip off) - if anything I'd have thought it would be better to assert it before stopping any clock and then deassert it after the clocks are running again which would be what mute would do. Why is that not sufficient?