All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: Re: [PATCH 2/7] ASoC: soc-core: add snd_soc_runtime_get_dai_fmt()
Date: Fri, 23 Apr 2021 19:35:03 +0100	[thread overview]
Message-ID: <20210423183503.GK5507@sirena.org.uk> (raw)
In-Reply-To: <87y2dbgk47.wl-kuninori.morimoto.gx@renesas.com>

[-- Attachment #1: Type: text/plain, Size: 2414 bytes --]

On Thu, Apr 22, 2021 at 10:53:44AM +0900, Kuninori Morimoto wrote:

> +/* Describes the possible PCM format */
> +#define SND_SOC_POSSIBLE_DAIFMT_FORMAT_SHIFT	0
> +#define SND_SOC_POSSIBLE_DAIFMT_FORMAT_MASK	(0xFFFF << SND_SOC_POSSIBLE_DAIFMT_FORMAT_SHIFT)
> +#define SND_SOC_POSSIBLE_DAIFMT_I2S		(1 << SND_SOC_DAI_FORMAT_I2S)
> +#define SND_SOC_POSSIBLE_DAIFMT_RIGHT_J		(1 << SND_SOC_DAI_FORMAT_RIGHT_J)
> +#define SND_SOC_POSSIBLE_DAIFMT_LEFT_J		(1 << SND_SOC_DAI_FORMAT_LEFT_J)
> +#define SND_SOC_POSSIBLE_DAIFMT_DSP_A		(1 << SND_SOC_DAI_FORMAT_DSP_A)
> +#define SND_SOC_POSSIBLE_DAIFMT_DSP_B		(1 << SND_SOC_DAI_FORMAT_DSP_B)
> +#define SND_SOC_POSSIBLE_DAIFMT_AC97		(1 << SND_SOC_DAI_FORMAT_AC97)
> +#define SND_SOC_POSSIBLE_DAIFMT_PDM		(1 << SND_SOC_DAI_FORMAT_PDM)

I'm not 100% sure I get why we have the separate _POSSIBLE_ macros here?
One thing we'll have to take account of is that there's some DAIs that
have some restrictions on what options they can combine - for example
only doing I2S with one format of clock but allowing clock inversion in
DSP mode.  It might be safer (if tedious for driver authors without some
help...) to just have arrays of fully specified daifmt values.

>  /* Digital Audio interface formatting */
> +u64 snd_soc_dai_get_fmt(struct snd_soc_dai *dai);

Like I said on the cover letter I think we need to be able to specify at
least two levels of preference here.  How about

	int snd_soc_dai_get_fmt(struct snd_soc_dai *dai,
				u64 *preferred, u64 *supported);

or something?  Just thinking off the top of my head, that's a bit ugly
and doesn't scale to multiple levels so I don't know if I'm *super*
happy with that interface.  But we might be better off using just arrays
of daifmt values like I say, if we do that perhaps just one array but
sorting it might do?

> +	/* use original dai_fmt if sound card specify */
> +	if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK))
> +		mask |= SND_SOC_DAIFMT_FORMAT_MASK;
> +	if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_CLOCK_MASK))
> +		mask |= SND_SOC_DAIFMT_CLOCK_MASK;
> +	if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_INV_MASK))
> +		mask |= SND_SOC_DAIFMT_INV_MASK;
> +	if (!(dai_link->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK))
> +		mask |= SND_SOC_DAIFMT_MASTER_MASK;
> +
> +	dai_link->dai_fmt =	dai_link->dai_fmt | (dai_fmt & mask);

If the sound card specifies something why not just use it verbatim
instead of trying to merge?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-04-23 18:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-22  1:52 [PATCH 0/7] ASoC: adds new .get_fmt support Kuninori Morimoto
2021-04-22  1:53 ` [PATCH 1/7] ASoC: soc-core: move snd_soc_runtime_set_dai_fmt() to upside Kuninori Morimoto
2021-04-22  1:53 ` [PATCH 2/7] ASoC: soc-core: add snd_soc_runtime_get_dai_fmt() Kuninori Morimoto
2021-04-23 18:35   ` Mark Brown [this message]
2021-04-26  6:13     ` Kuninori Morimoto
2021-04-26 13:08       ` Mark Brown
2021-04-26 22:39         ` Kuninori Morimoto
2021-04-22  1:53 ` [PATCH 3/7] ASoC: ak4613: add .get_fmt support Kuninori Morimoto
2021-04-22  1:53 ` [PATCH 4/7] ASoC: pcm3168a: " Kuninori Morimoto
2021-04-22  1:53 ` [PATCH 5/7] ASoC: rsnd: " Kuninori Morimoto
2021-04-22  1:54 ` [PATCH 6/7] ASoC: fsi: " Kuninori Morimoto
2021-04-22  1:54 ` [PATCH 7/7] ASoC: hdmi-codec: " Kuninori Morimoto
2021-04-23 18:18 ` [PATCH 0/7] ASoC: adds new " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210423183503.GK5507@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.