mbox series

[0/7] ASoC: adds new .get_fmt support

Message ID 871rb3hypy.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
Headers show
Series ASoC: adds new .get_fmt support | expand

Message

Kuninori Morimoto April 22, 2021, 1:52 a.m. UTC
Hi Mark

These are a little bit challenging patch-set.

We need to set dai_link->dai_fmt to select CPU/Codec settings,
and it is selected by Sound Card Driver, today.

Because of it, Sound Card user need to know both CPU / Codec
available dai_fmt, and needs to select it.
For example simple-card / audio-graph case, it is selected by
"format" and "bitclock/frame-master/inversion" on DT.

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.

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.

Kuninori Morimoto (7):
  ASoC: soc-core: move snd_soc_runtime_set_dai_fmt() to upside
  ASoC: soc-core: add snd_soc_runtime_get_dai_fmt()
  ASoC: ak4613: add .get_fmt support
  ASoC: pcm3168a: add .get_fmt support
  ASoC: rsnd: add .get_fmt support
  ASoC: fsi: add .get_fmt support
  ASoC: hdmi-codec: add .get_fmt support

 include/sound/soc-dai.h       |  35 ++++++
 sound/soc/codecs/ak4613.c     |  10 ++
 sound/soc/codecs/hdmi-codec.c |  19 ++++
 sound/soc/codecs/pcm3168a.c   |  13 +++
 sound/soc/sh/fsi.c            |  13 +++
 sound/soc/sh/rcar/core.c      |  16 +++
 sound/soc/soc-core.c          | 195 +++++++++++++++++++++++-----------
 sound/soc/soc-dai.c           |  19 ++++
 sound/soc/soc-utils.c         |  26 +++++
 9 files changed, 284 insertions(+), 62 deletions(-)

Comments

Mark Brown April 23, 2021, 6:18 p.m. UTC | #1
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.