summaryrefslogtreecommitdiff
path: root/sound/soc/mediatek/mt8195
diff options
context:
space:
mode:
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>2024-03-13 14:01:28 +0300
committerMark Brown <broonie@kernel.org>2024-03-25 17:19:07 +0300
commitd6c01755805d346a1382d2d81c214b2ca557487a (patch)
tree26456f7d82c55e00caa3e7cccab3b86fe92f16e8 /sound/soc/mediatek/mt8195
parent324c603a4efca7d1045e0bf3477ca54970eac72c (diff)
downloadlinux-d6c01755805d346a1382d2d81c214b2ca557487a.tar.xz
ASoC: mediatek: Commonize ADDA rate transform functions and enums
Both the enumerations for UL/DL rates, delay data and the functions adda_{dl,ul}_rate_transform were duplicated for each MediaTek SoC dai-adda driver: move the common bits to a new mtk-dai-adda-common file and its header. While at it, also add the "mtk_" prefix to the exported functions. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://msgid.link/r/20240313110147.1267793-4-angelogioacchino.delregno@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/mediatek/mt8195')
-rw-r--r--sound/soc/mediatek/mt8195/mt8195-dai-adda.c90
1 files changed, 3 insertions, 87 deletions
diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-adda.c b/sound/soc/mediatek/mt8195/mt8195-dai-adda.c
index 0dd35255066b..8da1587128cc 100644
--- a/sound/soc/mediatek/mt8195/mt8195-dai-adda.c
+++ b/sound/soc/mediatek/mt8195/mt8195-dai-adda.c
@@ -12,6 +12,7 @@
#include "mt8195-afe-clk.h"
#include "mt8195-afe-common.h"
#include "mt8195-reg.h"
+#include "../common/mtk-dai-adda-common.h"
#define ADDA_DL_GAIN_LOOPBACK 0x1800
#define ADDA_HIRES_THRES 48000
@@ -26,35 +27,6 @@ enum {
};
enum {
- MTK_AFE_ADDA_DL_RATE_8K = 0,
- MTK_AFE_ADDA_DL_RATE_11K = 1,
- MTK_AFE_ADDA_DL_RATE_12K = 2,
- MTK_AFE_ADDA_DL_RATE_16K = 3,
- MTK_AFE_ADDA_DL_RATE_22K = 4,
- MTK_AFE_ADDA_DL_RATE_24K = 5,
- MTK_AFE_ADDA_DL_RATE_32K = 6,
- MTK_AFE_ADDA_DL_RATE_44K = 7,
- MTK_AFE_ADDA_DL_RATE_48K = 8,
- MTK_AFE_ADDA_DL_RATE_96K = 9,
- MTK_AFE_ADDA_DL_RATE_192K = 10,
-};
-
-enum {
- MTK_AFE_ADDA_UL_RATE_8K = 0,
- MTK_AFE_ADDA_UL_RATE_16K = 1,
- MTK_AFE_ADDA_UL_RATE_32K = 2,
- MTK_AFE_ADDA_UL_RATE_48K = 3,
- MTK_AFE_ADDA_UL_RATE_96K = 4,
- MTK_AFE_ADDA_UL_RATE_192K = 5,
-};
-
-enum {
- DELAY_DATA_MISO1 = 0,
- DELAY_DATA_MISO0 = 1,
- DELAY_DATA_MISO2 = 1,
-};
-
-enum {
MTK_AFE_ADDA,
MTK_AFE_ADDA6,
};
@@ -63,62 +35,6 @@ struct mtk_dai_adda_priv {
bool hires_required;
};
-static unsigned int afe_adda_dl_rate_transform(struct mtk_base_afe *afe,
- unsigned int rate)
-{
- switch (rate) {
- case 8000:
- return MTK_AFE_ADDA_DL_RATE_8K;
- case 11025:
- return MTK_AFE_ADDA_DL_RATE_11K;
- case 12000:
- return MTK_AFE_ADDA_DL_RATE_12K;
- case 16000:
- return MTK_AFE_ADDA_DL_RATE_16K;
- case 22050:
- return MTK_AFE_ADDA_DL_RATE_22K;
- case 24000:
- return MTK_AFE_ADDA_DL_RATE_24K;
- case 32000:
- return MTK_AFE_ADDA_DL_RATE_32K;
- case 44100:
- return MTK_AFE_ADDA_DL_RATE_44K;
- case 48000:
- return MTK_AFE_ADDA_DL_RATE_48K;
- case 96000:
- return MTK_AFE_ADDA_DL_RATE_96K;
- case 192000:
- return MTK_AFE_ADDA_DL_RATE_192K;
- default:
- dev_info(afe->dev, "%s(), rate %d invalid, use 48kHz!!!\n",
- __func__, rate);
- return MTK_AFE_ADDA_DL_RATE_48K;
- }
-}
-
-static unsigned int afe_adda_ul_rate_transform(struct mtk_base_afe *afe,
- unsigned int rate)
-{
- switch (rate) {
- case 8000:
- return MTK_AFE_ADDA_UL_RATE_8K;
- case 16000:
- return MTK_AFE_ADDA_UL_RATE_16K;
- case 32000:
- return MTK_AFE_ADDA_UL_RATE_32K;
- case 48000:
- return MTK_AFE_ADDA_UL_RATE_48K;
- case 96000:
- return MTK_AFE_ADDA_UL_RATE_96K;
- case 192000:
- return MTK_AFE_ADDA_UL_RATE_192K;
- default:
- dev_info(afe->dev, "%s(), rate %d invalid, use 48kHz!!!\n",
- __func__, rate);
- return MTK_AFE_ADDA_UL_RATE_48K;
- }
-}
-
static int mt8195_adda_mtkaif_init(struct mtk_base_afe *afe)
{
struct mt8195_afe_private *afe_priv = afe->platform_priv;
@@ -644,7 +560,7 @@ static int mtk_dai_da_configure(struct mtk_base_afe *afe,
/* set sampling rate */
mask |= DL_2_INPUT_MODE_CTL_MASK;
- val |= DL_2_INPUT_MODE_CTL(afe_adda_dl_rate_transform(afe, rate));
+ val |= DL_2_INPUT_MODE_CTL(mtk_adda_dl_rate_transform(afe, rate));
/* turn off saturation */
mask |= DL_2_CH1_SATURATION_EN_CTL;
@@ -681,7 +597,7 @@ static int mtk_dai_ad_configure(struct mtk_base_afe *afe,
unsigned int mask = 0;
mask |= UL_VOICE_MODE_CTL_MASK;
- val |= UL_VOICE_MODE_CTL(afe_adda_ul_rate_transform(afe, rate));
+ val |= UL_VOICE_MODE_CTL(mtk_adda_ul_rate_transform(afe, rate));
switch (id) {
case MT8195_AFE_IO_UL_SRC1: