History log of /linux-master/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c
Revision Date Author Comments
# e70b8dd2 10-Jan-2024 AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

ASoC: mediatek: mt8195: Remove afe-dai component and rework codec link

Remove the extra 'mt8195-afe-pcm-dai' component, register the DAI
drivers to the main AFE component, and rework the DAI linking between
the headset codec (RT5682/RT5682S) and the TDM interface in the probe
function to stop assigning name, relying on the of_node of the codec.
Also replace the COMP_DUMMY codec entry with a COMP_EMPTY for the
ETDM2_IN and remove it entirely from ETDM1_OUT to fix the registration
flow for this sound card.

While at it, since we also need to swap the codec init function from
ETDM2_IN to ETDM1_OUT, remove the static assignment of both `ops` and
`init` for both, as we now assign these dynamically during probe.

Fixes: 13f58267cda3 ("ASoC: soc.h: don't create dummy Component via COMP_DUMMY()")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://msgid.link/r/20240110105757.539089-1-angelogioacchino.delregno@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# de9e7013 26-Sep-2023 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ASoC: mediatek: convert not to use asoc_xxx()

ASoC is now unified asoc_xxx() into snd_soc_xxx().
This patch convert asoc_xxx() to snd_soc_xxx().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877codh2qg.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# dc93f0dc 31-May-2023 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mediatek: mt8195: fix use-after-free in driver remove path

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>


# 863da1c1 03-May-2023 AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

ASoC: mediatek: mt8195-afe-pcm: Simplify with dev_err_probe()

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


# 2ca0ec01 03-May-2023 AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

ASoC: mediatek: mt8195-afe-pcm: Simplify runtime PM during probe

Use devm_pm_runtime_enable() and pm_runtime_resume_and_get() to
to simplify the probe function.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com
Link: https://lore.kernel.org/r/20230503113413.149235-4-angelogioacchino.delregno@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org


# 686d0416 03-May-2023 AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

ASoC: mediatek: mt8195-afe-pcm: Clean up unnecessary functions

Function mt8195_afe_init_registers() performs just a single call to
regmap_multi_reg_write(), it returns int and it's not error checked;
move that call to the probe function and also add some error check.

While at it, also move the contents of mt8195_afe_parse_of() to the
probe function as well: since this is getting a handle to topckgen
and since that's optional, the ifdef for CONFIG_SND_SOC_MT6359 can
also be removed.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com
Acked-by: Trevor Wu <trevor.wu@mediatek.com
Link: https://lore.kernel.org/r/20230503113413.149235-6-angelogioacchino.delregno@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org


# 6461fee6 15-Mar-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

ASoC: mediatek: mt8195-afe-pcm: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Link: https://lore.kernel.org/r/20230315150745.67084-114-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>


# f6708414 08-Mar-2022 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mediatek: mt8195: add reset controller

Audio hardware is possibly used in the firmware stage, so resetting audio
hardware before regcache records default register values is required.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220308072435.22460-2-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 7d642c9c 23-Feb-2022 Yang Li <yang.lee@linux.alibaba.com>

ASoC: mediatek: mt8195: Remove unnecessary print function dev_err()

The print function dev_err() is redundant because platform_get_irq()
already prints an error.

Eliminate the follow coccicheck warning:
./sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:3126:2-9: line 3126 is
redundant because platform_get_irq() already prints an error

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220224011046.76904-1-yang.lee@linux.alibaba.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# ff5a9017 20-Feb-2022 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mediatek: mt8195: enable apll tuner

Normally, the clock source of audio module is either 26M or APLL1/APLL2,
but APLL1/APLL2 are not the multiple of 26M.

In the patch, APLL1 and APLL2 tuners are enabled to handle sample rate
mismatch when the data path crosses two different clock domains.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20220221055716.18580-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 30e693ee 15-Dec-2021 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mediatek: mt8195: correct default value

mt8195_cg_patch is used to reset the default value of audio cg, so the
register value could be consistent with CCF reference count.
Nevertheless, AUDIO_TOP_CON1[1:0] is used to control an internal mux,
and it's expected to keep the default value 0.

This patch corrects the default value in case an unexpected behavior
happens in the future.

Fixes: 6746cc8582599 ("ASoC: mediatek: mt8195: add platform driver")
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20211216022424.28470-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 4d408ea0 29-Nov-2021 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mediatek: mt8195: support reserved memory assignment

For security purpose, restrict the memory assess region of AFE memif.
The specified memory region should be assigned from DTS.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20211130053905.28470-2-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 73983ad9 25-Oct-2021 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ASoC: mediatek: mt8195: rename shadowed array

cppcheck warning:

Checking sound/soc/mediatek/mt8195/mt8195-afe-pcm.c ...
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2884:35: style: Local
variable 'irq_data' shadows outer variable [shadowVariable]
struct mtk_base_irq_data const *irq_data;
^
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2235:39: note: Shadowed declaration
static const struct mtk_base_irq_data irq_data[MT8195_AFE_IRQ_NUM] = {
^
sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:2884:35: note: Shadow variable
struct mtk_base_irq_data const *irq_data;
^

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211025185933.144327-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 2b9b42c8 02-Sep-2021 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mt8195: remove unnecessary CONFIG_PM

The unnecessary conditional inclusion caused the following warning.

>> sound/soc/mediatek/mt8195/mt8195-afe-pcm.c:3260:32: warning: unused
>> variable 'mt8195_afe_pm_ops' [-Wunused-const-variable]
static const struct dev_pm_ops mt8195_afe_pm_ops = {
^
1 warning generated.

Because runtime_pm already handles the case without CONFIG_PM, we
can remove CONFIG_PM condition.

Fixes: 6746cc858259 ("ASoC: mediatek: mt8195: add platform driver")
Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20210902071440.6087-1-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# c6b1b574 01-Sep-2021 Cai Huoqing <caihuoqing@baidu.com>

ASoC: mediatek: mt8195: Make use of the helper function devm_platform_ioremap_resource()

Use the devm_platform_ioremap_resource() helper instead of
calling platform_get_resource() and devm_ioremap_resource()
separately

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20210901132742.31714-1-caihuoqing@baidu.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 6746cc85 19-Aug-2021 Trevor Wu <trevor.wu@mediatek.com>

ASoC: mediatek: mt8195: add platform driver

This patch adds mt8195 platform and affiliated driver.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20210819084144.18483-7-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>