aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/soc/mediatek/mt8183/mt8183-dai-i2s.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/mediatek/mt8183/mt8183-dai-i2s.c')
-rw-r--r--sound/soc/mediatek/mt8183/mt8183-dai-i2s.c70
1 files changed, 25 insertions, 45 deletions
diff --git a/sound/soc/mediatek/mt8183/mt8183-dai-i2s.c b/sound/soc/mediatek/mt8183/mt8183-dai-i2s.c
index 138591d71ebd..65e46ebe7be6 100644
--- a/sound/soc/mediatek/mt8183/mt8183-dai-i2s.c
+++ b/sound/soc/mediatek/mt8183/mt8183-dai-i2s.c
@@ -43,7 +43,6 @@ struct mtk_afe_i2s_priv {
int rate; /* for determine which apll to use */
int low_jitter_en;
- const char *share_property_name;
int share_i2s_id;
int mclk_id;
@@ -142,16 +141,13 @@ static int mt8183_i2s_hd_set(struct snd_kcontrol *kcontrol,
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
struct mtk_afe_i2s_priv *i2s_priv;
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
- int hd_en;
+ int hd_en, change;
if (ucontrol->value.enumerated.item[0] >= e->items)
return -EINVAL;
hd_en = ucontrol->value.integer.value[0];
- dev_info(afe->dev, "%s(), kcontrol name %s, hd_en %d\n",
- __func__, kcontrol->id.name, hd_en);
-
i2s_priv = get_i2s_priv_by_name(afe, kcontrol->id.name);
if (!i2s_priv) {
@@ -159,9 +155,10 @@ static int mt8183_i2s_hd_set(struct snd_kcontrol *kcontrol,
return -EINVAL;
}
+ change = i2s_priv->low_jitter_en != hd_en;
i2s_priv->low_jitter_en = hd_en;
- return 0;
+ return change;
}
static const struct snd_kcontrol_new mtk_dai_i2s_controls[] = {
@@ -277,18 +274,15 @@ static int mtk_apll_event(struct snd_soc_dapm_widget *w,
struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm);
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
- dev_info(cmpnt->dev, "%s(), name %s, event 0x%x\n",
- __func__, w->name, event);
-
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
- if (strcmp(w->name, APLL1_W_NAME) == 0)
+ if (snd_soc_dapm_widget_name_cmp(w, APLL1_W_NAME) == 0)
mt8183_apll1_enable(afe);
else
mt8183_apll2_enable(afe);
break;
case SND_SOC_DAPM_POST_PMD:
- if (strcmp(w->name, APLL1_W_NAME) == 0)
+ if (snd_soc_dapm_widget_name_cmp(w, APLL1_W_NAME) == 0)
mt8183_apll1_disable(afe);
else
mt8183_apll2_disable(afe);
@@ -308,9 +302,6 @@ static int mtk_mclk_en_event(struct snd_soc_dapm_widget *w,
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt);
struct mtk_afe_i2s_priv *i2s_priv;
- dev_info(cmpnt->dev, "%s(), name %s, event 0x%x\n",
- __func__, w->name, event);
-
i2s_priv = get_i2s_priv_by_name(afe, w->name);
if (!i2s_priv) {
@@ -716,11 +707,6 @@ static int mtk_dai_i2s_config(struct mtk_base_afe *afe,
unsigned int i2s_con = 0, fmt_con = I2S_FMT_I2S << I2S_FMT_SFT;
int ret = 0;
- dev_info(afe->dev, "%s(), id %d, rate %d, format %d\n",
- __func__,
- i2s_id,
- rate, format);
-
if (i2s_priv) {
i2s_priv->rate = rate;
@@ -811,8 +797,6 @@ static int mtk_dai_i2s_set_sysclk(struct snd_soc_dai *dai,
return -EINVAL;
}
- dev_info(afe->dev, "%s(), freq %d\n", __func__, freq);
-
apll = mt8183_get_apll_by_rate(afe, freq);
apll_rate = mt8183_get_apll_rate(afe, apll);
@@ -977,54 +961,55 @@ static const struct mtk_afe_i2s_priv mt8183_i2s_priv[DAI_I2S_NUM] = {
[DAI_I2S0] = {
.id = MT8183_DAI_I2S_0,
.mclk_id = MT8183_I2S0_MCK,
- .share_property_name = "i2s0-share",
.share_i2s_id = -1,
},
[DAI_I2S1] = {
.id = MT8183_DAI_I2S_1,
.mclk_id = MT8183_I2S1_MCK,
- .share_property_name = "i2s1-share",
.share_i2s_id = -1,
},
[DAI_I2S2] = {
.id = MT8183_DAI_I2S_2,
.mclk_id = MT8183_I2S2_MCK,
- .share_property_name = "i2s2-share",
.share_i2s_id = -1,
},
[DAI_I2S3] = {
.id = MT8183_DAI_I2S_3,
.mclk_id = MT8183_I2S3_MCK,
- .share_property_name = "i2s3-share",
.share_i2s_id = -1,
},
[DAI_I2S5] = {
.id = MT8183_DAI_I2S_5,
.mclk_id = MT8183_I2S5_MCK,
- .share_property_name = "i2s5-share",
.share_i2s_id = -1,
},
};
-static int mt8183_dai_i2s_get_share(struct mtk_base_afe *afe)
+/**
+ * mt8183_dai_i2s_set_share() - Set up I2S ports to share a single clock.
+ * @afe: Pointer to &struct mtk_base_afe
+ * @main_i2s_name: The name of the I2S port that will provide the clock
+ * @secondary_i2s_name: The name of the I2S port that will use this clock
+ */
+int mt8183_dai_i2s_set_share(struct mtk_base_afe *afe, const char *main_i2s_name,
+ const char *secondary_i2s_name)
{
- struct mt8183_afe_private *afe_priv = afe->platform_priv;
- const struct device_node *of_node = afe->dev->of_node;
- const char *of_str;
- const char *property_name;
- struct mtk_afe_i2s_priv *i2s_priv;
- int i;
+ struct mtk_afe_i2s_priv *secondary_i2s_priv;
+ int main_i2s_id;
- for (i = 0; i < DAI_I2S_NUM; i++) {
- i2s_priv = afe_priv->dai_priv[mt8183_i2s_priv[i].id];
- property_name = mt8183_i2s_priv[i].share_property_name;
- if (of_property_read_string(of_node, property_name, &of_str))
- continue;
- i2s_priv->share_i2s_id = get_i2s_id_by_name(afe, of_str);
- }
+ secondary_i2s_priv = get_i2s_priv_by_name(afe, secondary_i2s_name);
+ if (!secondary_i2s_priv)
+ return -EINVAL;
+
+ main_i2s_id = get_i2s_id_by_name(afe, main_i2s_name);
+ if (main_i2s_id < 0)
+ return main_i2s_id;
+
+ secondary_i2s_priv->share_i2s_id = main_i2s_id;
return 0;
}
+EXPORT_SYMBOL_GPL(mt8183_dai_i2s_set_share);
static int mt8183_dai_i2s_set_priv(struct mtk_base_afe *afe)
{
@@ -1074,10 +1059,5 @@ int mt8183_dai_i2s_register(struct mtk_base_afe *afe)
if (ret)
return ret;
- /* parse share i2s */
- ret = mt8183_dai_i2s_get_share(afe);
- if (ret)
- return ret;
-
return 0;
}