summaryrefslogtreecommitdiff
path: root/sound/soc/mediatek/mt8192
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/mediatek/mt8192')
-rw-r--r--sound/soc/mediatek/mt8192/mt8192-afe-common.h3
-rw-r--r--sound/soc/mediatek/mt8192/mt8192-dai-i2s.c49
-rw-r--r--sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c32
3 files changed, 52 insertions, 32 deletions
diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-common.h b/sound/soc/mediatek/mt8192/mt8192-afe-common.h
index d55eff46cc7f..ad461dcb6ee1 100644
--- a/sound/soc/mediatek/mt8192/mt8192-afe-common.h
+++ b/sound/soc/mediatek/mt8192/mt8192-afe-common.h
@@ -159,6 +159,9 @@ int mt8192_dai_src_register(struct mtk_base_afe *afe);
int mt8192_dai_pcm_register(struct mtk_base_afe *afe);
int mt8192_dai_tdm_register(struct mtk_base_afe *afe);
+int mt8192_dai_i2s_set_share(struct mtk_base_afe *afe, const char *main_i2s_name,
+ const char *secondary_i2s_name);
+
unsigned int mt8192_general_rate_transform(struct device *dev,
unsigned int rate);
unsigned int mt8192_rate_transform(struct device *dev,
diff --git a/sound/soc/mediatek/mt8192/mt8192-dai-i2s.c b/sound/soc/mediatek/mt8192/mt8192-dai-i2s.c
index 5b29340f9516..ea516d63d94d 100644
--- a/sound/soc/mediatek/mt8192/mt8192-dai-i2s.c
+++ b/sound/soc/mediatek/mt8192/mt8192-dai-i2s.c
@@ -45,7 +45,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;
@@ -1984,78 +1983,75 @@ static const struct mtk_afe_i2s_priv mt8192_i2s_priv[DAI_I2S_NUM] = {
[DAI_I2S0] = {
.id = MT8192_DAI_I2S_0,
.mclk_id = MT8192_I2S0_MCK,
- .share_property_name = "i2s0-share",
.share_i2s_id = -1,
},
[DAI_I2S1] = {
.id = MT8192_DAI_I2S_1,
.mclk_id = MT8192_I2S1_MCK,
- .share_property_name = "i2s1-share",
.share_i2s_id = -1,
},
[DAI_I2S2] = {
.id = MT8192_DAI_I2S_2,
.mclk_id = MT8192_I2S2_MCK,
- .share_property_name = "i2s2-share",
.share_i2s_id = -1,
},
[DAI_I2S3] = {
.id = MT8192_DAI_I2S_3,
.mclk_id = MT8192_I2S3_MCK,
- .share_property_name = "i2s3-share",
.share_i2s_id = -1,
},
[DAI_I2S5] = {
.id = MT8192_DAI_I2S_5,
.mclk_id = MT8192_I2S5_MCK,
- .share_property_name = "i2s5-share",
.share_i2s_id = -1,
},
[DAI_I2S6] = {
.id = MT8192_DAI_I2S_6,
.mclk_id = MT8192_I2S6_MCK,
- .share_property_name = "i2s6-share",
.share_i2s_id = -1,
},
[DAI_I2S7] = {
.id = MT8192_DAI_I2S_7,
.mclk_id = MT8192_I2S7_MCK,
- .share_property_name = "i2s7-share",
.share_i2s_id = -1,
},
[DAI_I2S8] = {
.id = MT8192_DAI_I2S_8,
.mclk_id = MT8192_I2S8_MCK,
- .share_property_name = "i2s8-share",
.share_i2s_id = -1,
},
[DAI_I2S9] = {
.id = MT8192_DAI_I2S_9,
.mclk_id = MT8192_I2S9_MCK,
- .share_property_name = "i2s9-share",
.share_i2s_id = -1,
},
};
-static int mt8192_dai_i2s_get_share(struct mtk_base_afe *afe)
+/**
+ * mt8192_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 mt8192_dai_i2s_set_share(struct mtk_base_afe *afe, const char *main_i2s_name,
+ const char *secondary_i2s_name)
{
- struct mt8192_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[mt8192_i2s_priv[i].id];
- property_name = mt8192_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(mt8192_dai_i2s_set_share);
static int mt8192_dai_i2s_set_priv(struct mtk_base_afe *afe)
{
@@ -2101,10 +2097,5 @@ int mt8192_dai_i2s_register(struct mtk_base_afe *afe)
if (ret)
return ret;
- /* parse share i2s */
- ret = mt8192_dai_i2s_get_share(afe);
- if (ret)
- return ret;
-
return 0;
}
diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index d0f9d66627b1..b93c3237ef2d 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -24,6 +24,8 @@
#include "mt8192-afe-clk.h"
#include "mt8192-afe-gpio.h"
+#define DRIVER_NAME "mt8192_mt6359"
+
#define RT1015_CODEC_DAI "rt1015-aif"
#define RT1015_DEV0_NAME "rt1015.1-0028"
#define RT1015_DEV1_NAME "rt1015.1-0029"
@@ -41,6 +43,18 @@ struct mt8192_mt6359_priv {
struct snd_soc_jack hdmi_jack;
};
+/* Headset jack detection DAPM pins */
+static struct snd_soc_jack_pin mt8192_jack_pins[] = {
+ {
+ .pin = "Headphone Jack",
+ .mask = SND_JACK_HEADPHONE,
+ },
+ {
+ .pin = "Headset Mic",
+ .mask = SND_JACK_MICROPHONE,
+ },
+};
+
static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -311,17 +325,27 @@ static int mt8192_mt6359_init(struct snd_soc_pcm_runtime *rtd)
static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd)
{
+ struct snd_soc_component *cmpnt_afe =
+ snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
+ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(cmpnt_afe);
struct snd_soc_component *cmpnt_codec =
asoc_rtd_to_codec(rtd, 0)->component;
struct mt8192_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_jack *jack = &priv->headset_jack;
int ret;
- ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
+ ret = mt8192_dai_i2s_set_share(afe, "I2S8", "I2S9");
+ if (ret) {
+ dev_err(rtd->dev, "Failed to set up shared clocks\n");
+ return ret;
+ }
+
+ ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
SND_JACK_HEADSET | SND_JACK_BTN_0 |
SND_JACK_BTN_1 | SND_JACK_BTN_2 |
SND_JACK_BTN_3,
- jack);
+ jack, mt8192_jack_pins,
+ ARRAY_SIZE(mt8192_jack_pins));
if (ret) {
dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
return ret;
@@ -1048,6 +1072,7 @@ static struct snd_soc_codec_conf rt1015_amp_conf[] = {
static struct snd_soc_card mt8192_mt6359_rt1015_rt5682_card = {
.name = RT1015_RT5682_CARD_NAME,
+ .driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = mt8192_mt6359_dai_links,
.num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
@@ -1083,6 +1108,7 @@ static const struct snd_kcontrol_new mt8192_mt6359_rt1015p_rt5682x_controls[] =
};
static struct snd_soc_card mt8192_mt6359_rt1015p_rt5682x_card = {
+ .driver_name = DRIVER_NAME,
.owner = THIS_MODULE,
.dai_link = mt8192_mt6359_dai_links,
.num_links = ARRAY_SIZE(mt8192_mt6359_dai_links),
@@ -1244,7 +1270,7 @@ static const struct dev_pm_ops mt8192_mt6359_pm_ops = {
static struct platform_driver mt8192_mt6359_driver = {
.driver = {
- .name = "mt8192_mt6359",
+ .name = DRIVER_NAME,
#ifdef CONFIG_OF
.of_match_table = mt8192_mt6359_dt_match,
#endif