summaryrefslogtreecommitdiff
path: root/include/sound/soc.h
AgeCommit message (Collapse)Author
2020-01-10ASoC: soc-core: add snd_soc_close_delayed_work()Kuninori Morimoto
We need to setup rtd->close_delayed_work_func. It will be set at snd_soc_dai_compress_new() or soc_new_pcm(). But these setups close_delayed_work() which is same name / same implemantaion, but different local code. To reduce duplicate code, this patch moves it as snd_soc_close_delayed_work() and share same code. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/8736cot4v2.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-01-10ASoC: soc-core: remove snd_soc_rtdcom_listKuninori Morimoto
Current ALSA SoC is using struct snd_soc_rtdcom_list to connecting component to rtd by using list_head. struct snd_soc_rtdcom_list { struct snd_soc_component *component; struct list_head list; /* rtd::component_list */ }; struct snd_soc_pcm_runtime { ... struct list_head component_list; /* list of connected components */ ... }; The CPU/Codec/Platform component which will be connected to rtd (a) is indicated via dai_link at snd_soc_add_pcm_runtime() int snd_soc_add_pcm_runtime(...) { ... /* Find CPU from registered CPUs */ rtd->cpu_dai = snd_soc_find_dai(dai_link->cpus); ... (a) snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); ... /* Find CODEC from registered CODECs */ (b) for_each_link_codecs(dai_link, i, codec) { rtd->codec_dais[i] = snd_soc_find_dai(codec); ... (a) snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component); } ... /* Find PLATFORM from registered PLATFORMs */ (b) for_each_link_platforms(dai_link, i, platform) { for_each_component(component) { ... (a) snd_soc_rtdcom_add(rtd, component); } } } It shows, it is possible to know how many components will be connected to rtd by using dai_link->num_cpus dai_link->num_codecs dai_link->num_platforms If so, we can use component pointer array instead of list_head, in such case, code can be more simple. This patch removes struct snd_soc_rtdcom_list that is only of temporary value, and convert to pointer array. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87a76wt4wm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-16ASoC: soc-core: remove legacy style of codec_confKuninori Morimoto
Now all driver is using snd_soc_dai_link_component for codec_conf. Let's remove legacy style Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/871rt959ic.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-16ASoC: soc-core: support snd_soc_dai_link_component for codec_confKuninori Morimoto
To find codec_conf component, it is using dev_name, of_node. But, we already has this kind of finding component method by snd_soc_dai_link_component, and snd_soc_is_matching_component(). We shouldn't have duplicate implementation to do same things. This patch adds snd_soc_dai_link_component support to find codec_conf component. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87lfrh59kj.wl-kuninori.morimoto.gx@renesas.com Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-11ASoC: Drop snd_soc_pcm_lib_ioctl()Takashi Iwai
Now all snd_soc_pcm_lib_ioctl() calls were dropped, and it became superfluous. Let's kill it. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20191210145406.21419-24-tiwai@suse.de Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-11ASoC: soc-core: tidyup for CONFIG_DMIKuninori Morimoto
soc-core.c has 2 #ifdef CONFIG_DMI, but we can merge these. OTOH, soc.h has dmi_longname, but it is needed if CONFIG_DMI was defined. In other words, It is not needed if CONFIG_DMI was not defined. This patch tidyup these. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87eexbbhyy.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-10Merge branch 'for-5.5' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.6
2019-12-10ASoC: soc-core: rename snd_soc_remove_dai_link() to snd_soc_remove_pcm_runtime()Kuninori Morimoto
Now soc-core and soc-topology is using snd_soc_remove_dai_link(). It removes pcm_runtime (= rtd) and disconnect it from card. The purpose is removing pcm_runtime, not dai_link. This patch renames function name. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/875zipyq5s.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-10ASoC: soc-core: rename snd_soc_add_dai_link() to snd_soc_add_pcm_runtime()Kuninori Morimoto
Now soc-core and soc-topology is using snd_soc_add_dai_link(). The abstract of this function is "create pcm_runtime from dai_link information and connect it to card". Thus, "add dai_link" is wrong/confusable naming. This patch renames function name. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/877e35yq5w.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-10ASoC: soc-core: move snd_soc_find_dai_link()Kuninori Morimoto
snd_soc_find_dai_link() is soc-topology specific function. We don't need to have it at soc-core. This patch moves it to soc-topology.c Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/878snlyq61.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-10ASoC: soc-core: find rtd via dai_link pointer at snd_soc_get_pcm_runtime()Kuninori Morimoto
Current snd_soc_get_pcm_runtime() is finding rtd by checking dai_link name. But, it is strange and waste of CPU power, because its user want to get from rtd from dai_link, not from dai_link name. This patch find rtd via dai_link pointer instead of its name. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/87a781yq67.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-10ASoC: soc-core: remove snd_soc_get_dai_substream()Kuninori Morimoto
No driver is using snd_soc_get_dai_substream(), and snd_soc_get_pcm_runtime() is enough for such purpose. We can revival it if it was needed in the future. Let's remove unused function. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/87d0cxyq6k.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-10ASoC: soc-core: remove dai_link_listKuninori Morimoto
ASoC is using many lists. Now, used dai_link is listed to card as dai_link_list. [card]->[dai_link]->[dai_link]->... BTW, this "dai_link" is used to create "rtd". And this rtd is listed to card as rtd_list. [card]->[rtd]->[rtd]->... Here, each rtd has dai_link. This means, we can track all dai_link via rtd list. This patch removes card dai_link_list, and uses rtd_list instead of it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/87fthtyq6z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-04ASoC: core: Init pcm runtime work early to avoid warningsCurtis Malainey
There are cases where we fail before we reach soc_new_pcm which would init the workqueue. When we fail we attempt to flush the queue which generates warnings from the workqueue subsystem when we have not inited the queue. Solution is to use a proxy function to get around this issue. Signed-off-by: Curtis Malainey <cujomalainey@chromium.org> Reviewed-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20191203173007.46504-1-cujomalainey@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-20ASoC: core: add SND_SOC_BYTES_ETzung-Bi Shih
Add SND_SOC_BYTES_E to accept getter and putter. Signed-off-by: Tzung-Bi Shih <tzungbi@google.com> Link: https://lore.kernel.org/r/20191120060844.224607-2-tzungbi@google.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-20ASoC: add control components managementJaroslav Kysela
This ASCII string can carry additional information about soundcard components or configuration. Add the possibility to set this string via the ASoC card. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Cc: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20191119174933.25526-1-perex@perex.cz Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-05ASoC: soc.h: dobj is used only when SND_SOC_TOPOLOGYKuninori Morimoto
snd_soc_dobj is used only when SND_SOC_TOPOLOGY was selected. Let's enable it under SND_SOC_TOPOLOGY. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87o8xq251d.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-05ASoC: soc-core: don't call snd_soc_dapm_new_dai_widgets() at ↵Kuninori Morimoto
snd_soc_register_dai() ALSA SoC has 2 functions. snd_soc_register_dai() is used from topology snd_soc_register_dais() is used from snd_soc_add_component() In general, people think like _dai() is called from _dais() with for loop. But in reality, these are very similar but different implementation. We shouldn't have duplicated and confusing implementation. snd_soc_register_dai() is now used from topology. But to reduce duplicated code, it should be used from _dais(), too. Because of topology side specific reason, it is calling snd_soc_dapm_new_dai_widgets(), but it is not needed _dais() side. This patch factorizes snd_soc_register_dai() to topology / _dais() common part, and topology specific part. And do topology specific part at soc-topology. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87sgn2251p.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-05ASoC: soc-core: have legacy_dai_naming at snd_soc_register_dai()Kuninori Morimoto
ALSA SoC has 2 functions. snd_soc_register_dai() is used from topology snd_soc_register_dais() is used from snd_soc_add_component() In general, people think like _dai() is called from _dais() with for loop. But in reality, these are very similar but different implementation. We shouldn't have duplicated and confusing implementation. snd_soc_register_dai() is now used from topology. But to reduce duplicated code, it should be used from _dais(), too. To prepare it, this patch adds missing parameter legacy_dai_naming to snd_soc_register_dai(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87tv7i251u.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-05ASoC: soc-core: add snd_soc_unregister_dai()Kuninori Morimoto
It is easy to read code if it is cleanly using paired function/naming, like start <-> stop, register <-> unregister, etc, etc. But, current ALSA SoC code is very random, unbalance, not paired, etc. It is easy to create bug at the such code, and is difficult to debug. This patch adds missing soc_del_dai() and snd_soc_unregister_dai(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87v9ry251z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-23ASoC: soc-core: add for_each_rtd_components() and replaceKuninori Morimoto
ALSA SoC has for_each_rtdcom() which is link list for rtd-component which is called as rtdcom. The relationship image is like below rtdcom rtdcom rtdcom component component component rtd->component_list -> list -> list -> list ... Here, the pointer get via normal link list is rtdcom, Thus, current for_each loop is like below, and need to get component via rtdcom->component for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; ... } but usually, user want to get pointer from for_each_xxx is component directly, like below. for_each_rtd_component(rtd, rtdcom, component) { ... } This patch expands list_for_each_entry manually, and enable to get component directly from for_each macro. Because of it, the macro becoming difficult to read, but macro itself becoming useful. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-22ASoC: soc-core: remove for_each_rtdcom_safe()Kuninori Morimoto
There is no user of for_each_rtdcom(). Let's remove it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87a7a264m9.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-08ASoC: soc-core: add snd_soc_pcm_lib_ioctl()Kuninori Morimoto
add snd_soc_pcm_lib_ioctl() to bypass to snd_pcm_lib_ioctl() Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87r23vaf39.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-01ASoC: soc-core: merge soc_free_pcm_runtime() and soc_rtd_free()Kuninori Morimoto
"rtd" is handled by soc_xxx_pcm_runtime(), and "rtd->dev" is handled by soc_rtd_xxx(). There is no reason to separate these, and it makes code complex. We can free these in the same time. Here soc_rtd_free() (A) which frees rtd->dev is called from soc_remove_link_dais() many times (1). Then, it is using dev_registered flags to avoid multi kfree() (2). This is no longer needed if we can merge these functions. static void soc_remove_link_dais(...) { ... (1) for_each_comp_order(order) { (1) for_each_card_rtds(card, rtd) { (A) soc_rtd_free(rtd); ... } } } (A) static void soc_rtd_free(...) { (2) if (rtd->dev_registered) { /* we don't need to call kfree() for rtd->dev */ device_unregister(rtd->dev); (2) rtd->dev_registered = 0; } } This patch merges soc_rtd_free() into soc_free_pcm_runtime(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/878squf7oi.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-21ASoC: soc-core: merge snd_soc_initialize_card_lists()Kuninori Morimoto
snd_soc_initialize_card_lists() is doing card related INIT_LIST_HEAD(), but, it is already doing at snd_soc_register_card(). We don't need to do it separately. This patch merges these. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/877e781ldq.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-15ASoC: core: Move pcm_mutex up to card level from snd_soc_pcm_runtimePeter Ujfalusi
The pcm_mutex is used to prevent concurrent execution of snd_pcm_ops callbacks. This works fine most of the cases but it can not handle setups when the same DAI is used by different rtd, for example: pcm3168a have two DAIs: one for Playback and one for Capture. If the codec is connected to a single CPU DAI we need to have two dai_link to support both playback and capture. In this case the snd_pcm_ops callbacks can be executed in parallel causing unexpected races in DAI drivers. By moving the pcm_mutex up to card level this can be solved while - hopefully - not breaking other setups. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20190813104532.16669-1-peter.ujfalusi@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-09ASoC: soc-core: add for_each_xxx macro for aux_devKuninori Morimoto
To be more readable code, this patch adds new for_each_xxx() macro for aux_dev. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87ftmc6w8s.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-09ASoC: soc-core: remove legacy style of aux_devKuninori Morimoto
Now all drivers are using snd_soc_dai_link_component for aux_dev. Let's remove legacy style Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87h86s6w8x.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-09ASoC: soc-core: support snd_soc_dai_link_component for aux_devKuninori Morimoto
To find aux_dev, ASoC is using .name, codec_name, codec_of_node. Here, .name is used to fallback in case of no codec. But, we already have this kind of component finding method by snd_soc_dai_link_component and soc_find_component(). We shouldn't have duplicated implementation to do same things. This patch adds snd_soc_dai_link_component support to finding aux_dev. Now, no driver is using only .name. All drivers are using codec_name and/or codec_of_node. This means no driver is finding component from .name so far. (Actually almost all drivers are using .name as just "device name", not for finding component...) This patch 1) add snd_soc_dai_link_component support for aux_dev. legacy style will be removed if all drivers are switched to new style. 2) try to find component via snd_soc_dai_link_component. Then, it doesn't try to find via .name, because no driver is using it so far. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87y3046wcf.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-08ASoC: soc-core: tidyup for card->deferred_resume_workKuninori Morimoto
card->deferred_resume_work is used if CONFIG_PM_SLEEP was defined. but 1) It is defined even though CONFIG_PM_SLEEP was not defined 2) random ifdef code is difficult to read. This patch tidyup these issues. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/877e7paho1.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-05ASoC: add soc-component.cKuninori Morimoto
ALSA SoC has many snd_soc_component_xxx(), but these are randomly located in many files. Because of it, code is difficult to read. This patch creates new soc-component.c, and moves existing snd_soc_component_xxx() into it. But not yet fully. We need more cleanup it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87imrp5roa.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-01ASoC: core: no need to check return value of debugfs_create functionsGreg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Also, there is no need to store the individual debugfs file name, just remove the whole directory all at once, saving a local variable. Note, the soc-pcm "state" file has now moved to a subdirectory, as it is only a good idea to save the dentries for debugfs directories, not individual files, as the individual file debugfs functions are changing to not return a dentry. Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.com> Cc: alsa-devel@alsa-project.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20190731131716.9764-2-gregkh@linuxfoundation.org Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-23ASoC: soc-dai: mv soc_dai_hw_params() to soc-daiKuninori Morimoto
Sometimes ALSA SoC naming is very random. Current soc_dai_hw_params() should use snd_soc_dai_xxx() style. And then, 1st parameter should be dai. Otherwise it is confusable. - soc_dai_hw_params(..., dai); + snd_soc_dai_hw_params(dai, ...); Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87zhl6hn5b.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-06-28ASoC: soc-core: support dai_link with platforms_num != 1Jerome Brunet
Add support platforms_num != 1 in dai_link. Initially, the main purpose of this change was to make the platform optional in the dai_link, instead of inserting the dummy platform driver. This particular case had just been solved by Kuninori Morimoto with commit 1d7689892878 ("ASoC: soc-core: allow no Platform on dai_link"). However, this change may still be useful for those who need multiple platform components on a single dai_link (it solves one of the FIXME note in soc-core) Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-06-19ASoC: soc-core: allow no Platform on dai_linkKuninori Morimoto
dai_link is used to selecting Component (= CPU/Codec/Platform) and DAI (= CPU/Codec). And selected CPU/Codec/Platform components are *listed* on Card. Many drivers don't need special Platform component, but was mandatory at legacy style ALSA SoC. Thus, there is this kind of settings on many drivers. dai_link->platform_of_node = dai_link->cpu_of_node; In this case, soc_bind_dai_link() will pick-up "CPU component" as "Platform component", and try to add it to snd_soc_pcm_runtime. But it will be ignored, because it is already added when CPU bindings. Historically, this kind of "CPU component" is used/selected as "Platform" on many ALSA SoC drivers. OTOH, Dummy Platform will be selected automatically by ALSA SoC if driver doesn't have Platform settings. These indicates that there are 2 type of Platforms exist at current ALSA SoC if driver doesn't need special Platform. 1) use Dummy Platform as Platform component 2) use CPU component as Platform component ALSA SoC will call Dummy Platform callback function if it is using Dummy Platform, but it is completely pointless. Because it is the sound card which doesn't need special Platform. Thus, the behavior we request to ALSA SoC is selecting 2) automatically instead of 1) if sound card doesn't need special Platform. And, 2) means "do nothing" as above explain. These were needed at legacy style dai_link, but is no longer needed at modern style dai_link anymore. This patch allows "no Platform" settings on dai_link, and will do nothing for it if there was no platform settings. This is same as 2). By this patch, all drivers which is selecting "CPU component" as "Platform" can remove such settings. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-06-19ASoC: soc.h: fixup for_each_card_links() macroKuninori Morimoto
Macro is using "link", not "dai_link" Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-06-06ASoC: soc-core: remove legacy style dai_linkKuninori Morimoto
All drivers switched to modern style dai_link (= struct snd_soc_dai_link_component). Let's remove legacy style dai_link. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-06-06ASoC: soc.h: add sound dai_link connection macroKuninori Morimoto
Modern style dai_link requests CPU/Codec/Platform component pointer array and its size, but it will be very verbose code. To avoid such scene, this patch adds dai_link connection macro. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-06-06ASoC: soc-core: use snd_soc_dai_link_component for CPUKuninori Morimoto
current ALSA SoC is starting to support modern style dai_linke (= struct snd_soc_dai_link_component) which is mainly used for multipul DAI/component connection. Now Codec has full multi-codec support, Platform is using modern style but still for single Platform. Only CPU is not yet supporting modern style yet. If we could support it for CPU, we can switch to modern style dai_link on all CPU/Codec/Platform, and remove legacy style from ALSA SoC. Multi-CPU will be supported in the future. This patch is initial support for modern style for CPU Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-05-13ASoC: soc.h: fe_compr can be bit fieldKuninori Morimoto
fe_compr is used at soc-compress, it can be bit field. This patch move it from int to bit field. > grep fe_compr -r sound/soc/* sound/soc/soc-compress.c: rtd->fe_compr = 1; sound/soc/soc-pcm.c: if (!fe->dpcm[stream].runtime && !fe->fe_compr) Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-04-08ASoC: core: conditionally increase module refcount on component openRanjani Sridharan
Recently, for Intel platforms the "ignore_module_refcount" field was introduced for the component driver. In order to avoid a deadlock preventing the PCI modules from being removed even when the card was idle, the refcounts were not incremented for the device driver module during component probe. However, this change introduced a nasty side effect: the device driver module can be unloaded while a pcm stream is open. This patch proposes to change the field to be renamed as "module_get_upon_open". When this field is set, the module refcount should be incremented on pcm open amd decremented upon pcm close. This will enable modules to be removed when no PCM playback/capture happens and prevent removal when the component is actually in use. Also, align with the skylake component driver with the new name. Fixes: b450b878('ASoC: core: don't increase component module refcount unconditionally' Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-03-11ASoC: dpcm: prevent snd_soc_dpcm use after freeKaiChieh Chuang
The dpcm get from fe_clients/be_clients may be free before use Add a spin lock at snd_soc_card level, to protect the dpcm instance. The lock may be used in atomic context, so use spin lock. Use irq spin lock version, since the lock may be used in interrupts. possible race condition between void dpcm_be_disconnect( ... list_del(&dpcm->list_be); list_del(&dpcm->list_fe); kfree(dpcm); ... and for_each_dpcm_fe() for_each_dpcm_be*() race condition example Thread 1: snd_soc_dapm_mixer_update_power() -> soc_dpcm_runtime_update() -> dpcm_be_disconnect() -> kfree(dpcm); Thread 2: dpcm_fe_dai_trigger() -> dpcm_be_dai_trigger() -> snd_soc_dpcm_can_be_free_stop() -> if (dpcm->fe == fe) Excpetion Scenario: two FE link to same BE FE1 -> BE FE2 -> Thread 1: switch of mixer between FE2 -> BE Thread 2: pcm_stop FE1 Exception: Unable to handle kernel paging request at virtual address dead0000000000e0 pc=<> [<ffffff8960e2cd10>] dpcm_be_dai_trigger+0x29c/0x47c sound/soc/soc-pcm.c:3226 if (dpcm->fe == fe) lr=<> [<ffffff8960e2f694>] dpcm_fe_dai_do_trigger+0x94/0x26c Backtrace: [<ffffff89602dba80>] notify_die+0x68/0xb8 [<ffffff896028c7dc>] die+0x118/0x2a8 [<ffffff89602a2f84>] __do_kernel_fault+0x13c/0x14c [<ffffff89602a27f4>] do_translation_fault+0x64/0xa0 [<ffffff8960280cf8>] do_mem_abort+0x4c/0xd0 [<ffffff8960282ad0>] el1_da+0x24/0x40 [<ffffff8960e2cd10>] dpcm_be_dai_trigger+0x29c/0x47c [<ffffff8960e2f694>] dpcm_fe_dai_do_trigger+0x94/0x26c [<ffffff8960e2edec>] dpcm_fe_dai_trigger+0x3c/0x44 [<ffffff8960de5588>] snd_pcm_do_stop+0x50/0x5c [<ffffff8960dded24>] snd_pcm_action+0xb4/0x13c [<ffffff8960ddfdb4>] snd_pcm_drop+0xa0/0x128 [<ffffff8960de69bc>] snd_pcm_common_ioctl+0x9d8/0x30f0 [<ffffff8960de1cac>] snd_pcm_ioctl_compat+0x29c/0x2f14 [<ffffff89604c9d60>] compat_SyS_ioctl+0x128/0x244 [<ffffff8960283740>] el0_svc_naked+0x34/0x38 [<ffffffffffffffff>] 0xffffffffffffffff Signed-off-by: KaiChieh Chuang <kaichieh.chuang@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-08ASoC: core: don't increase component module refcount unconditionallyPierre-Louis Bossart
The ASoC core has for the longest time increased the module reference counts, even before the transition to the component model. This is probably fine on most platforms, but it introduces a deadlock case on Intel devices with the Skylake and SOF drivers which cannot be removed due to their reference counts being modified by the core. In these 2 cases, the PCI or ACPI driver .probe creates a platform device to let the machine driver .probe register the audio card. Conversely the PCI or ACPI driver .remove will unregister the platform device which results in the card being removed by the machine driver .remove. With ascii art, this can be represented as modprobe snd_soc_skl/ soc-pci-dev/sof-acpci-dev ----------> pci/acpi probe ^ | | ---------------| | | | | V V increase register register machine refcount component platform_device ^ | | | | V component <---- register card <---- probe probe The issue is that by playing with the component's module reference counts during the card registration, it's no longer possible to remove the module which controls the component. This can be shown, e.g. with the following error: root@plb-XPS-13-9350:~# lsmod | grep snd_soc_skl snd_soc_skl 110592 1 root@plb-XPS-13-9350:~# rmmod snd_soc_skl rmmod: ERROR: Module snd_soc_skl is in use Increasing the reference count during the component probe is not useful. If the PCI/ACPI module is removed, the card will be removed anyway. To avoid breaking existing platforms and allowing Intel platforms to safely deal with module load/unload cases, this patch introduces a flag which needs to be set during the component initialization. This is a strictly opt-in capability that should only be used when the handling of the component module does not require a reference count increase to prevent removal during use. Note that this solution is not directly applicable to the legacy Atom/SST driver, which uses a different device hierarchy. There are however additional refcount issues which prevent the ACPI driver from being removed. This is a different issue which would need a different patch. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-28ASoC: add helper to change platform name for all dailinksPierre-Louis Bossart
To reuse the same machine drivers with Atom/SST, Skylake and SOF, we need to change the default platform_name (or platforms->name in the "modern" representation). So far, this override was done with an automatic override, which was broken by a set of changes for DT platforms related to deferred probe handling. This automatic override is actually not really needed, the machine driver can already receive the platform name as a platform_data parameter. This is used e.g. for HDaudio support where we have different PCI aliases used for different platforms. We can reuse the same mechanism and modify the machine drivers to override the dailinks prior to registrating the card. This will require additional work for SOF, but with this helper it'll be just two lines of additional code per machine driver which is reused, not the end of the world. This helper can be simplified when all drivers have transitioned to the "modern" representation of dailinks. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-21ASoC: soc-core: add .num_platform for dai_linkKuninori Morimoto
Current snd_soc_dai_link is starting to use snd_soc_dai_link_component (= modern) style for Platform, but it is still assuming single Platform so far. We will need to have multi Platform support in the not far future. Currently only simple card is using it as sound card driver, and other drivers are converted to it from legacy style by snd_soc_init_platform(). To avoid future problem of multi Platform support, let's add num_platforms before it is too late. In the same time, to make it same naming mothed, "platform" should be "platforms". This patch fixup it too. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-18ASoC: soc.h: add explanation of legacy/modern style of dai_linkKuninori Morimoto
Current ALSA SoC is assuming 1 CPU 1 Platform (= DMA) style system. Because of this background, it is directly using xxx_name / xxx_of_node / xxx_dai_name on dai_link. Let's call it as legacy style here. More complex style system like multi CPU multi Platform (= DMA) will coming. To supporting it, we can use snd_soc_dai_link_component on dai_link. Let's call it as modern style here. But current ALSA SoC can't support it so far. Thus, we need to have multi CPU / multi Codec / multi Platform style in the future on ALSA SoC. Currently we already have multi Codec support. Platform is starting to use modern style on dai_link, but still style only. Multi Platform is not yet implemented. And we still don't have multi CPU support on ALSA SoC, and not have modern style either. Currently, if driver is using legacy style Codec/Platform, it will be converted to modern style on soc-core. This means, we are using glue code for legacy vs modern style so far on ALSA SoC. We can fully switch to modern style on all drivers if ALSA SoC supported modern style for CPU, and then, legacy style code will be removed from ALSA SoC. Untile then, we need to keep both legacy/modern style and its glue code. This patch adds such future plan and background on soc.h Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-14ASoC: soc-core: fix init platform memory handlingCurtis Malainey
snd_soc_init_platform initializes pointers to snd_soc_dai_link which is statically allocated and it does this by devm_kzalloc. In the event of an EPROBE_DEFER the memory will be freed and the pointers are left dangling. snd_soc_init_platform sees the dangling pointers and assumes they are pointing to initialized memory and does not reallocate them on the second probe attempt which results in a use after free bug since devm has freed the memory from the first probe attempt. Since the intention for snd_soc_dai_link->platform is that it can be set statically by the machine driver we need to respect the pointer in the event we did not set it but still catch dangling pointers. The solution is to add a flag to track whether the pointer was dynamically allocated or not. Signed-off-by: Curtis Malainey <cujomalainey@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-12-13Merge branch 'for-4.20' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-4.21 intel dep
2018-11-26ASoC: soc.h: makes snd_soc_of_parse_audio_prefix() inlineKuninori Morimoto
commit 3b7103562c03c ("ASoC: soc-core: add snd_soc_of_parse_node_prefix()") maked snd_soc_of_parse_audio_prefix() as #define. But it'd be better to make this a static inline rather than a #define. It helps with error messages and type safety. This patch makes it inline. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-23ASoC: soc-core: add snd_soc_of_parse_node_prefix()Kuninori Morimoto
Current ASoC has snd_soc_of_parse_audio_prefix() to get codec_conf settings from DT which is used to avoid DAI naming conflict when CPU/Codec matching. Currently, it is parsing from "top node", but, we want to parse from "each sub node" if sound card had multi cpus/codecs. This patch adds new snd_soc_of_parse_node_prefix() to allow parsing settings from selected node. It is keeping existing snd_soc_of_parse_audio_prefix() by using macro. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>