summaryrefslogtreecommitdiff
path: root/include/sound/soc-component.h
AgeCommit message (Collapse)AuthorFilesLines
2023-09-01ASoC: Name iov_iter argument as iterator instead of bufferTakashi Iwai1-2/+2
While transitioning ASoC code for iov_iter usages, I kept the argument name as "buf" as the original code. But, iov_iter is an iterator, and using the name "buf" may be misleading: the crucial difference is that iov_iter can be proceeded after the operation, hence it can't be passed twice, while a simple "buffer" sounds as if reusable. To make the usage clearer, rename the argument from "buf" to "iter". There is no functional changes, just names. Fixes: 66201cacc33d ("ASoC: component: Add generic PCM copy ops") Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/CAHk-=wje+VkXjjfVTmK-uJdG_M5=ar14QxAwK+XDiq07k_pzBg@mail.gmail.com Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230831130457.8180-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-08-18ASoC: pcm: Drop obsoleted PCM copy_user opsTakashi Iwai1-7/+0
Now all ASoC users have been replaced to use the new PCM copy ops, let's drop the obsoleted copy_user ops and its helper function. Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230815190136.8987-25-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-08-18ASoC: component: Add generic PCM copy opsTakashi Iwai1-0/+7
For following the ALSA PCM core change, a new PCM copy ops is added toe ASoC component framework: snd_soc_component_driver receives the copy ops, and snd_soc_pcm_component_copy() helper is provided. This also fixes a long-standing potential bug where the ASoC driver covers only copy_user PCM callback and misses the copy from kernel pointers (such as OSS PCM layer), too. As of this patch, the old copy_user is still kept, but it'll be dropped later after all drivers are converted. Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230815190136.8987-19-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-06-13ASoC: remove old trigger ordering methodKuninori Morimoto1-2/+0
All drivers switch to use generic trigger ordering method. Let's remove old method. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87legufnyy.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-13ASoC: add new trigger ordering methodKuninori Morimoto1-0/+9
Current ASoC is assuming that trigger starting order is Link -> Component -> DAI as default, and its reverse order for stopping. But some Driver / Card want to reorder it for some reasons. We have such flags, but is unbalance like below. struct snd_soc_component_driver :: start_dma_last struct snd_soc_dai_link :: stop_dma_first We want to have more flexible, and more generic method. This patch adds new snd_soc_trigger_order for start/stop at component / DAI-link. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87r0qmfnzx.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-05-15ASoC: soc-component: Add notify control helper functionCharles Keepax1-0/+4
Add a function to allow ASoC drivers to easily notify an ALSA control change. This function will automatically add any component naming prefix into the control name. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com Link: https://lore.kernel.org/r/20230512122838.243002-3-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-02-28ASoC: soc-pcm: add option to start DMA after DAIClaudiu Beznea1-0/+2
Add option to start DMA component after DAI trigger. This is done by filling the new struct snd_soc_component_driver::start_dma_last. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Link: https://lore.kernel.org/r/20230228110145.3770525-2-claudiu.beznea@microchip.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-01-27ASoC: soc-component: add get_jack_typeAstrid Rost1-0/+2
Add function to return the jack type of snd_jack_types. This allows a generic card driver to add a jack with the specified type. Signed-off-by: Astrid Rost <astrid.rost@axis.com> Link: https://lore.kernel.org/r/20230123135913.2720991-2-astrid.rost@axis.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-27ASoC: soc-component: Remove non_legacy_dai_naming flagCharles Keepax1-1/+0
Now all the users are moved over to the new legacy_dai_naming flag, remove the now unused old flag. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220623125250.2355471-97-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-27ASoC: soc-component: Add legacy_dai_naming flagCharles Keepax1-0/+1
Historically, the legacy DAI naming scheme was applied to platform drivers and the newer scheme to CODEC drivers. During componentisation the core lost the knowledge of if a driver was a CODEC or platform, they were all now components. To continue to support the legacy naming on older platform drivers a flag was added to the snd_soc_component_driver structure, non_legacy_dai_naming, to indicate to use the new scheme and this was applied to all CODECs as part of the migration. However, a slight issue appears to be developing with respect to this flag being opt in for the non-legacy scheme, which presumably we want to be the primary scheme used. Many codec drivers appear to forget to include this flag: grep -l -r "snd_soc_component_driver" sound/soc/codecs/*.c | xargs grep -L "non_legacy_dai_naming" | wc 48 48 556 It would seem more sensible to change the flag to legacy_dai_naming making the new scheme opt out. As a first step this patch adds a new flag for this so that the users can be updated. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220623125250.2355471-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-06ASoC: simple-card-utils: Move snd_soc_component_is_codec to be localCharles Keepax1-5/+0
The helper function snd_soc_component_is_codec is based off the presence of the non_legacy_dai_naming flag. This isn't super robust as CPU side components may also specify this flag, and indeed the kernel already contains a couple that do. After componentisation there isn't really a totally robust solution to identifying what is a CODEC driver, without introducing a flag specifically for that purpose, and really the desirable direction to move in is that the distinction doesn't matter. This patch does two things to try to mitigate these problems. Firstly, now that all the other users of the helper function have been removed, it makes the helper function local to the driver rather, than being part of the core. This should help to discourage any new code from being created that depends on the CODEC driver distinction. Secondly, it updates the helper function itself to use the endianness flag rather than the non_legacy_dai_naming flag. The endianness flag is definitely invalid on a CPU side component, so it a more reliable indicator that the device is definitely a CODEC. The vast majority of buses require the CODEC to set the endianness flag, so the number of corner cases should be fairly minimal. It is worth noting that CODECs sending audio over SPI, or built into the CPU CODECs are potential corner cases, however the hope is that in most cases those types of devices do not consitute a simple audio card. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220519154318.2153729-57-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-05-09ASoC: soc-component: Add comment for the endianness flagCharles Keepax1-0/+9
Add a comment to make the purpose of the endianness flag on the snd_soc_component structure more clear. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220504170905.332415-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-05ASoC: soc-core: add debugfs_prefix member to snd_soc_component_driverHeiner Kallweit1-0/+4
Allow the component debugfs_prefix to be set from snd_soc_component_driver. First use case is avoiding a duplicate debugfs entry error in case a device has multiple components which have the same name therefore. Note that we don't set component->debugfs_prefix if it's set already. That's needed because partially component->debugfs_prefix is set before calling snd_soc_component_initialize(). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/d18bff6a-1df1-5f95-0cf8-10dbaa62d7be@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-11-29ASoC: soc-component: add snd_soc_pcm_component_delay()Kuninori Morimoto1-0/+4
Current soc-pcm.c :: soc_pcm_pointer() is assuming that component driver might update runtime->delay silently in snd_soc_pcm_component_pointer() (= A). static snd_pcm_uframes_t soc_pcm_pointer(...) { ... /* clearing the previous total delay */ => runtime->delay = 0; (A) offset = snd_soc_pcm_component_pointer(substream); /* base delay if assigned in pointer callback */ => delay = runtime->delay; ... } 1) The behavior that ".pointer callback secretly updates runtime->delay" is strange and confusable. 2) Current snd_soc_pcm_component_pointer() uses 1st found component's .pointer callback only, thus it is no problem for now. But runtime->delay might be overwrote if it adjusted to multiple components in the future. 3) Component delay is updated at .pointer callback timing (secretly). But some components which doesn't have .pointer callback might want to increase runtime->delay for some reasons. We already have .delay function for DAI, but not have for Component. This patch adds new snd_soc_pcm_component_delay() for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/874k8cy25t.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-18ASoC: soc-component: add snd_soc_component_is_codec()Kuninori Morimoto1-0/+5
Checking .non_legacy_dai_naming is not readable. Let's add new snd_soc_component_is_codec(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87h7dft7dn.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-01ASoC: soc-component: Remove conditional definition of debugfs data membersSimon Trimmer1-2/+0
This simplification allows the use of the standard kernel pattern of static inline dummy functions for debugfs code. Most systems will only have a small number of snd_soc_components so the memory impact is minimal. Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com> Suggested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20210930142116.528878-1-simont@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-09-20ASoC: compress/component: Use module_get_when_open/put_when_close for cstreamPeter Ujfalusi1-2/+4
Currently the try_module_get() and module_put() is not possible for compressed streams if the module_get_upon_open is set to 1 which means that\ the components are not protected in a same way as components when normal audio is used. SOF is setting module_get_upon_open to 1 for component drivers which works correctly for audio stream but when compressed stream is used then the module is not protected. Convert the compress open and free operation to mimic the steps of it's pcm counterpart to fix this issue. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210901095255.3617-3-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-09-20ASoC: soc-component: Convert the mark_module to void*Peter Ujfalusi1-5/+3
The mark_module of the snd_soc_component is strict snd_pcm_substream type which prevents it to be used by compressed streams. Change the type to void* along with the snd_soc_component_module_get() and snd_soc_component_module_put() to allow the same mark to be used by compressed when it's module_get_upon_open is set to 1. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20210901095255.3617-2-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-16ASoC: soc-utils: add snd_soc_component_is_dummy()Kuninori Morimoto1-0/+1
There is snd_soc_dai_is_dummy(), but not for component. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87zgxzxa2t.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-25ASoC: soc-component: Add snd_soc_pcm_component_ackShengjiu Wang1-0/+3
Add snd_soc_pcm_component_ack back, which can be used to get an updated buffer pointer in the platform driver. On Asymmetric multiprocessor, this pointer can be sent to Cortex-M core for audio processing. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Link: https://lore.kernel.org/r/1615516725-4975-2-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-10ASoC: constify of_phandle_args in snd_soc_get_dai_name()Krzysztof Kozlowski1-2/+2
The pointer to of_phandle_args passed to snd_soc_get_dai_name() and of_xlate_dai_name() implementations is not modified. Since it is being used only to translate passed OF node to a DAI name, it should not be modified, so mark it as const for correctness and safer code. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Link: https://lore.kernel.org/r/20210221153024.453583-1-krzk@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2021-01-27ASoC: soc-component: add snd_soc_component_read/write_field()Srinivas Kandagatla1-0/+6
It's often the case that we would write or read a particular field in register. With the current soc_component apis, reading a particular field in register would involve first read the register and then perform shift operations. Ex: to read from a field mask of 0xf0 val = snd_soc_component_read(component, reg); field = ((val & 0xf0) >> 0x4); This is sometimes prone to errors and code become less readable! With this new api we could just do field = snd_soc_component_read_field(component, reg, 0xf0); this makes it bit simple, easy to write and less error prone! This also applies to writing! There are various places in kernel which provides such field interfaces however soc_component seems to be missing this. This patch is inspired by FIELD_GET/FIELD_PREP macros in include/linux/bitfield.h Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20210126171749.1863-1-srinivas.kandagatla@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-09ASoC: soc-pcm: care trigger rollbackKuninori Morimoto1-1/+2
soc_pcm_trigger() calls DAI/Component/Link trigger, but some of them might be failed. static int soc_pcm_trigger(...) { ... switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: ret = snd_soc_link_trigger(substream, cmd); if (ret < 0) break; (*) ret = snd_soc_pcm_component_trigger(substream, cmd); if (ret < 0) break; ret = snd_soc_pcm_dai_trigger(substream, cmd); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: ret = snd_soc_pcm_dai_trigger(substream, cmd); if (ret < 0) break; ret = snd_soc_pcm_component_trigger(substream, cmd); if (ret < 0) break; ret = snd_soc_link_trigger(substream, cmd); break; } ... } For example, if soc_pcm_trigger() failed at (*) point, we need to rollback previous succeeded trigger. This patch adds trigger mark for DAI/Component/Link, and do STOP if START/RESUME/PAUSE_RELEASE were failed. Because it need to use new rollback parameter, we need to modify DAI/Component/Link trigger functions in the same time. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87a6uycssd.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-26ASoC: soc-component: add mark for snd_soc_component_compr_open/free()Kuninori Morimoto1-3/+3
soc_compr_open() does rollback when failed (A), but, it is almost same as soc_compr_free(). static int soc_compr_open(xxx) { ... if (ret < 0) goto xxx_err; ... return 0; ^ machine_err: | ... | out: (A) ... | pm_err: | ... v return ret; } The difference is soc_compr_free() is for all dai/component/substream, rollback is for succeeded part only. This kind of duplicated code can be a hotbed of bugs, thus, we want to share soc_compr_free() and rollback. 1) snd_soc_dai_compr_startup/shutdown() => 2) snd_soc_component_compr_open/free() 3) snd_soc_link_compr_startup/shutdown() This patch is for 2) snd_soc_component_compr_open/free(), and adds new cstream mark. It will mark cstream when startup() was suceeded. If rollback happen *after* that, it will check rollback flag and marked cstream. It cares *previous* startup() only now, but we might want to check *whole* marked cstream in the future. This patch is using macro so that it can be easily adjust to it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87lfey5iwk.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_get_metadata()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_get_metadata(). 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/87zh3l6gl8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_set_metadata()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_set_metadata(). 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/871rgx7v5t.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_copy()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_copy(). 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/87361d7v5z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_pointer()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_pointer(). 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/874klt7v65.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_ack()Kuninori Morimoto1-0/+1
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_ack(). 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/875z697v6c.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_get_codec_caps()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_get_codec_caps(). 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/877dqp7v6i.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_get_caps()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_get_caps(). 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/878sb57v6q.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_get_params()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch adds snd_soc_component_compr_get_params(). 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/87a6vl7v6x.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_set_params()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch moves soc-compress soc_compr_components_set_params() to soc-component as snd_soc_component_compr_set_params(). 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/87blg17v74.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_trigger()Kuninori Morimoto1-0/+1
component related function should be implemented at soc-component.c. This patch moves soc-compress soc_compr_components_trigger() to soc-component as snd_soc_component_compr_trigger(). 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/87d00h7v7k.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_free()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch moves soc-compress soc_compr_components_free() to soc-component as snd_soc_component_compr_free(). 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/87eekx7v7r.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-18ASoC: soc-component: add snd_soc_component_compr_open()Kuninori Morimoto1-0/+2
component related function should be implemented at soc-component.c. This patch moves soc-compress soc_compr_components_open() to soc-component as snd_soc_component_compr_open(). 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/87ft5d7v7x.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-26ASoC: soc-component: add mark for snd_soc_pcm_component_hw_params/free()Kuninori Morimoto1-3/+3
soc_pcm_hw_params() does rollback when failed (A), but, it is almost same as soc_pcm_hw_free(). static int soc_pcm_hw_params(xxx) { ... if (ret < 0) goto xxx_err; ... return ret; ^ component_err: | ... | interface_err: (A) ... | codec_err: | ... v return ret; } The difference is soc_pcm_hw_free() is for all dai/component/substream, rollback is for succeeded part only. This kind of duplicated code can be a hotbed of bugs, thus, we want to share soc_pcm_hw_free() and rollback. Now, soc_pcm_hw_params/free() are handling 1) snd_soc_link_hw_params/free() => 2) snd_soc_pcm_component_hw_params/free() 3) snd_soc_dai_hw_params/free() This patch is for 2) snd_soc_pcm_component_hw_params/free(). The idea of having bit-flag or counter is not enough for this purpose. For example if one DAI is used for 2xPlaybacks for some reasons, and if 1st Playback was succeeded but 2nd Playback was failed, 2nd Playback rollback doesn't need to call shutdown. But it has succeeded bit-flag or counter via 1st Playback, thus, 2nd Playback rollback will call unneeded shutdown. And 1st Playback's necessary shutdown will not be called, because bit-flag or counter was cleared by wrong 2nd Playback rollback. To avoid such case, this patch marks substream pointer when hw_params() was succeeded. If rollback needed, it will check rollback flag and marked substream pointer. One note here is that it cares *previous* hw_params() only now, but we might want to check *whole* marked substream in the future. This patch is using macro named "push/pop", so that it can be easily update. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87k0wdgqav.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28ASoC: soc-component: add mark for snd_soc_pcm_component_pm_runtime_get/put()Kuninori Morimoto1-0/+5
soc_pcm_open() does rollback when failed (A), but, it is almost same as soc_pcm_close(). static int soc_pcm_open(xxx) { ... if (ret < 0) goto xxx_err; ... return 0; ^ config_err: | ... | rtd_startup_err: (A) ... | component_err: | ... v return ret; } The difference is soc_pcm_close() is for all dai/component/substream, rollback is for succeeded part only. This kind of duplicated code can be a hotbed of bugs, thus, we want to share soc_pcm_close() and rollback. Now, soc_pcm_open/close() are handling 1) snd_soc_dai_startup/shutdown() 2) snd_soc_link_startup/shutdown() 3) snd_soc_component_module_get/put() 4) snd_soc_component_open/close() => 5) pm_runtime_put/get() This patch is for 5) pm_runtime_put/get(). The idea of having bit-flag or counter is not enough for this purpose. For example if one DAI is used for 2xPlaybacks for some reasons, and if 1st Playback was succeeded but 2nd Playback was failed, 2nd Playback rollback doesn't need to call shutdown. But it has succeeded bit-flag or counter via 1st Playback, thus, 2nd Playback rollback will call unneeded shutdown. And 1st Playback's necessary shutdown will not be called, because bit-flag or counter was cleared by wrong 2nd Playback rollback. To avoid such case, this patch marks substream pointer when get() was succeeded. If rollback needed, it will check rollback flag and marked substream pointer. One note here is that it cares *current* get() only now. but we might want to check *whole* marked substream in the future. This patch is using macro named "push/pop", so that it can be easily update. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87h7ribwnb.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-28ASoC: soc-component: add mark for soc_pcm_components_open/close()Kuninori Morimoto1-8/+15
soc_pcm_open() does rollback when failed (A), but, it is almost same as soc_pcm_close(). static int soc_pcm_open(xxx) { ... if (ret < 0) goto xxx_err; ... return 0; ^ config_err: | ... | rtd_startup_err: (A) ... | component_err: | ... v return ret; } The difference is soc_pcm_close() is for all dai/component/substream, rollback is for succeeded part only. This kind of duplicated code can be a hotbed of bugs, thus, we want to share soc_pcm_close() and rollback. Now, soc_pcm_open/close() are handling 1) snd_soc_dai_startup/shutdown() 2) snd_soc_link_startup/shutdown() => 3) snd_soc_component_module_get/put() => 4) snd_soc_component_open/close() 5) pm_runtime_put/get() This patch is for 3) snd_soc_component_module_get/put() 4) snd_soc_component_open/close(). The idea of having bit-flag or counter is not enough for this purpose. For example if one DAI is used for 2xPlaybacks for some reasons, and if 1st Playback was succeeded but 2nd Playback was failed, 2nd Playback rollback doesn't need to call shutdown. But it has succeeded bit-flag or counter via 1st Playback, thus, 2nd Playback rollback will call unneeded shutdown. And 1st Playback's necessary shutdown will not be called, because bit-flag or counter was cleared by wrong 2nd Playback rollback. To avoid such case, this patch marks substream pointer when open() was succeeded. If rollback needed, it will check rollback flag and marked substream pointer. One note here is that it cares *current* open() only now. but we might want to check *whole* marked substream in the future. This patch is using macro named "push/pop", so that it can be easily update. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87imbybwno.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-31ASoC: core: Relocate and expose snd_soc_component_initializeCezary Rojewski1-3/+0
To allow for two-step component registration, expose snd_soc_component_initialize function and move it back to soc-core.c. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20200731144146.6678-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-22ASoC: remove snd_soc_component_read32()Kuninori Morimoto1-1/+0
No driver is using snd_soc_component_read32() anymore. This patch removes it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/877dw74mbv.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-22ASoC: soc-component: merge snd_soc_component_read() and ↵Kuninori Morimoto1-3/+2
snd_soc_component_read32() We had read/write function for Codec, Platform, etc, but these has been merged into snd_soc_component_read/write(). Internally, it is using regmap or driver function. In read case, each styles are like below regmap ret = regmap_read(..., reg, &val); driver function val = xxx->read(..., reg); Because of this kind of different style, to keep same read style, when we merged each read function into snd_soc_component_read(), we created snd_soc_component_read32(), like below. commit 738b49efe6c6 ("ASoC: add snd_soc_component_read32") (1) val = snd_soc_component_read32(component, reg); (2) ret = snd_soc_component_read(component, reg, &val); Many drivers are using snd_soc_component_read32(), and some drivers are using snd_soc_component_read() today. In generally, we don't check read function successes, because, we will have many other issues at initial timing if read function didn't work. Now we can use soc_component_err() when error case. This means, it is easy to notice if error occurred. This patch aggressively merge snd_soc_component_read() and _read32(), and makes snd_soc_component_read/write() as generally style. This patch do 1) merge snd_soc_component_read() and snd_soc_component_read32() 2) it uses soc_component_err() when error case (easy to notice) 3) keeps read32 for now by #define 4) update snd_soc_component_read() for all drivers Because _read() user drivers are not too many, this patch changes all user drivers. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/87sgev4mfl.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: tidyup CopyrightKuninori Morimoto1-1/+2
This patch add missing company copyright 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/87eeqvw8w8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: add snd_soc_component_init()Kuninori Morimoto1-0/+3
we wantn't to directly access to component related parameter as much as possible to keep encapsulation. This patch adds snd_soc_component_init() for it. 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/87img7w8x2.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: add snd_soc_pcm_component_trigger()Kuninori Morimoto1-3/+2
We have 2 type of component functions snd_soc_component_xxx() is focusing to component itself, snd_soc_pcm_component_xxx() is focusing to rtd related component. Now we can update snd_soc_component_trigger() to snd_soc_pcm_component_trigger(). This patch do it. 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/87k10nw8xf.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: add snd_soc_pcm_component_hw_free()Kuninori Morimoto1-2/+2
We have 2 type of component functions snd_soc_component_xxx() is focusing to component itself, snd_soc_pcm_component_xxx() is focusing to rtd related component. Now we can update snd_soc_component_hw_free() to snd_soc_pcm_component_hw_free(). This patch do it. 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/87lfl3w8xv.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: add snd_soc_pcm_component_hw_params()Kuninori Morimoto1-3/+3
We have 2 type of component functions snd_soc_component_xxx() is focusing to component itself, snd_soc_pcm_component_xxx() is focusing to rtd related component. Now we can update snd_soc_component_hw_params() to snd_soc_pcm_component_hw_params(). This patch do it. 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/87mu5jw8y8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: add snd_soc_pcm_component_prepare()Kuninori Morimoto1-2/+1
We have 2 type of component functions snd_soc_component_xxx() is focusing to component itself, snd_soc_pcm_component_xxx() is focusing to rtd related component. Now we can update snd_soc_component_prepare() to snd_soc_pcm_component_prepare(). This patch do it. 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/87o8pzw8yl.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: move snd_soc_component_initialize() to soc-component.cKuninori Morimoto1-0/+4
snd_soc_component_xxx() should be implemented at soc-component.c 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/87r1uvw8zb.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-componentKuninori Morimoto1-0/+1
soc-component is handling snd_soc_component_xxx(). Move snd_soc_component_xxx_regmap() to it. 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/87sgfbw8zl.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>