Am looking at intel_hw_params(). Isn't sdw_stream_add_master() called for every dai in the dai link.
Yes, that's correct, but again a dai may use one or more ports.
if you defined each port as a dai, and want to call sdw_stream_add_master() for each port you are doing something the API was not designed for. There is a 'num_ports' argument for a reason :-)
per master, and that master_rt deals with one or more ports - your choice. >In qcom case stream is also allocated for in dai startup().
A 'stream' is an abstract data transport which can be split across multiple masters/sales and for each master/slave use multiple ports.
When calling sdw_stream_add_master/slave, you need to provide a port_config/num_ports to state which ports will be used on that master/slave when using the stream. That's how we e.g. deal with 4ch streams that are handled by two ports on each side.
To up-level a bit, the notion of 'stream' is actually very very similar to the notion of dailink. And in fact, the 'stream' is actually created for Intel in the dailink .startup callback, so I am quite in the dark on what you are trying to accomplish.
I think we are talking about two different issues,
1>one is the failure I see in sdw_stream_add_master() when I try to use dai-link dai-id style approach suggested. I will dig this bit more and collect more details!
2>(Main issue) Ability for slave to select different combination of ports at runtime based on the mixer setting or active dapm.
All this patch is trying do is the pass this *CURRENT/ACTIVE* static port mapping between slave and master while setting up the stream.
With the dailink approach number of ports are pretty much static and may not be required for particular use case. As above example if we have a headset with button click suppression we would need 2 Ports and similarly without we only need one port.
As I said above you cannot enable the button click suppression dynamically *after* the headset capture hw_params/prepare.
This is not possible with dai-link approach, unless we create two different dai links for the above example usecase!
The current approach is a worst-case one, where you would create a single 'headset capture' dailink.
We never envisioned a case where you modify what the definition of 'headset capture' is based on control events, and I really challenge the fact that it is feasible/realistic. This is really about streaming data across a bus, and we are limited on what we can do. It's the same problem that we never modify the number of channels dynamically on a PCM device.