Commit 513e22f3 authored by Mark Brown's avatar Mark Brown

Merge series "Modify documentation and machine driver for SC7180 sound card"...

Merge series "Modify documentation and machine driver for SC7180 sound card" from Ajye Huang <ajye.huang@gmail.com>:

Note:
- The patch is made by the collaboration of
 Ajye Huang <ajye_huang@compal.corp-partner.google.com>
 Cheng-Yi Chiang <cychiang@chromium.org>

v6:
- Documentation: Addressed suggestions from Rob Herring.
  - Define "maxItems: 1" in dmic-gpios property.
  - Only keep one example and add dmic-gpios property in.
v5:
- Machine driver:
  - Fix a format string warning (Reported-by: kernel test robot <lkp@intel.com>).
    detailed info at https://lore.kernel.org/patchwork/patch/1331087/

v4:
- Machine driver: Addressed suggestions from Tzung-Bi.
  - Remove redundant judgments in dmic_set() and dmic_get().
  - Remove 1 level indent of judgment of IS_ERR(data->dmic_sel).

v3:
- Machine driver: Addressed suggestions from Tzung-Bi.
  - Move variables "dmic_switch" and "dmic_sel" into struct sc7180_snd_data.
  - Remove redundant judgments in dmic_set().

v2:
- Documentation: Modify the dimc-gpios property description and examples.
- Machine driver:
  - Remove "qcom,sc7180-sndcard-rt5682-m98357-2mic" compatible
  - See gpio property and use anadditional control.

Thanks for the review!

Ajye Huang (2):
  ASoC: google: dt-bindings: modify machine bindings for two MICs case
  ASoC: qcom: sc7180: Modify machine driver for 2mic

 .../bindings/sound/google,sc7180-trogdor.yaml |  8 ++-
 sound/soc/qcom/sc7180.c                       | 61 +++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)

--
2.25.1
parents 50dc5f5c 3cfbf07c
...@@ -34,6 +34,10 @@ properties: ...@@ -34,6 +34,10 @@ properties:
"#size-cells": "#size-cells":
const: 0 const: 0
dmic-gpios:
maxItems: 1
description: GPIO for switching between DMICs
patternProperties: patternProperties:
"^dai-link(@[0-9])?$": "^dai-link(@[0-9])?$":
description: description:
...@@ -83,7 +87,7 @@ examples: ...@@ -83,7 +87,7 @@ examples:
- | - |
sound { sound {
compatible = "google,sc7180-trogdor"; compatible = "google,sc7180-trogdor";
model = "sc7180-rt5682-max98357a-1mic"; model = "sc7180-rt5682-max98357a-2mic";
audio-routing = audio-routing =
"Headphone Jack", "HPOL", "Headphone Jack", "HPOL",
...@@ -92,6 +96,8 @@ examples: ...@@ -92,6 +96,8 @@ examples:
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
dmic-gpios = <&tlmm 86 0>;
dai-link@0 { dai-link@0 {
link-name = "MultiMedia0"; link-name = "MultiMedia0";
reg = <0>; reg = <0>;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
// sc7180.c -- ALSA SoC Machine driver for SC7180 // sc7180.c -- ALSA SoC Machine driver for SC7180
#include <dt-bindings/sound/sc7180-lpass.h> #include <dt-bindings/sound/sc7180-lpass.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -28,6 +30,8 @@ struct sc7180_snd_data { ...@@ -28,6 +30,8 @@ struct sc7180_snd_data {
u32 pri_mi2s_clk_count; u32 pri_mi2s_clk_count;
struct snd_soc_jack hs_jack; struct snd_soc_jack hs_jack;
struct snd_soc_jack hdmi_jack; struct snd_soc_jack hdmi_jack;
struct gpio_desc *dmic_sel;
int dmic_switch;
}; };
static void sc7180_jack_free(struct snd_jack *jack) static void sc7180_jack_free(struct snd_jack *jack)
...@@ -169,6 +173,27 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream) ...@@ -169,6 +173,27 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream)
return 0; return 0;
} }
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 sc7180_snd_data *data = snd_soc_card_get_drvdata(dapm->card);
ucontrol->value.integer.value[0] = data->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 sc7180_snd_data *data = snd_soc_card_get_drvdata(dapm->card);
data->dmic_switch = ucontrol->value.integer.value[0];
gpiod_set_value(data->dmic_sel, data->dmic_switch);
return 0;
}
static void sc7180_snd_shutdown(struct snd_pcm_substream *substream) static void sc7180_snd_shutdown(struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
...@@ -206,6 +231,30 @@ static const struct snd_soc_dapm_widget sc7180_snd_widgets[] = { ...@@ -206,6 +231,30 @@ static const struct snd_soc_dapm_widget sc7180_snd_widgets[] = {
SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL),
}; };
static const char * const dmic_mux_text[] = {
"Front Mic",
"Rear Mic",
};
static SOC_ENUM_SINGLE_DECL(sc7180_dmic_enum,
SND_SOC_NOPM, 0, dmic_mux_text);
static const struct snd_kcontrol_new sc7180_dmic_mux_control =
SOC_DAPM_ENUM_EXT("DMIC Select Mux", sc7180_dmic_enum,
dmic_get, dmic_set);
static const struct snd_soc_dapm_widget sc7180_snd_dual_mic_widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MIC("DMIC", NULL),
SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &sc7180_dmic_mux_control),
};
static const struct snd_soc_dapm_route sc7180_snd_dual_mic_audio_route[] = {
{"Dmic Mux", "Front Mic", "DMIC"},
{"Dmic Mux", "Rear Mic", "DMIC"},
};
static void sc7180_add_ops(struct snd_soc_card *card) static void sc7180_add_ops(struct snd_soc_card *card)
{ {
struct snd_soc_dai_link *link; struct snd_soc_dai_link *link;
...@@ -238,6 +287,18 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) ...@@ -238,6 +287,18 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev)
card->dapm_widgets = sc7180_snd_widgets; card->dapm_widgets = sc7180_snd_widgets;
card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_widgets); card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_widgets);
if (of_property_read_bool(dev->of_node, "dmic-gpios")) {
card->dapm_widgets = sc7180_snd_dual_mic_widgets,
card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_dual_mic_widgets),
card->dapm_routes = sc7180_snd_dual_mic_audio_route,
card->num_dapm_routes = ARRAY_SIZE(sc7180_snd_dual_mic_audio_route),
data->dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW);
if (IS_ERR(data->dmic_sel)) {
dev_err(&pdev->dev, "DMIC gpio failed err=%ld\n", PTR_ERR(data->dmic_sel));
return PTR_ERR(data->dmic_sel);
}
}
ret = qcom_snd_parse_of(card); ret = qcom_snd_parse_of(card);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment