Repository navigation
ASoC: intel: sof_sdw_rt1308: amp_num should be += num_codecs #1954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -409,27 +409,23 @@ static int create_codec_dai_name(struct device *dev, | |
| return 0; | ||
| } | ||
|
|
||
| static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link, | ||
| static int set_dailink_init_func(const struct snd_soc_acpi_link_adr *link, | ||
| struct snd_soc_dai_link *dai_links, | ||
| bool playback) | ||
| { | ||
| int i; | ||
|
|
||
| for (i = 0; i < link->num_adr; i++) { | ||
| unsigned int part_id; | ||
| int codec_index; | ||
| unsigned int part_id; | ||
| int codec_index; | ||
|
|
||
| part_id = SDW_PART_ID(link->adr_d[i].adr); | ||
| codec_index = find_codec_info_part(part_id); | ||
| part_id = SDW_PART_ID(link->adr_d[0].adr); | ||
| codec_index = find_codec_info_part(part_id); | ||
|
|
||
| if (codec_index < 0) | ||
| return codec_index; | ||
| if (codec_index < 0) | ||
| return codec_index; | ||
|
|
||
| if (codec_info_list[codec_index].init) | ||
| codec_info_list[codec_index].init(link, dai_links, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@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.
@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. |
||
| &codec_info_list[codec_index], | ||
| playback); | ||
| } | ||
| if (codec_info_list[codec_index].init) | ||
| codec_info_list[codec_index].init(link, dai_links, | ||
| &codec_info_list[codec_index], | ||
| playback); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
@@ -622,8 +618,8 @@ static int create_sdw_dailink(struct device *dev, int *be_index, | |
| codecs, codec_num, | ||
| NULL, &sdw_ops); | ||
|
|
||
| ret = set_codec_init_func(link, dai_links + (*be_index)++, | ||
| playback); | ||
| ret = set_dailink_init_func(link, dai_links + (*be_index)++, | ||
| playback); | ||
| if (ret < 0) { | ||
| dev_err(dev, "failed to init codec %d", codec_index); | ||
| return ret; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,18 +130,17 @@ int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link, | |
| struct sof_sdw_codec_info *info, | ||
| bool playback) | ||
| { | ||
| info->amp_num++; | ||
| info->amp_num += dai_links->num_codecs; | ||
| if (info->amp_num == 1) | ||
| dai_links->init = first_spk_init; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| if (info->amp_num == 2) { | ||
| /* | ||
| * if two 1308s are in one dai link, the init function | ||
| * in this dai link will be first set for the first speaker, | ||
| * and it should be reset to initialize all speakers when | ||
| * the second speaker is found. | ||
| * if dai_links->num_codecs = 2, it implies that 2 rt1308s | ||
| * are in the same dai link. Otherwise they will be in 2 | ||
| * dai links. | ||
| */ | ||
| if (dai_links->init) | ||
| if (dai_links->num_codecs == 2) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| dai_links->init = all_spk_init; | ||
| else | ||
| dai_links->init = second_spk_init; | ||
|
|
||
There was a problem hiding this comment.
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.