Modify documentation and machine driver for mt8186_rt1019_rt5682s sound card
Merge series from Ajye Huang <ajye_huang@compal.corp-partner.google.com>: Support selecting between front and rear microphones on some of the MediaTek platforms.
This commit is contained in:
@@ -21,6 +21,13 @@ properties:
|
||||
$ref: "/schemas/types.yaml#/definitions/phandle"
|
||||
description: The phandle of MT8186 ASoC platform.
|
||||
|
||||
dmic-gpios:
|
||||
maxItems: 1
|
||||
description:
|
||||
dmic-gpios optional prop for switching between two DMICs.
|
||||
Ex, the GPIO can control a MUX HW component to select
|
||||
dmic clk and data form a Front or Rear dmic.
|
||||
|
||||
headset-codec:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
@@ -63,14 +70,19 @@ required:
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
sound: mt8186-sound {
|
||||
compatible = "mediatek,mt8186-mt6366-rt1019-rt5682s-sound";
|
||||
mediatek,platform = <&afe>;
|
||||
pinctrl-names = "aud_clk_mosi_off",
|
||||
"aud_clk_mosi_on";
|
||||
"aud_clk_mosi_on",
|
||||
"aud_gpio_dmic_sec";
|
||||
pinctrl-0 = <&aud_clk_mosi_off>;
|
||||
pinctrl-1 = <&aud_clk_mosi_on>;
|
||||
pinctrl-2 = <&aud_gpio_dmic_sec>;
|
||||
|
||||
dmic-gpios = <&pio 23 GPIO_ACTIVE_HIGH>;
|
||||
|
||||
headset-codec {
|
||||
sound-dai = <&rt5682s>;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
// Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
|
||||
//
|
||||
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
@@ -39,6 +41,8 @@
|
||||
|
||||
struct mt8186_mt6366_rt1019_rt5682s_priv {
|
||||
struct snd_soc_jack headset_jack, hdmi_jack;
|
||||
struct gpio_desc *dmic_sel;
|
||||
int dmic_switch;
|
||||
};
|
||||
|
||||
/* Headset jack detection DAPM pins */
|
||||
@@ -68,6 +72,94 @@ static struct snd_soc_codec_conf mt8186_mt6366_rt1019_rt5682s_codec_conf[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static int dmic_get(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
|
||||
struct mtk_soc_card_data *soc_card_data =
|
||||
snd_soc_card_get_drvdata(dapm->card);
|
||||
struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv;
|
||||
|
||||
ucontrol->value.integer.value[0] = priv->dmic_switch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dmic_set(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
|
||||
struct mtk_soc_card_data *soc_card_data =
|
||||
snd_soc_card_get_drvdata(dapm->card);
|
||||
struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv;
|
||||
|
||||
priv->dmic_switch = ucontrol->value.integer.value[0];
|
||||
if (priv->dmic_sel) {
|
||||
gpiod_set_value(priv->dmic_sel, priv->dmic_switch);
|
||||
dev_info(dapm->card->dev, "dmic_set_value %d\n",
|
||||
priv->dmic_switch);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const dmic_mux_text[] = {
|
||||
"Front Mic",
|
||||
"Rear Mic",
|
||||
};
|
||||
|
||||
static SOC_ENUM_SINGLE_DECL(mt8186_dmic_enum,
|
||||
SND_SOC_NOPM, 0, dmic_mux_text);
|
||||
|
||||
static const struct snd_kcontrol_new mt8186_dmic_mux_control =
|
||||
SOC_DAPM_ENUM_EXT("DMIC Select Mux", mt8186_dmic_enum,
|
||||
dmic_get, dmic_set);
|
||||
|
||||
static const struct snd_soc_dapm_widget dmic_widgets[] = {
|
||||
SND_SOC_DAPM_MIC("DMIC", NULL),
|
||||
SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &mt8186_dmic_mux_control),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route dmic_map[] = {
|
||||
/* digital mics */
|
||||
{"Dmic Mux", "Front Mic", "DMIC"},
|
||||
{"Dmic Mux", "Rear Mic", "DMIC"},
|
||||
};
|
||||
|
||||
static int primary_codec_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card);
|
||||
struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv;
|
||||
int ret;
|
||||
|
||||
ret = mt8186_mt6366_init(rtd);
|
||||
|
||||
if (ret) {
|
||||
dev_err(card->dev, "mt8186_mt6366_init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!priv->dmic_sel) {
|
||||
dev_info(card->dev, "dmic_sel is null\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
|
||||
ARRAY_SIZE(dmic_widgets));
|
||||
if (ret) {
|
||||
dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
|
||||
/* Don't need to add routes if widget addition failed */
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
|
||||
ARRAY_SIZE(dmic_map));
|
||||
|
||||
if (ret)
|
||||
dev_err(card->dev, "DMic map addition failed: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt8186_rt5682s_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_component *cmpnt_afe =
|
||||
@@ -775,7 +867,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = {
|
||||
.dpcm_playback = 1,
|
||||
.dpcm_capture = 1,
|
||||
.ignore_suspend = 1,
|
||||
.init = mt8186_mt6366_init,
|
||||
.init = primary_codec_init,
|
||||
SND_SOC_DAILINK_REG(adda),
|
||||
},
|
||||
{
|
||||
@@ -1015,6 +1107,14 @@ static int mt8186_mt6366_rt1019_rt5682s_dev_probe(struct platform_device *pdev)
|
||||
|
||||
soc_card_data->mach_priv = mach_priv;
|
||||
|
||||
mach_priv->dmic_sel = devm_gpiod_get_optional(&pdev->dev,
|
||||
"dmic", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(mach_priv->dmic_sel)) {
|
||||
dev_err(&pdev->dev, "DMIC gpio failed err=%ld\n",
|
||||
PTR_ERR(mach_priv->dmic_sel));
|
||||
return PTR_ERR(mach_priv->dmic_sel);
|
||||
}
|
||||
|
||||
adsp_node = of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0);
|
||||
if (adsp_node) {
|
||||
struct mtk_sof_priv *sof_priv;
|
||||
|
||||
Reference in New Issue
Block a user