Skip to content

Commit 798313f

Browse files
naveen-manoharbroonie
authored andcommitted
ASoC: Intel: sof_sdw: Add Volteer support with RT5682 SNDW helper function
Add support for Google Volteer device. As per new unified soundwire machine driver, add rt5682-sdw helper function, which configures codec to Link0. Signed-off-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Naveen Manohar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 095ee71 commit 798313f

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

sound/soc/intel/boards/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ config SND_SOC_INTEL_SOUNDWIRE_SOF_MACH
538538
select SND_SOC_RT1308_SDW
539539
select SND_SOC_RT1308
540540
select SND_SOC_RT715_SDW
541+
select SND_SOC_RT5682_SDW
541542
select SND_SOC_DMIC
542543
help
543544
Add support for Intel SoundWire-based platforms connected to

sound/soc/intel/boards/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o hda_dsp_common.o
3434
snd-soc-sof-sdw-objs += sof_sdw.o \
3535
sof_sdw_rt711.o sof_sdw_rt700.o \
3636
sof_sdw_rt1308.o sof_sdw_rt715.o \
37+
sof_sdw_rt5682.o \
3738
sof_sdw_dmic.o sof_sdw_hdmi.o hda_dsp_common.o
3839
obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o
3940
obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o

sound/soc/intel/boards/sof_sdw.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {
9191
},
9292
.driver_data = (void *)SOF_SDW_PCH_DMIC,
9393
},
94+
{
95+
.callback = sof_sdw_quirk_cb,
96+
.matches = {
97+
DMI_MATCH(DMI_SYS_VENDOR, "Google"),
98+
DMI_MATCH(DMI_PRODUCT_NAME, "Volteer"),
99+
},
100+
.driver_data = (void *)(SOF_SDW_TGL_HDMI | SOF_SDW_PCH_DMIC),
101+
},
94102

95103
{}
96104
};
@@ -128,6 +136,10 @@ static struct snd_soc_codec_conf codec_conf[] = {
128136
.dlc = COMP_CODEC_CONF("sdw:3:25d:715:0"),
129137
.name_prefix = "rt715",
130138
},
139+
{
140+
.dlc = COMP_CODEC_CONF("sdw:0:25d:5682:0"),
141+
.name_prefix = "rt5682",
142+
},
131143
};
132144

133145
static struct snd_soc_dai_link_component dmic_component[] = {
@@ -187,6 +199,12 @@ static struct sof_sdw_codec_info codec_info_list[] = {
187199
.dai_name = "rt715-aif2",
188200
.init = sof_sdw_rt715_init,
189201
},
202+
{
203+
.id = 0x5682,
204+
.direction = {true, true},
205+
.dai_name = "rt5682-sdw",
206+
.init = sof_sdw_rt5682_init,
207+
},
190208
};
191209

192210
static inline int find_codec_info_part(unsigned int part_id)

sound/soc/intel/boards/sof_sdw_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,10 @@ int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link,
105105
struct sof_sdw_codec_info *info,
106106
bool playback);
107107

108+
/* RT5682 support */
109+
int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
110+
struct snd_soc_dai_link *dai_links,
111+
struct sof_sdw_codec_info *info,
112+
bool playback);
113+
108114
#endif
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Copyright (c) 2020 Intel Corporation
3+
4+
/*
5+
* sof_sdw_rt5682 - Helpers to handle RT5682 from generic machine driver
6+
*/
7+
8+
#include <linux/device.h>
9+
#include <linux/errno.h>
10+
#include <linux/input.h>
11+
#include <linux/soundwire/sdw.h>
12+
#include <linux/soundwire/sdw_type.h>
13+
#include <sound/soc.h>
14+
#include <sound/soc-acpi.h>
15+
#include <sound/jack.h>
16+
#include "sof_sdw_common.h"
17+
18+
static const struct snd_soc_dapm_widget rt5682_widgets[] = {
19+
SND_SOC_DAPM_HP("Headphone", NULL),
20+
SND_SOC_DAPM_MIC("Headset Mic", NULL),
21+
};
22+
23+
static const struct snd_soc_dapm_route rt5682_map[] = {
24+
/*Headphones*/
25+
{ "Headphone", NULL, "rt5682 HPOL" },
26+
{ "Headphone", NULL, "rt5682 HPOR" },
27+
{ "rt5682 IN1P", NULL, "Headset Mic" },
28+
};
29+
30+
static const struct snd_kcontrol_new rt5682_controls[] = {
31+
SOC_DAPM_PIN_SWITCH("Headphone"),
32+
SOC_DAPM_PIN_SWITCH("Headset Mic"),
33+
};
34+
35+
static struct snd_soc_jack_pin rt5682_jack_pins[] = {
36+
{
37+
.pin = "Headphone",
38+
.mask = SND_JACK_HEADPHONE,
39+
},
40+
{
41+
.pin = "Headset Mic",
42+
.mask = SND_JACK_MICROPHONE,
43+
},
44+
};
45+
46+
static int rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd)
47+
{
48+
struct snd_soc_card *card = rtd->card;
49+
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
50+
struct snd_soc_component *component = rtd->codec_dai->component;
51+
struct snd_soc_jack *jack;
52+
int ret;
53+
54+
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
55+
"%s hs:rt5682",
56+
card->components);
57+
if (!card->components)
58+
return -ENOMEM;
59+
60+
ret = snd_soc_add_card_controls(card, rt5682_controls,
61+
ARRAY_SIZE(rt5682_controls));
62+
if (ret) {
63+
dev_err(card->dev, "rt5682 control addition failed: %d\n", ret);
64+
return ret;
65+
}
66+
67+
ret = snd_soc_dapm_new_controls(&card->dapm, rt5682_widgets,
68+
ARRAY_SIZE(rt5682_widgets));
69+
if (ret) {
70+
dev_err(card->dev, "rt5682 widgets addition failed: %d\n", ret);
71+
return ret;
72+
}
73+
74+
ret = snd_soc_dapm_add_routes(&card->dapm, rt5682_map,
75+
ARRAY_SIZE(rt5682_map));
76+
77+
if (ret) {
78+
dev_err(card->dev, "rt5682 map addition failed: %d\n", ret);
79+
return ret;
80+
}
81+
82+
ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
83+
SND_JACK_HEADSET | SND_JACK_BTN_0 |
84+
SND_JACK_BTN_1 | SND_JACK_BTN_2 |
85+
SND_JACK_BTN_3,
86+
&ctx->sdw_headset,
87+
rt5682_jack_pins,
88+
ARRAY_SIZE(rt5682_jack_pins));
89+
if (ret) {
90+
dev_err(rtd->card->dev, "Headset Jack creation failed: %d\n",
91+
ret);
92+
return ret;
93+
}
94+
95+
jack = &ctx->sdw_headset;
96+
97+
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
98+
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
99+
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
100+
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
101+
102+
ret = snd_soc_component_set_jack(component, jack, NULL);
103+
104+
if (ret)
105+
dev_err(rtd->card->dev, "Headset Jack call-back failed: %d\n",
106+
ret);
107+
108+
return ret;
109+
}
110+
111+
int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
112+
struct snd_soc_dai_link *dai_links,
113+
struct sof_sdw_codec_info *info,
114+
bool playback)
115+
{
116+
/*
117+
* headset should be initialized once.
118+
* Do it with dai link for playback.
119+
*/
120+
if (!playback)
121+
return 0;
122+
123+
dai_links->init = rt5682_rtd_init;
124+
125+
return 0;
126+
}

0 commit comments

Comments
 (0)