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 |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 44 | #define STAC_MACMINI 3 |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 45 | #define STAC_922X_MODELS 4 /* number of 922x models */ |
| 46 | #define STAC_D965_3ST 4 |
| 47 | #define STAC_D965_5ST 5 |
| 48 | #define STAC_927X_MODELS 6 /* number of 922x models */ |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 49 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 50 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 51 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 52 | unsigned int num_mixers; |
| 53 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 54 | int board_config; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 55 | unsigned int surr_switch: 1; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 56 | unsigned int line_switch: 1; |
| 57 | unsigned int mic_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 58 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 59 | unsigned int hp_detect: 1; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 60 | unsigned int gpio_mute: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 61 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 62 | /* playback */ |
| 63 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 64 | hda_nid_t dac_nids[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 65 | |
| 66 | /* capture */ |
| 67 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 68 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 69 | hda_nid_t *mux_nids; |
| 70 | unsigned int num_muxes; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 71 | hda_nid_t dig_in_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 72 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 73 | /* pin widgets */ |
| 74 | hda_nid_t *pin_nids; |
| 75 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 76 | unsigned int *pin_configs; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 77 | unsigned int *bios_pin_configs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 78 | |
| 79 | /* codec specific stuff */ |
| 80 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 81 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 82 | |
| 83 | /* capture source */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 84 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 85 | unsigned int cur_mux[3]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 86 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 87 | /* i/o switches */ |
| 88 | unsigned int io_switch[2]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 89 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 90 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 91 | |
| 92 | /* dynamic controls and input_mux */ |
| 93 | struct auto_pin_cfg autocfg; |
| 94 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 95 | struct snd_kcontrol_new *kctl_alloc; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 96 | struct hda_input_mux private_imux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | static hda_nid_t stac9200_adc_nids[1] = { |
| 100 | 0x03, |
| 101 | }; |
| 102 | |
| 103 | static hda_nid_t stac9200_mux_nids[1] = { |
| 104 | 0x0c, |
| 105 | }; |
| 106 | |
| 107 | static hda_nid_t stac9200_dac_nids[1] = { |
| 108 | 0x02, |
| 109 | }; |
| 110 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 111 | static hda_nid_t stac922x_adc_nids[2] = { |
| 112 | 0x06, 0x07, |
| 113 | }; |
| 114 | |
| 115 | static hda_nid_t stac922x_mux_nids[2] = { |
| 116 | 0x12, 0x13, |
| 117 | }; |
| 118 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 119 | static hda_nid_t stac927x_adc_nids[3] = { |
| 120 | 0x07, 0x08, 0x09 |
| 121 | }; |
| 122 | |
| 123 | static hda_nid_t stac927x_mux_nids[3] = { |
| 124 | 0x15, 0x16, 0x17 |
| 125 | }; |
| 126 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 127 | static hda_nid_t stac9205_adc_nids[2] = { |
| 128 | 0x12, 0x13 |
| 129 | }; |
| 130 | |
| 131 | static hda_nid_t stac9205_mux_nids[2] = { |
| 132 | 0x19, 0x1a |
| 133 | }; |
| 134 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 135 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 136 | 0x08, 0x09, 0x0d, 0x0e, |
| 137 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | static hda_nid_t stac922x_pin_nids[10] = { |
| 141 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 142 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 143 | }; |
| 144 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 145 | static hda_nid_t stac927x_pin_nids[14] = { |
| 146 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 147 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 148 | 0x14, 0x21, 0x22, 0x23, |
| 149 | }; |
| 150 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 151 | static hda_nid_t stac9205_pin_nids[12] = { |
| 152 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 153 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 154 | 0x21, 0x22, |
| 155 | |
| 156 | }; |
| 157 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 158 | 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] | 159 | { |
| 160 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 161 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 162 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 163 | } |
| 164 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 165 | 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] | 166 | { |
| 167 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 168 | struct sigmatel_spec *spec = codec->spec; |
| 169 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 170 | |
| 171 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 172 | return 0; |
| 173 | } |
| 174 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 175 | 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] | 176 | { |
| 177 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 178 | struct sigmatel_spec *spec = codec->spec; |
| 179 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 180 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 181 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 182 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 183 | } |
| 184 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 185 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 186 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 187 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 188 | {} |
| 189 | }; |
| 190 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 191 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 192 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 193 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 194 | {} |
| 195 | }; |
| 196 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 197 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 198 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 199 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 200 | /* unmute node 0x1b */ |
| 201 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 202 | /* select node 0x03 as DAC */ |
| 203 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 204 | {} |
| 205 | }; |
| 206 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 207 | static struct hda_verb stac927x_core_init[] = { |
| 208 | /* set master volume and direct control */ |
| 209 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 210 | {} |
| 211 | }; |
| 212 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 213 | static struct hda_verb stac9205_core_init[] = { |
| 214 | /* set master volume and direct control */ |
| 215 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 216 | {} |
| 217 | }; |
| 218 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 219 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 220 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 221 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
| 222 | { |
| 223 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 224 | .name = "Input Source", |
| 225 | .count = 1, |
| 226 | .info = stac92xx_mux_enum_info, |
| 227 | .get = stac92xx_mux_enum_get, |
| 228 | .put = stac92xx_mux_enum_put, |
| 229 | }, |
| 230 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 231 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 232 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 233 | { } /* end */ |
| 234 | }; |
| 235 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 236 | /* This needs to be generated dynamically based on sequence */ |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 237 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 238 | { |
| 239 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 240 | .name = "Input Source", |
| 241 | .count = 1, |
| 242 | .info = stac92xx_mux_enum_info, |
| 243 | .get = stac92xx_mux_enum_get, |
| 244 | .put = stac92xx_mux_enum_put, |
| 245 | }, |
| 246 | HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), |
Takashi Iwai | 0fd1708 | 2006-01-13 18:46:21 +0100 | [diff] [blame] | 247 | HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 248 | HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT), |
| 249 | { } /* end */ |
| 250 | }; |
| 251 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 252 | /* This needs to be generated dynamically based on sequence */ |
| 253 | static struct snd_kcontrol_new stac9227_mixer[] = { |
| 254 | { |
| 255 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 256 | .name = "Input Source", |
| 257 | .count = 1, |
| 258 | .info = stac92xx_mux_enum_info, |
| 259 | .get = stac92xx_mux_enum_get, |
| 260 | .put = stac92xx_mux_enum_put, |
| 261 | }, |
| 262 | HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 263 | HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 264 | { } /* end */ |
| 265 | }; |
| 266 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 267 | static snd_kcontrol_new_t stac927x_mixer[] = { |
| 268 | { |
| 269 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 270 | .name = "Input Source", |
| 271 | .count = 1, |
| 272 | .info = stac92xx_mux_enum_info, |
| 273 | .get = stac92xx_mux_enum_get, |
| 274 | .put = stac92xx_mux_enum_put, |
| 275 | }, |
| 276 | HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT), |
| 277 | HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT), |
| 278 | HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT), |
| 279 | { } /* end */ |
| 280 | }; |
| 281 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 282 | static snd_kcontrol_new_t stac9205_mixer[] = { |
| 283 | { |
| 284 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 285 | .name = "Input Source", |
| 286 | .count = 1, |
| 287 | .info = stac92xx_mux_enum_info, |
| 288 | .get = stac92xx_mux_enum_get, |
| 289 | .put = stac92xx_mux_enum_put, |
| 290 | }, |
| 291 | HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT), |
| 292 | HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 293 | HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT), |
| 294 | { } /* end */ |
| 295 | }; |
| 296 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 297 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 298 | { |
| 299 | struct sigmatel_spec *spec = codec->spec; |
| 300 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 301 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 302 | |
| 303 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 304 | if (err < 0) |
| 305 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 306 | |
| 307 | for (i = 0; i < spec->num_mixers; i++) { |
| 308 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 309 | if (err < 0) |
| 310 | return err; |
| 311 | } |
| 312 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 313 | if (spec->multiout.dig_out_nid) { |
| 314 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 315 | if (err < 0) |
| 316 | return err; |
| 317 | } |
| 318 | if (spec->dig_in_nid) { |
| 319 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 320 | if (err < 0) |
| 321 | return err; |
| 322 | } |
| 323 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 324 | } |
| 325 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 326 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 327 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 328 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 329 | }; |
| 330 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 331 | static unsigned int *stac9200_brd_tbl[] = { |
| 332 | ref9200_pin_configs, |
| 333 | }; |
| 334 | |
| 335 | static struct hda_board_config stac9200_cfg_tbl[] = { |
| 336 | { .modelname = "ref", |
| 337 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 338 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 339 | .config = STAC_REF }, |
| 340 | {} /* terminator */ |
| 341 | }; |
| 342 | |
| 343 | static unsigned int ref922x_pin_configs[10] = { |
| 344 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 345 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 346 | 0x40000100, 0x40000100, |
| 347 | }; |
| 348 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 349 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 350 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 351 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 352 | 0x02a19120, 0x40000100, |
| 353 | }; |
| 354 | |
| 355 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 356 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 357 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 358 | 0x02a19320, 0x40000100, |
| 359 | }; |
| 360 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 361 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
| 362 | [STAC_REF] = ref922x_pin_configs, |
| 363 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 364 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Linus Torvalds | 7c3dec0 | 2006-07-10 22:21:43 -0700 | [diff] [blame] | 365 | [STAC_MACMINI] = d945gtp5_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 366 | }; |
| 367 | |
| 368 | static struct hda_board_config stac922x_cfg_tbl[] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 369 | { .modelname = "5stack", .config = STAC_D945GTP5 }, |
| 370 | { .modelname = "3stack", .config = STAC_D945GTP3 }, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 371 | { .modelname = "ref", |
| 372 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 373 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 374 | .config = STAC_REF }, /* SigmaTel reference board */ |
Tobin Davis | 948a4db | 2006-08-22 19:43:46 +0200 | [diff] [blame] | 375 | /* Intel 945G based systems */ |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 376 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 377 | .pci_subdevice = 0x0101, |
| 378 | .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ |
| 379 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
Takashi Iwai | 353b9e6 | 2006-02-16 18:16:17 +0100 | [diff] [blame] | 380 | .pci_subdevice = 0x0202, |
Tobin Davis | 948a4db | 2006-08-22 19:43:46 +0200 | [diff] [blame] | 381 | .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack */ |
Takashi Iwai | 353b9e6 | 2006-02-16 18:16:17 +0100 | [diff] [blame] | 382 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
Tobin Davis | 948a4db | 2006-08-22 19:43:46 +0200 | [diff] [blame] | 383 | .pci_subdevice = 0x0606, |
| 384 | .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ |
Takashi Iwai | 353b9e6 | 2006-02-16 18:16:17 +0100 | [diff] [blame] | 385 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
Tobin Davis | 948a4db | 2006-08-22 19:43:46 +0200 | [diff] [blame] | 386 | .pci_subdevice = 0x0601, |
| 387 | .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ |
| 388 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 389 | .pci_subdevice = 0x0111, |
| 390 | .config = STAC_D945GTP3 }, /* Intel D945GZP - 3 Stack */ |
| 391 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 392 | .pci_subdevice = 0x1115, |
| 393 | .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ |
| 394 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 395 | .pci_subdevice = 0x1116, |
| 396 | .config = STAC_D945GTP3 }, /* Intel D945GBO - 3 Stack */ |
| 397 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 398 | .pci_subdevice = 0x1117, |
| 399 | .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ |
| 400 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 401 | .pci_subdevice = 0x1118, |
| 402 | .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ |
| 403 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 404 | .pci_subdevice = 0x1119, |
| 405 | .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ |
| 406 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 407 | .pci_subdevice = 0x8826, |
| 408 | .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */ |
| 409 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 410 | .pci_subdevice = 0x5049, |
| 411 | .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */ |
| 412 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 413 | .pci_subdevice = 0x5055, |
| 414 | .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */ |
| 415 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 416 | .pci_subdevice = 0x5048, |
| 417 | .config = STAC_D945GTP3 }, /* Intel D945GPB - 3 Stack */ |
| 418 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 419 | .pci_subdevice = 0x0110, |
| 420 | .config = STAC_D945GTP3 }, /* Intel D945GLR - 3 Stack */ |
| 421 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 422 | .pci_subdevice = 0x0404, |
| 423 | .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */ |
| 424 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 425 | .pci_subdevice = 0x0303, |
| 426 | .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */ |
| 427 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 428 | .pci_subdevice = 0x0013, |
| 429 | .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ |
Matt Porter | d62c40e | 2006-01-23 15:26:27 +0100 | [diff] [blame] | 430 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 431 | .pci_subdevice = 0x0417, |
| 432 | .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */ |
Tobin Davis | 948a4db | 2006-08-22 19:43:46 +0200 | [diff] [blame] | 433 | /* Intel 945P based systems */ |
| 434 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 435 | .pci_subdevice = 0x0b0b, |
| 436 | .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack */ |
| 437 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 438 | .pci_subdevice = 0x0112, |
| 439 | .config = STAC_D945GTP3 }, /* Intel D945PLN - 3 Stack */ |
| 440 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 441 | .pci_subdevice = 0x0d0d, |
| 442 | .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */ |
| 443 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 444 | .pci_subdevice = 0x0909, |
| 445 | .config = STAC_D945GTP3 }, /* Intel D945PAW - 3 Stack */ |
| 446 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 447 | .pci_subdevice = 0x0505, |
| 448 | .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */ |
| 449 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 450 | .pci_subdevice = 0x0707, |
| 451 | .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */ |
| 452 | /* other systems */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 453 | { .pci_subvendor = 0x8384, |
| 454 | .pci_subdevice = 0x7680, |
| 455 | .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */ |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 456 | {} /* terminator */ |
| 457 | }; |
| 458 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 459 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 460 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 461 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 462 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 463 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 464 | }; |
| 465 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 466 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 467 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 468 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 469 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 470 | 0x40000100, 0x40000100 |
| 471 | }; |
| 472 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 473 | static unsigned int d965_5st_pin_configs[14] = { |
| 474 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 475 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 476 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 477 | 0x40000100, 0x40000100 |
| 478 | }; |
| 479 | |
| 480 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 481 | [STAC_REF] = ref927x_pin_configs, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 482 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 483 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 484 | }; |
| 485 | |
| 486 | static struct hda_board_config stac927x_cfg_tbl[] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 487 | { .modelname = "5stack", .config = STAC_D965_5ST }, |
| 488 | { .modelname = "3stack", .config = STAC_D965_3ST }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 489 | { .modelname = "ref", |
| 490 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 491 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 492 | .config = STAC_REF }, /* SigmaTel reference board */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 493 | /* Intel 946 based systems */ |
| 494 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 495 | .pci_subdevice = 0x3d01, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 496 | .config = STAC_D965_3ST }, /* D946 configuration */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 497 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 498 | .pci_subdevice = 0xa301, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 499 | .config = STAC_D965_3ST }, /* Intel D946GZT - 3 stack */ |
| 500 | /* 965 based 3 stack systems */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 501 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 502 | .pci_subdevice = 0x2116, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 503 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 504 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 505 | .pci_subdevice = 0x2115, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 506 | .config = STAC_D965_3ST }, /* Intel DQ965WC - 3 Stack */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 507 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 508 | .pci_subdevice = 0x2114, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 509 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 510 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 511 | .pci_subdevice = 0x2113, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 512 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 513 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 514 | .pci_subdevice = 0x2112, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 515 | .config = STAC_D965_3ST }, /* Intel DG965MS - 3 Stack */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 516 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 517 | .pci_subdevice = 0x2111, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 518 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 519 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 520 | .pci_subdevice = 0x2110, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 521 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 522 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 523 | .pci_subdevice = 0x2009, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 524 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 525 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 526 | .pci_subdevice = 0x2008, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 527 | .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 528 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 529 | .pci_subdevice = 0x2007, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 530 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 531 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 532 | .pci_subdevice = 0x2006, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 533 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 534 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 535 | .pci_subdevice = 0x2005, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 536 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 537 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 538 | .pci_subdevice = 0x2004, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 539 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 540 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 541 | .pci_subdevice = 0x2003, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 542 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 543 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 544 | .pci_subdevice = 0x2002, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 545 | .config = STAC_D965_3ST }, /* Intel D965 3Stack config */ |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 546 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 547 | .pci_subdevice = 0x2001, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 548 | .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */ |
| 549 | /* 965 based 5 stack systems */ |
| 550 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 551 | .pci_subdevice = 0x2301, |
| 552 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 553 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 554 | .pci_subdevice = 0x2302, |
| 555 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 556 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 557 | .pci_subdevice = 0x2303, |
| 558 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 559 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 560 | .pci_subdevice = 0x2304, |
| 561 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 562 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 563 | .pci_subdevice = 0x2305, |
| 564 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 565 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 566 | .pci_subdevice = 0x2501, |
| 567 | .config = STAC_D965_5ST }, /* Intel DG965MQ - 5 Stack */ |
| 568 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 569 | .pci_subdevice = 0x2502, |
| 570 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 571 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 572 | .pci_subdevice = 0x2503, |
| 573 | .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */ |
| 574 | { .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 575 | .pci_subdevice = 0x2504, |
| 576 | .config = STAC_D965_5ST }, /* Intel DQ965GF - 5 Stack */ |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 577 | {} /* terminator */ |
| 578 | }; |
| 579 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 580 | static unsigned int ref9205_pin_configs[12] = { |
| 581 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
| 582 | 0x01813122, 0x01a19021, 0x40000100, 0x40000100, |
| 583 | 0x40000100, 0x40000100, 0x01441030, 0x01c41030 |
| 584 | }; |
| 585 | |
| 586 | static unsigned int *stac9205_brd_tbl[] = { |
| 587 | ref9205_pin_configs, |
| 588 | }; |
| 589 | |
| 590 | static struct hda_board_config stac9205_cfg_tbl[] = { |
| 591 | { .modelname = "ref", |
| 592 | .pci_subvendor = PCI_VENDOR_ID_INTEL, |
| 593 | .pci_subdevice = 0x2668, /* DFI LanParty */ |
| 594 | .config = STAC_REF }, /* SigmaTel reference board */ |
Takashi Iwai | 2c7782b | 2006-08-25 13:11:26 +0200 | [diff] [blame] | 595 | /* Dell laptops have BIOS problem */ |
| 596 | { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5, |
| 597 | .config = STAC_REF }, /* Dell Inspiron 630m */ |
| 598 | { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2, |
| 599 | .config = STAC_REF }, /* Dell Latitude D620 */ |
| 600 | { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb, |
| 601 | .config = STAC_REF }, /* Dell Latitude 120L */ |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 602 | {} /* terminator */ |
| 603 | }; |
| 604 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 605 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) |
| 606 | { |
| 607 | int i; |
| 608 | struct sigmatel_spec *spec = codec->spec; |
| 609 | |
| 610 | if (! spec->bios_pin_configs) { |
| 611 | spec->bios_pin_configs = kcalloc(spec->num_pins, |
| 612 | sizeof(*spec->bios_pin_configs), GFP_KERNEL); |
| 613 | if (! spec->bios_pin_configs) |
| 614 | return -ENOMEM; |
| 615 | } |
| 616 | |
| 617 | for (i = 0; i < spec->num_pins; i++) { |
| 618 | hda_nid_t nid = spec->pin_nids[i]; |
| 619 | unsigned int pin_cfg; |
| 620 | |
| 621 | pin_cfg = snd_hda_codec_read(codec, nid, 0, |
| 622 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); |
| 623 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", |
| 624 | nid, pin_cfg); |
| 625 | spec->bios_pin_configs[i] = pin_cfg; |
| 626 | } |
| 627 | |
| 628 | return 0; |
| 629 | } |
| 630 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 631 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
| 632 | { |
| 633 | int i; |
| 634 | struct sigmatel_spec *spec = codec->spec; |
| 635 | unsigned int pin_cfg; |
| 636 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 637 | if (! spec->pin_nids || ! spec->pin_configs) |
| 638 | return; |
| 639 | |
| 640 | for (i = 0; i < spec->num_pins; i++) { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 641 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 642 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, |
| 643 | spec->pin_configs[i] & 0x000000ff); |
| 644 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 645 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, |
| 646 | (spec->pin_configs[i] & 0x0000ff00) >> 8); |
| 647 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 648 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, |
| 649 | (spec->pin_configs[i] & 0x00ff0000) >> 16); |
| 650 | snd_hda_codec_write(codec, spec->pin_nids[i], 0, |
| 651 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, |
| 652 | spec->pin_configs[i] >> 24); |
| 653 | pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, |
| 654 | AC_VERB_GET_CONFIG_DEFAULT, |
| 655 | 0x00); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 656 | 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] | 657 | } |
| 658 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 659 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 660 | /* |
| 661 | * Analog playback callbacks |
| 662 | */ |
| 663 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 664 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 665 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 666 | { |
| 667 | struct sigmatel_spec *spec = codec->spec; |
| 668 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 669 | } |
| 670 | |
| 671 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 672 | struct hda_codec *codec, |
| 673 | unsigned int stream_tag, |
| 674 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 675 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 676 | { |
| 677 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 678 | 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] | 679 | } |
| 680 | |
| 681 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 682 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 683 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 684 | { |
| 685 | struct sigmatel_spec *spec = codec->spec; |
| 686 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 687 | } |
| 688 | |
| 689 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 690 | * Digital playback callbacks |
| 691 | */ |
| 692 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 693 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 694 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 695 | { |
| 696 | struct sigmatel_spec *spec = codec->spec; |
| 697 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 698 | } |
| 699 | |
| 700 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 701 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 702 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 703 | { |
| 704 | struct sigmatel_spec *spec = codec->spec; |
| 705 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 706 | } |
| 707 | |
| 708 | |
| 709 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 710 | * Analog capture callbacks |
| 711 | */ |
| 712 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 713 | struct hda_codec *codec, |
| 714 | unsigned int stream_tag, |
| 715 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 716 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 717 | { |
| 718 | struct sigmatel_spec *spec = codec->spec; |
| 719 | |
| 720 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 721 | stream_tag, 0, format); |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 726 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 727 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 728 | { |
| 729 | struct sigmatel_spec *spec = codec->spec; |
| 730 | |
| 731 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 732 | return 0; |
| 733 | } |
| 734 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 735 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 736 | .substreams = 1, |
| 737 | .channels_min = 2, |
| 738 | .channels_max = 2, |
| 739 | /* NID is set in stac92xx_build_pcms */ |
| 740 | .ops = { |
| 741 | .open = stac92xx_dig_playback_pcm_open, |
| 742 | .close = stac92xx_dig_playback_pcm_close |
| 743 | }, |
| 744 | }; |
| 745 | |
| 746 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 747 | .substreams = 1, |
| 748 | .channels_min = 2, |
| 749 | .channels_max = 2, |
| 750 | /* NID is set in stac92xx_build_pcms */ |
| 751 | }; |
| 752 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 753 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 754 | .substreams = 1, |
| 755 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 756 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 757 | .nid = 0x02, /* NID to query formats and rates */ |
| 758 | .ops = { |
| 759 | .open = stac92xx_playback_pcm_open, |
| 760 | .prepare = stac92xx_playback_pcm_prepare, |
| 761 | .cleanup = stac92xx_playback_pcm_cleanup |
| 762 | }, |
| 763 | }; |
| 764 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 765 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 766 | .substreams = 1, |
| 767 | .channels_min = 2, |
| 768 | .channels_max = 2, |
| 769 | .nid = 0x06, /* NID to query formats and rates */ |
| 770 | .ops = { |
| 771 | .open = stac92xx_playback_pcm_open, |
| 772 | .prepare = stac92xx_playback_pcm_prepare, |
| 773 | .cleanup = stac92xx_playback_pcm_cleanup |
| 774 | }, |
| 775 | }; |
| 776 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 777 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
| 778 | .substreams = 2, |
| 779 | .channels_min = 2, |
| 780 | .channels_max = 2, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 781 | /* NID is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 782 | .ops = { |
| 783 | .prepare = stac92xx_capture_pcm_prepare, |
| 784 | .cleanup = stac92xx_capture_pcm_cleanup |
| 785 | }, |
| 786 | }; |
| 787 | |
| 788 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 789 | { |
| 790 | struct sigmatel_spec *spec = codec->spec; |
| 791 | struct hda_pcm *info = spec->pcm_rec; |
| 792 | |
| 793 | codec->num_pcms = 1; |
| 794 | codec->pcm_info = info; |
| 795 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 796 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 797 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 798 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 799 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 800 | |
| 801 | if (spec->alt_switch) { |
| 802 | codec->num_pcms++; |
| 803 | info++; |
| 804 | info->name = "STAC92xx Analog Alt"; |
| 805 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 806 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 807 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 808 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 809 | codec->num_pcms++; |
| 810 | info++; |
| 811 | info->name = "STAC92xx Digital"; |
| 812 | if (spec->multiout.dig_out_nid) { |
| 813 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 814 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 815 | } |
| 816 | if (spec->dig_in_nid) { |
| 817 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 818 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 819 | } |
| 820 | } |
| 821 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 822 | return 0; |
| 823 | } |
| 824 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 825 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 826 | { |
| 827 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 828 | AC_PAR_PIN_CAP); |
| 829 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 830 | if (pincap & AC_PINCAP_VREF_100) |
| 831 | return AC_PINCTL_VREF_100; |
| 832 | if (pincap & AC_PINCAP_VREF_80) |
| 833 | return AC_PINCTL_VREF_80; |
| 834 | if (pincap & AC_PINCAP_VREF_50) |
| 835 | return AC_PINCTL_VREF_50; |
| 836 | if (pincap & AC_PINCAP_VREF_GRD) |
| 837 | return AC_PINCTL_VREF_GRD; |
| 838 | return 0; |
| 839 | } |
| 840 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 841 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 842 | |
| 843 | { |
| 844 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
| 845 | } |
| 846 | |
| 847 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 848 | { |
| 849 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; |
| 850 | uinfo->count = 1; |
| 851 | uinfo->value.integer.min = 0; |
| 852 | uinfo->value.integer.max = 1; |
| 853 | return 0; |
| 854 | } |
| 855 | |
| 856 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 857 | { |
| 858 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 859 | struct sigmatel_spec *spec = codec->spec; |
| 860 | int io_idx = kcontrol-> private_value & 0xff; |
| 861 | |
| 862 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 863 | return 0; |
| 864 | } |
| 865 | |
| 866 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 867 | { |
| 868 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 869 | struct sigmatel_spec *spec = codec->spec; |
| 870 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 871 | int io_idx = kcontrol-> private_value & 0xff; |
| 872 | unsigned short val = ucontrol->value.integer.value[0]; |
| 873 | |
| 874 | spec->io_switch[io_idx] = val; |
| 875 | |
| 876 | if (val) |
| 877 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 878 | else { |
| 879 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 880 | if (io_idx) /* set VREF for mic */ |
| 881 | pinctl |= stac92xx_get_vref(codec, nid); |
| 882 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 883 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 884 | return 1; |
| 885 | } |
| 886 | |
| 887 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 888 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 889 | .name = xname, \ |
| 890 | .index = 0, \ |
| 891 | .info = stac92xx_io_switch_info, \ |
| 892 | .get = stac92xx_io_switch_get, \ |
| 893 | .put = stac92xx_io_switch_put, \ |
| 894 | .private_value = xpval, \ |
| 895 | } |
| 896 | |
| 897 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 898 | enum { |
| 899 | STAC_CTL_WIDGET_VOL, |
| 900 | STAC_CTL_WIDGET_MUTE, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 901 | STAC_CTL_WIDGET_IO_SWITCH, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 902 | }; |
| 903 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 904 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 905 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 906 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 907 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 908 | }; |
| 909 | |
| 910 | /* add dynamic controls */ |
| 911 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) |
| 912 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 913 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 914 | |
| 915 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 916 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 917 | |
| 918 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 919 | if (! knew) |
| 920 | return -ENOMEM; |
| 921 | if (spec->kctl_alloc) { |
| 922 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 923 | kfree(spec->kctl_alloc); |
| 924 | } |
| 925 | spec->kctl_alloc = knew; |
| 926 | spec->num_kctl_alloc = num; |
| 927 | } |
| 928 | |
| 929 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 930 | *knew = stac92xx_control_templates[type]; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 931 | knew->name = kstrdup(name, GFP_KERNEL); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 932 | if (! knew->name) |
| 933 | return -ENOMEM; |
| 934 | knew->private_value = val; |
| 935 | spec->num_kctl_used++; |
| 936 | return 0; |
| 937 | } |
| 938 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 939 | /* flag inputs as additional dynamic lineouts */ |
| 940 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 941 | { |
| 942 | struct sigmatel_spec *spec = codec->spec; |
| 943 | |
| 944 | switch (cfg->line_outs) { |
| 945 | case 3: |
| 946 | /* add line-in as side */ |
| 947 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 948 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; |
| 949 | spec->line_switch = 1; |
| 950 | cfg->line_outs++; |
| 951 | } |
| 952 | break; |
| 953 | case 2: |
| 954 | /* add line-in as clfe and mic as side */ |
| 955 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 956 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; |
| 957 | spec->line_switch = 1; |
| 958 | cfg->line_outs++; |
| 959 | } |
| 960 | if (cfg->input_pins[AUTO_PIN_MIC]) { |
| 961 | cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; |
| 962 | spec->mic_switch = 1; |
| 963 | cfg->line_outs++; |
| 964 | } |
| 965 | break; |
| 966 | case 1: |
| 967 | /* add line-in as surr and mic as clfe */ |
| 968 | if (cfg->input_pins[AUTO_PIN_LINE]) { |
| 969 | cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; |
| 970 | spec->line_switch = 1; |
| 971 | cfg->line_outs++; |
| 972 | } |
| 973 | if (cfg->input_pins[AUTO_PIN_MIC]) { |
| 974 | cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; |
| 975 | spec->mic_switch = 1; |
| 976 | cfg->line_outs++; |
| 977 | } |
| 978 | break; |
| 979 | } |
| 980 | |
| 981 | return 0; |
| 982 | } |
| 983 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 984 | /* |
| 985 | * XXX The line_out pin widget connection list may not be set to the |
| 986 | * desired DAC nid. This is the case on 927x where ports A and B can |
| 987 | * be routed to several DACs. |
| 988 | * |
| 989 | * This requires an analysis of the line-out/hp pin configuration |
| 990 | * to provide a best fit for pin/DAC configurations that are routable. |
| 991 | * For now, 927x DAC4 is not supported and 927x DAC1 output to ports |
| 992 | * A and B is not supported. |
| 993 | */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 994 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 995 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, |
| 996 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 997 | { |
| 998 | struct sigmatel_spec *spec = codec->spec; |
| 999 | hda_nid_t nid; |
| 1000 | int i; |
| 1001 | |
| 1002 | /* check the pins hardwired to audio widget */ |
| 1003 | for (i = 0; i < cfg->line_outs; i++) { |
| 1004 | nid = cfg->line_out_pins[i]; |
| 1005 | spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, |
| 1006 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1007 | } |
| 1008 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1009 | spec->multiout.num_dacs = cfg->line_outs; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1010 | |
| 1011 | return 0; |
| 1012 | } |
| 1013 | |
| 1014 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1015 | static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, |
| 1016 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1017 | { |
| 1018 | char name[32]; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1019 | static const char *chname[4] = { |
| 1020 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 1021 | }; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1022 | hda_nid_t nid; |
| 1023 | int i, err; |
| 1024 | |
| 1025 | for (i = 0; i < cfg->line_outs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1026 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1027 | continue; |
| 1028 | |
| 1029 | nid = spec->multiout.dac_nids[i]; |
| 1030 | |
| 1031 | if (i == 2) { |
| 1032 | /* Center/LFE */ |
| 1033 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume", |
| 1034 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 1035 | return err; |
| 1036 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume", |
| 1037 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 1038 | return err; |
| 1039 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch", |
| 1040 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) |
| 1041 | return err; |
| 1042 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch", |
| 1043 | HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) |
| 1044 | return err; |
| 1045 | } else { |
| 1046 | sprintf(name, "%s Playback Volume", chname[i]); |
| 1047 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 1048 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 1049 | return err; |
| 1050 | sprintf(name, "%s Playback Switch", chname[i]); |
| 1051 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 1052 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 1053 | return err; |
| 1054 | } |
| 1055 | } |
| 1056 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1057 | if (spec->line_switch) |
| 1058 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) |
| 1059 | return err; |
| 1060 | |
| 1061 | if (spec->mic_switch) |
| 1062 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) |
| 1063 | return err; |
| 1064 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | /* add playback controls for HP output */ |
| 1069 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 1070 | { |
| 1071 | struct sigmatel_spec *spec = codec->spec; |
| 1072 | hda_nid_t pin = cfg->hp_pin; |
| 1073 | hda_nid_t nid; |
| 1074 | int i, err; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1075 | unsigned int wid_caps; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1076 | |
| 1077 | if (! pin) |
| 1078 | return 0; |
| 1079 | |
Takashi Iwai | 54d1740 | 2005-11-21 16:33:22 +0100 | [diff] [blame] | 1080 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1081 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1082 | spec->hp_detect = 1; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1083 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1084 | nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 1085 | for (i = 0; i < cfg->line_outs; i++) { |
| 1086 | if (! spec->multiout.dac_nids[i]) |
| 1087 | continue; |
| 1088 | if (spec->multiout.dac_nids[i] == nid) |
| 1089 | return 0; |
| 1090 | } |
| 1091 | |
| 1092 | spec->multiout.hp_nid = nid; |
| 1093 | |
| 1094 | /* control HP volume/switch on the output mixer amp */ |
| 1095 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume", |
| 1096 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 1097 | return err; |
| 1098 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch", |
| 1099 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) |
| 1100 | return err; |
| 1101 | |
| 1102 | return 0; |
| 1103 | } |
| 1104 | |
| 1105 | /* create playback/capture controls for input pins */ |
| 1106 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 1107 | { |
| 1108 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1109 | struct hda_input_mux *imux = &spec->private_imux; |
| 1110 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 1111 | int i, j, k; |
| 1112 | |
| 1113 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1114 | int index = -1; |
| 1115 | if (cfg->input_pins[i]) { |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1116 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1117 | |
| 1118 | for (j=0; j<spec->num_muxes; j++) { |
| 1119 | int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); |
| 1120 | for (k=0; k<num_cons; k++) |
| 1121 | if (con_lst[k] == cfg->input_pins[i]) { |
| 1122 | index = k; |
| 1123 | break; |
| 1124 | } |
| 1125 | if (index >= 0) |
| 1126 | break; |
| 1127 | } |
| 1128 | imux->items[imux->num_items].index = index; |
| 1129 | imux->num_items++; |
| 1130 | } |
| 1131 | } |
| 1132 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1133 | if (imux->num_items == 1) { |
| 1134 | /* |
| 1135 | * Set the current input for the muxes. |
| 1136 | * The STAC9221 has two input muxes with identical source |
| 1137 | * NID lists. Hopefully this won't get confused. |
| 1138 | */ |
| 1139 | for (i = 0; i < spec->num_muxes; i++) { |
| 1140 | snd_hda_codec_write(codec, spec->mux_nids[i], 0, |
| 1141 | AC_VERB_SET_CONNECT_SEL, |
| 1142 | imux->items[0].index); |
| 1143 | } |
| 1144 | } |
| 1145 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1146 | return 0; |
| 1147 | } |
| 1148 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1149 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 1150 | { |
| 1151 | struct sigmatel_spec *spec = codec->spec; |
| 1152 | int i; |
| 1153 | |
| 1154 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 1155 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 1156 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 1161 | { |
| 1162 | struct sigmatel_spec *spec = codec->spec; |
| 1163 | hda_nid_t pin; |
| 1164 | |
| 1165 | pin = spec->autocfg.hp_pin; |
| 1166 | if (pin) /* connect to front */ |
| 1167 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 1168 | } |
| 1169 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1170 | 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] | 1171 | { |
| 1172 | struct sigmatel_spec *spec = codec->spec; |
| 1173 | int err; |
| 1174 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1175 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1176 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1177 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1178 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1179 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1180 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 1181 | return err; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1182 | if (spec->multiout.num_dacs == 0) |
| 1183 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 1184 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1185 | |
| 1186 | if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || |
| 1187 | (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || |
| 1188 | (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 1189 | return err; |
| 1190 | |
| 1191 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1192 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1193 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1194 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1195 | if (spec->autocfg.dig_out_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1196 | spec->multiout.dig_out_nid = dig_out; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1197 | if (spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1198 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1199 | |
| 1200 | if (spec->kctl_alloc) |
| 1201 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 1202 | |
| 1203 | spec->input_mux = &spec->private_imux; |
| 1204 | |
| 1205 | return 1; |
| 1206 | } |
| 1207 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1208 | /* add playback controls for HP output */ |
| 1209 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 1210 | struct auto_pin_cfg *cfg) |
| 1211 | { |
| 1212 | struct sigmatel_spec *spec = codec->spec; |
| 1213 | hda_nid_t pin = cfg->hp_pin; |
| 1214 | unsigned int wid_caps; |
| 1215 | |
| 1216 | if (! pin) |
| 1217 | return 0; |
| 1218 | |
| 1219 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1220 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1221 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1222 | |
| 1223 | return 0; |
| 1224 | } |
| 1225 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame^] | 1226 | /* add playback controls for LFE output */ |
| 1227 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 1228 | struct auto_pin_cfg *cfg) |
| 1229 | { |
| 1230 | struct sigmatel_spec *spec = codec->spec; |
| 1231 | int err; |
| 1232 | hda_nid_t lfe_pin = 0x0; |
| 1233 | int i; |
| 1234 | |
| 1235 | /* |
| 1236 | * search speaker outs and line outs for a mono speaker pin |
| 1237 | * with an amp. If one is found, add LFE controls |
| 1238 | * for it. |
| 1239 | */ |
| 1240 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 1241 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
| 1242 | unsigned long wcaps = get_wcaps(codec, pin); |
| 1243 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 1244 | if (wcaps == AC_WCAP_OUT_AMP) |
| 1245 | /* found a mono speaker with an amp, must be lfe */ |
| 1246 | lfe_pin = pin; |
| 1247 | } |
| 1248 | |
| 1249 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 1250 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 1251 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 1252 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
| 1253 | unsigned long cfg; |
| 1254 | cfg = snd_hda_codec_read(codec, pin, 0, |
| 1255 | AC_VERB_GET_CONFIG_DEFAULT, |
| 1256 | 0x00); |
| 1257 | if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) { |
| 1258 | unsigned long wcaps = get_wcaps(codec, pin); |
| 1259 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 1260 | if (wcaps == AC_WCAP_OUT_AMP) |
| 1261 | /* found a mono speaker with an amp, |
| 1262 | must be lfe */ |
| 1263 | lfe_pin = pin; |
| 1264 | } |
| 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | if (lfe_pin) { |
| 1269 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 1270 | "LFE Playback Volume", |
| 1271 | HDA_COMPOSE_AMP_VAL(lfe_pin, 1, 0, |
| 1272 | HDA_OUTPUT)); |
| 1273 | if (err < 0) |
| 1274 | return err; |
| 1275 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 1276 | "LFE Playback Switch", |
| 1277 | HDA_COMPOSE_AMP_VAL(lfe_pin, 1, 0, |
| 1278 | HDA_OUTPUT)); |
| 1279 | if (err < 0) |
| 1280 | return err; |
| 1281 | } |
| 1282 | |
| 1283 | return 0; |
| 1284 | } |
| 1285 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1286 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 1287 | { |
| 1288 | struct sigmatel_spec *spec = codec->spec; |
| 1289 | int err; |
| 1290 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 1291 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1292 | return err; |
| 1293 | |
| 1294 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 1295 | return err; |
| 1296 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1297 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 1298 | return err; |
| 1299 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame^] | 1300 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 1301 | return err; |
| 1302 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1303 | if (spec->autocfg.dig_out_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1304 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1305 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1306 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1307 | |
| 1308 | if (spec->kctl_alloc) |
| 1309 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 1310 | |
| 1311 | spec->input_mux = &spec->private_imux; |
| 1312 | |
| 1313 | return 1; |
| 1314 | } |
| 1315 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1316 | /* |
| 1317 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 1318 | * funky external mute control using GPIO pins. |
| 1319 | */ |
| 1320 | |
| 1321 | static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 1322 | { |
| 1323 | unsigned int gpiostate, gpiomask, gpiodir; |
| 1324 | |
| 1325 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 1326 | AC_VERB_GET_GPIO_DATA, 0); |
| 1327 | |
| 1328 | if (!muted) |
| 1329 | gpiostate |= (1 << pin); |
| 1330 | else |
| 1331 | gpiostate &= ~(1 << pin); |
| 1332 | |
| 1333 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 1334 | AC_VERB_GET_GPIO_MASK, 0); |
| 1335 | gpiomask |= (1 << pin); |
| 1336 | |
| 1337 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 1338 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 1339 | gpiodir |= (1 << pin); |
| 1340 | |
| 1341 | /* AppleHDA seems to do this -- WTF is this verb?? */ |
| 1342 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 1343 | |
| 1344 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1345 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 1346 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1347 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 1348 | |
| 1349 | msleep(1); |
| 1350 | |
| 1351 | snd_hda_codec_write(codec, codec->afg, 0, |
| 1352 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 1353 | } |
| 1354 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1355 | static int stac92xx_init(struct hda_codec *codec) |
| 1356 | { |
| 1357 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1358 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1359 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1360 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1361 | snd_hda_sequence_write(codec, spec->init); |
| 1362 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1363 | /* set up pins */ |
| 1364 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 1365 | /* Enable unsolicited responses on the HP widget */ |
| 1366 | snd_hda_codec_write(codec, cfg->hp_pin, 0, |
| 1367 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 1368 | STAC_UNSOL_ENABLE); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1369 | /* fake event to set up pins */ |
| 1370 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
Tobin Davis | 68a6abd | 2006-08-21 19:02:10 +0200 | [diff] [blame] | 1371 | /* enable the headphones by default. If/when unsol_event detection works, this will be ignored */ |
| 1372 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1373 | } else { |
| 1374 | stac92xx_auto_init_multi_out(codec); |
| 1375 | stac92xx_auto_init_hp_out(codec); |
| 1376 | } |
| 1377 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1378 | hda_nid_t nid = cfg->input_pins[i]; |
| 1379 | if (nid) { |
| 1380 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 1381 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) |
| 1382 | pinctl |= stac92xx_get_vref(codec, nid); |
| 1383 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 1384 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 1385 | } |
| 1386 | if (cfg->dig_out_pin) |
| 1387 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, |
| 1388 | AC_PINCTL_OUT_EN); |
| 1389 | if (cfg->dig_in_pin) |
| 1390 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 1391 | AC_PINCTL_IN_EN); |
| 1392 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1393 | if (spec->gpio_mute) { |
| 1394 | stac922x_gpio_mute(codec, 0, 0); |
| 1395 | stac922x_gpio_mute(codec, 1, 0); |
| 1396 | } |
| 1397 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1398 | return 0; |
| 1399 | } |
| 1400 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1401 | static void stac92xx_free(struct hda_codec *codec) |
| 1402 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1403 | struct sigmatel_spec *spec = codec->spec; |
| 1404 | int i; |
| 1405 | |
| 1406 | if (! spec) |
| 1407 | return; |
| 1408 | |
| 1409 | if (spec->kctl_alloc) { |
| 1410 | for (i = 0; i < spec->num_kctl_used; i++) |
| 1411 | kfree(spec->kctl_alloc[i].name); |
| 1412 | kfree(spec->kctl_alloc); |
| 1413 | } |
| 1414 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1415 | if (spec->bios_pin_configs) |
| 1416 | kfree(spec->bios_pin_configs); |
| 1417 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1418 | kfree(spec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1419 | } |
| 1420 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1421 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 1422 | unsigned int flag) |
| 1423 | { |
| 1424 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 1425 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
| 1426 | snd_hda_codec_write(codec, nid, 0, |
| 1427 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1428 | pin_ctl | flag); |
| 1429 | } |
| 1430 | |
| 1431 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 1432 | unsigned int flag) |
| 1433 | { |
| 1434 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 1435 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
| 1436 | snd_hda_codec_write(codec, nid, 0, |
| 1437 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1438 | pin_ctl & ~flag); |
| 1439 | } |
| 1440 | |
| 1441 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 1442 | { |
| 1443 | struct sigmatel_spec *spec = codec->spec; |
| 1444 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1445 | int i, presence; |
| 1446 | |
| 1447 | if ((res >> 26) != STAC_HP_EVENT) |
| 1448 | return; |
| 1449 | |
| 1450 | presence = snd_hda_codec_read(codec, cfg->hp_pin, 0, |
| 1451 | AC_VERB_GET_PIN_SENSE, 0x00) >> 31; |
| 1452 | |
| 1453 | if (presence) { |
| 1454 | /* disable lineouts, enable hp */ |
| 1455 | for (i = 0; i < cfg->line_outs; i++) |
| 1456 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 1457 | AC_PINCTL_OUT_EN); |
| 1458 | stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); |
| 1459 | } else { |
| 1460 | /* enable lineouts, disable hp */ |
| 1461 | for (i = 0; i < cfg->line_outs; i++) |
| 1462 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 1463 | AC_PINCTL_OUT_EN); |
| 1464 | stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); |
| 1465 | } |
| 1466 | } |
| 1467 | |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1468 | #ifdef CONFIG_PM |
| 1469 | static int stac92xx_resume(struct hda_codec *codec) |
| 1470 | { |
| 1471 | struct sigmatel_spec *spec = codec->spec; |
| 1472 | int i; |
| 1473 | |
| 1474 | stac92xx_init(codec); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1475 | stac92xx_set_config_regs(codec); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1476 | for (i = 0; i < spec->num_mixers; i++) |
| 1477 | snd_hda_resume_ctls(codec, spec->mixers[i]); |
| 1478 | if (spec->multiout.dig_out_nid) |
| 1479 | snd_hda_resume_spdif_out(codec); |
| 1480 | if (spec->dig_in_nid) |
| 1481 | snd_hda_resume_spdif_in(codec); |
| 1482 | |
| 1483 | return 0; |
| 1484 | } |
| 1485 | #endif |
| 1486 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1487 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 1488 | .build_controls = stac92xx_build_controls, |
| 1489 | .build_pcms = stac92xx_build_pcms, |
| 1490 | .init = stac92xx_init, |
| 1491 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 1492 | .unsol_event = stac92xx_unsol_event, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 1493 | #ifdef CONFIG_PM |
| 1494 | .resume = stac92xx_resume, |
| 1495 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1496 | }; |
| 1497 | |
| 1498 | static int patch_stac9200(struct hda_codec *codec) |
| 1499 | { |
| 1500 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1501 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1502 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1503 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1504 | if (spec == NULL) |
| 1505 | return -ENOMEM; |
| 1506 | |
| 1507 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1508 | spec->num_pins = 8; |
| 1509 | spec->pin_nids = stac9200_pin_nids; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1510 | spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1511 | if (spec->board_config < 0) { |
| 1512 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 1513 | err = stac92xx_save_bios_config_regs(codec); |
| 1514 | if (err < 0) { |
| 1515 | stac92xx_free(codec); |
| 1516 | return err; |
| 1517 | } |
| 1518 | spec->pin_configs = spec->bios_pin_configs; |
| 1519 | } else { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1520 | spec->pin_configs = stac9200_brd_tbl[spec->board_config]; |
| 1521 | stac92xx_set_config_regs(codec); |
| 1522 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1523 | |
| 1524 | spec->multiout.max_channels = 2; |
| 1525 | spec->multiout.num_dacs = 1; |
| 1526 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 1527 | spec->adc_nids = stac9200_adc_nids; |
| 1528 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1529 | spec->num_muxes = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1530 | |
| 1531 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1532 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1533 | |
| 1534 | err = stac9200_parse_auto_config(codec); |
| 1535 | if (err < 0) { |
| 1536 | stac92xx_free(codec); |
| 1537 | return err; |
| 1538 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1539 | |
| 1540 | codec->patch_ops = stac92xx_patch_ops; |
| 1541 | |
| 1542 | return 0; |
| 1543 | } |
| 1544 | |
| 1545 | static int patch_stac922x(struct hda_codec *codec) |
| 1546 | { |
| 1547 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1548 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1549 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 1550 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1551 | if (spec == NULL) |
| 1552 | return -ENOMEM; |
| 1553 | |
| 1554 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1555 | spec->num_pins = 10; |
| 1556 | spec->pin_nids = stac922x_pin_nids; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1557 | spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1558 | if (spec->board_config < 0) { |
| 1559 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 1560 | "using BIOS defaults\n"); |
| 1561 | err = stac92xx_save_bios_config_regs(codec); |
| 1562 | if (err < 0) { |
| 1563 | stac92xx_free(codec); |
| 1564 | return err; |
| 1565 | } |
| 1566 | spec->pin_configs = spec->bios_pin_configs; |
| 1567 | } else if (stac922x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1568 | spec->pin_configs = stac922x_brd_tbl[spec->board_config]; |
| 1569 | stac92xx_set_config_regs(codec); |
| 1570 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1571 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1572 | spec->adc_nids = stac922x_adc_nids; |
| 1573 | spec->mux_nids = stac922x_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1574 | spec->num_muxes = 2; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1575 | |
| 1576 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1577 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1578 | |
| 1579 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1580 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1581 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
| 1582 | if (err < 0) { |
| 1583 | stac92xx_free(codec); |
| 1584 | return err; |
| 1585 | } |
| 1586 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 1587 | if (spec->board_config == STAC_MACMINI) |
| 1588 | spec->gpio_mute = 1; |
| 1589 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1590 | codec->patch_ops = stac92xx_patch_ops; |
| 1591 | |
| 1592 | return 0; |
| 1593 | } |
| 1594 | |
| 1595 | static int patch_stac927x(struct hda_codec *codec) |
| 1596 | { |
| 1597 | struct sigmatel_spec *spec; |
| 1598 | int err; |
| 1599 | |
| 1600 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1601 | if (spec == NULL) |
| 1602 | return -ENOMEM; |
| 1603 | |
| 1604 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1605 | spec->num_pins = 14; |
| 1606 | spec->pin_nids = stac927x_pin_nids; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1607 | spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1608 | if (spec->board_config < 0) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1609 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n"); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1610 | err = stac92xx_save_bios_config_regs(codec); |
| 1611 | if (err < 0) { |
| 1612 | stac92xx_free(codec); |
| 1613 | return err; |
| 1614 | } |
| 1615 | spec->pin_configs = spec->bios_pin_configs; |
| 1616 | } else if (stac927x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1617 | spec->pin_configs = stac927x_brd_tbl[spec->board_config]; |
| 1618 | stac92xx_set_config_regs(codec); |
| 1619 | } |
| 1620 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1621 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1622 | case STAC_D965_3ST: |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1623 | spec->adc_nids = stac927x_adc_nids; |
| 1624 | spec->mux_nids = stac927x_mux_nids; |
| 1625 | spec->num_muxes = 3; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1626 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1627 | spec->mixer = stac9227_mixer; |
| 1628 | break; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1629 | case STAC_D965_5ST: |
| 1630 | spec->adc_nids = stac927x_adc_nids; |
| 1631 | spec->mux_nids = stac927x_mux_nids; |
| 1632 | spec->num_muxes = 3; |
| 1633 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1634 | spec->mixer = stac9227_mixer; |
| 1635 | break; |
| 1636 | default: |
| 1637 | spec->adc_nids = stac927x_adc_nids; |
| 1638 | spec->mux_nids = stac927x_mux_nids; |
| 1639 | spec->num_muxes = 3; |
| 1640 | spec->init = stac927x_core_init; |
| 1641 | spec->mixer = stac927x_mixer; |
| 1642 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1643 | |
| 1644 | spec->multiout.dac_nids = spec->dac_nids; |
| 1645 | |
| 1646 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1647 | if (err < 0) { |
| 1648 | stac92xx_free(codec); |
| 1649 | return err; |
| 1650 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1651 | |
| 1652 | codec->patch_ops = stac92xx_patch_ops; |
| 1653 | |
| 1654 | return 0; |
| 1655 | } |
| 1656 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1657 | static int patch_stac9205(struct hda_codec *codec) |
| 1658 | { |
| 1659 | struct sigmatel_spec *spec; |
| 1660 | int err; |
| 1661 | |
| 1662 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1663 | if (spec == NULL) |
| 1664 | return -ENOMEM; |
| 1665 | |
| 1666 | codec->spec = spec; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1667 | spec->num_pins = 14; |
| 1668 | spec->pin_nids = stac9205_pin_nids; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1669 | spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1670 | if (spec->board_config < 0) { |
| 1671 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
| 1672 | err = stac92xx_save_bios_config_regs(codec); |
| 1673 | if (err < 0) { |
| 1674 | stac92xx_free(codec); |
| 1675 | return err; |
| 1676 | } |
| 1677 | spec->pin_configs = spec->bios_pin_configs; |
| 1678 | } else { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1679 | spec->pin_configs = stac9205_brd_tbl[spec->board_config]; |
| 1680 | stac92xx_set_config_regs(codec); |
| 1681 | } |
| 1682 | |
| 1683 | spec->adc_nids = stac9205_adc_nids; |
| 1684 | spec->mux_nids = stac9205_mux_nids; |
| 1685 | spec->num_muxes = 3; |
| 1686 | |
| 1687 | spec->init = stac9205_core_init; |
| 1688 | spec->mixer = stac9205_mixer; |
| 1689 | |
| 1690 | spec->multiout.dac_nids = spec->dac_nids; |
| 1691 | |
| 1692 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
| 1693 | if (err < 0) { |
| 1694 | stac92xx_free(codec); |
| 1695 | return err; |
| 1696 | } |
| 1697 | |
| 1698 | codec->patch_ops = stac92xx_patch_ops; |
| 1699 | |
| 1700 | return 0; |
| 1701 | } |
| 1702 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1703 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1704 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1705 | */ |
| 1706 | |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 1707 | /* static config for Sony VAIO FE550G and Sony VAIO AR */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1708 | static hda_nid_t vaio_dacs[] = { 0x2 }; |
| 1709 | #define VAIO_HP_DAC 0x5 |
| 1710 | static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; |
| 1711 | static hda_nid_t vaio_mux_nids[] = { 0x15 }; |
| 1712 | |
| 1713 | static struct hda_input_mux vaio_mux = { |
| 1714 | .num_items = 2, |
| 1715 | .items = { |
Takashi Iwai | d773781 | 2006-04-25 13:05:43 +0200 | [diff] [blame] | 1716 | /* { "HP", 0x0 }, */ |
| 1717 | { "Line", 0x1 }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1718 | { "Mic", 0x2 }, |
| 1719 | { "PCM", 0x3 }, |
| 1720 | } |
| 1721 | }; |
| 1722 | |
| 1723 | static struct hda_verb vaio_init[] = { |
| 1724 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 1725 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 1726 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 1727 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 1728 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
| 1729 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ |
| 1730 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 1731 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 1732 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 1733 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 1734 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 1735 | {} |
| 1736 | }; |
| 1737 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1738 | static struct hda_verb vaio_ar_init[] = { |
| 1739 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 1740 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 1741 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 1742 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 1743 | /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ |
| 1744 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
| 1745 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */ |
| 1746 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 1747 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 1748 | /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ |
| 1749 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 1750 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 1751 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 1752 | {} |
| 1753 | }; |
| 1754 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1755 | /* bind volumes of both NID 0x02 and 0x05 */ |
| 1756 | static int vaio_master_vol_put(struct snd_kcontrol *kcontrol, |
| 1757 | struct snd_ctl_elem_value *ucontrol) |
| 1758 | { |
| 1759 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1760 | long *valp = ucontrol->value.integer.value; |
| 1761 | int change; |
| 1762 | |
| 1763 | change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, |
| 1764 | 0x7f, valp[0] & 0x7f); |
| 1765 | change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, |
| 1766 | 0x7f, valp[1] & 0x7f); |
| 1767 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
| 1768 | 0x7f, valp[0] & 0x7f); |
| 1769 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
| 1770 | 0x7f, valp[1] & 0x7f); |
| 1771 | return change; |
| 1772 | } |
| 1773 | |
| 1774 | /* bind volumes of both NID 0x02 and 0x05 */ |
| 1775 | static int vaio_master_sw_put(struct snd_kcontrol *kcontrol, |
| 1776 | struct snd_ctl_elem_value *ucontrol) |
| 1777 | { |
| 1778 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1779 | long *valp = ucontrol->value.integer.value; |
| 1780 | int change; |
| 1781 | |
| 1782 | change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 1783 | 0x80, (valp[0] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1784 | change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 1785 | 0x80, (valp[1] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1786 | snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 1787 | 0x80, (valp[0] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1788 | snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0, |
Takashi Iwai | a9393d7 | 2006-05-03 11:59:03 +0200 | [diff] [blame] | 1789 | 0x80, (valp[1] ? 0 : 0x80)); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1790 | return change; |
| 1791 | } |
| 1792 | |
| 1793 | static struct snd_kcontrol_new vaio_mixer[] = { |
| 1794 | { |
| 1795 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1796 | .name = "Master Playback Volume", |
| 1797 | .info = snd_hda_mixer_amp_volume_info, |
| 1798 | .get = snd_hda_mixer_amp_volume_get, |
| 1799 | .put = vaio_master_vol_put, |
Takashi Iwai | c256652 | 2006-08-17 18:21:36 +0200 | [diff] [blame] | 1800 | .tlv = { .c = snd_hda_mixer_amp_tlv }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1801 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 1802 | }, |
| 1803 | { |
| 1804 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1805 | .name = "Master Playback Switch", |
| 1806 | .info = snd_hda_mixer_amp_switch_info, |
| 1807 | .get = snd_hda_mixer_amp_switch_get, |
| 1808 | .put = vaio_master_sw_put, |
| 1809 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 1810 | }, |
| 1811 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 1812 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 1813 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 1814 | { |
| 1815 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1816 | .name = "Capture Source", |
| 1817 | .count = 1, |
| 1818 | .info = stac92xx_mux_enum_info, |
| 1819 | .get = stac92xx_mux_enum_get, |
| 1820 | .put = stac92xx_mux_enum_put, |
| 1821 | }, |
| 1822 | {} |
| 1823 | }; |
| 1824 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1825 | static struct snd_kcontrol_new vaio_ar_mixer[] = { |
| 1826 | { |
| 1827 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1828 | .name = "Master Playback Volume", |
| 1829 | .info = snd_hda_mixer_amp_volume_info, |
| 1830 | .get = snd_hda_mixer_amp_volume_get, |
| 1831 | .put = vaio_master_vol_put, |
| 1832 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 1833 | }, |
| 1834 | { |
| 1835 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1836 | .name = "Master Playback Switch", |
| 1837 | .info = snd_hda_mixer_amp_switch_info, |
| 1838 | .get = snd_hda_mixer_amp_switch_get, |
| 1839 | .put = vaio_master_sw_put, |
| 1840 | .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 1841 | }, |
| 1842 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 1843 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 1844 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 1845 | /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT), |
| 1846 | HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/ |
| 1847 | { |
| 1848 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1849 | .name = "Capture Source", |
| 1850 | .count = 1, |
| 1851 | .info = stac92xx_mux_enum_info, |
| 1852 | .get = stac92xx_mux_enum_get, |
| 1853 | .put = stac92xx_mux_enum_put, |
| 1854 | }, |
| 1855 | {} |
| 1856 | }; |
| 1857 | |
| 1858 | static struct hda_codec_ops stac9872_patch_ops = { |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1859 | .build_controls = stac92xx_build_controls, |
| 1860 | .build_pcms = stac92xx_build_pcms, |
| 1861 | .init = stac92xx_init, |
| 1862 | .free = stac92xx_free, |
| 1863 | #ifdef CONFIG_PM |
| 1864 | .resume = stac92xx_resume, |
| 1865 | #endif |
| 1866 | }; |
| 1867 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1868 | enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ |
| 1869 | CXD9872RD_VAIO, |
| 1870 | /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ |
| 1871 | STAC9872AK_VAIO, |
| 1872 | /* Unknown. id=0x83847661 and subsys=0x104D1200. */ |
| 1873 | STAC9872K_VAIO, |
| 1874 | /* AR Series. id=0x83847664 and subsys=104D1300 */ |
| 1875 | CXD9872AKD_VAIO |
| 1876 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1877 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1878 | static struct hda_board_config stac9872_cfg_tbl[] = { |
| 1879 | { .modelname = "vaio", .config = CXD9872RD_VAIO }, |
| 1880 | { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1881 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1882 | .config = CXD9872RD_VAIO }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1883 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1884 | .config = CXD9872RD_VAIO }, |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 1885 | { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1886 | .config = CXD9872AKD_VAIO }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1887 | {} |
| 1888 | }; |
| 1889 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1890 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1891 | { |
| 1892 | struct sigmatel_spec *spec; |
| 1893 | int board_config; |
| 1894 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1895 | board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1896 | if (board_config < 0) |
| 1897 | /* unknown config, let generic-parser do its job... */ |
| 1898 | return snd_hda_parse_generic_codec(codec); |
| 1899 | |
| 1900 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1901 | if (spec == NULL) |
| 1902 | return -ENOMEM; |
| 1903 | |
| 1904 | codec->spec = spec; |
| 1905 | switch (board_config) { |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1906 | case CXD9872RD_VAIO: |
| 1907 | case STAC9872AK_VAIO: |
| 1908 | case STAC9872K_VAIO: |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1909 | spec->mixer = vaio_mixer; |
| 1910 | spec->init = vaio_init; |
| 1911 | spec->multiout.max_channels = 2; |
| 1912 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 1913 | spec->multiout.dac_nids = vaio_dacs; |
| 1914 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 1915 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 1916 | spec->adc_nids = vaio_adcs; |
| 1917 | spec->input_mux = &vaio_mux; |
| 1918 | spec->mux_nids = vaio_mux_nids; |
| 1919 | break; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1920 | |
| 1921 | case CXD9872AKD_VAIO: |
| 1922 | spec->mixer = vaio_ar_mixer; |
| 1923 | spec->init = vaio_ar_init; |
| 1924 | spec->multiout.max_channels = 2; |
| 1925 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 1926 | spec->multiout.dac_nids = vaio_dacs; |
| 1927 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 1928 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 1929 | spec->adc_nids = vaio_adcs; |
| 1930 | spec->input_mux = &vaio_mux; |
| 1931 | spec->mux_nids = vaio_mux_nids; |
| 1932 | break; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1933 | } |
| 1934 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1935 | codec->patch_ops = stac9872_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 1936 | return 0; |
| 1937 | } |
| 1938 | |
| 1939 | |
| 1940 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1941 | * patch entries |
| 1942 | */ |
| 1943 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
| 1944 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 1945 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 1946 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 1947 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 1948 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 1949 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 1950 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 1951 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 1952 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 1953 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 1954 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 1955 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 1956 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1957 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 1958 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 1959 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 1960 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 1961 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 1962 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 1963 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 1964 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 1965 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 1966 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 1967 | /* The following does not take into account .id=0x83847661 when subsys = |
| 1968 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 1969 | * currently not fully supported. |
| 1970 | */ |
| 1971 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 1972 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 1973 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1974 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 1975 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 1976 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 1977 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 1978 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 1979 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 1980 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 1981 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1982 | {} /* terminator */ |
| 1983 | }; |