Skip to content

ASoC: intel: sof_sdw_rt1308: amp_num should be += num_codecs - #1954

Closed
bardliao wants to merge 3 commits into
thesofproject:topic/sof-devfrom
bardliao:rt1308_init
Closed

bardliao wants to merge 3 commits into
thesofproject:topic/sof-devfrom
bardliao:rt1308_init

Conversation

@bardliao

@bardliao bardliao commented Mar 30, 2020 •

Copy link
Copy Markdown
Collaborator

The amp_num represents the number of amps. A dai link may have
more than one amp. So amp_num should += the number of amps in
the dai link. And test dai_links->init does not work since dai_links->init
is already set when we test it.

Fixes: #1953

The amp_num represents the number of amps. A dai link may have
more than one amp. So amp_num should += the number of amps in
the dai link.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao bardliao changed the title ASoC: intel: sof_sdw_rt1308: amp_num should be += num_cpus ASoC: intel: sof_sdw_rt1308: amp_num should be += num_codecs Mar 30, 2020
spk_init should be use

It is more readable to test dai_links->num_codecs than dai_links->init.
Also, sof_sdw_rt1308_init() will be called once if two rt1308s are
aggregated.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
…me dailink

The only reason that we do that is to calculate how many rt1308s do we have.
However, we can get the number by dailinks->num_codecs. Now, we increase
rt1308 amp_num by += num_codecs. So we can do codec init in each dailink
now.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
return codec_index;

if (codec_info_list[codec_index].init)
codec_info_list[codec_index].init(link, dai_links,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the process well enough, but this raises an alarm for me. Are we really sure that it's always enough to just call .init() once for the first codec iinfo? That we'll never have mixed codecs or a codec, that needs certain initialisation performed for each instance? Individual codec .init() implementations might need to check whether an instance has already initialised on this card, but can we really skip this completely globally?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I guess this is ok as this init() is specific to the sof-sdw driver and you only do dailink specific actions, but it's worth a check still. I.e. is this future proof to not all init for all codecs on the dailink?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the process well enough, but this raises an alarm for me. Are we really sure that it's always enough to just call .init() once for the first codec iinfo? That we'll never have mixed codecs or a codec, that needs certain initialisation performed for each instance? Individual codec .init() implementations might need to check whether an instance has already initialised on this card, but can we really skip this completely globally?

@lyakh If we look at the "codec init" functions, we can see that they are used to set dailink init function. So it is fine to called them once per dailink. We don't support mixed codecs in a dailink for now. If we want to do that, we will do more modification than this PR. Current code doesn't allow us to have different init function for the same codec either. So, I think the PR is safe for current code.

@bardliao I guess this is ok as this init() is specific to the sof-sdw driver and you only do dailink specific actions, but it's worth a check still. I.e. is this future proof to not all init for all codecs on the dailink?

@kv2019i Yes, I checked all the init functions for supported codecs. None of them need to be called more than once per dailink. In fact, sof_sdw_rt1308_init() was the only one which will be called more than one time per dailink before this change.

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. A couple of questions inline.

info->amp_num++;
info->amp_num += dai_links->num_codecs;
if (info->amp_num == 1)
dai_links->init = first_spk_init;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao How about the logic below checking "info->amp_num == 1". Is this still valid in case amp_num is incremented possibly by many amps in one call?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @kv2019i . This code assumes amp_num ==1 or ==2, I don't understand this at all. Also num_codecs can include other devices, not just the amps, so the logic is not future proof?

return codec_index;

if (codec_info_list[codec_index].init)
codec_info_list[codec_index].init(link, dai_links,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I guess this is ok as this init() is specific to the sof-sdw driver and you only do dailink specific actions, but it's worth a check still. I.e. is this future proof to not all init for all codecs on the dailink?

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @bardliao I am not convinced. I don't think it's right to change the logic and deal with the case where multiple devices per link means multiple amplifiers per link. That's a restriction we never had before.

info->amp_num++;
info->amp_num += dai_links->num_codecs;
if (info->amp_num == 1)
dai_links->init = first_spk_init;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @kv2019i . This code assumes amp_num ==1 or ==2, I don't understand this at all. Also num_codecs can include other devices, not just the amps, so the logic is not future proof?

unsigned int part_id;
int codec_index;
unsigned int part_id;
int codec_index;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I don't think this change is correct.
We don't want to make the assumption that if there are more than one devices on the link then they are all RT1308. That's not good, it means we cannot support hybrid configurations.

* dai links.
*/
if (dai_links->init)
if (dai_links->num_codecs == 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bardliao I think the check would be a lot more intuitive if you say if (dai_lisnk->num_codecs == info->amp_num)

@plbossart plbossart Mar 30, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but that's a wrong assumption! We should NOT assume num_codecs == num_amps.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yes you are right @plbossart . It makes sense only if there is only one set of amps.

@RanderWang

Copy link
Copy Markdown

@bardliao the root reason is: set_codec_init_func only search the codecs in current link since there was no group support at design time. Now we need to check all the codecs in all links for a special group.

@bardliao

Copy link
Copy Markdown
Collaborator Author

Thanks all. I will create a new PR for #1953

@bardliao bardliao closed this Mar 31, 2020
jason77-wang pushed a commit to jason77-wang/linux-1 that referenced this pull request Apr 10, 2020
Init codecs which belong to the same group id on all links.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
(backported from thesofproject#1954)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
jason77-wang pushed a commit to jason77-wang/linux-1 that referenced this pull request Apr 15, 2020
BugLink: https://bugs.launchpad.net/bugs/1872916

Init codecs which belong to the same group id on all links.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
(backported from thesofproject#1954)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][CML]Aplay0,2 rt1308 right speaker have sound output when muted speaker in alsamixer.

7 participants