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