alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Question about daifmt of legacy DT on simple-card
@ 2021-01-14  4:24 Kuninori Morimoto
  2021-01-14 13:50 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Kuninori Morimoto @ 2021-01-14  4:24 UTC (permalink / raw)
  To: Mark Brown, Jyri Sarha; +Cc: Linux-ALSA


Hi ALSA SoC
Cc Jyri

For historical reason, simple-card supports legacy DT daifmt
settings. Then, I noticed one strange code.

	-- simple-card-utils.c ---

	asoc_simple_parse_daifmt(xxx)
	{
(A)		daifmt = snd_soc_of_parse_daifmt(...);
		daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;

		if (!bitclkmaster && !framemaster) {
			/*
			 * No dai-link level and master setting was not found from
			 * sound node level, revert back to legacy DT parsing and
			 * take the settings from codec node.
			 */
(B)			daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) |
				(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
		} ...
		...
	}

It rollbacks to legacy DT parsing at (B) if (A) didn't have
master settings.
Here, (B) re-try to get daifmt, and use "or" with (daifmt & ~CLOCK mask).
Why CLOCK mask ? and shouldn't it use mask when "or" ?
Otherwise FORMAT and INV part will be duplicated, I think.
for example
	daifmt = (snd_soc_of_parse_daifmt() &  SND_SOC_DAIFMT_CLOCK_MASK) |
		 (daifmt                    & ~SND_SOC_DAIFMT_CLOCK_MASK)

I think using snd_soc_of_parse_daifmt() only is very enough at (B),
but am I misunderstanding ??

The original code was from

	b3ca11ff59bc5842b01f13421a17e6d9a8936784
	("ASoC: simple-card: Move dai-link level properties away from dai subnodes")

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about daifmt of legacy DT on simple-card
  2021-01-14  4:24 Question about daifmt of legacy DT on simple-card Kuninori Morimoto
@ 2021-01-14 13:50 ` Mark Brown
  2021-01-14 23:20   ` Kuninori Morimoto
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2021-01-14 13:50 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Jyri Sarha

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

On Thu, Jan 14, 2021 at 01:24:04PM +0900, Kuninori Morimoto wrote:

> It rollbacks to legacy DT parsing at (B) if (A) didn't have
> master settings.
> Here, (B) re-try to get daifmt, and use "or" with (daifmt & ~CLOCK mask).
> Why CLOCK mask ? and shouldn't it use mask when "or" ?
> Otherwise FORMAT and INV part will be duplicated, I think.
> for example
> 	daifmt = (snd_soc_of_parse_daifmt() &  SND_SOC_DAIFMT_CLOCK_MASK) |
> 		 (daifmt                    & ~SND_SOC_DAIFMT_CLOCK_MASK)

> I think using snd_soc_of_parse_daifmt() only is very enough at (B),
> but am I misunderstanding ??

I have to confess I'm not entirely clear on what the intent is behind
the code; we can work out what it *does* but looking at it again I'd be
hard pressed to say what the actual intent is.  At the very least it
needs more comments :/

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about daifmt of legacy DT on simple-card
  2021-01-14 13:50 ` Mark Brown
@ 2021-01-14 23:20   ` Kuninori Morimoto
  0 siblings, 0 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2021-01-14 23:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Jyri Sarha


Hi Mark

Thank you for your feedback

> > It rollbacks to legacy DT parsing at (B) if (A) didn't have
> > master settings.
> > Here, (B) re-try to get daifmt, and use "or" with (daifmt & ~CLOCK mask).
> > Why CLOCK mask ? and shouldn't it use mask when "or" ?
> > Otherwise FORMAT and INV part will be duplicated, I think.
> > for example
> > 	daifmt = (snd_soc_of_parse_daifmt() &  SND_SOC_DAIFMT_CLOCK_MASK) |
> > 		 (daifmt                    & ~SND_SOC_DAIFMT_CLOCK_MASK)
> 
> > I think using snd_soc_of_parse_daifmt() only is very enough at (B),
> > but am I misunderstanding ??
> 
> I have to confess I'm not entirely clear on what the intent is behind
> the code; we can work out what it *does* but looking at it again I'd be
> hard pressed to say what the actual intent is.  At the very least it
> needs more comments :/

I re-check it, and maybe my above assumption was not correct.
I think I could understand what it want to do,
but not 100% sure.
I can/want to cleanup around here.

Because my assumption might not 100% true,
I will post the patch with [RFC] prefix.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-14 23:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14  4:24 Question about daifmt of legacy DT on simple-card Kuninori Morimoto
2021-01-14 13:50 ` Mark Brown
2021-01-14 23:20   ` Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).