Merge series "Support SC7180 sound card variation without headset" from xuyuqing <xuyuqing@huaqin.corp-partner.google.com>:
Use compatible string to let machine driver handle the case where ALC5682 headset codec is replaced with ADAU7002 dmic codec xuyuqing (2): ASoC: google: dt-bindings: add new compatible for sc7180-coachz ASoC: qcom: sc7180: Add machine driver for sound card .../bindings/sound/google,sc7180-trogdor.yaml | 4 +- sound/soc/qcom/Kconfig | 1 + sound/soc/qcom/sc7180.c | 86 ++++++++++++++++--- 3 files changed, 77 insertions(+), 14 deletions(-) -- 2.25.1
This commit is contained in:
commit
9c2368e353
|
@ -15,7 +15,9 @@ description:
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
compatible:
|
compatible:
|
||||||
const: google,sc7180-trogdor
|
enum:
|
||||||
|
- google,sc7180-trogdor
|
||||||
|
- google,sc7180-coachz
|
||||||
|
|
||||||
audio-routing:
|
audio-routing:
|
||||||
$ref: /schemas/types.yaml#/definitions/non-unique-string-array
|
$ref: /schemas/types.yaml#/definitions/non-unique-string-array
|
||||||
|
|
|
@ -145,6 +145,7 @@ config SND_SOC_SC7180
|
||||||
select SND_SOC_LPASS_SC7180
|
select SND_SOC_LPASS_SC7180
|
||||||
select SND_SOC_MAX98357A
|
select SND_SOC_MAX98357A
|
||||||
select SND_SOC_RT5682_I2C
|
select SND_SOC_RT5682_I2C
|
||||||
|
select SND_SOC_ADAU7002
|
||||||
help
|
help
|
||||||
To add support for audio on Qualcomm Technologies Inc.
|
To add support for audio on Qualcomm Technologies Inc.
|
||||||
SC7180 SoC-based systems.
|
SC7180 SoC-based systems.
|
||||||
|
|
|
@ -221,16 +221,69 @@ static void sc7180_snd_shutdown(struct snd_pcm_substream *substream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sc7180_adau7002_init(struct snd_soc_pcm_runtime *rtd)
|
||||||
|
{
|
||||||
|
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
|
||||||
|
|
||||||
|
switch (cpu_dai->id) {
|
||||||
|
case MI2S_PRIMARY:
|
||||||
|
return 0;
|
||||||
|
case MI2S_SECONDARY:
|
||||||
|
return 0;
|
||||||
|
case LPASS_DP_RX:
|
||||||
|
return sc7180_hdmi_init(rtd);
|
||||||
|
default:
|
||||||
|
dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__,
|
||||||
|
cpu_dai->id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sc7180_adau7002_snd_startup(struct snd_pcm_substream *substream)
|
||||||
|
{
|
||||||
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||||
|
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
|
||||||
|
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
|
||||||
|
|
||||||
|
switch (cpu_dai->id) {
|
||||||
|
case MI2S_PRIMARY:
|
||||||
|
snd_soc_dai_set_fmt(codec_dai,
|
||||||
|
SND_SOC_DAIFMT_CBS_CFS |
|
||||||
|
SND_SOC_DAIFMT_NB_NF |
|
||||||
|
SND_SOC_DAIFMT_I2S);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case MI2S_SECONDARY:
|
||||||
|
break;
|
||||||
|
case LPASS_DP_RX:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__,
|
||||||
|
cpu_dai->id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct snd_soc_ops sc7180_ops = {
|
static const struct snd_soc_ops sc7180_ops = {
|
||||||
.startup = sc7180_snd_startup,
|
.startup = sc7180_snd_startup,
|
||||||
.shutdown = sc7180_snd_shutdown,
|
.shutdown = sc7180_snd_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_ops sc7180_adau7002_ops = {
|
||||||
|
.startup = sc7180_adau7002_snd_startup,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct snd_soc_dapm_widget sc7180_snd_widgets[] = {
|
static const struct snd_soc_dapm_widget sc7180_snd_widgets[] = {
|
||||||
SND_SOC_DAPM_HP("Headphone Jack", NULL),
|
SND_SOC_DAPM_HP("Headphone Jack", NULL),
|
||||||
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_widget sc7180_adau7002_snd_widgets[] = {
|
||||||
|
SND_SOC_DAPM_MIC("DMIC", NULL),
|
||||||
|
};
|
||||||
|
|
||||||
static const char * const dmic_mux_text[] = {
|
static const char * const dmic_mux_text[] = {
|
||||||
"Front Mic",
|
"Front Mic",
|
||||||
"Rear Mic",
|
"Rear Mic",
|
||||||
|
@ -255,23 +308,15 @@ static const struct snd_soc_dapm_route sc7180_snd_dual_mic_audio_route[] = {
|
||||||
{"Dmic Mux", "Rear Mic", "DMIC"},
|
{"Dmic Mux", "Rear Mic", "DMIC"},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void sc7180_add_ops(struct snd_soc_card *card)
|
|
||||||
{
|
|
||||||
struct snd_soc_dai_link *link;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for_each_card_prelinks(card, i, link) {
|
|
||||||
link->ops = &sc7180_ops;
|
|
||||||
link->init = sc7180_init;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int sc7180_snd_platform_probe(struct platform_device *pdev)
|
static int sc7180_snd_platform_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct snd_soc_card *card;
|
struct snd_soc_card *card;
|
||||||
struct sc7180_snd_data *data;
|
struct sc7180_snd_data *data;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
|
struct snd_soc_dai_link *link;
|
||||||
int ret;
|
int ret;
|
||||||
|
int i;
|
||||||
|
bool no_headphone;
|
||||||
|
|
||||||
/* Allocate the private data */
|
/* Allocate the private data */
|
||||||
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
||||||
|
@ -299,17 +344,32 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (of_device_is_compatible(dev->of_node, "google,sc7180-coachz")) {
|
||||||
|
no_headphone = true;
|
||||||
|
card->dapm_widgets = sc7180_adau7002_snd_widgets;
|
||||||
|
card->num_dapm_widgets = ARRAY_SIZE(sc7180_adau7002_snd_widgets);
|
||||||
|
}
|
||||||
|
|
||||||
ret = qcom_snd_parse_of(card);
|
ret = qcom_snd_parse_of(card);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
sc7180_add_ops(card);
|
for_each_card_prelinks(card, i, link) {
|
||||||
|
if (no_headphone) {
|
||||||
|
link->ops = &sc7180_adau7002_ops;
|
||||||
|
link->init = sc7180_adau7002_init;
|
||||||
|
} else {
|
||||||
|
link->ops = &sc7180_ops;
|
||||||
|
link->init = sc7180_init;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return devm_snd_soc_register_card(dev, card);
|
return devm_snd_soc_register_card(dev, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id sc7180_snd_device_id[] = {
|
static const struct of_device_id sc7180_snd_device_id[] = {
|
||||||
{ .compatible = "google,sc7180-trogdor"},
|
{.compatible = "google,sc7180-trogdor"},
|
||||||
|
{.compatible = "google,sc7180-coachz"},
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, sc7180_snd_device_id);
|
MODULE_DEVICE_TABLE(of, sc7180_snd_device_id);
|
||||||
|
|
Loading…
Reference in a new issue