Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Matt Porter and committed by
Jaroslav Kysela
8b65727b 06bf2f49

+125 -5
+125 -5
sound/pci/hda/patch_sigmatel.c
··· 44 44 #define STAC_922X_MODELS 4 /* number of 922x models */ 45 45 #define STAC_D965_3ST 4 46 46 #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 */ 48 48 49 49 struct sigmatel_spec { 50 50 struct snd_kcontrol_new *mixers[4]; ··· 67 67 unsigned int num_adcs; 68 68 hda_nid_t *mux_nids; 69 69 unsigned int num_muxes; 70 + hda_nid_t *dmic_nids; 71 + unsigned int num_dmics; 72 + hda_nid_t dmux_nid; 70 73 hda_nid_t dig_in_nid; 71 74 72 75 /* pin widgets */ ··· 83 80 struct snd_kcontrol_new *mixer; 84 81 85 82 /* capture source */ 83 + struct hda_input_mux *dinput_mux; 84 + unsigned int cur_dmux; 86 85 struct hda_input_mux *input_mux; 87 86 unsigned int cur_mux[3]; 88 87 ··· 97 92 struct auto_pin_cfg autocfg; 98 93 unsigned int num_kctl_alloc, num_kctl_used; 99 94 struct snd_kcontrol_new *kctl_alloc; 95 + struct hda_input_mux private_dimux; 100 96 struct hda_input_mux private_imux; 101 97 }; 102 98 ··· 137 131 0x19, 0x1a 138 132 }; 139 133 134 + static hda_nid_t stac9205_dmic_nids[3] = { 135 + 0x17, 0x18, 0 136 + }; 137 + 140 138 static hda_nid_t stac9200_pin_nids[8] = { 141 139 0x08, 0x09, 0x0d, 0x0e, 142 140 0x0f, 0x10, 0x11, 0x12, ··· 163 153 0x21, 0x22, 164 154 165 155 }; 156 + 157 + static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, 158 + struct snd_ctl_elem_info *uinfo) 159 + { 160 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 161 + struct sigmatel_spec *spec = codec->spec; 162 + return snd_hda_input_mux_info(spec->dinput_mux, uinfo); 163 + } 164 + 165 + static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, 166 + struct snd_ctl_elem_value *ucontrol) 167 + { 168 + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 169 + struct sigmatel_spec *spec = codec->spec; 170 + 171 + ucontrol->value.enumerated.item[0] = spec->cur_dmux; 172 + return 0; 173 + } 174 + 175 + static int stac92xx_dmux_enum_put(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 + return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, 182 + spec->dmux_nid, &spec->cur_dmux); 183 + } 166 184 167 185 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 168 186 { ··· 317 279 }; 318 280 319 281 static snd_kcontrol_new_t stac9205_mixer[] = { 282 + { 283 + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 284 + .name = "Digital Input Source", 285 + .count = 1, 286 + .info = stac92xx_dmux_enum_info, 287 + .get = stac92xx_dmux_enum_get, 288 + .put = stac92xx_dmux_enum_put, 289 + }, 320 290 { 321 291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 322 292 .name = "Input Source", ··· 631 585 632 586 static unsigned int ref9205_pin_configs[12] = { 633 587 0x40000100, 0x40000100, 0x01016011, 0x01014010, 634 - 0x01813122, 0x01a19021, 0x40000100, 0x40000100, 635 - 0x40000100, 0x40000100, 0x01441030, 0x01c41030 588 + 0x01813122, 0x01a19021, 0x40000100, 0x40000100, 589 + 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 636 590 }; 637 591 638 592 static unsigned int *stac9205_brd_tbl[] = { ··· 1200 1154 return 0; 1201 1155 } 1202 1156 1157 + /* labels for dmic mux inputs */ 1158 + const char *stac92xx_dmic_labels[5] = { 1159 + "Analog Inputs", "Digital Mic 1", "Digital Mic 2", 1160 + "Digital Mic 3", "Digital Mic 4" 1161 + }; 1162 + 1163 + /* create playback/capture controls for input pins on dmic capable codecs */ 1164 + static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, 1165 + const struct auto_pin_cfg *cfg) 1166 + { 1167 + struct sigmatel_spec *spec = codec->spec; 1168 + struct hda_input_mux *dimux = &spec->private_dimux; 1169 + hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 1170 + int i, j; 1171 + 1172 + dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; 1173 + dimux->items[dimux->num_items].index = 0; 1174 + dimux->num_items++; 1175 + 1176 + for (i = 0; i < spec->num_dmics; i++) { 1177 + int index; 1178 + int num_cons; 1179 + unsigned int def_conf; 1180 + 1181 + def_conf = snd_hda_codec_read(codec, 1182 + spec->dmic_nids[i], 1183 + 0, 1184 + AC_VERB_GET_CONFIG_DEFAULT, 1185 + 0); 1186 + if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 1187 + continue; 1188 + 1189 + num_cons = snd_hda_get_connections(codec, 1190 + spec->dmux_nid, 1191 + con_lst, 1192 + HDA_MAX_NUM_INPUTS); 1193 + for (j = 0; j < num_cons; j++) 1194 + if (con_lst[j] == spec->dmic_nids[i]) { 1195 + index = j; 1196 + goto found; 1197 + } 1198 + continue; 1199 + found: 1200 + dimux->items[dimux->num_items].label = 1201 + stac92xx_dmic_labels[dimux->num_items]; 1202 + dimux->items[dimux->num_items].index = index; 1203 + dimux->num_items++; 1204 + } 1205 + 1206 + return 0; 1207 + } 1208 + 1203 1209 /* create playback/capture controls for input pins */ 1204 1210 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 1205 1211 { ··· 1336 1238 struct sigmatel_spec *spec = codec->spec; 1337 1239 int err; 1338 1240 1339 - if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) 1241 + if ((err = snd_hda_parse_pin_def_config(codec, 1242 + &spec->autocfg, 1243 + spec->dmic_nids)) < 0) 1340 1244 return err; 1341 1245 if (! spec->autocfg.line_outs) 1342 1246 return 0; /* can't find valid pin config */ ··· 1354 1254 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) 1355 1255 return err; 1356 1256 1257 + if (spec->num_dmics > 0) 1258 + if ((err = stac92xx_auto_create_dmic_input_ctls(codec, 1259 + &spec->autocfg)) < 0) 1260 + return err; 1261 + 1357 1262 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 1358 1263 if (spec->multiout.max_channels > 2) 1359 1264 spec->surr_switch = 1; ··· 1372 1267 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 1373 1268 1374 1269 spec->input_mux = &spec->private_imux; 1270 + spec->dinput_mux = &spec->private_dimux; 1375 1271 1376 1272 return 1; 1377 1273 } ··· 1472 1366 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 1473 1367 1474 1368 spec->input_mux = &spec->private_imux; 1369 + spec->dinput_mux = &spec->private_dimux; 1475 1370 1476 1371 return 1; 1477 1372 } ··· 1555 1448 stac92xx_auto_set_pinctl(codec, nid, pinctl); 1556 1449 } 1557 1450 } 1451 + if (spec->num_dmics > 0) 1452 + for (i = 0; i < spec->num_dmics; i++) 1453 + stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], 1454 + AC_PINCTL_IN_EN); 1455 + 1558 1456 if (cfg->dig_out_pin) 1559 1457 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 1560 1458 AC_PINCTL_OUT_EN); ··· 1730 1618 spec->adc_nids = stac9200_adc_nids; 1731 1619 spec->mux_nids = stac9200_mux_nids; 1732 1620 spec->num_muxes = 1; 1621 + spec->num_dmics = 0; 1733 1622 1734 1623 spec->init = stac9200_core_init; 1735 1624 spec->mixer = stac9200_mixer; ··· 1776 1663 spec->adc_nids = stac922x_adc_nids; 1777 1664 spec->mux_nids = stac922x_mux_nids; 1778 1665 spec->num_muxes = 2; 1666 + spec->num_dmics = 0; 1779 1667 1780 1668 spec->init = stac922x_core_init; 1781 1669 spec->mixer = stac922x_mixer; ··· 1828 1714 spec->adc_nids = stac927x_adc_nids; 1829 1715 spec->mux_nids = stac927x_mux_nids; 1830 1716 spec->num_muxes = 3; 1717 + spec->num_dmics = 0; 1831 1718 spec->init = d965_core_init; 1832 1719 spec->mixer = stac9227_mixer; 1833 1720 break; ··· 1836 1721 spec->adc_nids = stac927x_adc_nids; 1837 1722 spec->mux_nids = stac927x_mux_nids; 1838 1723 spec->num_muxes = 3; 1724 + spec->num_dmics = 0; 1839 1725 spec->init = d965_core_init; 1840 1726 spec->mixer = stac9227_mixer; 1841 1727 break; ··· 1844 1728 spec->adc_nids = stac927x_adc_nids; 1845 1729 spec->mux_nids = stac927x_mux_nids; 1846 1730 spec->num_muxes = 3; 1731 + spec->num_dmics = 0; 1847 1732 spec->init = stac927x_core_init; 1848 1733 spec->mixer = stac927x_mixer; 1849 1734 } ··· 1890 1773 1891 1774 spec->adc_nids = stac9205_adc_nids; 1892 1775 spec->mux_nids = stac9205_mux_nids; 1893 - spec->num_muxes = 3; 1776 + spec->num_muxes = 2; 1777 + spec->dmic_nids = stac9205_dmic_nids; 1778 + spec->num_dmics = 2; 1779 + spec->dmux_nid = 0x1d; 1894 1780 1895 1781 spec->init = stac9205_core_init; 1896 1782 spec->mixer = stac9205_mixer;