On Thu, Apr 22, 2021 at 10:52:57AM +0900, Kuninori Morimoto wrote:
But, it can be automatically selected if both CPU and Codec drivers indicate it to ALSA SoC Framework, somehow. If we can use it, Sound Card Driver user no longer need to select it, and I want to use this style on new audio-graph-card2.
It could even be done with the existing ones if we just make the format property optional. The automatic selection is something we really ought to at least try to do so thanks for working on this!
This patch-set adds new .get_fmt callback which indicate available dai_fmt to ALSA SoC Framework. Of course Sound Card Driver can still select dai_link->dai_fmt, same as before. If Sound Card Driver didn't set it, and if both CPU / Codec had .get_fmt callback, dai_link->dai_fmt will be automatically selected.
One of the biggest things to consider here is that there's a bunch of devices that have varying degrees of support for different formats so that while they *can* do some formats it's only in specific setups. The most common example is generic serial port devices which can often cope with I2S so long as there are no extra clock cycles but don't *really* fully support I2S (they clock off the first edge on LRCLK and ignore the other edge) but there are other examples. This means we probably want drivers to be able to list at least two levels of preferences for formats separately then try to ideally use one they both like, but it gets a little tricky. We probably also want to have some priority list in the kernel where we try to rank how likely formats are to have bugs in the hardware to maximise the chances that things will work.