summaryrefslogtreecommitdiff
path: root/sound/soc/mediatek
AgeCommit message (Collapse)AuthorFilesLines
2023-09-11ASoC: mediatek: mt8188-mt6359: support dynamic pinctrlTrevor Wu1-0/+21
To avoid power leakage, it is recommended to replace the default pinctrl state with dynamic pinctrl since certain audio pinmux functions can remain in a HIGH state even when audio is disabled. Linking pinctrl with DAPM using SND_SOC_DAPM_PINCTRL will ensure that audio pins remain in GPIO mode by default and only switch to an audio function when necessary. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230825024935.10878-2-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-28Merge tag 'asoc-v6.6' of ↵Takashi Iwai17-56/+1679
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus ASoC: Updates for v6.6 The rest of the updates for v6.6, some of the highlights include: - A big API cleanup from Morimoto-san, rationalising the places we put functions. - Lots of work on the SOF framework, AMD and Intel drivers, including a lot of cleanup and new device support. - Standardisation of the presentation of jacks from drivers. - Provision of some generic sound card DT properties. - Conversion oof more drivers to the maple tree register cache. - New drivers for AMD Van Gogh, AWInic AW88261, Cirrus Logic cs42l43, various Intel platforms, Mediatek MT7986, RealTek RT1017 and StarFive JH7110.
2023-08-18ASoC: mediatek: Convert to generic PCM copy opsTakashi Iwai1-17/+10
This patch converts the mediatek BT SCO driver code to use the new unified PCM copy callback. It's a straightforward conversion from *_user() to *_iter() variants. As copy_form/to_iter() updates the internal offset at each read/write, we can drop the cur_*_idx counter in the loop, too. Note that copy_from/to_iter() returns the copied bytes, hence the error condition is adjusted accordingly. Reviewed-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20230815190136.8987-20-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-08-17ASoC: mediatek: mt7986: add machine driver with wm8960Maso Huang3-0/+207
Add support for mt7986 board with wm8960. Signed-off-by: Maso Huang <maso.huang@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230817101338.18782-5-maso.huang@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-17ASoC: mediatek: mt7986: add platform driverMaso Huang4-0/+641
Add mt7986 platform driver. Signed-off-by: Maso Huang <maso.huang@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230817101338.18782-4-maso.huang@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-17ASoC: mediatek: mt7986: support etdm in platform driverMaso Huang1-0/+411
Add mt7986 etdm dai driver support. Signed-off-by: Maso Huang <maso.huang@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230817101338.18782-3-maso.huang@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-17ASoC: mediatek: mt7986: add common headerMaso Huang2-0/+245
Add header files for register definition and structure. Signed-off-by: Maso Huang <maso.huang@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230817101338.18782-2-maso.huang@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-14ASoC: mediatek: merge DAI call back functions into opsKuninori Morimoto1-25/+31
ALSA SoC merges DAI call backs into .ops. This patch merge these into one. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Acked-by: Trevor Wu <trevor.wu@mediatek.com> Link: https://lore.kernel.org/r/87sf8t9m6n.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8186-mt6366-da7219-max98357: Map missing jack kcontrolsAlper Nebi Yasak1-0/+6
Commit 8e9867486806 ("ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins") maps kcontrols for Headphone and Headset Mic jacks for this driver so that PulseAudio and PipeWire can handle jack detection events for these peripherals. The DA7219 codec used here can also distinguish between Headphone and Line Out connections that go into the same physical port. Expose the latter to userspace as a kcontrol as well and add the necessary widgets. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-19-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8183-mt6358-ts3a227-max98357: Map missing jack kcontrolsAlper Nebi Yasak1-6/+47
This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The TS3A227 component used here can detect Headphones and Headset Mic connections. Expose each to userspace as kcontrols and add the necessary widgets. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-18-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8183-da7219-max98357: Map missing jack kcontrolsAlper Nebi Yasak1-7/+36
This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The DA7219 codec used here can detect Headphones, Headset Mic and Line Out connections. Expose each to userspace as kcontrols and add the necessary widgets. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-17-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8173-rt5650: Map missing jack kcontrolsAlper Nebi Yasak1-5/+18
This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The RT5645 codec used here can detect Headphone and Headset Mic connections. Expose both to userspace as kcontrols. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-16-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8173-rt5650-rt5676: Map missing jack kcontrolsAlper Nebi Yasak1-5/+18
This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The RT5645 codec used here can detect Headphone and Headset Mic connections. Expose both to userspace as kcontrols. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-15-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8173-rt5650-rt5514: Map missing jack kcontrolsAlper Nebi Yasak1-5/+18
This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The RT5645 codec used here can detect Headphone and Headset Mic connections. Expose each to userspace as kcontrols. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-14-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-07ASoC: mediatek: mt8173-max98090: Configure jack as a Headset jackAlper Nebi Yasak1-1/+1
This driver has correctly mapped jack kcontrols for Headphone and Headset Mic. However, it is configuring the jack to only care about Headphone events. The MAX98090 codec used here can detect both connections, so configure the jack as such. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Link: https://lore.kernel.org/r/20230802175737.263412-13-alpernebiyasak@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-08-03ASoC: mediatek: mt8186: Remove unused mutex.Sebastian Andrzej Siewior1-2/+0
The mutex mutex_request_dram has no user. Remove mutex_request_dram. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230803083908.9DxbPvOK@linutronix.de Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-25Merge tag 'asoc-v6.6-early' of ↵Takashi Iwai3-5/+22
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next ASoC: Updates for v6.6 Here's an initial batch of updates for ASoC for this release cycle. We've got a bunch of new drivers in here, a bit of core work from Morimoto-san and quite a lot of janitorial work. There's several updates that pull in changes from other subsystems in order to build on them: - An adaptor to allow use of IIO DACs and ADCs in ASoC which pulls in some IIO changes. - Create a library function for intlog10() and use it in the NAU8825 driver. - Include the ASoC tests, including the topology tests, in the default KUnit full test coverage. This also involves enabling UML builds of ALSA since that's the default KUnit test environment which pulls in the addition of some stubs to the driver. - More factoring out from Morimoto-san. - Convert a lot of drivers to use the more modern maple tree register cache. - Support for AMD machines with MAX98388 and NAU8821, Cirrus Logic CS35L36, Intel AVS machines with ES8336 and RT5663 and NXP i.MX93.
2023-07-21ASoC: mediatek: mt8188: Simplify with snd_ctl_find_id_mixer()Takashi Iwai1-11/+1
Replace an open code with the new snd_ctl_find_id_mixer(). There is no functional change. Acked-by: Mark Brown <broonie@kernel.org> Cc: Trevor Wu <trevor.wu@mediatek.com> Link: https://lore.kernel.org/r/20230720082108.31346-11-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-07-19ASoC: mediatek: mt8188: DPCM used FE and BE merged parametersTrevor Wu1-0/+15
To ensure that DPCM takes into account the backend hardware limitations when user space queries the hw_params of a device, we need to add dpcm_merged_format, dpcm_merged_chan, and dpcm_merged_rate to the FE dai_links. This patch includes only stereo FE dai_links, since multi-channel FEs may be reserved for specific purposes. Therefore, it may not be appropriate to consider BE conditions. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Link: https://lore.kernel.org/r/20230706064123.29790-1-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-17ASoC: mediatek: mt8186: Convert to devm_platform_ioremap_resource()Yangtao Li1-3/+1
Use devm_platform_ioremap_resource() to simplify code. Signed-off-by: Yangtao Li <frank.li@vivo.com> Link: https://lore.kernel.org/r/20230711034846.69437-3-frank.li@vivo.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-10ASoC: mediatek: mt8188: add memory-region supportTrevor Wu1-2/+6
In certain projects, it is necessary to utilize the reserved memory region for audio dma. The patch takes into account the dts property 'memory-region', allowing for the specification of memory for afe memif through device tree. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Link: https://lore.kernel.org/r/20230629074348.21670-2-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-20ASoC: soc-core.c: add index on snd_soc_of_get_dai_name()Kuninori Morimoto1-1/+1
Current snd_soc_of_get_dai_name() doesn't accept index for #sound-dai-cells. It is not useful for user. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87pm5qdgng.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-16ASoC: Merge fixes due to dependenciesMark Brown10-70/+48
So we can apply the tlv320aic3xxx DT conversion.
2023-06-12ASoC: mediatek: mt8173: Fix irq error pathRicardo Ribalda Delgado1-4/+5
After reordering the irq probe, the error path was not properly done. Lets fix it. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Cc: stable@kernel.org Fixes: 4cbb264d4e91 ("ASoC: mediatek: mt8173: Enable IRQ when pdata is ready") Signed-off-by: Ricardo Ribalda Delgado <ribalda@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230612-mt8173-fixup-v2-2-432aa99ce24d@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-12ASoC: mediatek: mt8173: Fix snd_soc_component_initialize error pathRicardo Ribalda Delgado1-2/+2
If the second component fails to initialize, cleanup the first on. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Cc: stable@kernel.org Fixes: f1b5bf07365d ("ASoC: mt2701/mt8173: replace platform to component") Signed-off-by: Ricardo Ribalda Delgado <ribalda@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230612-mt8173-fixup-v2-1-432aa99ce24d@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-09ASoC: mediatek: mt8192-mt6359: Go back to old headphone pin nameNícolas F. R. A. Prado1-1/+1
This reverts commit cbbc0ec6dea09c ("ASoC: mediatek: mt8192-mt6359: Remove " Jack" from Headphone pin name"). That commit removed the " Jack" suffix with the reasoning that it is automatically added to the name of the kcontrol created, which is true, but this name is also used to look for the DAPM widget that will be toggled when the jack status is updated. Since the widget is still called "Headphone Jack" the jack can't link to the widget and the following error is shown: mt8192_mt6359 sound: ASoC: DAPM unknown pin Headphone It is not possible to also rename the headphone DAPM widget because its name is used by a switch kcontrol, "Headphone Jack Switch", both to link to the headphone widget and to assemble its name. This switch's name is referenced in the upstream UCM file, so renaming it would break userspace. Since the original commit didn't bring any benefit, besides sparing a few CPU cycles, simply revert it. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20230608221050.217968-1-nfraprado@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-08ASoC: mediatek: mt8188-mt6359: Use bitfield macros for registersAngeloGioacchino Del Regno1-13/+19
Replace open coded instances of FIELD_GET() with it, move register definitions at the top of the file and also replace magic numbers with register definitions. While at it, also change a regmap_update_bits() call to regmap_write() because the top 29 bits of AUD_TOP_CFG (31:3) are reserved (unused). Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230608084727.74403-6-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-08ASoC: mediatek: mt8188-mt6359: Clean up log levelsAngeloGioacchino Del Regno1-11/+10
Change some dev_info prints to dev_err() and some to dev_dbg(), depending on the actual severity of them. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230608084727.74403-5-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-08ASoC: mediatek: mt8188-mt6359: Cleanup return 0 disguised as return retAngeloGioacchino Del Regno1-8/+12
Change all instances of `return ret` to `return 0` at the end of functions where ret is always zero and also change functions mt8188_{hdmi,dptx}_codec_init to be consistent with how other functions are returning errors Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230608084727.74403-4-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-08ASoC: mediatek: mt8188-mt6359: clean up a return in codec_initDan Carpenter1-1/+1
This code triggers a Smatch static checker warning and does sort of look like an error path. sound/soc/mediatek/mt8188/mt8188-mt6359.c:597 mt8188_max98390_codec_init() warn: missing error code? 'ret' However, returning 0 is intentional. Make that explicit. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230608084727.74403-3-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-08ASoC: mediatek: mt8188-mt6359: Compress of_device_id entriesAngeloGioacchino Del Regno1-9/+3
Those entries fit in one line: compress them to reduce line count. While at it, also add the sentinel comment to the last entry. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230608084727.74403-2-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-07ASoC: mediatek: mt8188-mt6359: add i2c dependencyArnd Bergmann1-0/+1
The newly added driver is missing this dependency, causing a possible build failure: WARNING: unmet direct dependencies detected for SND_SOC_MAX98390 WARNING: unmet direct dependencies detected for SND_SOC_NAU8825 Depends on [m]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && I2C [=m] Selected by [y]: - SND_SOC_MT8188_MT6359 [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_SOC_MT8188 [=y] && MTK_PMIC_WRAP [=y] aarch64-linux-ld: sound/soc/codecs/max98390.o: in function `max98390_i2c_probe': max98390.c:(.text+0x514): undefined reference to `__devm_regmap_init_i2c' Fixes: 9f08dcbddeb30 ("ASoC: mediatek: mt8188-mt6359: support new board with nau88255") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20230607120831.3587379-1-arnd@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-02ASoC: mediatek: mt8188-mt6359: support new board with nau88255Trevor Wu2-1/+330
This patch adds multiple i2s codecs support including NAU88L25, MAX98390, and the dumb amp like NAU8318 usage. In addition, dmic-codec is also added to skip the beginning pop noise. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Link: https://lore.kernel.org/r/20230526093150.22923-7-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-02ASoC: mediatek: common: soundcard driver add dai_fmt supportTrevor Wu1-2/+51
There are two changes included in the patch. First, add set_dailink_daifmt() function, so dai_fmt can be updated by the configuration in dai-link sub node. Second, remove codec phandle from required property in dai-link sub node. For example, user possibly needs to update dai-format for all etdm co-clock dai-links, but codec doesn't need to be specified in capture dai-link for a speaker amp. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230526093150.22923-5-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-02ASoC: mediatek: mt8188-mt6359: register hdmi/dp jack pinsTrevor Wu1-4/+23
Some userspace applications need jack control events, so register hdmi and dp jack pins to activate jack control events. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230526093150.22923-4-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-02ASoC: mediatek: mt8188: separate ADDA playback dai from capture daiTrevor Wu3-45/+65
MT8188 will support SOF. In SOF, be_hw_params_fixup callback are used to configure BE hardware parameters. However, playback and capture stream share the same callback function in which it can't know the stream type. It's possible to require different parameters for playback and capture stream, so separate them into two dais for SOF usage. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Link: https://lore.kernel.org/r/20230526093150.22923-2-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-01ASoC: mediatek: mt8195: fix use-after-free in driver remove pathTrevor Wu5-34/+24
During mt8195_afe_init_clock(), mt8195_audsys_clk_register() was called followed by several other devm functions. At mt8195_afe_deinit_clock() located at mt8195_afe_pcm_dev_remove(), mt8195_audsys_clk_unregister() was called. However, there was an issue with the order in which these functions were called. Specifically, the remove callback of platform_driver was called before devres released the resource, resulting in a use-after-free issue during remove time. At probe time, the order of calls was: 1. mt8195_audsys_clk_register 2. afe_priv->clk = devm_kcalloc 3. afe_priv->clk[i] = devm_clk_get At remove time, the order of calls was: 1. mt8195_audsys_clk_unregister 3. free afe_priv->clk[i] 2. free afe_priv->clk To resolve the problem, we can utilize devm_add_action_or_reset() in mt8195_audsys_clk_register() so that the remove order can be changed to 3->2->1. Fixes: 6746cc858259 ("ASoC: mediatek: mt8195: add platform driver") Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230601033318.10408-3-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-06-01ASoC: mediatek: mt8188: fix use-after-free in driver remove pathTrevor Wu5-36/+24
During mt8188_afe_init_clock(), mt8188_audsys_clk_register() was called followed by several other devm functions. The caller of mt8188_afe_init_clock() utilized devm_add_action_or_reset() to call mt8188_afe_deinit_clock(). However, the order was incorrect, causing a use-after-free issue during remove time. At probe time, the order of calls was: 1. mt8188_audsys_clk_register 2. afe_priv->clk = devm_kcalloc 3. afe_priv->clk[i] = devm_clk_get At remove time, the order of calls was: 1. mt8188_audsys_clk_unregister 3. free afe_priv->clk[i] 2. free afe_priv->clk To resolve the problem, it's necessary to move devm_add_action_or_reset() to the appropriate position so that the remove order can be 3->2->1. Fixes: f6b026479b13 ("ASoC: mediatek: mt8188: support audio clock control") Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230601033318.10408-2-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-05-30ES8316 audio codec fixes on Rock5BMark Brown5-34/+24
Merge series from Cristian Ciocaltea <cristian.ciocaltea@collabora.com>: This patch series handles a few issues related to the ES8316 audio codec, discovered while doing some testing on the Rock 5B board.
2023-05-23ASoC: do not include pm_runtime.h if not usedClaudiu Beznea4-5/+0
Do not include pm_runtime.h header in files where APIs exported by pm_runtime.h are not used. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> # for omap-mcbsp-st.c Link: https://lore.kernel.org/r/20230517094903.2895238-2-claudiu.beznea@microchip.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-05-18ASoC: mediatek: mt8192-mt6359: Remove " Jack" from Headphone pin nameAngeloGioacchino Del Regno1-1/+1
Function jack_kctl_name_gen() will remove the redundant " Jack" from the name, if present, and then it will add it back, so that all of the controls are named "(pin-name) Jack". Remove " Jack" from the Headphone pin name to spare some CPU cycles. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com Link: https://lore.kernel.org/r/20230517151516.343037-1-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: add required clocksTrevor Wu2-0/+8
apll2_d4, apll12_div4, top_a2sys and top_aud_iec are possibly used in the future. To prevent from breaking binding ABI after any mt8188 dts upstream, add these clocks to clock list in advance. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Link: https://lore.kernel.org/r/20230510035526.18137-8-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: add bus protectionTrevor Wu1-0/+76
Add bus protection for reset controller. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Link: https://lore.kernel.org/r/20230510035526.18137-7-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: combine afe component registrationTrevor Wu1-35/+2
There is no benefit to separate two components for AFE, so DAI driver registration is moved to dev_snd_soc_register_component to merge these two components. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Link: https://lore.kernel.org/r/20230510035526.18137-6-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: refine APLL controlTrevor Wu3-23/+241
Currently, APLL is only used in ETDM module, so APLL and APLL tuner don't need to be enabled when AFE is used. Integrate APLL control into ETDM DAPM routes, so that APLL can be enabled when it is really required. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Link: https://lore.kernel.org/r/20230510035526.18137-5-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: revise ETDM control flowTrevor Wu2-386/+406
Replace register controls in snd_soc_dai_ops with snd_soc_dapm_widgets. startup, shutdown and trigger ops are removed, and create DAPM_SUPPLY to handle mclk, clock gating and etdm enabling. Additionally, mclk setup sequence is also updated because of new supply enabling sequence. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Link: https://lore.kernel.org/r/20230510035526.18137-4-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: complete set_tdm_slot functionTrevor Wu1-3/+18
User can configures slot number of TDM mode via set_tdm_slot callback. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Link: https://lore.kernel.org/r/20230510035526.18137-3-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8188: remove supply AUDIO_HIRESTrevor Wu1-37/+0
AUDIO_HIRES is not required in MT8188. Because top_audio_h is disabled when hires clock is not used, set_parent is a redundant operation. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com Link: https://lore.kernel.org/r/20230510035526.18137-2-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-15ASoC: mediatek: mt8186: Fix use-after-free in driver remove pathDouglas Anderson5-34/+24
When devm runs function in the "remove" path for a device it runs them in the reverse order. That means that if you have parts of your driver that aren't using devm or are using "roll your own" devm w/ devm_add_action_or_reset() you need to keep that in mind. The mt8186 audio driver didn't quite get this right. Specifically, in mt8186_init_clock() it called mt8186_audsys_clk_register() and then went on to call a bunch of other devm function. The caller of mt8186_init_clock() used devm_add_action_or_reset() to call mt8186_deinit_clock() but, because of the intervening devm functions, the order was wrong. Specifically at probe time, the order was: 1. mt8186_audsys_clk_register() 2. afe_priv->clk = devm_kcalloc(...) 3. afe_priv->clk[i] = devm_clk_get(...) At remove time, the order (which should have been 3, 2, 1) was: 1. mt8186_audsys_clk_unregister() 3. Free all of afe_priv->clk[i] 2. Free afe_priv->clk The above seemed to be causing a use-after-free. Luckily, it's easy to fix this by simply using devm more correctly. Let's move the devm_add_action_or_reset() to the right place. In addition to fixing the use-after-free, code inspection shows that this fixes a leak (missing call to mt8186_audsys_clk_unregister()) that would have happened if any of the syscon_regmap_lookup_by_phandle() calls in mt8186_init_clock() had failed. Fixes: 55b423d5623c ("ASoC: mediatek: mt8186: support audio clock control in platform driver") Signed-off-by: Douglas Anderson <dianders@chromium.org Link: https://lore.kernel.org/r/20230511092437.1.I31cceffc8c45bb1af16eb613e197b3df92cdc19e@changeid Signed-off-by: Mark Brown <broonie@kernel.org
2023-05-08ASoC: mediatek: mt8195-afe-pcm: Simplify with dev_err_probe()AngeloGioacchino Del Regno1-31/+14
Shorten the probe function by switching to dev_err_probe() where possible. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com Link: https://lore.kernel.org/r/20230503113413.149235-5-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org