Re: [PATCH] soundwire: stream: only change state if needed

From: Pierre-Louis Bossart
Date: Tue Mar 17 2020 - 11:32:38 EST



The change below would be an error case for Intel, so it's probably better if we go with your suggestion. You have a very specific state handling due to your power amps and it's probably better to keep it platform-specific.

Just trying to understand, why would it be error for Intel case?

IMO, If stream state is SDW_STREAM_ENABLED that also implicit that its prepared too. Similar thing with SDW_STREAM_DEPREPARED.
Isn't it?

the stream state is a scalar value, not a mask. The state machine only allows transition from CONFIGURED TO PREPARED or from DEPREPARED TO PREPARED, or DISABLED to PREPARED.
There is no allowed transition from ENABLED TO PREPARED, you have to go through the DISABLED state and make sure a bank switch occurred, and re-do a bank switch to prepare again.
I agree with you if are on single dai case. Am happy to move to stream handling to machine driver for now.

But this also means that in cases like multi-codec its not recommended to call sdw_prepare and sdw_enable in a single function from codec.
Which might be worth documenting.

Well, the bigger question is why use sdw_stream functions at the codec level in the first place? All other codec drivers seem to have no issue leaving the dais owned by the master control stream state changes.

I am not saying I object or it's bad, just that there were significant changes in usages of the 'stream' concept since it was introduced, as well as threads in MIPI circles to clarify the prepare/enable dependencies, so it'd be useful to have a complete picture of what different platforms need/want.