Skip to content

Commit 8b65727

Browse files
Matt PorterJaroslav Kysela
authored andcommitted
[ALSA] hda: add dig mic support for sigmatel codecs
Adds support for digital microphone pin widgets on SigmaTel codecs. Enables support only on the 9205 codecs for now. Signed-off-by: Matt Porter <mporter@embeddedalley.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
1 parent 06bf2f4 commit 8b65727

1 file changed

Lines changed: 125 additions & 5 deletions

File tree

‎sound/pci/hda/patch_sigmatel.c‎

Lines changed: 125 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define STAC_922X_MODELS 4 /* number of 922x models */
4545
#define STAC_D965_3ST 4
4646
#define STAC_D965_5ST 5
47-
#define STAC_927X_MODELS 6 /* number of 922x models */
47+
#define STAC_927X_MODELS 6 /* number of 927x models */
4848

4949
struct sigmatel_spec {
5050
struct snd_kcontrol_new *mixers[4];
@@ -67,6 +67,9 @@ struct sigmatel_spec {
6767
unsigned int num_adcs;
6868
hda_nid_t *mux_nids;
6969
unsigned int num_muxes;
70+
hda_nid_t *dmic_nids;
71+
unsigned int num_dmics;
72+
hda_nid_t dmux_nid;
7073
hda_nid_t dig_in_nid;
7174

7275
/* pin widgets */
@@ -80,6 +83,8 @@ struct sigmatel_spec {
8083
struct snd_kcontrol_new *mixer;
8184

8285
/* capture source */
86+
struct hda_input_mux *dinput_mux;
87+
unsigned int cur_dmux;
8388
struct hda_input_mux *input_mux;
8489
unsigned int cur_mux[3];
8590

@@ -92,6 +97,7 @@ struct sigmatel_spec {
9297
struct auto_pin_cfg autocfg;
9398
unsigned int num_kctl_alloc, num_kctl_used;
9499
struct snd_kcontrol_new *kctl_alloc;
100+
struct hda_input_mux private_dimux;
95101
struct hda_input_mux private_imux;
96102
};
97103

@@ -131,6 +137,10 @@ static hda_nid_t stac9205_mux_nids[2] = {
131137
0x19, 0x1a
132138
};
133139

140+
static hda_nid_t stac9205_dmic_nids[3] = {
141+
0x17, 0x18, 0
142+
};
143+
134144
static hda_nid_t stac9200_pin_nids[8] = {
135145
0x08, 0x09, 0x0d, 0x0e,
136146
0x0f, 0x10, 0x11, 0x12,
@@ -154,6 +164,34 @@ static hda_nid_t stac9205_pin_nids[12] = {
154164

155165
};
156166

167+
static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
168+
struct snd_ctl_elem_info *uinfo)
169+
{
170+
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
171+
struct sigmatel_spec *spec = codec->spec;
172+
return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
173+
}
174+
175+
static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
176+
struct snd_ctl_elem_value *ucontrol)
177+
{
178+
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
179+
struct sigmatel_spec *spec = codec->spec;
180+
181+
ucontrol->value.enumerated.item[0] = spec->cur_dmux;
182+
return 0;
183+
}
184+
185+
static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
186+
struct snd_ctl_elem_value *ucontrol)
187+
{
188+
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
189+
struct sigmatel_spec *spec = codec->spec;
190+
191+
return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
192+
spec->dmux_nid, &spec->cur_dmux);
193+
}
194+
157195
static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
158196
{
159197
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
@@ -279,6 +317,14 @@ static snd_kcontrol_new_t stac927x_mixer[] = {
279317
};
280318

281319
static snd_kcontrol_new_t stac9205_mixer[] = {
320+
{
321+
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
322+
.name = "Digital Input Source",
323+
.count = 1,
324+
.info = stac92xx_dmux_enum_info,
325+
.get = stac92xx_dmux_enum_get,
326+
.put = stac92xx_dmux_enum_put,
327+
},
282328
{
283329
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
284330
.name = "Input Source",
@@ -585,8 +631,8 @@ static struct hda_board_config stac927x_cfg_tbl[] = {
585631

586632
static unsigned int ref9205_pin_configs[12] = {
587633
0x40000100, 0x40000100, 0x01016011, 0x01014010,
588-
0x01813122, 0x01a19021, 0x40000100, 0x40000100,
589-
0x40000100, 0x40000100, 0x01441030, 0x01c41030
634+
0x01813122, 0x01a19021, 0x40000100, 0x40000100,
635+
0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
590636
};
591637

592638
static unsigned int *stac9205_brd_tbl[] = {
@@ -1154,6 +1200,58 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
11541200
return 0;
11551201
}
11561202

1203+
/* labels for dmic mux inputs */
1204+
const char *stac92xx_dmic_labels[5] = {
1205+
"Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1206+
"Digital Mic 3", "Digital Mic 4"
1207+
};
1208+
1209+
/* create playback/capture controls for input pins on dmic capable codecs */
1210+
static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1211+
const struct auto_pin_cfg *cfg)
1212+
{
1213+
struct sigmatel_spec *spec = codec->spec;
1214+
struct hda_input_mux *dimux = &spec->private_dimux;
1215+
hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1216+
int i, j;
1217+
1218+
dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1219+
dimux->items[dimux->num_items].index = 0;
1220+
dimux->num_items++;
1221+
1222+
for (i = 0; i < spec->num_dmics; i++) {
1223+
int index;
1224+
int num_cons;
1225+
unsigned int def_conf;
1226+
1227+
def_conf = snd_hda_codec_read(codec,
1228+
spec->dmic_nids[i],
1229+
0,
1230+
AC_VERB_GET_CONFIG_DEFAULT,
1231+
0);
1232+
if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1233+
continue;
1234+
1235+
num_cons = snd_hda_get_connections(codec,
1236+
spec->dmux_nid,
1237+
con_lst,
1238+
HDA_MAX_NUM_INPUTS);
1239+
for (j = 0; j < num_cons; j++)
1240+
if (con_lst[j] == spec->dmic_nids[i]) {
1241+
index = j;
1242+
goto found;
1243+
}
1244+
continue;
1245+
found:
1246+
dimux->items[dimux->num_items].label =
1247+
stac92xx_dmic_labels[dimux->num_items];
1248+
dimux->items[dimux->num_items].index = index;
1249+
dimux->num_items++;
1250+
}
1251+
1252+
return 0;
1253+
}
1254+
11571255
/* create playback/capture controls for input pins */
11581256
static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
11591257
{
@@ -1238,7 +1336,9 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
12381336
struct sigmatel_spec *spec = codec->spec;
12391337
int err;
12401338

1241-
if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
1339+
if ((err = snd_hda_parse_pin_def_config(codec,
1340+
&spec->autocfg,
1341+
spec->dmic_nids)) < 0)
12421342
return err;
12431343
if (! spec->autocfg.line_outs)
12441344
return 0; /* can't find valid pin config */
@@ -1254,6 +1354,11 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
12541354
(err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
12551355
return err;
12561356

1357+
if (spec->num_dmics > 0)
1358+
if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1359+
&spec->autocfg)) < 0)
1360+
return err;
1361+
12571362
spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12581363
if (spec->multiout.max_channels > 2)
12591364
spec->surr_switch = 1;
@@ -1267,6 +1372,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
12671372
spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12681373

12691374
spec->input_mux = &spec->private_imux;
1375+
spec->dinput_mux = &spec->private_dimux;
12701376

12711377
return 1;
12721378
}
@@ -1366,6 +1472,7 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
13661472
spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13671473

13681474
spec->input_mux = &spec->private_imux;
1475+
spec->dinput_mux = &spec->private_dimux;
13691476

13701477
return 1;
13711478
}
@@ -1448,6 +1555,11 @@ static int stac92xx_init(struct hda_codec *codec)
14481555
stac92xx_auto_set_pinctl(codec, nid, pinctl);
14491556
}
14501557
}
1558+
if (spec->num_dmics > 0)
1559+
for (i = 0; i < spec->num_dmics; i++)
1560+
stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
1561+
AC_PINCTL_IN_EN);
1562+
14511563
if (cfg->dig_out_pin)
14521564
stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
14531565
AC_PINCTL_OUT_EN);
@@ -1618,6 +1730,7 @@ static int patch_stac9200(struct hda_codec *codec)
16181730
spec->adc_nids = stac9200_adc_nids;
16191731
spec->mux_nids = stac9200_mux_nids;
16201732
spec->num_muxes = 1;
1733+
spec->num_dmics = 0;
16211734

16221735
spec->init = stac9200_core_init;
16231736
spec->mixer = stac9200_mixer;
@@ -1663,6 +1776,7 @@ static int patch_stac922x(struct hda_codec *codec)
16631776
spec->adc_nids = stac922x_adc_nids;
16641777
spec->mux_nids = stac922x_mux_nids;
16651778
spec->num_muxes = 2;
1779+
spec->num_dmics = 0;
16661780

16671781
spec->init = stac922x_core_init;
16681782
spec->mixer = stac922x_mixer;
@@ -1714,20 +1828,23 @@ static int patch_stac927x(struct hda_codec *codec)
17141828
spec->adc_nids = stac927x_adc_nids;
17151829
spec->mux_nids = stac927x_mux_nids;
17161830
spec->num_muxes = 3;
1831+
spec->num_dmics = 0;
17171832
spec->init = d965_core_init;
17181833
spec->mixer = stac9227_mixer;
17191834
break;
17201835
case STAC_D965_5ST:
17211836
spec->adc_nids = stac927x_adc_nids;
17221837
spec->mux_nids = stac927x_mux_nids;
17231838
spec->num_muxes = 3;
1839+
spec->num_dmics = 0;
17241840
spec->init = d965_core_init;
17251841
spec->mixer = stac9227_mixer;
17261842
break;
17271843
default:
17281844
spec->adc_nids = stac927x_adc_nids;
17291845
spec->mux_nids = stac927x_mux_nids;
17301846
spec->num_muxes = 3;
1847+
spec->num_dmics = 0;
17311848
spec->init = stac927x_core_init;
17321849
spec->mixer = stac927x_mixer;
17331850
}
@@ -1773,7 +1890,10 @@ static int patch_stac9205(struct hda_codec *codec)
17731890

17741891
spec->adc_nids = stac9205_adc_nids;
17751892
spec->mux_nids = stac9205_mux_nids;
1776-
spec->num_muxes = 3;
1893+
spec->num_muxes = 2;
1894+
spec->dmic_nids = stac9205_dmic_nids;
1895+
spec->num_dmics = 2;
1896+
spec->dmux_nid = 0x1d;
17771897

17781898
spec->init = stac9205_core_init;
17791899
spec->mixer = stac9205_mixer;

0 commit comments

Comments
 (0)