-
Notifications
You must be signed in to change notification settings - Fork 133
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
[RFC] ASoC: Add Multi CPU DAI support #1644
Conversation
sound/soc/soc-core.c
Outdated
struct snd_soc_dai *codec_dai; | ||
int i; | ||
|
||
pinctrl_pm_select_sleep_state(cpu_dai->dev); | ||
for_each_rtd_codec_dai(rtd, i, cpu_dai) { |
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.
@bardliao typo here. For_each_cpu_dai?
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.
Thank will update it.
sound/soc/soc-core.c
Outdated
|
||
if (cpu_dai->active) | ||
pinctrl_pm_select_default_state(cpu_dai->dev); | ||
for_each_rtd_codec_dai(rtd, i, cpu_dai) { |
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.
Looks like typo here as well? For each cpu dai?
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.
Indeed. Thanks.
@@ -491,6 +491,14 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( | |||
if (!rtd->codec_dais) | |||
goto free_rtd; | |||
|
|||
/* | |||
* for rtd->cpu_dais | |||
*/ |
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.
This comment is not very helpful at all
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.
This is to be consistent with the existing code. ie
/*
* for rtd->codec_dais
*/
above.
sound/soc/soc-pcm.c
Outdated
/* prune the BE if it's no longer in our active list */ | ||
if (widget && widget_in_list(list, widget)) | ||
/* | ||
* The BE is pruned only if none of the the cpu_dai |
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.
Duplicate "the" in comment
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.
Thank will update it.
8f63a25
to
bd28394
Compare
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.
Looks good @bardliao, see comments below
@@ -1149,6 +1154,9 @@ struct snd_soc_pcm_runtime { | |||
struct snd_soc_dai **codec_dais; | |||
unsigned int num_codecs; | |||
|
|||
struct snd_soc_dai **cpu_dais; | |||
unsigned int num_cpu_dai; | |||
|
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.
I wonder why we need to keep 'codec_dai' now that we have 'codec_dais" and 'num_codecs'?
Also why do we need 'cpu_dai' as well as 'cpus_dais' and 'num_cpu_dai'
Looks like room for additional cleanups
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.
I wonder why we need to keep 'codec_dai' now that we have 'codec_dais" and 'num_codecs'?
Also why do we need 'cpu_dai' as well as 'cpus_dais' and 'num_cpu_dai'
Looks like room for additional cleanups
Indeed, we can send another patch to remove cpu_dai and codec_dai
sound/soc/soc-core.c
Outdated
if (cpu_dai->component->driver->non_legacy_dai_naming) { | ||
unsigned int inv_dai_fmt; | ||
for_each_rtd_cpu_dai(rtd, i, cpu_dai) { | ||
if (cpu_dai->component->driver->non_legacy_dai_naming) { |
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.
what is the 'legacy_dai_naming' and can it be removed now?
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.
what is the 'legacy_dai_naming' and can it be removed now?
@plbossart No, I don't think it can be removed now. Codec will be registered to cpu dai in CODEC <-> CODEC link, and we can use the non_legacy_dai_naming flag to know that is codec.
for_each_rtd_cpu_dai(rtd, i, cpu_dai) { | ||
ret = snd_soc_dai_hw_params(cpu_dai, substream, params); | ||
if (ret < 0) | ||
goto interface_err; |
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.
you need to add the error handling here, the interface_err only deals with the codec case
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.
you need to add the error handling here, the interface_err only deals with the codec case
Yes, thanks @plbossart
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.
@plbossart Updated
if (widget && widget_in_list(list, widget)) | ||
do_prune = 0; | ||
} | ||
if (!do_prune) |
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.
this will conflict with @lyakh 's work...
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.
this will conflict with @lyakh 's work...
Sorry, @plbossart @lyakh Could you describe it in more detail? Which PR will be affected?
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.
@bardliao it's #1501 but I think it should be ok for you to proceed with your PR for now. I'm not sure what @plbossart's plan is, but as far as I understand, even after #1501 is fully reviewed and approved here, we'll first need to also get it reviewed on ALSA and virtualisation lists, so, it will take a while.
sound/soc/soc-pcm.c
Outdated
@@ -3038,7 +3172,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
out: | |||
dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", | |||
(rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name, | |||
cpu_dai->name); | |||
(rtd->num_cpu_dai > 1) ? "multicpu" : rtd->cpu_dai->name); |
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.
this looks really ugly, what cant' we use rtd->cpu_dais[0].name and completely remove the use of rtd->cpu_dai?
sound/soc/soc-dapm.c
Outdated
for_each_rtd_codec_dai(rtd, i, codec_dai) { | ||
for_each_rtd_cpu_dai(rtd, j, cpu_dai) { | ||
dapm_add_valid_dai_widget(card, rtd, | ||
codec_dai, cpu_dai); |
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.
this seems odd. You will not have a connection between each CPU dai and each codec_dai
e,g. for Soundwire, you will connect ALH1.3 to RT1308.1.aif1 and ALH2.3 to RT1308.2.aif1
There will be no routing/link between e.g. ALH1.3 and RT1308.2.aif1
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.
this seems odd. You will not have a connection between each CPU dai and each codec_dai
e,g. for Soundwire, you will connect ALH1.3 to RT1308.1.aif1 and ALH2.3 to RT1308.2.aif1
There will be no routing/link between e.g. ALH1.3 and RT1308.2.aif1
Yes, it is what we are missing now. Thanks @plbossart
@morimoto if you have spare cycles your feedback on this PR would be more than appreciated. |
fa4266b
to
30cc579
Compare
8d64b21
to
4a4b971
Compare
@plbossart I compared and merged @morimoto 's version. Could you review it? I have two question.
|
4a4b971
to
fdce38f
Compare
sound/soc/soc-pcm.c
Outdated
cpu_rate_max = min_not_zero(cpu_rate_max, cpu_stream->rate_max); | ||
formats &= cpu_stream->formats; | ||
cpu_rates = snd_pcm_rate_mask_intersect(cpu_stream->rates, | ||
rates); |
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.
cpu_rates?
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.
Good catch. Thanks @lyakh
if (widget && widget_in_list(list, widget)) | ||
do_prune = 0; | ||
} | ||
if (!do_prune) |
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.
@bardliao it's #1501 but I think it should be ok for you to proceed with your PR for now. I'm not sure what @plbossart's plan is, but as far as I understand, even after #1501 is fully reviewed and approved here, we'll first need to also get it reviewed on ALSA and virtualisation lists, so, it will take a while.
sound/soc/soc-dapm.c
Outdated
dapm_add_valid_dai_widget(card, rtd, | ||
codec_dai, | ||
rtd->cpu_dais[i]); | ||
} |
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.
superfluous parentheses
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.
Updated. Thanks.
sound/soc/soc-dapm.c
Outdated
} else { | ||
for_each_rtd_codec_dai(rtd, i, codec_dai) { | ||
dapm_add_valid_dai_widget(card, rtd, | ||
codec_dai, rtd->cpu_dais[0]); | ||
} |
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.
ditto
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.
Updated. Thanks.
@@ -62,6 +62,10 @@ int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream, | |||
struct snd_dmaengine_dai_dma_data *dma_data; | |||
int ret; | |||
|
|||
if (rtd->num_cpus > 1) | |||
dev_warn(rtd->dev, | |||
"%s doesn't support Multi CPU yet\n", __func__); |
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.
What would actually happen in such a case? Would it still work at least with just one CPU codec? Shouldn't we return an error in this and similar cases instrad?
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.
What would actually happen in such a case? Would it still work at least with just one CPU codec? Shouldn't we return an error in this and similar cases instrad?
To be honest, I don't know how to test it. I should still work with one CPU. I don't want to return an error for now is because I want to know what will happen if these functions are invoked with multi cpus.
fdce38f
to
0e7bc90
Compare
@bardliao I've lost track of the directions here, Mark Brown seemed to think this was a good patchset, are you going to update the PR, send the changes directly to alsa-devel? Let me know, thanks! |
@plbossart Yes, I will double check the comments and send a new version to alsa-devel after addressing all comments. |
0e7bc90
to
e695059
Compare
ce89c61
to
279476a
Compare
"ASoC: Neither/both cpu name/of_node are set for %s\n", | ||
link->name); | ||
return -EINVAL; | ||
} | ||
|
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.
Something is off here. Either the error message is wrong or the if condition is wrong. If none of cpu->name / cpu->of_node are set we won't hit the error message.
This is not a blocker for this PR as the issue was pre-existent. Will send an email to alsa-devel.
279476a
to
39b2ecc
Compare
ASoC core supports multiple codec DAIs but supports only a CPU DAI. To support multiple cpu DAIs, add cpu_dai and num_cpu_dai in snd_soc_dai_link and snd_soc_pcm_runtime structures similar to support for codec_dai. This is intended as a preparatory patch to eventually support the unification of the Codec and CPU DAI. Inline with multiple codec DAI approach, add support to allocate, init, bind and probe multiple cpu_dai on init if driver specifies that. Also add support to loop over multiple cpu_dai during suspend and resume. This is intended as a preparatory patch to eventually unify the CPU and Codec DAI into DAI components. Signed-off-by: Shreyas NC <shreyas.nc@intel.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
39b2ecc
to
a2aee90
Compare
Add support in PCM operations to invoke multiple cpu dais as we do for multiple codec dais. Also the symmetry calculations are updated to reflect multiple cpu dais. Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Shreyas NC <shreyas.nc@intel.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Adding a helper to connect widget for a specific cpu and codec dai The helper will help dapm_connect_dai_link_widgets() to reduce indents. Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Shreyas NC <shreyas.nc@intel.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
DAPM handles DAIs during soc_dapm_stream_event() and during addition and creation of DAI widgets i.e., dapm_add_valid_dai_widget() and dapm_connect_dai_link_widgets(). Extend these functions to handle multiple cpu dai. Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Shreyas NC <shreyas.nc@intel.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Multi cpu is not supported by all functions yet. Add an error message and return. Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
Now multi-cpu-dai is supported. We have the same resaon as multi-codec-dai to skip CPUs which don't support the current stream. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
df0bcf1
to
918814f
Compare
replaced by PR #1802 |
This is a rebase version of https://www.alsa-project.org/pipermail/alsa-devel/2018-June/137190.html
The original commit message is:
Thanks @ranj063 for the comments. I addressed some, but I need more
time or help from others for the other comments.