summaryrefslogtreecommitdiff
path: root/sound/soc/soc-core.c
AgeCommit message (Collapse)Author
2017-11-10Merge remote-tracking branches 'asoc/topic/cygnus', 'asoc/topic/da7213', ↵Mark Brown
'asoc/topic/davinci' and 'asoc/topic/doc' into asoc-next
2017-11-01ASoC: fix build warning in soc-core.cRandy Dunlap
Fix kernel-doc build error. A symbol that ends with an underscore character ('_') has special meaning in reST (reStructuredText), so add a '*' to prevent this error and to indicate that there are several of these values to choose from. ../sound/soc/soc-core.c:2799: ERROR: Unknown target name: "snd_soc_daifmt". Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-23ASoC: snd_soc_component_driver has non_legacy_dai_namingKuninori Morimoto
Codec will be replaced into Component, then Codec side doesn't use legacy_dai_naming on snd_soc_register_dais(). This patch adds new non_legacy_dai_naming flag on Component driver and use converted its value for snd_soc_register_dais(). When Codec is replaced into Component, Codec driver needs to have non_legacy_dai_naming = 1 flags. Existing CPU side of course doesn't have this flag, thus CPU calls it as true. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-23ASoC: snd_soc_component_driver has endiannessKuninori Morimoto
Codec will be replaced into Component, then Codec side only needs to call fixup_codec_formats() at this point. This patch adds new endianness flag on Component driver and call convert_endianness_formats() (= was fixup_codec_format()) if endianness was true. When Codec is replaced into Component, Codec driver needs to have endianness = 1 flags. Existing CPU side of course doesn't have this flag, thus CPU doesn't call it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-10ASoC: soc-core: remove unnecessary message from snd_soc_register_component()Kuninori Morimoto
No need to print an error message if kzalloc fails. The core will print it. Reported-by: Daniel Baluta <daniel.baluta@gmail.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-10Merge branch 'topic/component' of ↵Mark Brown
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-core
2017-10-10ASoC: soc-core: add snd_soc_add_component()Kuninori Morimoto
ALSA SoC platform/codec will be replaced to component soon. But, some function exist in "platform" doesn't exist in "component". Current soc-core has snd_soc_register_component(), but doesn't have snd_soc_add_component() like snd_soc_add_platform(). This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04ASoC: soc-core: add component lookup functionsKuninori Morimoto
ALSA SoC platform/codec will be replaced to component soon. This means 1 device might have multiple components. But current unregister component function only checks "dev" to find it. This means, unexpected component might be unregistered by current function. But, it is no problem if driver registered only 1 component. To prepare avoid this issue, this patch adds new component lookup function. it finds component by "dev" and "driver name". Here, the reason why it uses "driver name" is that "component name" was created by fmt_single_name() and difficult to use it from driver. Driver of course knows its "driver name", thus, using it is more easy. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-27ASoC: add Component level set_bias_levelKuninori Morimoto
In current ALSA SoC, Codec only has set_bias_level feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Codec driver has .idle_bias_off for dapm bias. But Component driver doesn't have it, and dapm->idle_bias_off is set as "true". To keep compatibility, this patch adds "idle_bias_on" instead of ".idle_bias_off" on Component driver. dapm->idle_bias_off will be set by inverted idle_bias_on. When we replace Codec to Component, the driver which has ".idle_bias_off = true" is just remove it, and the driver which doesn't have it will have new ".idle_bias_on = true". Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-27ASoC: add Component level pcm_new/pcm_free v2Kuninori Morimoto
In current ALSA SoC, Platform only has pcm_new/pcm_free feature, but it should be supported on Component level. This patch adds it. The v1 was added commit 99b04f4c4051f7 ("ASoC: add Component level pcm_new/pcm_free") but it called all "card" connected component's pcm_new/free, it was wrong. This patch calls "rtd" connected component. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-26ASoC: add null_snd_soc_ops and reduce NULL ops checkKuninori Morimoto
Double NULL pointer check for ops and ops->func is difficult to read and might be forget to check it if new func was add. This patch adds new null_snd_soc_ops and use it if rtd->dai_link didn't have it to avoid NULL ops, and reduces ops NULL check. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-25ASoC: remove unneeded dai->driver checkKuninori Morimoto
On soc_add_dai(), it is checking dai->driver->xxx, This means, dai->driver is mandatory, never been NULL. dai->driver check is not needed. This patch removes it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-25ASoC: soc-core: remove rtd NULL check on soc_free_pcm_runtime()Kuninori Morimoto
static soc_free_pcm_runtime() is never called with rtd == NULL. This patch removes unnecessary rtd == NULL check from soc_free_pcm_runtime(). Furthermore, NULL check before kfree() is not needed. This patch removes such ckeck too. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-04Merge tag 'asoc-v4.14' of ↵Takashi Iwai
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus ASoC: Updates for v4.14 This is quite a large release by volume of patches and diff, a lot of that is mechanical cleanup patches but it's great to also see a range of vendors actively working on adding new features and fixing issues in their drivers. Intel and Realtek have been especially active here. - Continued work towards moving everything to the component model from Morimoto-san. - Use of devres for jack detection GPIOs, eliminating some potential resource leaks. - Jack detection support for Qualcomm MSM8916. - Support for Allwinner H3, Cirrus Logic CS43130, Intel Kabylake systems with RT5663, Realtek RT274, TI TLV320AIC32x6 and Wolfson WM8523.
2017-09-01Merge remote-tracking branch 'asoc/topic/core' into asoc-nextMark Brown
2017-08-30ASoC: add Component level set_jackKuninori Morimoto
In current ALSA SoC, Codec only has set_jack feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-30ASoC: add Component level set_pllKuninori Morimoto
In current ALSA SoC, Codec only has set_pll feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-30ASoC: add Component level set_sysclkKuninori Morimoto
In current ALSA SoC, Codec only has set_sysclk feature. Codec will be merged into Component in next generation ALSA SoC, thus current Codec specific feature need to be merged into it. This is glue patch for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-30Merge tag 'v4.13-rc7' into asoc-componentMark Brown
Linux 4.13-rc7
2017-08-30ALSA: Get rid of card power_lockTakashi Iwai
Currently we're taking power_lock at each card component for assuring the power-up sequence, but it doesn't help anything in the implementation at the moment: it just serializes unnecessarily the callers, but it doesn't protect about the power state change itself. It used to have some usefulness in the early days where we managed the PM manually. But now the suspend/resume core procedure is beyond our hands, and power_lock lost its meaning. This patch drops the power_lock from allover the places. There shouldn't be any issues by this change, as it's no helper regarding the power state change. Rather we'll get better performance by removing the serialization; which is the only slight concern of any behavior change, but it can't be a showstopper, after all. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-08-25ASoC: remove duplicate definition of dapm_routes/num_dapm_routesKuninori Morimoto
snd_soc_component and snd_soc_component_driver both have dapm_routes/num_dapm_routes, but these are duplicated. Let's remove duplicated definition. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-25ASoC: remove duplicate definition of dapm_widgets/num_dapm_widgetsKuninori Morimoto
snd_soc_component and snd_soc_component_driver both have dapm_widgets/num_dapm_widgets, but these are duplicated. Let's remove duplicated definition. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-25ASoC: remove duplicate definition of controls/num_controlsKuninori Morimoto
snd_soc_component and snd_soc_component_driver both have controls/num_controls, but these are duplicated. Let's remove duplicated definition. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-25ASoC: use snd_soc_component_get_dapm()Kuninori Morimoto
Now we have snd_soc_component_get_dapm(), and as soc.h say below, let's use it. /* Don't use these, use snd_soc_component_get_dapm() */ struct snd_soc_dapm_context dapm; Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-25ASoC: Add a sanity check before using dai driver nameJeffy Chen
The dai driver's name is allowed to be NULL. So add a sanity check for that. Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reported-by: Donglin Peng <dolinux.peng@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-22ASoC: soc-core: Allow searching dai driver name in snd_soc_find_daiJeffy Chen
Currently we are searching dai name in snd_soc_find_dai, which could either be dai driver name or component device name(for legacy naming). Allow searching dai driver name in snd_soc_find_dai too, so that we can use dai driver name to find legacy naming dais. Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-16ASoC: soc-core: snd_soc_unregister_component() unregister all componentKuninori Morimoto
Current snd_soc_unregister_component() unregisters first found component only which was specified by dev. This style can't specify concrete component if system registered some component with same dev. And system need to call this function many times. This patch unregister all related component by 1 call. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-10Merge branch 'topic/component' of ↵Mark Brown
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-core
2017-08-10ASoC: use snd_soc_rtdcom_add() and convert to consistent operationKuninori Morimoto
Basically, current ALSA SoC framework is based on CPU/Codec/Platform, but its operation doesn't have consistent. Thus, source code was unreadable, and difficult to understand. This patch connects each component (= CPU/Codec/Platform) to rtd by using snd_soc_rtdcom_add(), and convert uneven operations to consistent operation. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-10ASoC: soc-core: add snd_soc_rtdcom_xxx()Kuninori Morimoto
Current snd_soc_pcm_runtime has platform / codec pointers, and we could use these specific pointer. But these will be replaced to more generic "component" soon, and will need more generic method to get each connected component pointer from rtd. This patch adds new snd_soc_rtdcom_xxx() to connect/disconnect component to rtd. It means same as previous "platform" / "codec" pointer style, but more generic. We can find necessary component pointer from rtd by using component driver name on snd_soc_rtdcom_lookup(). Here, the reason why it uses "driver name" is that "component name" was created by fmt_single_name() and difficult to use it from driver. Driver of course knows its "driver name", thus, using it is more easy. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07ASoC: soc-core: remove duplicate mutex_unlock from ↵Kuninori Morimoto
snd_soc_unregister_component() Current snd_soc_unregister_component() is using multiple mutex_unlock() for found/non-found cases. But it is unreadable and confusable code. This patch tidyup current code to be readable. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07ASoC: soc-core: rename "cmpnt" to "component"Kuninori Morimoto
To unify notation, to readable. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07ASoC: soc-core: Use IS_ERR_OR_NULL()Fabio Estevam
The check of IS_ERR or NULL pointer can be replaced by IS_ERR_OR_NULL(), which helps readability. Signed-off-by: Fabio Estevam <festevam@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-07ASoC: soc-core: Remove unneeded dentry member from snd_soc_codecFabio Estevam
There is no need to have the *debugfs_reg dentry member as part of the snd_soc_codec structure as its only usage is inside soc_init_codec_debugfs(). Use a local dentry variable instead. Signed-off-by: Fabio Estevam <festevam@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-01Merge remote-tracking branches 'asoc/fix/dpcm', 'asoc/fix/imx', ↵Mark Brown
'asoc/fix/msm8916', 'asoc/fix/multi-pcm', 'asoc/fix/of-graph' and 'asoc/fix/pxa' into asoc-linus
2017-08-01device property: Fix usecount for of_graph_get_port_parent()Tony Lindgren
Fix inconsistent use of of_graph_get_port_parent() where asoc_simple_card_parse_graph_dai() does of_node_get() before calling it while other callers do not. We can fix this by not trashing the node passed to of_graph_get_port_parent(). Let's also make sure the callers have correct refcounts and remove related incorrect of_node_put() calls for of_for_each_phandle as that's done by of_phandle_iterator_next() except when we break out of the loop early. Let's fix both issues with a single patch to avoid kobject refcounts getting messed up more if two patches are merged separately. Otherwise strange issues can happen caused by memory corruption caused by too many kobject_del() calls such as: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747 ... (___might_sleep) (__mutex_lock) (mutex_lock_nested) (kernfs_remove) (kobject_del) (kobject_put) (of_get_next_parent) (of_graph_get_port_parent) (asoc_simple_card_parse_graph_dai [snd_soc_simple_card_utils]) (asoc_graph_card_probe [snd_soc_audio_graph_card]) Fixes: 0ef472a973eb ("of_graph: add of_graph_get_port_parent()") Fixes: 2692c1c63c29 ("ASoC: add audio-graph-card support") Fixes: 1689333f8311 ("ASoC: simple-card-utils: add asoc_simple_card_parse_graph_dai()") Signed-off-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Rob Herring <robh@kernel.org> Tested-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17ASoC: fix pcm-creation regressionJohan Hovold
This reverts commit 99b04f4c4051 ("ASoC: add Component level pcm_new/pcm_free"), which started calling the pcm_new callback for every component in a *card* when creating a new pcm, something which does not seem to make any sense. This specifically led to memory leaks in systems with more than one platform component and where DMA memory is allocated in the platform-driver callback. For example, when both mcasp devices are being used on an am335x board, DMA memory would be allocated twice for every DAI link during probe. When CONFIG_SND_VERBOSE_PROCFS was set this fortunately also led to warnings such as: WARNING: CPU: 0 PID: 565 at ../fs/proc/generic.c:346 proc_register+0x110/0x154 proc_dir_entry 'sub0/prealloc' already registered Since there seems to be no users of the new component callbacks, and the current implementation introduced a regression, let's revert the offending commit for now. Fixes: 99b04f4c4051 ("ASoC: add Component level pcm_new/pcm_free") Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable <stable@vger.kernel.org> # 4.10
2017-07-03Merge remote-tracking branch 'asoc/topic/rcar' into asoc-nextMark Brown
2017-07-03Merge remote-tracking branch 'asoc/topic/intel' into asoc-nextMark Brown
2017-06-30ASoC: fix semicolon.cocci warningsWu Fengguang
sound/soc/soc-core.c:1961:2-3: Unneeded semicolon Remove unneeded semicolon. Generated by: scripts/coccinelle/misc/semicolon.cocci Fixes: 98faf436ee05 ("ASoC: Drop invalid DMI fields when setting card long name from DMI info") CC: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28ASoC: Drop invalid DMI fields when setting card long name from DMI infoMengdong Lin
Sometimes DMI fields may be invalid and so can't give useful vendor, product or board info, such as "Type2 - Board Manufacturer" or "Type1 - TBD by OEM". Including such invalid DMI fileds may create silly card long name. So this patch creates a black list of invalid strings. And if a DMI field contains any string in this list, it will be excluded from the card long name. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-24Merge branch 'topic/dai-id' of ↵Mark Brown
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-of-graph
2017-05-24ASoC: add snd_soc_get_dai_id() functionKuninori Morimoto
ALSA SoC needs to know connected DAI ID for detecting. It is not a big problem if device/driver was only for sound, but getting DAI ID will be difficult if device includes both Video/Sound, like HDMI. To solve this issue, this patch adds new snd_soc_get_dai_id() and its related .of_xlate_dai_id callback on component driver. In below case, we can handle Sound port (= port@2) as ID = 0 if .of_xlate_dai_id has its support. hdmi { port@0 { /* VIDEO */ }; port@1 { /* VIDEO */ }; port@2 { /* SOUND */ }; }; Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-24ASoC: Fix use-after-free at card unregistrationTakashi Iwai
soc_cleanup_card_resources() call snd_card_free() at the last of its procedure. This turned out to lead to a use-after-free. PCM runtimes have been already removed via soc_remove_pcm_runtimes(), while it's dereferenced later in soc_pcm_free() called via snd_card_free(). The fix is simple: just move the snd_card_free() call to the beginning of the whole procedure. This also gives another benefit: it guarantees that all operations have been shut down before actually releasing the resources, which was racy until now. Reported-and-tested-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: <stable@vger.kernel.org>
2017-05-17ASoC: soc-core: enable "dai-format" on snd_soc_of_parse_daifmt()Kuninori Morimoto
Current snd_soc_of_parse_daifmt() detects [prefix]format, but "format" was unclear in some case. This patch checks "dai-format" first, and try to check "[prefix]format" if "dai-format" was not exist. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-08scripts/spelling.txt: add regsiter -> register spelling mistakeStephen Boyd
This typo is quite common. Fix it and add it to the spelling file so that checkpatch catches it earlier. Link: http://lkml.kernel.org/r/20170317011131.6881-2-sboyd@codeaurora.org Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-04-30Merge remote-tracking branches 'asoc/topic/uda1380', ↵Mark Brown
'asoc/topic/unregister', 'asoc/topic/ux500', 'asoc/topic/wm5100' and 'asoc/topic/wm8903' into asoc-next
2017-04-30Merge remote-tracking branch 'asoc/topic/intel' into asoc-nextMark Brown
2017-04-30Merge remote-tracking branch 'asoc/topic/core' into asoc-nextMark Brown
2017-04-24ASoC: Call snd_soc_set_dmi_name() unconditionallyTakashi Iwai
Since recently UCM can pick up a configuration specific to the board via card longname field, and we introduced a helper function snd_soc_set_dmi_name() for that. So far, it was used only in one place (sound/soc/intel/boards/broadwell.c), but it should be more widely applied. This patch puts a big hammer for that: it lets snd_soc_register_card() calling snd_soc_set_dmi_name() unconditionally, so that all x86 devices get the better longname string. This would have no impact for other systems without DMI support, as snd_soc_set_dmi_name() is no-op on them. Signed-off-by: Takashi Iwai <tiwai@suse.de> Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>