Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
| 4 | * HD audio interface patch for SigmaTel STAC92xx |
| 5 | * |
| 6 | * Copyright (c) 2005 Embedded Alley Solutions, Inc. |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 7 | * Matt Porter <mporter@embeddedalley.com> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 8 | * |
| 9 | * Based on patch_cmedia.c and patch_realtek.c |
| 10 | * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> |
| 11 | * |
| 12 | * This driver is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This driver is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <sound/driver.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/delay.h> |
| 30 | #include <linux/slab.h> |
| 31 | #include <linux/pci.h> |
| 32 | #include <sound/core.h> |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 33 | #include <sound/asoundef.h> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 34 | #include "hda_codec.h" |
| 35 | #include "hda_local.h" |
| 36 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 37 | #define NUM_CONTROL_ALLOC 32 |
| 38 | #define STAC_HP_EVENT 0x37 |
| 39 | #define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT) |
| 40 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 41 | #define STAC_REF 0 |
| 42 | #define STAC_D945GTP3 1 |
| 43 | #define STAC_D945GTP5 2 |
| 44 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 45 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 46 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 47 | unsigned int num_mixers; |
| 48 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 49 | int board_config; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 50 | unsigned int surr_switch: 1; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 51 | unsigned int line_switch: 1; |
| 52 | unsigned int mic_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 53 | unsigned int alt_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 54 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 55 | /* playback */ |
| 56 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 57 | hda_nid_t dac_nids[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 58 | |
| 59 | /* capture */ |
| 60 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 61 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 62 | hda_nid_t *mux_nids; |
| 63 | unsigned int num_muxes; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 64 | hda_nid_t dig_in_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 65 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 66 | /* pin widgets */ |
| 67 | hda_nid_t *pin_nids; |
| 68 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 69 | unsigned int *pin_configs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 70 | |
| 71 | /* codec specific stuff */ |
| 72 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 73 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 74 | |
| 75 | /* capture source */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 76 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 77 | unsigned int cur_mux[3]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 78 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 79 | /* i/o switches */ |
| 80 | unsigned int io_switch[2]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 81 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 82 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 83 | |
| 84 | /* dynamic controls and input_mux */ |
| 85 | struct auto_pin_cfg autocfg; |
| 86 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 87 | struct snd_kcontrol_new *kctl_alloc; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 88 | struct hda_input_mux private_imux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | static hda_nid_t stac9200_adc_nids[1] = { |
| 92 | 0x03, |
| 93 | }; |
| 94 | |
| 95 | static hda_nid_t stac9200_mux_nids[1] = { |
| 96 | 0x0c, |
| 97 | }; |
| 98 | |
| 99 | static hda_nid_t stac9200_dac_nids[1] = { |
| 100 | 0x02, |
| 101 | }; |
| 102 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 103 | static hda_nid_t stac922x_adc_nids[2] = { |
| 104 | 0x06, 0x07, |
| 105 | }; |
| 106 | |
| 107 | static hda_nid_t stac922x_mux_nids[2] = { |
| 108 | 0x12, 0x13, |
| 109 | }; |
| 110 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 111 | static hda_nid_t stac927x_adc_nids[3] = { |
| 112 | 0x07, 0x08, 0x09 |
| 113 | }; |
| 114 | |
| 115 | static hda_nid_t stac927x_mux_nids[3] = { |
| 116 | 0x15, 0x16, 0x17 |
| 117 | }; |
| 118 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 119 | static hda_nid_t stac9200_pin_nids[8] = { |
| 120 | 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | static hda_nid_t stac922x_pin_nids[10] = { |
| 124 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 125 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 126 | }; |
| 127 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 128 | static hda_nid_t stac927x_pin_nids[14] = { |
| 129 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 130 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 131 | 0x14, 0x21, 0x22, 0x23, |
| 132 | }; |
| 133 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 134 | static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 135 | { |
| 136 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 137 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 138 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 139 | } |
| 140 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 141 | static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 142 | { |
| 143 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 144 | struct sigmatel_spec *spec = codec->spec; |
| 145 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 146 | |
| 147 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 148 | return 0; |
| 149 | } |
| 150 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 151 | static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 152 | { |
| 153 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 154 | struct sigmatel_spec *spec = codec->spec; |
| 155 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 156 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 157 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 158 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 159 | } |
| 160 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 161 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 162 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 163 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 164 | {} |
| 165 | }; |
| 166 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 167 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 168 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 169 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 170 | {} |
| 171 | }; |
| 172 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 173 | static struct hda_verb stac927x_core_init[] = { |
| 174 | /* set master volume and direct control */ |
| 175 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 176 | {} |
| 177 | }; |
| 178 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 179 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 180 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 181 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
| 182 | { |
| 183 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 184 | .name = "Input Source", |
| 185 | .count = 1, |
| 186 | .info = stac92xx_mux_enum_info, |
| 187 | .get = stac92xx_mux_enum_get, |
| 188 | .put = stac92xx_mux_enum_put, |
| 189 | }, |
| 190 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 191 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 192 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 193 | { } /* end */ |
| 194 | }; |
| 195 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 196 | /* This needs to be generated dynamically based on sequence */ |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 197 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 198 | { |
| 199 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 200 | .name = "Input Source", |
| 201 | .count = 1, |
| 202 | .info = stac92xx_mux_enum_info, |
| 203 | .get = stac92xx_mux_enum_get, |
| 204 | .put = stac92xx_mux_enum_put, |
| 205 | }, |
| 206 | HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), |
Takashi Iwai | 0fd1708 | 2006-01-13 18:46:21 +0100 | [diff] [blame] | 207 | HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 208 | HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 209 | { } /* end */ |
| 210 | }; |
| 211 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 212 | static snd_kcontrol_new_t stac927x_mixer[] = { |
| 213 | { |
| 214 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 215 | .name = "Input Source", |
| 216 | .count = 1, |
| 217 | .info = stac92xx_mux_enum_info, |
| 218 | .get = stac92xx_mux_enum_get, |
| 219 | .put = stac92xx_mux_enum_put, |
| 220 | }, |
| 221 | HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 222 | HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT), |
| 223 | HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 224 | { } /* end */ |
| 225 | }; |
| 226 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 227 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 228 | { |
| 229 | struct sigmatel_spec *spec = codec->spec; |
| 230 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 231 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 232 | |
| 233 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 234 | if (err < 0) |
| 235 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 236 | |
| 237 | for (i = 0; i < spec->num_mixers; i++) { |
| 238 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 239 | if (err < 0) |
| 240 | return err; |
| 241 | } |
| 242 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 243 | if (spec->multiout.dig_out_nid) { |
| 244 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 245 | if (err < 0) |
| 246 | return err; |
| 247 | } |
| 248 | if (spec->dig_in_nid) { |
| 249 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 250 | if (err < 0) |
| 251 | return err; |
| 252 | } |
| 253 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 256 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 257 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 258 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 259 | }; |
| 260 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 261 | static unsigned int *stac9200_brd_tbl[] = { |
| 262 | ref9200_pin_configs, |
| 263 | }; |
| 264 | |
| 265 | static struct hda_board_config stac9200_cfg_tbl[] = { |
| 266 | { .modelname = "ref", |
| 267 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 268 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 269 | .config = STAC_REF }, |
| 270 | {} /* terminator */ |
| 271 | }; |
| 272 | |
| 273 | static unsigned int ref922x_pin_configs[10] = { |
| 274 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 275 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 276 | 0x40000100, 0x40000100, |
| 277 | }; |
| 278 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 279 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 280 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 281 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 282 | 0x02a19120, 0x40000100, |
| 283 | }; |
| 284 | |
| 285 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 286 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 287 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 288 | 0x02a19320, 0x40000100, |
| 289 | }; |
| 290 | |
| 291 | static unsigned int *stac922x_brd_tbl[] = { |
| 292 | ref922x_pin_configs, |
| 293 | d945gtp3_pin_configs, |
| 294 | d945gtp5_pin_configs, |
| 295 | }; |
| 296 | |
| 297 | static struct hda_board_config stac922x_cfg_tbl[] = { |
| 298 | { .modelname = "ref", |
| 299 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 300 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 301 | .config = STAC_REF }, /* SigmaTel reference board */ |
| 302 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 303 | .pci_subdevice = 0x0101, |
| 304 | .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ |
| 305 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
Takashi Iwai | 353b9e6 | 2006-02-16 18:16:17 +0100 | [diff] [blame^] | 306 | .pci_subdevice = 0x0202, |
| 307 | .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack, 9221 A1 */ |
| 308 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 309 | .pci_subdevice = 0x0b0b, |
| 310 | .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack, 9221 A1 */ |
| 311 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 312 | .pci_subdevice = 0x0404, |
| 313 | .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */ |
| 314 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 315 | .pci_subdevice = 0x0303, |
| 316 | .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */ |
| 317 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 318 | .pci_subdevice = 0x0013, |
| 319 | .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ |
Matt Porter | d62c40e | 2006-01-23 15:26:27 +0100 | [diff] [blame] | 320 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 321 | .pci_subdevice = 0x0417, |
| 322 | .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */ |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 323 | {} /* terminator */ |
| 324 | }; |
| 325 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 326 | static unsigned int ref927x_pin_configs[14] = { |
| 327 | 0x01813122, 0x01a19021, 0x01014010, 0x01016011, |
| 328 | 0x01012012, 0x01011014, 0x40000100, 0x40000100, |
| 329 | 0x40000100, 0x40000100, 0x40000100, 0x01441030, |
| 330 | 0x01c41030, 0x40000100, |
| 331 | }; |
| 332 | |
| 333 | static unsigned int *stac927x_brd_tbl[] = { |
| 334 | ref927x_pin_configs, |
| 335 | }; |
| 336 | |
| 337 | static struct hda_board_config stac927x_cfg_tbl[] = { |
| 338 | { .modelname = "ref", |
| 339 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 340 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 341 | .config = STAC_REF }, /* SigmaTel reference board */ |
| 342 | {} /* terminator */ |
| 343 | }; |
| 344 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 345 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
| 346 | { |
| 347 | int i; |
| 348 | struct sigmatel_spec *spec = codec->spec; |
| 349 | unsigned int pin_cfg; |
| 350 | |
| 351 | for (i=0; i < spec->num_pins; i++) { |
| 352 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 353 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, |
| 354 | spec->pin_configs[i] & 0x000000ff); |
| 355 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 356 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, |
| 357 | (spec->pin_configs[i] & 0x0000ff00) >> 8); |
| 358 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 359 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, |
| 360 | (spec->pin_configs[i] & 0x00ff0000) >> 16); |
| 361 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 362 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, |
| 363 | spec->pin_configs[i] >> 24); |
| 364 | pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, |
| 365 | AC_VERB_GET_CONFIG_DEFAULT, |
| 366 | 0x00); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 367 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 368 | } |
| 369 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 370 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 371 | /* |
| 372 | * Analog playback callbacks |
| 373 | */ |
| 374 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 375 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 376 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 377 | { |
| 378 | struct sigmatel_spec *spec = codec->spec; |
| 379 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 380 | } |
| 381 | |
| 382 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 383 | struct hda_codec *codec, |
| 384 | unsigned int stream_tag, |
| 385 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 386 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 387 | { |
| 388 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 389 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 393 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 394 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 395 | { |
| 396 | struct sigmatel_spec *spec = codec->spec; |
| 397 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 398 | } |
| 399 | |
| 400 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 401 | * Digital playback callbacks |
| 402 | */ |
| 403 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 404 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 405 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 406 | { |
| 407 | struct sigmatel_spec *spec = codec->spec; |
| 408 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 409 | } |
| 410 | |
| 411 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 412 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 413 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 414 | { |
| 415 | struct sigmatel_spec *spec = codec->spec; |
| 416 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 417 | } |
| 418 | |
| 419 | |
| 420 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 421 | * Analog capture callbacks |
| 422 | */ |
| 423 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 424 | struct hda_codec *codec, |
| 425 | unsigned int stream_tag, |
| 426 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 427 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 428 | { |
| 429 | struct sigmatel_spec *spec = codec->spec; |
| 430 | |
| 431 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 432 | stream_tag, 0, format); |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 437 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 438 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 439 | { |
| 440 | struct sigmatel_spec *spec = codec->spec; |
| 441 | |
| 442 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 443 | return 0; |
| 444 | } |
| 445 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 446 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 447 | .substreams = 1, |
| 448 | .channels_min = 2, |
| 449 | .channels_max = 2, |
| 450 | /* NID is set in stac92xx_build_pcms */ |
| 451 | .ops = { |
| 452 | .open = stac92xx_dig_playback_pcm_open, |
| 453 | .close = stac92xx_dig_playback_pcm_close |
| 454 | }, |
| 455 | }; |
| 456 | |
| 457 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 458 | .substreams = 1, |
| 459 | .channels_min = 2, |
| 460 | .channels_max = 2, |
| 461 | /* NID is set in stac92xx_build_pcms */ |
| 462 | }; |
| 463 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 464 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 465 | .substreams = 1, |
| 466 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 467 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 468 | .nid = 0x02, /* NID to query formats and rates */ |
| 469 | .ops = { |
| 470 | .open = stac92xx_playback_pcm_open, |
| 471 | .prepare = stac92xx_playback_pcm_prepare, |
| 472 | .cleanup = stac92xx_playback_pcm_cleanup |
| 473 | }, |
| 474 | }; |
| 475 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 476 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 477 | .substreams = 1, |
| 478 | .channels_min = 2, |
| 479 | .channels_max = 2, |
| 480 | .nid = 0x06, /* NID to query formats and rates */ |
| 481 | .ops = { |
| 482 | .open = stac92xx_playback_pcm_open, |
| 483 | .prepare = stac92xx_playback_pcm_prepare, |
| 484 | .cleanup = stac92xx_playback_pcm_cleanup |
| 485 | }, |
| 486 | }; |
| 487 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 488 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
| 489 | .substreams = 2, |
| 490 | .channels_min = 2, |
| 491 | .channels_max = 2, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 492 | /* NID is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 493 | .ops = { |
| 494 | .prepare = stac92xx_capture_pcm_prepare, |
| 495 | .cleanup = stac92xx_capture_pcm_cleanup |
| 496 | }, |
| 497 | }; |
| 498 | |
| 499 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 500 | { |
| 501 | struct sigmatel_spec *spec = codec->spec; |
| 502 | struct hda_pcm *info = spec->pcm_rec; |
| 503 | |
| 504 | codec->num_pcms = 1; |
| 505 | codec->pcm_info = info; |
| 506 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 507 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 508 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 509 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 510 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 511 | |
| 512 | if (spec->alt_switch) { |
| 513 | codec->num_pcms++; |
| 514 | info++; |
| 515 | info->name = "STAC92xx Analog Alt"; |
| 516 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 517 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 518 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 519 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 520 | codec->num_pcms++; |
| 521 | info++; |
| 522 | info->name = "STAC92xx Digital"; |
| 523 | if (spec->multiout.dig_out_nid) { |
| 524 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 525 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 526 | } |
| 527 | if (spec->dig_in_nid) { |
| 528 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 529 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 530 | } |
| 531 | } |
| 532 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 533 | return 0; |
| 534 | } |
| 535 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 536 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 537 | |
| 538 | { |
| 539 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 540 | } |
| 541 | |
| 542 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 543 | { |
| 544 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 545 | uinfo->count = 1; |
| 546 | uinfo->value.integer.min = 0; |
| 547 | uinfo->value.integer.max = 1; |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 552 | { |
| 553 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 554 | struct sigmatel_spec *spec = codec->spec; |
| 555 | int io_idx = kcontrol-> private_value & 0xff; |
| 556 | |
| 557 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 558 | return 0; |
| 559 | } |
| 560 | |
| 561 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 562 | { |
| 563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 564 | struct sigmatel_spec *spec = codec->spec; |
| 565 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 566 | int io_idx = kcontrol-> private_value & 0xff; |
| 567 | unsigned short val = ucontrol->value.integer.value[0]; |
| 568 | |
| 569 | spec->io_switch[io_idx] = val; |
| 570 | |
| 571 | if (val) |
| 572 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 573 | else |
| 574 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN); |
| 575 | |
| 576 | return 1; |
| 577 | } |
| 578 | |
| 579 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 580 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 581 | .name = xname, \ |
| 582 | .index = 0, \ |
| 583 | .info = stac92xx_io_switch_info, \ |
| 584 | .get = stac92xx_io_switch_get, \ |
| 585 | .put = stac92xx_io_switch_put, \ |
| 586 | .private_value = xpval, \ |
| 587 | } |
| 588 | |
| 589 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 590 | enum { |
| 591 | STAC_CTL_WIDGET_VOL, |
| 592 | STAC_CTL_WIDGET_MUTE, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 593 | STAC_CTL_WIDGET_IO_SWITCH, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 594 | }; |
| 595 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 596 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 597 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 598 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 599 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 600 | }; |
| 601 | |
| 602 | /* add dynamic controls */ |
| 603 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) |
| 604 | { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 605 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 606 | |
| 607 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 608 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 609 | |
| 610 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 611 | if (! knew) |
| 612 | return -ENOMEM; |
| 613 | if (spec->kctl_alloc) { |
| 614 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 615 | kfree(spec->kctl_alloc); |
| 616 | } |
| 617 | spec->kctl_alloc = knew; |
| 618 | spec->num_kctl_alloc = num; |
| 619 | } |
| 620 | |
| 621 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 622 | *knew = stac92xx_control_templates[type]; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 623 | knew->name = kstrdup(name, GFP_KERNEL); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 624 | if (! knew->name) |
| 625 | return -ENOMEM; |
| 626 | knew->private_value = val; |
| 627 | spec->num_kctl_used++; |
| 628 | return 0; |
| 629 | } |
| 630 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 631 | /* flag inputs as additional dynamic lineouts */ |
| 632 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 633 | { |
| 634 | struct sigmatel_spec *spec = codec->spec; |
| 635 | |
| 636 | switch (cfg->line_outs) { |
| 637 | case 3: |
| 638 | /* add line-in as side */ |
| 639 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 640 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; |
| 641 | spec->line_switch = 1; |
| 642 | cfg->line_outs++; |
| 643 | } |
| 644 | break; |
| 645 | case 2: |
| 646 | /* add line-in as clfe and mic as side */ |
| 647 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 648 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; |
| 649 | spec->line_switch = 1; |
| 650 | cfg->line_outs++; |
| 651 | } |
| 652 | if (cfg->input_pins[AUTO_PIN_MIC]) { |
| 653 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; |
| 654 | spec->mic_switch = 1; |
| 655 | cfg->line_outs++; |
| 656 | } |
| 657 | break; |
| 658 | case 1: |
| 659 | /* add line-in as surr and mic as clfe */ |
| 660 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 661 | cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; |
| 662 | spec->line_switch = 1; |
| 663 | cfg->line_outs++; |
| 664 | } |
| 665 | if (cfg->input_pins[AUTO_PIN_MIC]) { |
| 666 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; |
| 667 | spec->mic_switch = 1; |
| 668 | cfg->line_outs++; |
| 669 | } |
| 670 | break; |
| 671 | } |
| 672 | |
| 673 | return 0; |
| 674 | } |
| 675 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 676 | /* |
| 677 | * XXX The line_out pin widget connection list may not be set to the |
| 678 | * desired DAC nid. This is the case on 927x where ports A and B can |
| 679 | * be routed to several DACs. |
| 680 | * |
| 681 | * This requires an analysis of the line-out/hp pin configuration |
| 682 | * to provide a best fit for pin/DAC configurations that are routable. |
| 683 | * For now, 927x DAC4 is not supported and 927x DAC1 output to ports |
| 684 | * A and B is not supported. |
| 685 | */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 686 | /* fill in the dac_nids table from the parsed pin configuration */ |
| 687 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 688 | { |
| 689 | struct sigmatel_spec *spec = codec->spec; |
| 690 | hda_nid_t nid; |
| 691 | int i; |
| 692 | |
| 693 | /* check the pins hardwired to audio widget */ |
| 694 | for (i = 0; i < cfg->line_outs; i++) { |
| 695 | nid = cfg->line_out_pins[i]; |
| 696 | spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, |
| 697 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 698 | } |
| 699 | |
Takashi Iwai | ad0651f | 2006-01-24 10:34:34 +0100 | [diff] [blame] | 700 | if (cfg->line_outs) |
| 701 | spec->multiout.num_dacs = cfg->line_outs; |
| 702 | else if (cfg->hp_pin) { |
| 703 | spec->multiout.dac_nids[0] = snd_hda_codec_read(codec, cfg->hp_pin, 0, |
| 704 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 705 | spec->multiout.num_dacs = 1; |
| 706 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 707 | |
| 708 | return 0; |
| 709 | } |
| 710 | |
| 711 | /* add playback controls from the parsed DAC table */ |
| 712 | static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg) |
| 713 | { |
| 714 | char name[32]; |
| 715 | static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; |
| 716 | hda_nid_t nid; |
| 717 | int i, err; |
| 718 | |
| 719 | for (i = 0; i < cfg->line_outs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 720 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 721 | continue; |
| 722 | |
| 723 | nid = spec->multiout.dac_nids[i]; |
| 724 | |
| 725 | if (i == 2) { |
| 726 | /* Center/LFE */ |
| 727 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume", |
| 728 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 729 | return err; |
| 730 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume", |
| 731 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 732 | return err; |
| 733 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch", |
| 734 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 735 | return err; |
| 736 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch", |
| 737 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 738 | return err; |
| 739 | } else { |
| 740 | sprintf(name, "%s Playback Volume", chname[i]); |
| 741 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 742 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 743 | return err; |
| 744 | sprintf(name, "%s Playback Switch", chname[i]); |
| 745 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 746 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 747 | return err; |
| 748 | } |
| 749 | } |
| 750 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 751 | if (spec->line_switch) |
| 752 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) |
| 753 | return err; |
| 754 | |
| 755 | if (spec->mic_switch) |
| 756 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) |
| 757 | return err; |
| 758 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 759 | return 0; |
| 760 | } |
| 761 | |
| 762 | /* add playback controls for HP output */ |
| 763 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 764 | { |
| 765 | struct sigmatel_spec *spec = codec->spec; |
| 766 | hda_nid_t pin = cfg->hp_pin; |
| 767 | hda_nid_t nid; |
| 768 | int i, err; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 769 | unsigned int wid_caps; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 770 | |
| 771 | if (! pin) |
| 772 | return 0; |
| 773 | |
Takashi Iwai | 54d1740 | 2005-11-21 16:33:22 +0100 | [diff] [blame] | 774 | wid_caps = get_wcaps(codec, pin); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 775 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 776 | /* Enable unsolicited responses on the HP widget */ |
| 777 | snd_hda_codec_write(codec, pin, 0, |
| 778 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 779 | STAC_UNSOL_ENABLE); |
| 780 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 781 | nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 782 | for (i = 0; i < cfg->line_outs; i++) { |
| 783 | if (! spec->multiout.dac_nids[i]) |
| 784 | continue; |
| 785 | if (spec->multiout.dac_nids[i] == nid) |
| 786 | return 0; |
| 787 | } |
| 788 | |
| 789 | spec->multiout.hp_nid = nid; |
| 790 | |
| 791 | /* control HP volume/switch on the output mixer amp */ |
| 792 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume", |
| 793 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 794 | return err; |
| 795 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 796 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 797 | return err; |
| 798 | |
| 799 | return 0; |
| 800 | } |
| 801 | |
| 802 | /* create playback/capture controls for input pins */ |
| 803 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 804 | { |
| 805 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 806 | struct hda_input_mux *imux = &spec->private_imux; |
| 807 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 808 | int i, j, k; |
| 809 | |
| 810 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 811 | int index = -1; |
| 812 | if (cfg->input_pins[i]) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 813 | /* Enable active pin widget as an input */ |
| 814 | stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN); |
| 815 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 816 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 817 | |
| 818 | for (j=0; j<spec->num_muxes; j++) { |
| 819 | int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); |
| 820 | for (k=0; k<num_cons; k++) |
| 821 | if (con_lst[k] == cfg->input_pins[i]) { |
| 822 | index = k; |
| 823 | break; |
| 824 | } |
| 825 | if (index >= 0) |
| 826 | break; |
| 827 | } |
| 828 | imux->items[imux->num_items].index = index; |
| 829 | imux->num_items++; |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | return 0; |
| 834 | } |
| 835 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 836 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 837 | { |
| 838 | struct sigmatel_spec *spec = codec->spec; |
| 839 | int i; |
| 840 | |
| 841 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 842 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 843 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 844 | } |
| 845 | } |
| 846 | |
| 847 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 848 | { |
| 849 | struct sigmatel_spec *spec = codec->spec; |
| 850 | hda_nid_t pin; |
| 851 | |
| 852 | pin = spec->autocfg.hp_pin; |
| 853 | if (pin) /* connect to front */ |
| 854 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 855 | } |
| 856 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 857 | static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 858 | { |
| 859 | struct sigmatel_spec *spec = codec->spec; |
| 860 | int err; |
| 861 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 862 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 863 | return err; |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 864 | if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin) |
| 865 | return 0; /* can't find valid pin config */ |
| 866 | stac92xx_auto_init_multi_out(codec); |
| 867 | stac92xx_auto_init_hp_out(codec); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 868 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 869 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 870 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 871 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 872 | |
| 873 | if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 874 | (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || |
| 875 | (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 876 | return err; |
| 877 | |
| 878 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 879 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 880 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 881 | |
| 882 | if (spec->autocfg.dig_out_pin) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 883 | spec->multiout.dig_out_nid = dig_out; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 884 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); |
| 885 | } |
| 886 | if (spec->autocfg.dig_in_pin) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 887 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 888 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); |
| 889 | } |
| 890 | |
| 891 | if (spec->kctl_alloc) |
| 892 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 893 | |
| 894 | spec->input_mux = &spec->private_imux; |
| 895 | |
| 896 | return 1; |
| 897 | } |
| 898 | |
| 899 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 900 | { |
| 901 | struct sigmatel_spec *spec = codec->spec; |
| 902 | int err; |
| 903 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 904 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 905 | return err; |
| 906 | |
| 907 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 908 | return err; |
| 909 | |
| 910 | if (spec->autocfg.dig_out_pin) { |
| 911 | spec->multiout.dig_out_nid = 0x05; |
| 912 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); |
| 913 | } |
| 914 | if (spec->autocfg.dig_in_pin) { |
| 915 | spec->dig_in_nid = 0x04; |
| 916 | stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); |
| 917 | } |
| 918 | |
| 919 | if (spec->kctl_alloc) |
| 920 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 921 | |
| 922 | spec->input_mux = &spec->private_imux; |
| 923 | |
| 924 | return 1; |
| 925 | } |
| 926 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 927 | static int stac92xx_init(struct hda_codec *codec) |
| 928 | { |
| 929 | struct sigmatel_spec *spec = codec->spec; |
| 930 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 931 | snd_hda_sequence_write(codec, spec->init); |
| 932 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 933 | return 0; |
| 934 | } |
| 935 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 936 | static void stac92xx_free(struct hda_codec *codec) |
| 937 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 938 | struct sigmatel_spec *spec = codec->spec; |
| 939 | int i; |
| 940 | |
| 941 | if (! spec) |
| 942 | return; |
| 943 | |
| 944 | if (spec->kctl_alloc) { |
| 945 | for (i = 0; i < spec->num_kctl_used; i++) |
| 946 | kfree(spec->kctl_alloc[i].name); |
| 947 | kfree(spec->kctl_alloc); |
| 948 | } |
| 949 | |
| 950 | kfree(spec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 951 | } |
| 952 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 953 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 954 | unsigned int flag) |
| 955 | { |
| 956 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 957 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
| 958 | snd_hda_codec_write(codec, nid, 0, |
| 959 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 960 | pin_ctl | flag); |
| 961 | } |
| 962 | |
| 963 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 964 | unsigned int flag) |
| 965 | { |
| 966 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 967 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
| 968 | snd_hda_codec_write(codec, nid, 0, |
| 969 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 970 | pin_ctl & ~flag); |
| 971 | } |
| 972 | |
| 973 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 974 | { |
| 975 | struct sigmatel_spec *spec = codec->spec; |
| 976 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 977 | int i, presence; |
| 978 | |
| 979 | if ((res >> 26) != STAC_HP_EVENT) |
| 980 | return; |
| 981 | |
| 982 | presence = snd_hda_codec_read(codec, cfg->hp_pin, 0, |
| 983 | AC_VERB_GET_PIN_SENSE, 0x00) >> 31; |
| 984 | |
| 985 | if (presence) { |
| 986 | /* disable lineouts, enable hp */ |
| 987 | for (i = 0; i < cfg->line_outs; i++) |
| 988 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 989 | AC_PINCTL_OUT_EN); |
| 990 | stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); |
| 991 | } else { |
| 992 | /* enable lineouts, disable hp */ |
| 993 | for (i = 0; i < cfg->line_outs; i++) |
| 994 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 995 | AC_PINCTL_OUT_EN); |
| 996 | stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); |
| 997 | } |
| 998 | } |
| 999 | |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1000 | #ifdef CONFIG_PM |
| 1001 | static int stac92xx_resume(struct hda_codec *codec) |
| 1002 | { |
| 1003 | struct sigmatel_spec *spec = codec->spec; |
| 1004 | int i; |
| 1005 | |
| 1006 | stac92xx_init(codec); |
| 1007 | for (i = 0; i < spec->num_mixers; i++) |
| 1008 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
| 1009 | if (spec->multiout.dig_out_nid) |
| 1010 | snd_hda_resume_spdif_out(codec); |
| 1011 | if (spec->dig_in_nid) |
| 1012 | snd_hda_resume_spdif_in(codec); |
| 1013 | |
| 1014 | return 0; |
| 1015 | } |
| 1016 | #endif |
| 1017 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1018 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 1019 | .build_controls = stac92xx_build_controls, |
| 1020 | .build_pcms = stac92xx_build_pcms, |
| 1021 | .init = stac92xx_init, |
| 1022 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1023 | .unsol_event = stac92xx_unsol_event, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1024 | #ifdef CONFIG_PM |
| 1025 | .resume = stac92xx_resume, |
| 1026 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1027 | }; |
| 1028 | |
| 1029 | static int patch_stac9200(struct hda_codec *codec) |
| 1030 | { |
| 1031 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1032 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1033 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1034 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1035 | if (spec == NULL) |
| 1036 | return -ENOMEM; |
| 1037 | |
| 1038 | codec->spec = spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1039 | spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl); |
| 1040 | if (spec->board_config < 0) |
| 1041 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 1042 | else { |
| 1043 | spec->num_pins = 8; |
| 1044 | spec->pin_nids = stac9200_pin_nids; |
| 1045 | spec->pin_configs = stac9200_brd_tbl[spec->board_config]; |
| 1046 | stac92xx_set_config_regs(codec); |
| 1047 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1048 | |
| 1049 | spec->multiout.max_channels = 2; |
| 1050 | spec->multiout.num_dacs = 1; |
| 1051 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 1052 | spec->adc_nids = stac9200_adc_nids; |
| 1053 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1054 | spec->num_muxes = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1055 | |
| 1056 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1057 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1058 | |
| 1059 | err = stac9200_parse_auto_config(codec); |
| 1060 | if (err < 0) { |
| 1061 | stac92xx_free(codec); |
| 1062 | return err; |
| 1063 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1064 | |
| 1065 | codec->patch_ops = stac92xx_patch_ops; |
| 1066 | |
| 1067 | return 0; |
| 1068 | } |
| 1069 | |
| 1070 | static int patch_stac922x(struct hda_codec *codec) |
| 1071 | { |
| 1072 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1073 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1074 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1075 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1076 | if (spec == NULL) |
| 1077 | return -ENOMEM; |
| 1078 | |
| 1079 | codec->spec = spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1080 | spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl); |
| 1081 | if (spec->board_config < 0) |
| 1082 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n"); |
| 1083 | else { |
| 1084 | spec->num_pins = 10; |
| 1085 | spec->pin_nids = stac922x_pin_nids; |
| 1086 | spec->pin_configs = stac922x_brd_tbl[spec->board_config]; |
| 1087 | stac92xx_set_config_regs(codec); |
| 1088 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1089 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1090 | spec->adc_nids = stac922x_adc_nids; |
| 1091 | spec->mux_nids = stac922x_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1092 | spec->num_muxes = 2; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1093 | |
| 1094 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1095 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1096 | |
| 1097 | spec->multiout.dac_nids = spec->dac_nids; |
| 1098 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1099 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
| 1100 | if (err < 0) { |
| 1101 | stac92xx_free(codec); |
| 1102 | return err; |
| 1103 | } |
| 1104 | |
| 1105 | codec->patch_ops = stac92xx_patch_ops; |
| 1106 | |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | static int patch_stac927x(struct hda_codec *codec) |
| 1111 | { |
| 1112 | struct sigmatel_spec *spec; |
| 1113 | int err; |
| 1114 | |
| 1115 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1116 | if (spec == NULL) |
| 1117 | return -ENOMEM; |
| 1118 | |
| 1119 | codec->spec = spec; |
| 1120 | spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl); |
| 1121 | if (spec->board_config < 0) |
| 1122 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n"); |
| 1123 | else { |
| 1124 | spec->num_pins = 14; |
| 1125 | spec->pin_nids = stac927x_pin_nids; |
| 1126 | spec->pin_configs = stac927x_brd_tbl[spec->board_config]; |
| 1127 | stac92xx_set_config_regs(codec); |
| 1128 | } |
| 1129 | |
| 1130 | spec->adc_nids = stac927x_adc_nids; |
| 1131 | spec->mux_nids = stac927x_mux_nids; |
| 1132 | spec->num_muxes = 3; |
| 1133 | |
| 1134 | spec->init = stac927x_core_init; |
| 1135 | spec->mixer = stac927x_mixer; |
| 1136 | |
| 1137 | spec->multiout.dac_nids = spec->dac_nids; |
| 1138 | |
| 1139 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1140 | if (err < 0) { |
| 1141 | stac92xx_free(codec); |
| 1142 | return err; |
| 1143 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1144 | |
| 1145 | codec->patch_ops = stac92xx_patch_ops; |
| 1146 | |
| 1147 | return 0; |
| 1148 | } |
| 1149 | |
| 1150 | /* |
| 1151 | * patch entries |
| 1152 | */ |
| 1153 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
| 1154 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 1155 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 1156 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 1157 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 1158 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 1159 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 1160 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1161 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 1162 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 1163 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 1164 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 1165 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 1166 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 1167 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 1168 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 1169 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 1170 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1171 | {} /* terminator */ |
| 1172 | }; |