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, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 42 | STAC_9200_DELL_D21, |
| 43 | STAC_9200_DELL_D22, |
| 44 | STAC_9200_DELL_D23, |
| 45 | STAC_9200_DELL_M21, |
| 46 | STAC_9200_DELL_M22, |
| 47 | STAC_9200_DELL_M23, |
| 48 | STAC_9200_DELL_M24, |
| 49 | STAC_9200_DELL_M25, |
| 50 | STAC_9200_DELL_M26, |
| 51 | STAC_9200_DELL_M27, |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 52 | STAC_9200_GATEWAY, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 53 | STAC_9200_MODELS |
| 54 | }; |
| 55 | |
| 56 | enum { |
| 57 | STAC_9205_REF, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 58 | STAC_9205_DELL_M42, |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 59 | STAC_9205_DELL_M43, |
| 60 | STAC_9205_DELL_M44, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 61 | STAC_9205_MODELS |
| 62 | }; |
| 63 | |
| 64 | enum { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 65 | STAC_92HD73XX_REF, |
| 66 | STAC_92HD73XX_MODELS |
| 67 | }; |
| 68 | |
| 69 | enum { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 70 | STAC_92HD71BXX_REF, |
| 71 | STAC_92HD71BXX_MODELS |
| 72 | }; |
| 73 | |
| 74 | enum { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 75 | STAC_925x_REF, |
| 76 | STAC_M2_2, |
| 77 | STAC_MA6, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 78 | STAC_PA6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 79 | STAC_925x_MODELS |
| 80 | }; |
| 81 | |
| 82 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 83 | STAC_D945_REF, |
| 84 | STAC_D945GTP3, |
| 85 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 86 | STAC_INTEL_MAC_V1, |
| 87 | STAC_INTEL_MAC_V2, |
| 88 | STAC_INTEL_MAC_V3, |
| 89 | STAC_INTEL_MAC_V4, |
| 90 | STAC_INTEL_MAC_V5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 91 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 92 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 93 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 94 | STAC_MACBOOK_PRO_V1, |
| 95 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 96 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 97 | STAC_IMAC_INTEL_20, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 98 | STAC_922X_DELL_D81, |
| 99 | STAC_922X_DELL_D82, |
| 100 | STAC_922X_DELL_M81, |
| 101 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 102 | STAC_922X_MODELS |
| 103 | }; |
| 104 | |
| 105 | enum { |
| 106 | STAC_D965_REF, |
| 107 | STAC_D965_3ST, |
| 108 | STAC_D965_5ST, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 109 | STAC_DELL_3ST, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 110 | STAC_927X_MODELS |
| 111 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 112 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 113 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 114 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 115 | unsigned int num_mixers; |
| 116 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 117 | int board_config; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 118 | unsigned int surr_switch: 1; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 119 | unsigned int line_switch: 1; |
| 120 | unsigned int mic_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 121 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 122 | unsigned int hp_detect: 1; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 123 | unsigned int gpio_mute: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 124 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 125 | unsigned int gpio_mask, gpio_data; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 126 | unsigned char aloopback_mask; |
| 127 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 128 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 129 | /* playback */ |
| 130 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 131 | hda_nid_t dac_nids[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 132 | |
| 133 | /* capture */ |
| 134 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 135 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 136 | hda_nid_t *mux_nids; |
| 137 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 138 | hda_nid_t *dmic_nids; |
| 139 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 140 | hda_nid_t *dmux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 141 | hda_nid_t dig_in_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 142 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 143 | /* pin widgets */ |
| 144 | hda_nid_t *pin_nids; |
| 145 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 146 | unsigned int *pin_configs; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 147 | unsigned int *bios_pin_configs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 148 | |
| 149 | /* codec specific stuff */ |
| 150 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 151 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 152 | |
| 153 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 154 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 155 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 156 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 157 | unsigned int cur_mux[3]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 158 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 159 | /* i/o switches */ |
| 160 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 161 | unsigned int clfe_swap; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 162 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 163 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 164 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 165 | |
| 166 | /* dynamic controls and input_mux */ |
| 167 | struct auto_pin_cfg autocfg; |
| 168 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 169 | struct snd_kcontrol_new *kctl_alloc; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 170 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 171 | struct hda_input_mux private_imux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | static hda_nid_t stac9200_adc_nids[1] = { |
| 175 | 0x03, |
| 176 | }; |
| 177 | |
| 178 | static hda_nid_t stac9200_mux_nids[1] = { |
| 179 | 0x0c, |
| 180 | }; |
| 181 | |
| 182 | static hda_nid_t stac9200_dac_nids[1] = { |
| 183 | 0x02, |
| 184 | }; |
| 185 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 186 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 187 | 0x1a, 0x1b |
| 188 | }; |
| 189 | |
| 190 | #define STAC92HD73XX_NUM_DMICS 2 |
| 191 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 192 | 0x13, 0x14, 0 |
| 193 | }; |
| 194 | |
| 195 | #define STAC92HD73_DAC_COUNT 5 |
| 196 | static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = { |
| 197 | 0x15, 0x16, 0x17, 0x18, 0x19, |
| 198 | }; |
| 199 | |
| 200 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 201 | 0x28, 0x29, 0x2a, 0x2b, |
| 202 | }; |
| 203 | |
| 204 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 205 | 0x20, 0x21, |
| 206 | }; |
| 207 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 208 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 209 | 0x12, 0x13, |
| 210 | }; |
| 211 | |
| 212 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 213 | 0x1a, 0x1b |
| 214 | }; |
| 215 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 216 | static hda_nid_t stac92hd71bxx_dmux_nids[1] = { |
| 217 | 0x1c, |
| 218 | }; |
| 219 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 220 | static hda_nid_t stac92hd71bxx_dac_nids[2] = { |
| 221 | 0x10, /*0x11, */ |
| 222 | }; |
| 223 | |
| 224 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 225 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 226 | 0x18, 0x19, 0 |
| 227 | }; |
| 228 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 229 | static hda_nid_t stac925x_adc_nids[1] = { |
| 230 | 0x03, |
| 231 | }; |
| 232 | |
| 233 | static hda_nid_t stac925x_mux_nids[1] = { |
| 234 | 0x0f, |
| 235 | }; |
| 236 | |
| 237 | static hda_nid_t stac925x_dac_nids[1] = { |
| 238 | 0x02, |
| 239 | }; |
| 240 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 241 | #define STAC925X_NUM_DMICS 1 |
| 242 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 243 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 244 | }; |
| 245 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 246 | static hda_nid_t stac922x_adc_nids[2] = { |
| 247 | 0x06, 0x07, |
| 248 | }; |
| 249 | |
| 250 | static hda_nid_t stac922x_mux_nids[2] = { |
| 251 | 0x12, 0x13, |
| 252 | }; |
| 253 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 254 | static hda_nid_t stac927x_adc_nids[3] = { |
| 255 | 0x07, 0x08, 0x09 |
| 256 | }; |
| 257 | |
| 258 | static hda_nid_t stac927x_mux_nids[3] = { |
| 259 | 0x15, 0x16, 0x17 |
| 260 | }; |
| 261 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 262 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 263 | 0x1b, |
| 264 | }; |
| 265 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 266 | #define STAC927X_NUM_DMICS 2 |
| 267 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 268 | 0x13, 0x14, 0 |
| 269 | }; |
| 270 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 271 | static hda_nid_t stac9205_adc_nids[2] = { |
| 272 | 0x12, 0x13 |
| 273 | }; |
| 274 | |
| 275 | static hda_nid_t stac9205_mux_nids[2] = { |
| 276 | 0x19, 0x1a |
| 277 | }; |
| 278 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 279 | static hda_nid_t stac9205_dmux_nids[1] = { |
| 280 | 0x1d, |
| 281 | }; |
| 282 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 283 | #define STAC9205_NUM_DMICS 2 |
| 284 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 285 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 286 | }; |
| 287 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 288 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 289 | 0x08, 0x09, 0x0d, 0x0e, |
| 290 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 293 | static hda_nid_t stac925x_pin_nids[8] = { |
| 294 | 0x07, 0x08, 0x0a, 0x0b, |
| 295 | 0x0c, 0x0d, 0x10, 0x11, |
| 296 | }; |
| 297 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 298 | static hda_nid_t stac922x_pin_nids[10] = { |
| 299 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 300 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 301 | }; |
| 302 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 303 | static hda_nid_t stac92hd73xx_pin_nids[12] = { |
| 304 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 305 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 306 | 0x14, 0x22 |
| 307 | }; |
| 308 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 309 | static hda_nid_t stac92hd71bxx_pin_nids[10] = { |
| 310 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 311 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
| 312 | }; |
| 313 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 314 | static hda_nid_t stac927x_pin_nids[14] = { |
| 315 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 316 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 317 | 0x14, 0x21, 0x22, 0x23, |
| 318 | }; |
| 319 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 320 | static hda_nid_t stac9205_pin_nids[12] = { |
| 321 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 322 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 323 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 324 | }; |
| 325 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 326 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 327 | struct snd_ctl_elem_info *uinfo) |
| 328 | { |
| 329 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 330 | struct sigmatel_spec *spec = codec->spec; |
| 331 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 332 | } |
| 333 | |
| 334 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 335 | struct snd_ctl_elem_value *ucontrol) |
| 336 | { |
| 337 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 338 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 339 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 340 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 341 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 346 | struct snd_ctl_elem_value *ucontrol) |
| 347 | { |
| 348 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 349 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 350 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 351 | |
| 352 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 353 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 354 | } |
| 355 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 356 | 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] | 357 | { |
| 358 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 359 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 360 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 361 | } |
| 362 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 363 | 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] | 364 | { |
| 365 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 366 | struct sigmatel_spec *spec = codec->spec; |
| 367 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 368 | |
| 369 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 370 | return 0; |
| 371 | } |
| 372 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 373 | 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] | 374 | { |
| 375 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 376 | struct sigmatel_spec *spec = codec->spec; |
| 377 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 378 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 379 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 380 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 381 | } |
| 382 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 383 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 384 | |
| 385 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 386 | struct snd_ctl_elem_value *ucontrol) |
| 387 | { |
| 388 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 389 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 390 | struct sigmatel_spec *spec = codec->spec; |
| 391 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 392 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 393 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 398 | struct snd_ctl_elem_value *ucontrol) |
| 399 | { |
| 400 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 401 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 402 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 403 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 404 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 405 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 406 | idx_val = spec->aloopback_mask << idx; |
| 407 | if (ucontrol->value.integer.value[0]) |
| 408 | val = spec->aloopback | idx_val; |
| 409 | else |
| 410 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 411 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 412 | return 0; |
| 413 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 414 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 415 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 416 | /* Only return the bits defined by the shift value of the |
| 417 | * first two bytes of the mask |
| 418 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 419 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 420 | kcontrol->private_value & 0xFFFF, 0x0); |
| 421 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 422 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 423 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 424 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 425 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 426 | } else { |
| 427 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 428 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 432 | kcontrol->private_value >> 16, dac_mode); |
| 433 | |
| 434 | return 1; |
| 435 | } |
| 436 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 437 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 438 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 439 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 440 | {} |
| 441 | }; |
| 442 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 443 | static struct hda_verb stac9200_eapd_init[] = { |
| 444 | /* set dac0mux for dac converter */ |
| 445 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 446 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 447 | {} |
| 448 | }; |
| 449 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 450 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 451 | /* set master volume and direct control */ |
| 452 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 453 | /* setup audio connections */ |
| 454 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 455 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 456 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 457 | /* setup adcs to point to mixer */ |
| 458 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 459 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 460 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Front Mic */ |
| 461 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Mic */ |
| 462 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Line In */ |
| 463 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 464 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 465 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 466 | /* setup import muxs */ |
| 467 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 468 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 469 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 470 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 471 | {} |
| 472 | }; |
| 473 | |
| 474 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 475 | /* set master volume and direct control */ |
| 476 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 477 | /* setup audio connections */ |
| 478 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 479 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 480 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 481 | /* connect hp ports to dac3 */ |
| 482 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 483 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 484 | /* setup adcs to point to mixer */ |
| 485 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 486 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 487 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Front Mic */ |
| 488 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Mic */ |
| 489 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Line In */ |
| 490 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 491 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 492 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 493 | /* setup import muxs */ |
| 494 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 495 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 496 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 497 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 498 | {} |
| 499 | }; |
| 500 | |
| 501 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 502 | /* set master volume and direct control */ |
| 503 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 504 | /* setup audio connections */ |
| 505 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 506 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 507 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 }, |
| 508 | /* dac3 is connected to import3 mux */ |
| 509 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
| 510 | /* connect hp ports to dac4 */ |
| 511 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04}, |
| 512 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04}, |
| 513 | /* setup adcs to point to mixer */ |
| 514 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 515 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 516 | { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Front Mic */ |
| 517 | { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Mic */ |
| 518 | { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Line In */ |
| 519 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 520 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 521 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 522 | /* setup import muxs */ |
| 523 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 524 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 525 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 526 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 527 | {} |
| 528 | }; |
| 529 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 530 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 531 | /* set master volume and direct control */ |
| 532 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 533 | /* connect headphone jack to dac1 */ |
| 534 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 535 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */ |
| 536 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ |
| 537 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 538 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 539 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 540 | /* unmute mono out node */ |
| 541 | { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 542 | }; |
| 543 | |
| 544 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
| 545 | /* set master volume and direct control */ |
| 546 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 547 | /* connect headphone jack to dac1 */ |
| 548 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 549 | /* connect ports 0d and 0f to audio mixer */ |
| 550 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2}, |
| 551 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 552 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 553 | /* unmute dac0 input in audio mixer */ |
| 554 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 555 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ |
| 556 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 557 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 558 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 559 | /* unmute mono out node */ |
| 560 | { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 561 | {} |
| 562 | }; |
| 563 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 564 | static struct hda_verb stac925x_core_init[] = { |
| 565 | /* set dac0mux for dac converter */ |
| 566 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 567 | {} |
| 568 | }; |
| 569 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 570 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 571 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 572 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 573 | {} |
| 574 | }; |
| 575 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 576 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 577 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 578 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 579 | /* unmute node 0x1b */ |
| 580 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 581 | /* select node 0x03 as DAC */ |
| 582 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 583 | {} |
| 584 | }; |
| 585 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 586 | static struct hda_verb stac927x_core_init[] = { |
| 587 | /* set master volume and direct control */ |
| 588 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 589 | {} |
| 590 | }; |
| 591 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 592 | static struct hda_verb stac9205_core_init[] = { |
| 593 | /* set master volume and direct control */ |
| 594 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 595 | {} |
| 596 | }; |
| 597 | |
Matthew Ranostay | 47744f6 | 2007-10-19 08:19:56 +0200 | [diff] [blame] | 598 | #define STAC_DIGITAL_INPUT_SOURCE(cnt) \ |
| 599 | { \ |
| 600 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 601 | .name = "Digital Input Source", \ |
| 602 | .count = cnt, \ |
| 603 | .info = stac92xx_dmux_enum_info, \ |
| 604 | .get = stac92xx_dmux_enum_get, \ |
| 605 | .put = stac92xx_dmux_enum_put,\ |
| 606 | } |
| 607 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 608 | #define STAC_INPUT_SOURCE(cnt) \ |
Maxim Levitsky | ca7c5a8 | 2007-08-31 12:52:19 +0200 | [diff] [blame] | 609 | { \ |
| 610 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 611 | .name = "Input Source", \ |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 612 | .count = cnt, \ |
Maxim Levitsky | ca7c5a8 | 2007-08-31 12:52:19 +0200 | [diff] [blame] | 613 | .info = stac92xx_mux_enum_info, \ |
| 614 | .get = stac92xx_mux_enum_get, \ |
| 615 | .put = stac92xx_mux_enum_put, \ |
| 616 | } |
| 617 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 618 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 619 | { \ |
| 620 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 621 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 622 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 623 | .info = stac92xx_aloopback_info, \ |
| 624 | .get = stac92xx_aloopback_get, \ |
| 625 | .put = stac92xx_aloopback_put, \ |
| 626 | .private_value = verb_read | (verb_write << 16), \ |
| 627 | } |
| 628 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 629 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 630 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 631 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 632 | STAC_INPUT_SOURCE(1), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 633 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 634 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 635 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 636 | { } /* end */ |
| 637 | }; |
| 638 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 639 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
| 640 | STAC_DIGITAL_INPUT_SOURCE(2), |
| 641 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 642 | |
| 643 | /* hardware gain controls */ |
Matthew Ranostay | 71685b9 | 2007-12-14 12:07:31 +0100 | [diff] [blame] | 644 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x13, 0x0, HDA_INPUT), |
| 645 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x14, 0x0, HDA_INPUT), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 646 | |
| 647 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 648 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 649 | |
| 650 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 651 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 652 | |
| 653 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 654 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 655 | |
| 656 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 657 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 658 | |
| 659 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 660 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 661 | |
| 662 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 663 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 664 | |
| 665 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 666 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 667 | { } /* end */ |
| 668 | }; |
| 669 | |
| 670 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
| 671 | STAC_DIGITAL_INPUT_SOURCE(2), |
| 672 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 673 | |
| 674 | /* hardware gain controls */ |
Matthew Ranostay | 71685b9 | 2007-12-14 12:07:31 +0100 | [diff] [blame] | 675 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x13, 0x0, HDA_INPUT), |
| 676 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x14, 0x0, HDA_INPUT), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 677 | |
| 678 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 679 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 680 | |
| 681 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 682 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 683 | |
| 684 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 685 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 686 | |
| 687 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 688 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 689 | |
| 690 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 691 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 692 | |
| 693 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 694 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 695 | |
| 696 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 697 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 698 | { } /* end */ |
| 699 | }; |
| 700 | |
| 701 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
| 702 | STAC_DIGITAL_INPUT_SOURCE(2), |
| 703 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 704 | |
| 705 | /* hardware gain controls */ |
Matthew Ranostay | 71685b9 | 2007-12-14 12:07:31 +0100 | [diff] [blame] | 706 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x13, 0x0, HDA_INPUT), |
| 707 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x14, 0x0, HDA_INPUT), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 708 | |
| 709 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 710 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 711 | |
| 712 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 713 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 714 | |
| 715 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 716 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 717 | |
| 718 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 719 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 720 | |
| 721 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 722 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 723 | |
| 724 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 725 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 726 | |
| 727 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 728 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 729 | { } /* end */ |
| 730 | }; |
| 731 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 732 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 733 | STAC_DIGITAL_INPUT_SOURCE(1), |
| 734 | STAC_INPUT_SOURCE(2), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 735 | |
| 736 | /* hardware gain controls */ |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 737 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x18, 0x0, HDA_OUTPUT), |
| 738 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x19, 0x0, HDA_OUTPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 739 | |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 740 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 741 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 742 | HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT), |
| 743 | |
| 744 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 745 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 746 | HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT), |
| 747 | |
| 748 | HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT), |
| 749 | HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 750 | { } /* end */ |
| 751 | }; |
| 752 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 753 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
| 754 | STAC_DIGITAL_INPUT_SOURCE(1), |
| 755 | STAC_INPUT_SOURCE(2), |
| 756 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
| 757 | |
| 758 | /* hardware gain controls */ |
| 759 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x18, 0x0, HDA_OUTPUT), |
| 760 | HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x19, 0x0, HDA_OUTPUT), |
| 761 | |
| 762 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 763 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 764 | HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT), |
| 765 | |
| 766 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 767 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 768 | HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT), |
| 769 | { } /* end */ |
| 770 | }; |
| 771 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 772 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 773 | STAC_INPUT_SOURCE(1), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 774 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
| 775 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT), |
| 776 | HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT), |
| 777 | { } /* end */ |
| 778 | }; |
| 779 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 780 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Matthew Ranostay | 47744f6 | 2007-10-19 08:19:56 +0200 | [diff] [blame] | 781 | STAC_DIGITAL_INPUT_SOURCE(1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 782 | STAC_INPUT_SOURCE(2), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 783 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 784 | |
| 785 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 786 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
| 787 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT), |
| 788 | |
| 789 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 790 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
| 791 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT), |
| 792 | |
| 793 | { } /* end */ |
| 794 | }; |
| 795 | |
| 796 | /* This needs to be generated dynamically based on sequence */ |
| 797 | static struct snd_kcontrol_new stac922x_mixer[] = { |
| 798 | STAC_INPUT_SOURCE(2), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 799 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 800 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
| 801 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT), |
| 802 | |
| 803 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 804 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
| 805 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT), |
| 806 | { } /* end */ |
| 807 | }; |
| 808 | |
| 809 | |
| 810 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Matthew Ranostay | 47744f6 | 2007-10-19 08:19:56 +0200 | [diff] [blame] | 811 | STAC_DIGITAL_INPUT_SOURCE(1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 812 | STAC_INPUT_SOURCE(3), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 813 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 814 | |
| 815 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 816 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
| 817 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT), |
| 818 | |
| 819 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 820 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
| 821 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT), |
| 822 | |
| 823 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 824 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
| 825 | HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 826 | { } /* end */ |
| 827 | }; |
| 828 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 829 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 830 | { |
| 831 | struct sigmatel_spec *spec = codec->spec; |
| 832 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 833 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 834 | |
| 835 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 836 | if (err < 0) |
| 837 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 838 | |
| 839 | for (i = 0; i < spec->num_mixers; i++) { |
| 840 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 841 | if (err < 0) |
| 842 | return err; |
| 843 | } |
| 844 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 845 | if (spec->multiout.dig_out_nid) { |
| 846 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 847 | if (err < 0) |
| 848 | return err; |
| 849 | } |
| 850 | if (spec->dig_in_nid) { |
| 851 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 852 | if (err < 0) |
| 853 | return err; |
| 854 | } |
| 855 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 856 | } |
| 857 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 858 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 859 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 860 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 861 | }; |
| 862 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 863 | /* |
| 864 | STAC 9200 pin configs for |
| 865 | 102801A8 |
| 866 | 102801DE |
| 867 | 102801E8 |
| 868 | */ |
| 869 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 870 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 871 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 872 | }; |
| 873 | |
| 874 | /* |
| 875 | STAC 9200 pin configs for |
| 876 | 102801C0 |
| 877 | 102801C1 |
| 878 | */ |
| 879 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 880 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 881 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 882 | }; |
| 883 | |
| 884 | /* |
| 885 | STAC 9200 pin configs for |
| 886 | 102801C4 (Dell Dimension E310) |
| 887 | 102801C5 |
| 888 | 102801C7 |
| 889 | 102801D9 |
| 890 | 102801DA |
| 891 | 102801E3 |
| 892 | */ |
| 893 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 894 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 895 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 896 | }; |
| 897 | |
| 898 | |
| 899 | /* |
| 900 | STAC 9200-32 pin configs for |
| 901 | 102801B5 (Dell Inspiron 630m) |
| 902 | 102801D8 (Dell Inspiron 640m) |
| 903 | */ |
| 904 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 905 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 906 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 907 | }; |
| 908 | |
| 909 | /* |
| 910 | STAC 9200-32 pin configs for |
| 911 | 102801C2 (Dell Latitude D620) |
| 912 | 102801C8 |
| 913 | 102801CC (Dell Latitude D820) |
| 914 | 102801D4 |
| 915 | 102801D6 |
| 916 | */ |
| 917 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 918 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 919 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 920 | }; |
| 921 | |
| 922 | /* |
| 923 | STAC 9200-32 pin configs for |
| 924 | 102801CE (Dell XPS M1710) |
| 925 | 102801CF (Dell Precision M90) |
| 926 | */ |
| 927 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 928 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 929 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 930 | }; |
| 931 | |
| 932 | /* |
| 933 | STAC 9200-32 pin configs for |
| 934 | 102801C9 |
| 935 | 102801CA |
| 936 | 102801CB (Dell Latitude 120L) |
| 937 | 102801D3 |
| 938 | */ |
| 939 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 940 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 941 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 942 | }; |
| 943 | |
| 944 | /* |
| 945 | STAC 9200-32 pin configs for |
| 946 | 102801BD (Dell Inspiron E1505n) |
| 947 | 102801EE |
| 948 | 102801EF |
| 949 | */ |
| 950 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 951 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 952 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 953 | }; |
| 954 | |
| 955 | /* |
| 956 | STAC 9200-32 pin configs for |
| 957 | 102801F5 (Dell Inspiron 1501) |
| 958 | 102801F6 |
| 959 | */ |
| 960 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 961 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 962 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 963 | }; |
| 964 | |
| 965 | /* |
| 966 | STAC 9200-32 |
| 967 | 102801CD (Dell Inspiron E1705/9400) |
| 968 | */ |
| 969 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 970 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 971 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 972 | }; |
| 973 | |
| 974 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 975 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 976 | [STAC_REF] = ref9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 977 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 978 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 979 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 980 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 981 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 982 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 983 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 984 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 985 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 986 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 987 | }; |
| 988 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 989 | static const char *stac9200_models[STAC_9200_MODELS] = { |
| 990 | [STAC_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 991 | [STAC_9200_DELL_D21] = "dell-d21", |
| 992 | [STAC_9200_DELL_D22] = "dell-d22", |
| 993 | [STAC_9200_DELL_D23] = "dell-d23", |
| 994 | [STAC_9200_DELL_M21] = "dell-m21", |
| 995 | [STAC_9200_DELL_M22] = "dell-m22", |
| 996 | [STAC_9200_DELL_M23] = "dell-m23", |
| 997 | [STAC_9200_DELL_M24] = "dell-m24", |
| 998 | [STAC_9200_DELL_M25] = "dell-m25", |
| 999 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1000 | [STAC_9200_DELL_M27] = "dell-m27", |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1001 | [STAC_9200_GATEWAY] = "gateway", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1002 | }; |
| 1003 | |
| 1004 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1005 | /* SigmaTel reference board */ |
| 1006 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1007 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1008 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1009 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1010 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1011 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1012 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1013 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1014 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1015 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1016 | "unknown Dell", STAC_9200_DELL_D22), |
| 1017 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1018 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1019 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1020 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1021 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1022 | "unknown Dell", STAC_9200_DELL_D23), |
| 1023 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1024 | "unknown Dell", STAC_9200_DELL_D23), |
| 1025 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1026 | "unknown Dell", STAC_9200_DELL_M22), |
| 1027 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1028 | "unknown Dell", STAC_9200_DELL_M24), |
| 1029 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1030 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1031 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1032 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1033 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1034 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1035 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1036 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1037 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1038 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1039 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1040 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1041 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1042 | "unknown Dell", STAC_9200_DELL_M22), |
| 1043 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1044 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1045 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1046 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1047 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1048 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1049 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1050 | "unknown Dell", STAC_9200_DELL_D23), |
| 1051 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1052 | "unknown Dell", STAC_9200_DELL_D23), |
| 1053 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1054 | "unknown Dell", STAC_9200_DELL_D21), |
| 1055 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1056 | "unknown Dell", STAC_9200_DELL_D23), |
| 1057 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1058 | "unknown Dell", STAC_9200_DELL_D21), |
| 1059 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1060 | "unknown Dell", STAC_9200_DELL_M25), |
| 1061 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1062 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1063 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1064 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1065 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1066 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1067 | /* Panasonic */ |
| 1068 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1069 | /* Gateway machines needs EAPD to be set on resume */ |
| 1070 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY), |
| 1071 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", |
| 1072 | STAC_9200_GATEWAY), |
| 1073 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", |
| 1074 | STAC_9200_GATEWAY), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1075 | {} /* terminator */ |
| 1076 | }; |
| 1077 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1078 | static unsigned int ref925x_pin_configs[8] = { |
| 1079 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1080 | 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e, |
| 1081 | }; |
| 1082 | |
| 1083 | static unsigned int stac925x_MA6_pin_configs[8] = { |
| 1084 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1085 | 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, |
| 1086 | }; |
| 1087 | |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1088 | static unsigned int stac925x_PA6_pin_configs[8] = { |
| 1089 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1090 | 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e, |
| 1091 | }; |
| 1092 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1093 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Steve Longerbeam | 7353e14 | 2007-05-29 14:36:17 +0200 | [diff] [blame] | 1094 | 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020, |
| 1095 | 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1096 | }; |
| 1097 | |
| 1098 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1099 | [STAC_REF] = ref925x_pin_configs, |
| 1100 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
| 1101 | [STAC_MA6] = stac925x_MA6_pin_configs, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1102 | [STAC_PA6] = stac925x_PA6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1103 | }; |
| 1104 | |
| 1105 | static const char *stac925x_models[STAC_925x_MODELS] = { |
| 1106 | [STAC_REF] = "ref", |
| 1107 | [STAC_M2_2] = "m2-2", |
| 1108 | [STAC_MA6] = "m6", |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1109 | [STAC_PA6] = "pa6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1110 | }; |
| 1111 | |
| 1112 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1113 | /* SigmaTel reference board */ |
| 1114 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1115 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1116 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), |
| 1117 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), |
| 1118 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1119 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1120 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2), |
| 1121 | {} /* terminator */ |
| 1122 | }; |
| 1123 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1124 | static unsigned int ref92hd73xx_pin_configs[12] = { |
| 1125 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1126 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1127 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
| 1128 | }; |
| 1129 | |
| 1130 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
| 1131 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
| 1132 | }; |
| 1133 | |
| 1134 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
| 1135 | [STAC_92HD73XX_REF] = "ref", |
| 1136 | }; |
| 1137 | |
| 1138 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1139 | /* SigmaTel reference board */ |
| 1140 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1141 | "DFI LanParty", STAC_92HD73XX_REF), |
| 1142 | {} /* terminator */ |
| 1143 | }; |
| 1144 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1145 | static unsigned int ref92hd71bxx_pin_configs[10] = { |
| 1146 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
| 1147 | 0x0181302e, 0x01114010, 0x01a19020, 0x90a000f0, |
| 1148 | 0x90a000f0, 0x01452050, |
| 1149 | }; |
| 1150 | |
| 1151 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1152 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
| 1153 | }; |
| 1154 | |
| 1155 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
| 1156 | [STAC_92HD71BXX_REF] = "ref", |
| 1157 | }; |
| 1158 | |
| 1159 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1160 | /* SigmaTel reference board */ |
| 1161 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1162 | "DFI LanParty", STAC_92HD71BXX_REF), |
| 1163 | {} /* terminator */ |
| 1164 | }; |
| 1165 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1166 | static unsigned int ref922x_pin_configs[10] = { |
| 1167 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1168 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1169 | 0x40000100, 0x40000100, |
| 1170 | }; |
| 1171 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1172 | /* |
| 1173 | STAC 922X pin configs for |
| 1174 | 102801A7 |
| 1175 | 102801AB |
| 1176 | 102801A9 |
| 1177 | 102801D1 |
| 1178 | 102801D2 |
| 1179 | */ |
| 1180 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1181 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1182 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1183 | 0x01813122, 0x400001f2, |
| 1184 | }; |
| 1185 | |
| 1186 | /* |
| 1187 | STAC 922X pin configs for |
| 1188 | 102801AC |
| 1189 | 102801D0 |
| 1190 | */ |
| 1191 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1192 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1193 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1194 | 0x01813122, 0x400001f1, |
| 1195 | }; |
| 1196 | |
| 1197 | /* |
| 1198 | STAC 922X pin configs for |
| 1199 | 102801BF |
| 1200 | */ |
| 1201 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1202 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1203 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1204 | 0x40C003f1, 0x405003f0, |
| 1205 | }; |
| 1206 | |
| 1207 | /* |
| 1208 | STAC 9221 A1 pin configs for |
| 1209 | 102801D7 (Dell XPS M1210) |
| 1210 | */ |
| 1211 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1212 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1213 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1214 | 0x508003f3, 0x405003f4, |
| 1215 | }; |
| 1216 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1217 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1218 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1219 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1220 | 0x02a19120, 0x40000100, |
| 1221 | }; |
| 1222 | |
| 1223 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1224 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1225 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1226 | 0x02a19320, 0x40000100, |
| 1227 | }; |
| 1228 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1229 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1230 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1231 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1232 | 0x400000fc, 0x400000fb, |
| 1233 | }; |
| 1234 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1235 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1236 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1237 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1238 | 0x400000fc, 0x400000fb, |
| 1239 | }; |
| 1240 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1241 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1242 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1243 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 1244 | 0x400000fc, 0x400000fb, |
| 1245 | }; |
| 1246 | |
| 1247 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 1248 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1249 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1250 | 0x400000fc, 0x400000fb, |
| 1251 | }; |
| 1252 | |
| 1253 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 1254 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1255 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1256 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1257 | }; |
| 1258 | |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1259 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1260 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1261 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1262 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 1263 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1264 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 1265 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 1266 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 1267 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 1268 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1269 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1270 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 1271 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 1272 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 1273 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 1274 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 1275 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1276 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 1277 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 1278 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 1279 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1280 | }; |
| 1281 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1282 | static const char *stac922x_models[STAC_922X_MODELS] = { |
| 1283 | [STAC_D945_REF] = "ref", |
| 1284 | [STAC_D945GTP5] = "5stack", |
| 1285 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1286 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 1287 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 1288 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 1289 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 1290 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1291 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1292 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1293 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 1294 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 1295 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1296 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1297 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1298 | [STAC_922X_DELL_D81] = "dell-d81", |
| 1299 | [STAC_922X_DELL_D82] = "dell-d82", |
| 1300 | [STAC_922X_DELL_M81] = "dell-m81", |
| 1301 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1302 | }; |
| 1303 | |
| 1304 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 1305 | /* SigmaTel reference board */ |
| 1306 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1307 | "DFI LanParty", STAC_D945_REF), |
| 1308 | /* Intel 945G based systems */ |
| 1309 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 1310 | "Intel D945G", STAC_D945GTP3), |
| 1311 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 1312 | "Intel D945G", STAC_D945GTP3), |
| 1313 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 1314 | "Intel D945G", STAC_D945GTP3), |
| 1315 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 1316 | "Intel D945G", STAC_D945GTP3), |
| 1317 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 1318 | "Intel D945G", STAC_D945GTP3), |
| 1319 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 1320 | "Intel D945G", STAC_D945GTP3), |
| 1321 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 1322 | "Intel D945G", STAC_D945GTP3), |
| 1323 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 1324 | "Intel D945G", STAC_D945GTP3), |
| 1325 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 1326 | "Intel D945G", STAC_D945GTP3), |
| 1327 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 1328 | "Intel D945G", STAC_D945GTP3), |
| 1329 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 1330 | "Intel D945G", STAC_D945GTP3), |
| 1331 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 1332 | "Intel D945G", STAC_D945GTP3), |
| 1333 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 1334 | "Intel D945G", STAC_D945GTP3), |
| 1335 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 1336 | "Intel D945G", STAC_D945GTP3), |
| 1337 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 1338 | "Intel D945G", STAC_D945GTP3), |
| 1339 | /* Intel D945G 5-stack systems */ |
| 1340 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 1341 | "Intel D945G", STAC_D945GTP5), |
| 1342 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 1343 | "Intel D945G", STAC_D945GTP5), |
| 1344 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 1345 | "Intel D945G", STAC_D945GTP5), |
| 1346 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 1347 | "Intel D945G", STAC_D945GTP5), |
| 1348 | /* Intel 945P based systems */ |
| 1349 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 1350 | "Intel D945P", STAC_D945GTP3), |
| 1351 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 1352 | "Intel D945P", STAC_D945GTP3), |
| 1353 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 1354 | "Intel D945P", STAC_D945GTP3), |
| 1355 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 1356 | "Intel D945P", STAC_D945GTP3), |
| 1357 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 1358 | "Intel D945P", STAC_D945GTP3), |
| 1359 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 1360 | "Intel D945P", STAC_D945GTP5), |
| 1361 | /* other systems */ |
| 1362 | /* Apple Mac Mini (early 2006) */ |
| 1363 | SND_PCI_QUIRK(0x8384, 0x7680, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1364 | "Mac Mini", STAC_INTEL_MAC_V3), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1365 | /* Dell systems */ |
| 1366 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 1367 | "unknown Dell", STAC_922X_DELL_D81), |
| 1368 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 1369 | "unknown Dell", STAC_922X_DELL_D81), |
| 1370 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 1371 | "unknown Dell", STAC_922X_DELL_D81), |
| 1372 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 1373 | "unknown Dell", STAC_922X_DELL_D82), |
| 1374 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 1375 | "unknown Dell", STAC_922X_DELL_M81), |
| 1376 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 1377 | "unknown Dell", STAC_922X_DELL_D82), |
| 1378 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 1379 | "unknown Dell", STAC_922X_DELL_D81), |
| 1380 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 1381 | "unknown Dell", STAC_922X_DELL_D81), |
| 1382 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 1383 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1384 | {} /* terminator */ |
| 1385 | }; |
| 1386 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1387 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1388 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 1389 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 1390 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 1391 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1392 | }; |
| 1393 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1394 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1395 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 1396 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 1397 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1398 | 0x40000100, 0x40000100 |
| 1399 | }; |
| 1400 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1401 | static unsigned int d965_5st_pin_configs[14] = { |
| 1402 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 1403 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 1404 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 1405 | 0x40000100, 0x40000100 |
| 1406 | }; |
| 1407 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1408 | static unsigned int dell_3st_pin_configs[14] = { |
| 1409 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 1410 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
| 1411 | 0x403003fa, 0x40000100, 0x40000100, 0x404003fb, |
| 1412 | 0x40c003fc, 0x40000100 |
| 1413 | }; |
| 1414 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1415 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1416 | [STAC_D965_REF] = ref927x_pin_configs, |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1417 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 1418 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1419 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1420 | }; |
| 1421 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1422 | static const char *stac927x_models[STAC_927X_MODELS] = { |
| 1423 | [STAC_D965_REF] = "ref", |
| 1424 | [STAC_D965_3ST] = "3stack", |
| 1425 | [STAC_D965_5ST] = "5stack", |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1426 | [STAC_DELL_3ST] = "dell-3stack", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1427 | }; |
| 1428 | |
| 1429 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 1430 | /* SigmaTel reference board */ |
| 1431 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1432 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1433 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1434 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 1435 | 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] | 1436 | /* 965 based 3 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1437 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), |
| 1438 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), |
| 1439 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), |
| 1440 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), |
| 1441 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST), |
| 1442 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST), |
| 1443 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST), |
| 1444 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST), |
| 1445 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST), |
| 1446 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST), |
| 1447 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST), |
| 1448 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST), |
| 1449 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST), |
| 1450 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), |
| 1451 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), |
| 1452 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), |
Tim Gardner | 5e915bb | 2007-10-10 10:42:00 +0200 | [diff] [blame] | 1453 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1454 | /* Dell 3 stack systems */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1455 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1456 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 1457 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1458 | /* 965 based 5 stack systems */ |
Tim Gardner | 5e915bb | 2007-10-10 10:42:00 +0200 | [diff] [blame] | 1459 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_D965_5ST), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1460 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), |
| 1461 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), |
| 1462 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), |
| 1463 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), |
| 1464 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST), |
| 1465 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST), |
| 1466 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST), |
| 1467 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST), |
| 1468 | 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] | 1469 | {} /* terminator */ |
| 1470 | }; |
| 1471 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1472 | static unsigned int ref9205_pin_configs[12] = { |
| 1473 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 1474 | 0x01813122, 0x01a19021, 0x40000100, 0x40000100, |
| 1475 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1476 | }; |
| 1477 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1478 | /* |
| 1479 | STAC 9205 pin configs for |
| 1480 | 102801F1 |
| 1481 | 102801F2 |
| 1482 | 102801FC |
| 1483 | 102801FD |
| 1484 | 10280204 |
| 1485 | 1028021F |
| 1486 | */ |
| 1487 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 1488 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 1489 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 1490 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 1491 | }; |
| 1492 | |
| 1493 | /* |
| 1494 | STAC 9205 pin configs for |
| 1495 | 102801F9 |
| 1496 | 102801FA |
| 1497 | 102801FE |
| 1498 | 102801FF (Dell Precision M4300) |
| 1499 | 10280206 |
| 1500 | 10280200 |
| 1501 | 10280201 |
| 1502 | */ |
| 1503 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1504 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 1505 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 1506 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 1507 | }; |
| 1508 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1509 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1510 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 1511 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 1512 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 1513 | }; |
| 1514 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1515 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1516 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1517 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 1518 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 1519 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1520 | }; |
| 1521 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1522 | static const char *stac9205_models[STAC_9205_MODELS] = { |
| 1523 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1524 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1525 | [STAC_9205_DELL_M43] = "dell-m43", |
| 1526 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1527 | }; |
| 1528 | |
| 1529 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 1530 | /* SigmaTel reference board */ |
| 1531 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1532 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1533 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 1534 | "unknown Dell", STAC_9205_DELL_M42), |
| 1535 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 1536 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1537 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 1538 | "Dell Precision", STAC_9205_DELL_M43), |
| 1539 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 1540 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1541 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 1542 | "Dell Precision", STAC_9205_DELL_M43), |
Matthew Ranostay | e45e459 | 2007-09-10 23:09:42 +0200 | [diff] [blame] | 1543 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 1544 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1545 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 1546 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1547 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 1548 | "unknown Dell", STAC_9205_DELL_M42), |
| 1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 1550 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1551 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 1552 | "Dell Precision", STAC_9205_DELL_M43), |
| 1553 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1554 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1555 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 1556 | "Dell Precision", STAC_9205_DELL_M43), |
| 1557 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 1558 | "Dell Inspiron", STAC_9205_DELL_M44), |
| 1559 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 1560 | "Dell Inspiron", STAC_9205_DELL_M44), |
| 1561 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 1562 | "Dell Inspiron", STAC_9205_DELL_M44), |
| 1563 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 1564 | "Dell Inspiron", STAC_9205_DELL_M44), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1565 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 1566 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 1567 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 1568 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1569 | {} /* terminator */ |
| 1570 | }; |
| 1571 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1572 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) |
| 1573 | { |
| 1574 | int i; |
| 1575 | struct sigmatel_spec *spec = codec->spec; |
| 1576 | |
| 1577 | if (! spec->bios_pin_configs) { |
| 1578 | spec->bios_pin_configs = kcalloc(spec->num_pins, |
| 1579 | sizeof(*spec->bios_pin_configs), GFP_KERNEL); |
| 1580 | if (! spec->bios_pin_configs) |
| 1581 | return -ENOMEM; |
| 1582 | } |
| 1583 | |
| 1584 | for (i = 0; i < spec->num_pins; i++) { |
| 1585 | hda_nid_t nid = spec->pin_nids[i]; |
| 1586 | unsigned int pin_cfg; |
| 1587 | |
| 1588 | pin_cfg = snd_hda_codec_read(codec, nid, 0, |
| 1589 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); |
| 1590 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", |
| 1591 | nid, pin_cfg); |
| 1592 | spec->bios_pin_configs[i] = pin_cfg; |
| 1593 | } |
| 1594 | |
| 1595 | return 0; |
| 1596 | } |
| 1597 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1598 | static void stac92xx_set_config_reg(struct hda_codec *codec, |
| 1599 | hda_nid_t pin_nid, unsigned int pin_config) |
| 1600 | { |
| 1601 | int i; |
| 1602 | snd_hda_codec_write(codec, pin_nid, 0, |
| 1603 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, |
| 1604 | pin_config & 0x000000ff); |
| 1605 | snd_hda_codec_write(codec, pin_nid, 0, |
| 1606 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, |
| 1607 | (pin_config & 0x0000ff00) >> 8); |
| 1608 | snd_hda_codec_write(codec, pin_nid, 0, |
| 1609 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, |
| 1610 | (pin_config & 0x00ff0000) >> 16); |
| 1611 | snd_hda_codec_write(codec, pin_nid, 0, |
| 1612 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, |
| 1613 | pin_config >> 24); |
| 1614 | i = snd_hda_codec_read(codec, pin_nid, 0, |
| 1615 | AC_VERB_GET_CONFIG_DEFAULT, |
| 1616 | 0x00); |
| 1617 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", |
| 1618 | pin_nid, i); |
| 1619 | } |
| 1620 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1621 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
| 1622 | { |
| 1623 | int i; |
| 1624 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1625 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1626 | if (!spec->pin_configs) |
| 1627 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 1628 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1629 | for (i = 0; i < spec->num_pins; i++) |
| 1630 | stac92xx_set_config_reg(codec, spec->pin_nids[i], |
| 1631 | spec->pin_configs[i]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1632 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1633 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 1634 | static void stac92xx_enable_gpio_mask(struct hda_codec *codec) |
Matthew Ranostay | 92a22be | 2007-06-19 16:48:28 +0200 | [diff] [blame] | 1635 | { |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 1636 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1637 | /* Configure GPIOx as output */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1638 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 1639 | AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1640 | /* Configure GPIOx as CMOS */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1641 | snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1642 | /* Assert GPIOx */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1643 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 1644 | AC_VERB_SET_GPIO_DATA, spec->gpio_data); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 1645 | /* Enable GPIOx */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1646 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 1647 | AC_VERB_SET_GPIO_MASK, spec->gpio_mask); |
Matthew Ranostay | 92a22be | 2007-06-19 16:48:28 +0200 | [diff] [blame] | 1648 | } |
| 1649 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1650 | /* |
| 1651 | * Analog playback callbacks |
| 1652 | */ |
| 1653 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1654 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1655 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1656 | { |
| 1657 | struct sigmatel_spec *spec = codec->spec; |
| 1658 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); |
| 1659 | } |
| 1660 | |
| 1661 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1662 | struct hda_codec *codec, |
| 1663 | unsigned int stream_tag, |
| 1664 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1665 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1666 | { |
| 1667 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1668 | 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] | 1669 | } |
| 1670 | |
| 1671 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1672 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1673 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1674 | { |
| 1675 | struct sigmatel_spec *spec = codec->spec; |
| 1676 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1677 | } |
| 1678 | |
| 1679 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1680 | * Digital playback callbacks |
| 1681 | */ |
| 1682 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 1683 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1684 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1685 | { |
| 1686 | struct sigmatel_spec *spec = codec->spec; |
| 1687 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1688 | } |
| 1689 | |
| 1690 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 1691 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1692 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1693 | { |
| 1694 | struct sigmatel_spec *spec = codec->spec; |
| 1695 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1696 | } |
| 1697 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1698 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1699 | struct hda_codec *codec, |
| 1700 | unsigned int stream_tag, |
| 1701 | unsigned int format, |
| 1702 | struct snd_pcm_substream *substream) |
| 1703 | { |
| 1704 | struct sigmatel_spec *spec = codec->spec; |
| 1705 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1706 | stream_tag, format, substream); |
| 1707 | } |
| 1708 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1709 | |
| 1710 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1711 | * Analog capture callbacks |
| 1712 | */ |
| 1713 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 1714 | struct hda_codec *codec, |
| 1715 | unsigned int stream_tag, |
| 1716 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1717 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1718 | { |
| 1719 | struct sigmatel_spec *spec = codec->spec; |
| 1720 | |
| 1721 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], |
| 1722 | stream_tag, 0, format); |
| 1723 | return 0; |
| 1724 | } |
| 1725 | |
| 1726 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 1727 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1728 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1729 | { |
| 1730 | struct sigmatel_spec *spec = codec->spec; |
| 1731 | |
| 1732 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1736 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 1737 | .substreams = 1, |
| 1738 | .channels_min = 2, |
| 1739 | .channels_max = 2, |
| 1740 | /* NID is set in stac92xx_build_pcms */ |
| 1741 | .ops = { |
| 1742 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1743 | .close = stac92xx_dig_playback_pcm_close, |
| 1744 | .prepare = stac92xx_dig_playback_pcm_prepare |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1745 | }, |
| 1746 | }; |
| 1747 | |
| 1748 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 1749 | .substreams = 1, |
| 1750 | .channels_min = 2, |
| 1751 | .channels_max = 2, |
| 1752 | /* NID is set in stac92xx_build_pcms */ |
| 1753 | }; |
| 1754 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1755 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 1756 | .substreams = 1, |
| 1757 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1758 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1759 | .nid = 0x02, /* NID to query formats and rates */ |
| 1760 | .ops = { |
| 1761 | .open = stac92xx_playback_pcm_open, |
| 1762 | .prepare = stac92xx_playback_pcm_prepare, |
| 1763 | .cleanup = stac92xx_playback_pcm_cleanup |
| 1764 | }, |
| 1765 | }; |
| 1766 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1767 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 1768 | .substreams = 1, |
| 1769 | .channels_min = 2, |
| 1770 | .channels_max = 2, |
| 1771 | .nid = 0x06, /* NID to query formats and rates */ |
| 1772 | .ops = { |
| 1773 | .open = stac92xx_playback_pcm_open, |
| 1774 | .prepare = stac92xx_playback_pcm_prepare, |
| 1775 | .cleanup = stac92xx_playback_pcm_cleanup |
| 1776 | }, |
| 1777 | }; |
| 1778 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1779 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1780 | .channels_min = 2, |
| 1781 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1782 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1783 | .ops = { |
| 1784 | .prepare = stac92xx_capture_pcm_prepare, |
| 1785 | .cleanup = stac92xx_capture_pcm_cleanup |
| 1786 | }, |
| 1787 | }; |
| 1788 | |
| 1789 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 1790 | { |
| 1791 | struct sigmatel_spec *spec = codec->spec; |
| 1792 | struct hda_pcm *info = spec->pcm_rec; |
| 1793 | |
| 1794 | codec->num_pcms = 1; |
| 1795 | codec->pcm_info = info; |
| 1796 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1797 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1798 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1799 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1800 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1801 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1802 | |
| 1803 | if (spec->alt_switch) { |
| 1804 | codec->num_pcms++; |
| 1805 | info++; |
| 1806 | info->name = "STAC92xx Analog Alt"; |
| 1807 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 1808 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1809 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1810 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 1811 | codec->num_pcms++; |
| 1812 | info++; |
| 1813 | info->name = "STAC92xx Digital"; |
| 1814 | if (spec->multiout.dig_out_nid) { |
| 1815 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 1816 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 1817 | } |
| 1818 | if (spec->dig_in_nid) { |
| 1819 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 1820 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 1821 | } |
| 1822 | } |
| 1823 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1824 | return 0; |
| 1825 | } |
| 1826 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1827 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 1828 | { |
| 1829 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 1830 | AC_PAR_PIN_CAP); |
| 1831 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 1832 | if (pincap & AC_PINCAP_VREF_100) |
| 1833 | return AC_PINCTL_VREF_100; |
| 1834 | if (pincap & AC_PINCAP_VREF_80) |
| 1835 | return AC_PINCTL_VREF_80; |
| 1836 | if (pincap & AC_PINCAP_VREF_50) |
| 1837 | return AC_PINCTL_VREF_50; |
| 1838 | if (pincap & AC_PINCAP_VREF_GRD) |
| 1839 | return AC_PINCTL_VREF_GRD; |
| 1840 | return 0; |
| 1841 | } |
| 1842 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1843 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 1844 | |
| 1845 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 1846 | snd_hda_codec_write_cache(codec, nid, 0, |
| 1847 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1848 | } |
| 1849 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 1850 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1851 | |
| 1852 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 1853 | { |
| 1854 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1855 | struct sigmatel_spec *spec = codec->spec; |
| 1856 | int io_idx = kcontrol-> private_value & 0xff; |
| 1857 | |
| 1858 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 1859 | return 0; |
| 1860 | } |
| 1861 | |
| 1862 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 1863 | { |
| 1864 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1865 | struct sigmatel_spec *spec = codec->spec; |
| 1866 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 1867 | int io_idx = kcontrol-> private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 1868 | unsigned short val = !!ucontrol->value.integer.value[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1869 | |
| 1870 | spec->io_switch[io_idx] = val; |
| 1871 | |
| 1872 | if (val) |
| 1873 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 1874 | else { |
| 1875 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 1876 | if (io_idx) /* set VREF for mic */ |
| 1877 | pinctl |= stac92xx_get_vref(codec, nid); |
| 1878 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 1879 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 1880 | |
| 1881 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 1882 | * appropriately according to the pin direction |
| 1883 | */ |
| 1884 | if (spec->hp_detect) |
| 1885 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 1886 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1887 | return 1; |
| 1888 | } |
| 1889 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1890 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 1891 | |
| 1892 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 1893 | struct snd_ctl_elem_value *ucontrol) |
| 1894 | { |
| 1895 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1896 | struct sigmatel_spec *spec = codec->spec; |
| 1897 | |
| 1898 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 1899 | return 0; |
| 1900 | } |
| 1901 | |
| 1902 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 1903 | struct snd_ctl_elem_value *ucontrol) |
| 1904 | { |
| 1905 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1906 | struct sigmatel_spec *spec = codec->spec; |
| 1907 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 1908 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1909 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 1910 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1911 | return 0; |
| 1912 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 1913 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1914 | |
| 1915 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 1916 | spec->clfe_swap ? 0x4 : 0x0); |
| 1917 | |
| 1918 | return 1; |
| 1919 | } |
| 1920 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1921 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 1922 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1923 | .name = xname, \ |
| 1924 | .index = 0, \ |
| 1925 | .info = stac92xx_io_switch_info, \ |
| 1926 | .get = stac92xx_io_switch_get, \ |
| 1927 | .put = stac92xx_io_switch_put, \ |
| 1928 | .private_value = xpval, \ |
| 1929 | } |
| 1930 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1931 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 1932 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1933 | .name = xname, \ |
| 1934 | .index = 0, \ |
| 1935 | .info = stac92xx_clfe_switch_info, \ |
| 1936 | .get = stac92xx_clfe_switch_get, \ |
| 1937 | .put = stac92xx_clfe_switch_put, \ |
| 1938 | .private_value = xpval, \ |
| 1939 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1940 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1941 | enum { |
| 1942 | STAC_CTL_WIDGET_VOL, |
| 1943 | STAC_CTL_WIDGET_MUTE, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1944 | STAC_CTL_WIDGET_IO_SWITCH, |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1945 | STAC_CTL_WIDGET_CLFE_SWITCH |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1946 | }; |
| 1947 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1948 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1949 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 1950 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1951 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 1952 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1953 | }; |
| 1954 | |
| 1955 | /* add dynamic controls */ |
| 1956 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) |
| 1957 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1958 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1959 | |
| 1960 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 1961 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 1962 | |
| 1963 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 1964 | if (! knew) |
| 1965 | return -ENOMEM; |
| 1966 | if (spec->kctl_alloc) { |
| 1967 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 1968 | kfree(spec->kctl_alloc); |
| 1969 | } |
| 1970 | spec->kctl_alloc = knew; |
| 1971 | spec->num_kctl_alloc = num; |
| 1972 | } |
| 1973 | |
| 1974 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 1975 | *knew = stac92xx_control_templates[type]; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 1976 | knew->name = kstrdup(name, GFP_KERNEL); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1977 | if (! knew->name) |
| 1978 | return -ENOMEM; |
| 1979 | knew->private_value = val; |
| 1980 | spec->num_kctl_used++; |
| 1981 | return 0; |
| 1982 | } |
| 1983 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1984 | /* flag inputs as additional dynamic lineouts */ |
| 1985 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 1986 | { |
| 1987 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1988 | unsigned int wcaps, wtype; |
| 1989 | int i, num_dacs = 0; |
| 1990 | |
| 1991 | /* use the wcaps cache to count all DACs available for line-outs */ |
| 1992 | for (i = 0; i < codec->num_nodes; i++) { |
| 1993 | wcaps = codec->wcaps[i]; |
| 1994 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 1995 | if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) |
| 1996 | num_dacs++; |
| 1997 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1998 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 1999 | snd_printdd("%s: total dac count=%d\n", __func__, num_dacs); |
| 2000 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2001 | switch (cfg->line_outs) { |
| 2002 | case 3: |
| 2003 | /* add line-in as side */ |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2004 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2005 | cfg->line_out_pins[cfg->line_outs] = |
| 2006 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2007 | spec->line_switch = 1; |
| 2008 | cfg->line_outs++; |
| 2009 | } |
| 2010 | break; |
| 2011 | case 2: |
| 2012 | /* add line-in as clfe and mic as side */ |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2013 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2014 | cfg->line_out_pins[cfg->line_outs] = |
| 2015 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2016 | spec->line_switch = 1; |
| 2017 | cfg->line_outs++; |
| 2018 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2019 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2020 | cfg->line_out_pins[cfg->line_outs] = |
| 2021 | cfg->input_pins[AUTO_PIN_MIC]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2022 | spec->mic_switch = 1; |
| 2023 | cfg->line_outs++; |
| 2024 | } |
| 2025 | break; |
| 2026 | case 1: |
| 2027 | /* add line-in as surr and mic as clfe */ |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2028 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2029 | cfg->line_out_pins[cfg->line_outs] = |
| 2030 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2031 | spec->line_switch = 1; |
| 2032 | cfg->line_outs++; |
| 2033 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2034 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2035 | cfg->line_out_pins[cfg->line_outs] = |
| 2036 | cfg->input_pins[AUTO_PIN_MIC]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2037 | spec->mic_switch = 1; |
| 2038 | cfg->line_outs++; |
| 2039 | } |
| 2040 | break; |
| 2041 | } |
| 2042 | |
| 2043 | return 0; |
| 2044 | } |
| 2045 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2046 | |
| 2047 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2048 | { |
| 2049 | int i; |
| 2050 | |
| 2051 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 2052 | if (spec->multiout.dac_nids[i] == nid) |
| 2053 | return 1; |
| 2054 | } |
| 2055 | |
| 2056 | return 0; |
| 2057 | } |
| 2058 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2059 | /* |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2060 | * Fill in the dac_nids table from the parsed pin configuration |
| 2061 | * This function only works when every pin in line_out_pins[] |
| 2062 | * contains atleast one DAC in its connection list. Some 92xx |
| 2063 | * codecs are not connected directly to a DAC, such as the 9200 |
| 2064 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2065 | */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2066 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2067 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2068 | { |
| 2069 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2070 | int i, j, conn_len = 0; |
| 2071 | hda_nid_t nid, conn[HDA_MAX_CONNECTIONS]; |
| 2072 | unsigned int wcaps, wtype; |
| 2073 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2074 | for (i = 0; i < cfg->line_outs; i++) { |
| 2075 | nid = cfg->line_out_pins[i]; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2076 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 2077 | HDA_MAX_CONNECTIONS); |
| 2078 | for (j = 0; j < conn_len; j++) { |
| 2079 | wcaps = snd_hda_param_read(codec, conn[j], |
| 2080 | AC_PAR_AUDIO_WIDGET_CAP); |
| 2081 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 2082 | |
| 2083 | if (wtype != AC_WID_AUD_OUT || |
| 2084 | (wcaps & AC_WCAP_DIGITAL)) |
| 2085 | continue; |
| 2086 | /* conn[j] is a DAC routed to this line-out */ |
| 2087 | if (!is_in_dac_nids(spec, conn[j])) |
| 2088 | break; |
| 2089 | } |
| 2090 | |
| 2091 | if (j == conn_len) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2092 | if (spec->multiout.num_dacs > 0) { |
| 2093 | /* we have already working output pins, |
| 2094 | * so let's drop the broken ones again |
| 2095 | */ |
| 2096 | cfg->line_outs = spec->multiout.num_dacs; |
| 2097 | break; |
| 2098 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2099 | /* error out, no available DAC found */ |
| 2100 | snd_printk(KERN_ERR |
| 2101 | "%s: No available DAC for pin 0x%x\n", |
| 2102 | __func__, nid); |
| 2103 | return -ENODEV; |
| 2104 | } |
| 2105 | |
| 2106 | spec->multiout.dac_nids[i] = conn[j]; |
| 2107 | spec->multiout.num_dacs++; |
| 2108 | if (conn_len > 1) { |
| 2109 | /* select this DAC in the pin's input mux */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2110 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2111 | AC_VERB_SET_CONNECT_SEL, j); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2112 | |
| 2113 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2114 | } |
| 2115 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2116 | snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
| 2117 | spec->multiout.num_dacs, |
| 2118 | spec->multiout.dac_nids[0], |
| 2119 | spec->multiout.dac_nids[1], |
| 2120 | spec->multiout.dac_nids[2], |
| 2121 | spec->multiout.dac_nids[3], |
| 2122 | spec->multiout.dac_nids[4]); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2123 | return 0; |
| 2124 | } |
| 2125 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2126 | /* create volume control/switch for the given prefx type */ |
| 2127 | static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) |
| 2128 | { |
| 2129 | char name[32]; |
| 2130 | int err; |
| 2131 | |
| 2132 | sprintf(name, "%s Playback Volume", pfx); |
| 2133 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 2134 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2135 | if (err < 0) |
| 2136 | return err; |
| 2137 | sprintf(name, "%s Playback Switch", pfx); |
| 2138 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 2139 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2140 | if (err < 0) |
| 2141 | return err; |
| 2142 | return 0; |
| 2143 | } |
| 2144 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2145 | /* add playback controls from the parsed DAC table */ |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2146 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2147 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2148 | { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2149 | static const char *chname[4] = { |
| 2150 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 2151 | }; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2152 | hda_nid_t nid; |
| 2153 | int i, err; |
| 2154 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2155 | struct sigmatel_spec *spec = codec->spec; |
| 2156 | unsigned int wid_caps; |
| 2157 | |
| 2158 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2159 | for (i = 0; i < cfg->line_outs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2160 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2161 | continue; |
| 2162 | |
| 2163 | nid = spec->multiout.dac_nids[i]; |
| 2164 | |
| 2165 | if (i == 2) { |
| 2166 | /* Center/LFE */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2167 | err = create_controls(spec, "Center", nid, 1); |
| 2168 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2169 | return err; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2170 | err = create_controls(spec, "LFE", nid, 2); |
| 2171 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2172 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2173 | |
| 2174 | wid_caps = get_wcaps(codec, nid); |
| 2175 | |
| 2176 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 2177 | err = stac92xx_add_control(spec, |
| 2178 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2179 | "Swap Center/LFE Playback Switch", nid); |
| 2180 | |
| 2181 | if (err < 0) |
| 2182 | return err; |
| 2183 | } |
| 2184 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2185 | } else { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2186 | err = create_controls(spec, chname[i], nid, 3); |
| 2187 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2188 | return err; |
| 2189 | } |
| 2190 | } |
| 2191 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2192 | if (spec->line_switch) |
| 2193 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) |
| 2194 | return err; |
| 2195 | |
| 2196 | if (spec->mic_switch) |
| 2197 | if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) |
| 2198 | return err; |
| 2199 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2200 | return 0; |
| 2201 | } |
| 2202 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2203 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2204 | { |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2205 | if (is_in_dac_nids(spec, nid)) |
| 2206 | return 1; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2207 | if (spec->multiout.hp_nid == nid) |
| 2208 | return 1; |
| 2209 | return 0; |
| 2210 | } |
| 2211 | |
| 2212 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2213 | { |
| 2214 | if (!spec->multiout.hp_nid) |
| 2215 | spec->multiout.hp_nid = nid; |
| 2216 | else if (spec->multiout.num_dacs > 4) { |
| 2217 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 2218 | return 1; |
| 2219 | } else { |
| 2220 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 2221 | spec->multiout.num_dacs++; |
| 2222 | } |
| 2223 | return 0; |
| 2224 | } |
| 2225 | |
| 2226 | /* add playback controls for Speaker and HP outputs */ |
| 2227 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 2228 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2229 | { |
| 2230 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2231 | hda_nid_t nid; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2232 | int i, old_num_dacs, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2233 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2234 | old_num_dacs = spec->multiout.num_dacs; |
| 2235 | for (i = 0; i < cfg->hp_outs; i++) { |
| 2236 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
| 2237 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 2238 | spec->hp_detect = 1; |
| 2239 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 2240 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2241 | if (check_in_dac_nids(spec, nid)) |
| 2242 | nid = 0; |
| 2243 | if (! nid) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2244 | continue; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2245 | add_spec_dacs(spec, nid); |
| 2246 | } |
| 2247 | for (i = 0; i < cfg->speaker_outs; i++) { |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2248 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2249 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2250 | if (check_in_dac_nids(spec, nid)) |
| 2251 | nid = 0; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2252 | if (! nid) |
| 2253 | continue; |
| 2254 | add_spec_dacs(spec, nid); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2255 | } |
Matthew Ranostay | 1b290a5 | 2007-07-12 15:17:34 +0200 | [diff] [blame] | 2256 | for (i = 0; i < cfg->line_outs; i++) { |
| 2257 | nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0, |
| 2258 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2259 | if (check_in_dac_nids(spec, nid)) |
| 2260 | nid = 0; |
| 2261 | if (! nid) |
| 2262 | continue; |
| 2263 | add_spec_dacs(spec, nid); |
| 2264 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2265 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { |
| 2266 | static const char *pfxs[] = { |
| 2267 | "Speaker", "External Speaker", "Speaker2", |
| 2268 | }; |
| 2269 | err = create_controls(spec, pfxs[i - old_num_dacs], |
| 2270 | spec->multiout.dac_nids[i], 3); |
| 2271 | if (err < 0) |
| 2272 | return err; |
| 2273 | } |
| 2274 | if (spec->multiout.hp_nid) { |
| 2275 | const char *pfx; |
Takashi Iwai | 6020c00 | 2007-11-19 11:56:26 +0100 | [diff] [blame] | 2276 | if (old_num_dacs == spec->multiout.num_dacs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2277 | pfx = "Master"; |
| 2278 | else |
| 2279 | pfx = "Headphone"; |
| 2280 | err = create_controls(spec, pfx, spec->multiout.hp_nid, 3); |
| 2281 | if (err < 0) |
| 2282 | return err; |
| 2283 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2284 | |
| 2285 | return 0; |
| 2286 | } |
| 2287 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2288 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 2289 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2290 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 2291 | "Digital Mic 3", "Digital Mic 4" |
| 2292 | }; |
| 2293 | |
| 2294 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 2295 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 2296 | const struct auto_pin_cfg *cfg) |
| 2297 | { |
| 2298 | struct sigmatel_spec *spec = codec->spec; |
| 2299 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 2300 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 2301 | int i, j; |
| 2302 | |
| 2303 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 2304 | dimux->items[dimux->num_items].index = 0; |
| 2305 | dimux->num_items++; |
| 2306 | |
| 2307 | for (i = 0; i < spec->num_dmics; i++) { |
| 2308 | int index; |
| 2309 | int num_cons; |
| 2310 | unsigned int def_conf; |
| 2311 | |
| 2312 | def_conf = snd_hda_codec_read(codec, |
| 2313 | spec->dmic_nids[i], |
| 2314 | 0, |
| 2315 | AC_VERB_GET_CONFIG_DEFAULT, |
| 2316 | 0); |
| 2317 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 2318 | continue; |
| 2319 | |
| 2320 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 2321 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2322 | con_lst, |
| 2323 | HDA_MAX_NUM_INPUTS); |
| 2324 | for (j = 0; j < num_cons; j++) |
| 2325 | if (con_lst[j] == spec->dmic_nids[i]) { |
| 2326 | index = j; |
| 2327 | goto found; |
| 2328 | } |
| 2329 | continue; |
| 2330 | found: |
| 2331 | dimux->items[dimux->num_items].label = |
| 2332 | stac92xx_dmic_labels[dimux->num_items]; |
| 2333 | dimux->items[dimux->num_items].index = index; |
| 2334 | dimux->num_items++; |
| 2335 | } |
| 2336 | |
| 2337 | return 0; |
| 2338 | } |
| 2339 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2340 | /* create playback/capture controls for input pins */ |
| 2341 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 2342 | { |
| 2343 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2344 | struct hda_input_mux *imux = &spec->private_imux; |
| 2345 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 2346 | int i, j, k; |
| 2347 | |
| 2348 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2349 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2350 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2351 | if (!cfg->input_pins[i]) |
| 2352 | continue; |
| 2353 | index = -1; |
| 2354 | for (j = 0; j < spec->num_muxes; j++) { |
| 2355 | int num_cons; |
| 2356 | num_cons = snd_hda_get_connections(codec, |
| 2357 | spec->mux_nids[j], |
| 2358 | con_lst, |
| 2359 | HDA_MAX_NUM_INPUTS); |
| 2360 | for (k = 0; k < num_cons; k++) |
| 2361 | if (con_lst[k] == cfg->input_pins[i]) { |
| 2362 | index = k; |
| 2363 | goto found; |
| 2364 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2365 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2366 | continue; |
| 2367 | found: |
| 2368 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 2369 | imux->items[imux->num_items].index = index; |
| 2370 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2371 | } |
| 2372 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2373 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 2374 | /* |
| 2375 | * Set the current input for the muxes. |
| 2376 | * The STAC9221 has two input muxes with identical source |
| 2377 | * NID lists. Hopefully this won't get confused. |
| 2378 | */ |
| 2379 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2380 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 2381 | AC_VERB_SET_CONNECT_SEL, |
| 2382 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 2383 | } |
| 2384 | } |
| 2385 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2386 | return 0; |
| 2387 | } |
| 2388 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2389 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 2390 | { |
| 2391 | struct sigmatel_spec *spec = codec->spec; |
| 2392 | int i; |
| 2393 | |
| 2394 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 2395 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 2396 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 2397 | } |
| 2398 | } |
| 2399 | |
| 2400 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 2401 | { |
| 2402 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2403 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2404 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2405 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 2406 | hda_nid_t pin; |
| 2407 | pin = spec->autocfg.hp_pins[i]; |
| 2408 | if (pin) /* connect to front */ |
| 2409 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 2410 | } |
| 2411 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 2412 | hda_nid_t pin; |
| 2413 | pin = spec->autocfg.speaker_pins[i]; |
| 2414 | if (pin) /* connect to front */ |
| 2415 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 2416 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2417 | } |
| 2418 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2419 | 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] | 2420 | { |
| 2421 | struct sigmatel_spec *spec = codec->spec; |
| 2422 | int err; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 2423 | int hp_speaker_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2424 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2425 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 2426 | &spec->autocfg, |
| 2427 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2428 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2429 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 2430 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2431 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 2432 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 2433 | * be set up as multi-channel outputs. |
| 2434 | */ |
| 2435 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 2436 | spec->autocfg.hp_outs > 1) { |
| 2437 | /* Copy hp_outs to line_outs, backup line_outs in |
| 2438 | * speaker_outs so that the following routines can handle |
| 2439 | * HP pins as primary outputs. |
| 2440 | */ |
| 2441 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 2442 | sizeof(spec->autocfg.line_out_pins)); |
| 2443 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 2444 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 2445 | sizeof(spec->autocfg.hp_pins)); |
| 2446 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
| 2447 | hp_speaker_swap = 1; |
| 2448 | } |
| 2449 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2450 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 2451 | return err; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2452 | if (spec->multiout.num_dacs == 0) |
| 2453 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 2454 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2455 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2456 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); |
| 2457 | |
| 2458 | if (err < 0) |
| 2459 | return err; |
| 2460 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 2461 | if (hp_speaker_swap == 1) { |
| 2462 | /* Restore the hp_outs and line_outs */ |
| 2463 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 2464 | sizeof(spec->autocfg.line_out_pins)); |
| 2465 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 2466 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins, |
| 2467 | sizeof(spec->autocfg.speaker_pins)); |
| 2468 | spec->autocfg.line_outs = spec->autocfg.speaker_outs; |
| 2469 | memset(spec->autocfg.speaker_pins, 0, |
| 2470 | sizeof(spec->autocfg.speaker_pins)); |
| 2471 | spec->autocfg.speaker_outs = 0; |
| 2472 | } |
| 2473 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2474 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
| 2475 | |
| 2476 | if (err < 0) |
| 2477 | return err; |
| 2478 | |
| 2479 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
| 2480 | |
| 2481 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2482 | return err; |
| 2483 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2484 | if (spec->num_dmics > 0) |
| 2485 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 2486 | &spec->autocfg)) < 0) |
| 2487 | return err; |
| 2488 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2489 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2490 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2491 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2492 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2493 | if (spec->autocfg.dig_out_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2494 | spec->multiout.dig_out_nid = dig_out; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2495 | if (spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2496 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2497 | |
| 2498 | if (spec->kctl_alloc) |
| 2499 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2500 | |
| 2501 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 2502 | if (!spec->dinput_mux) |
| 2503 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2504 | |
| 2505 | return 1; |
| 2506 | } |
| 2507 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2508 | /* add playback controls for HP output */ |
| 2509 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 2510 | struct auto_pin_cfg *cfg) |
| 2511 | { |
| 2512 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2513 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2514 | unsigned int wid_caps; |
| 2515 | |
| 2516 | if (! pin) |
| 2517 | return 0; |
| 2518 | |
| 2519 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 2520 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2521 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2522 | |
| 2523 | return 0; |
| 2524 | } |
| 2525 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 2526 | /* add playback controls for LFE output */ |
| 2527 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 2528 | struct auto_pin_cfg *cfg) |
| 2529 | { |
| 2530 | struct sigmatel_spec *spec = codec->spec; |
| 2531 | int err; |
| 2532 | hda_nid_t lfe_pin = 0x0; |
| 2533 | int i; |
| 2534 | |
| 2535 | /* |
| 2536 | * search speaker outs and line outs for a mono speaker pin |
| 2537 | * with an amp. If one is found, add LFE controls |
| 2538 | * for it. |
| 2539 | */ |
| 2540 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 2541 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
| 2542 | unsigned long wcaps = get_wcaps(codec, pin); |
| 2543 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 2544 | if (wcaps == AC_WCAP_OUT_AMP) |
| 2545 | /* found a mono speaker with an amp, must be lfe */ |
| 2546 | lfe_pin = pin; |
| 2547 | } |
| 2548 | |
| 2549 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 2550 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 2551 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 2552 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
| 2553 | unsigned long cfg; |
| 2554 | cfg = snd_hda_codec_read(codec, pin, 0, |
| 2555 | AC_VERB_GET_CONFIG_DEFAULT, |
| 2556 | 0x00); |
| 2557 | if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) { |
| 2558 | unsigned long wcaps = get_wcaps(codec, pin); |
| 2559 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 2560 | if (wcaps == AC_WCAP_OUT_AMP) |
| 2561 | /* found a mono speaker with an amp, |
| 2562 | must be lfe */ |
| 2563 | lfe_pin = pin; |
| 2564 | } |
| 2565 | } |
| 2566 | } |
| 2567 | |
| 2568 | if (lfe_pin) { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2569 | err = create_controls(spec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 2570 | if (err < 0) |
| 2571 | return err; |
| 2572 | } |
| 2573 | |
| 2574 | return 0; |
| 2575 | } |
| 2576 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2577 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 2578 | { |
| 2579 | struct sigmatel_spec *spec = codec->spec; |
| 2580 | int err; |
| 2581 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2582 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2583 | return err; |
| 2584 | |
| 2585 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 2586 | return err; |
| 2587 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2588 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 2589 | return err; |
| 2590 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 2591 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 2592 | return err; |
| 2593 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2594 | if (spec->autocfg.dig_out_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2595 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2596 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2597 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2598 | |
| 2599 | if (spec->kctl_alloc) |
| 2600 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 2601 | |
| 2602 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2603 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2604 | |
| 2605 | return 1; |
| 2606 | } |
| 2607 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 2608 | /* |
| 2609 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 2610 | * funky external mute control using GPIO pins. |
| 2611 | */ |
| 2612 | |
| 2613 | static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 2614 | { |
| 2615 | unsigned int gpiostate, gpiomask, gpiodir; |
| 2616 | |
| 2617 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 2618 | AC_VERB_GET_GPIO_DATA, 0); |
| 2619 | |
| 2620 | if (!muted) |
| 2621 | gpiostate |= (1 << pin); |
| 2622 | else |
| 2623 | gpiostate &= ~(1 << pin); |
| 2624 | |
| 2625 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 2626 | AC_VERB_GET_GPIO_MASK, 0); |
| 2627 | gpiomask |= (1 << pin); |
| 2628 | |
| 2629 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 2630 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 2631 | gpiodir |= (1 << pin); |
| 2632 | |
| 2633 | /* AppleHDA seems to do this -- WTF is this verb?? */ |
| 2634 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 2635 | |
| 2636 | snd_hda_codec_write(codec, codec->afg, 0, |
| 2637 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 2638 | snd_hda_codec_write(codec, codec->afg, 0, |
| 2639 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 2640 | |
| 2641 | msleep(1); |
| 2642 | |
| 2643 | snd_hda_codec_write(codec, codec->afg, 0, |
| 2644 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 2645 | } |
| 2646 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2647 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 2648 | unsigned int event) |
| 2649 | { |
| 2650 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 2651 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2652 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 2653 | (AC_USRSP_EN | event)); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2654 | } |
| 2655 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2656 | static int stac92xx_init(struct hda_codec *codec) |
| 2657 | { |
| 2658 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2659 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2660 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2661 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2662 | snd_hda_sequence_write(codec, spec->init); |
| 2663 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2664 | /* set up pins */ |
| 2665 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 2666 | /* Enable unsolicited responses on the HP widget */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2667 | for (i = 0; i < cfg->hp_outs; i++) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2668 | enable_pin_detect(codec, cfg->hp_pins[i], |
| 2669 | STAC_HP_EVENT); |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 2670 | /* force to enable the first line-out; the others are set up |
| 2671 | * in unsol_event |
| 2672 | */ |
| 2673 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
| 2674 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb995a8 | 2006-09-21 14:28:21 +0200 | [diff] [blame] | 2675 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2676 | /* fake event to set up pins */ |
| 2677 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 2678 | } else { |
| 2679 | stac92xx_auto_init_multi_out(codec); |
| 2680 | stac92xx_auto_init_hp_out(codec); |
| 2681 | } |
| 2682 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2683 | hda_nid_t nid = cfg->input_pins[i]; |
| 2684 | if (nid) { |
| 2685 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2686 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) |
| 2687 | pinctl |= stac92xx_get_vref(codec, nid); |
| 2688 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2689 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2690 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2691 | if (spec->num_dmics > 0) |
| 2692 | for (i = 0; i < spec->num_dmics; i++) |
| 2693 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 2694 | AC_PINCTL_IN_EN); |
| 2695 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 2696 | if (cfg->dig_out_pin) |
| 2697 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, |
| 2698 | AC_PINCTL_OUT_EN); |
| 2699 | if (cfg->dig_in_pin) |
| 2700 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 2701 | AC_PINCTL_IN_EN); |
| 2702 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 2703 | if (spec->gpio_mute) { |
| 2704 | stac922x_gpio_mute(codec, 0, 0); |
| 2705 | stac922x_gpio_mute(codec, 1, 0); |
| 2706 | } |
| 2707 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2708 | return 0; |
| 2709 | } |
| 2710 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2711 | static void stac92xx_free(struct hda_codec *codec) |
| 2712 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2713 | struct sigmatel_spec *spec = codec->spec; |
| 2714 | int i; |
| 2715 | |
| 2716 | if (! spec) |
| 2717 | return; |
| 2718 | |
| 2719 | if (spec->kctl_alloc) { |
| 2720 | for (i = 0; i < spec->num_kctl_used; i++) |
| 2721 | kfree(spec->kctl_alloc[i].name); |
| 2722 | kfree(spec->kctl_alloc); |
| 2723 | } |
| 2724 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2725 | if (spec->bios_pin_configs) |
| 2726 | kfree(spec->bios_pin_configs); |
| 2727 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2728 | kfree(spec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2729 | } |
| 2730 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2731 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 2732 | unsigned int flag) |
| 2733 | { |
| 2734 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 2735 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2736 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 2737 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 2738 | /* |
| 2739 | * we need to check the current set-up direction of |
| 2740 | * shared input pins since they can be switched via |
| 2741 | * "xxx as Output" mixer switch |
| 2742 | */ |
| 2743 | struct sigmatel_spec *spec = codec->spec; |
| 2744 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2745 | if ((nid == cfg->input_pins[AUTO_PIN_LINE] && |
| 2746 | spec->line_switch) || |
| 2747 | (nid == cfg->input_pins[AUTO_PIN_MIC] && |
| 2748 | spec->mic_switch)) |
| 2749 | return; |
| 2750 | } |
| 2751 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2752 | /* if setting pin direction bits, clear the current |
| 2753 | direction bits first */ |
| 2754 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 2755 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 2756 | |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2757 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2758 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2759 | pin_ctl | flag); |
| 2760 | } |
| 2761 | |
| 2762 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 2763 | unsigned int flag) |
| 2764 | { |
| 2765 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 2766 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2767 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2768 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2769 | pin_ctl & ~flag); |
| 2770 | } |
| 2771 | |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2772 | static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2773 | { |
| 2774 | if (!nid) |
| 2775 | return 0; |
| 2776 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2777 | & (1 << 31)) { |
| 2778 | unsigned int pinctl; |
| 2779 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 2780 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 2781 | if (pinctl & AC_PINCTL_IN_EN) |
| 2782 | return 0; /* mic- or line-input */ |
| 2783 | else |
| 2784 | return 1; /* HP-output */ |
| 2785 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2786 | return 0; |
| 2787 | } |
| 2788 | |
| 2789 | static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2790 | { |
| 2791 | struct sigmatel_spec *spec = codec->spec; |
| 2792 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2793 | int i, presence; |
| 2794 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2795 | presence = 0; |
| 2796 | for (i = 0; i < cfg->hp_outs; i++) { |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2797 | presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2798 | if (presence) |
| 2799 | break; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2800 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2801 | |
| 2802 | if (presence) { |
| 2803 | /* disable lineouts, enable hp */ |
| 2804 | for (i = 0; i < cfg->line_outs; i++) |
| 2805 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 2806 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2807 | for (i = 0; i < cfg->speaker_outs; i++) |
| 2808 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 2809 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2810 | } else { |
| 2811 | /* enable lineouts, disable hp */ |
| 2812 | for (i = 0; i < cfg->line_outs; i++) |
| 2813 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 2814 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2815 | for (i = 0; i < cfg->speaker_outs; i++) |
| 2816 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 2817 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2818 | } |
| 2819 | } |
| 2820 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 2821 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2822 | { |
| 2823 | switch (res >> 26) { |
| 2824 | case STAC_HP_EVENT: |
| 2825 | stac92xx_hp_detect(codec, res); |
| 2826 | break; |
| 2827 | } |
| 2828 | } |
| 2829 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2830 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 2831 | static int stac92xx_resume(struct hda_codec *codec) |
| 2832 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 2833 | struct sigmatel_spec *spec = codec->spec; |
| 2834 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2835 | stac92xx_set_config_regs(codec); |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 2836 | snd_hda_sequence_write(codec, spec->init); |
| 2837 | if (spec->gpio_mute) { |
| 2838 | stac922x_gpio_mute(codec, 0, 0); |
| 2839 | stac922x_gpio_mute(codec, 1, 0); |
| 2840 | } |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2841 | snd_hda_codec_resume_amp(codec); |
| 2842 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 2843 | /* invoke unsolicited event to reset the HP state */ |
| 2844 | if (spec->hp_detect) |
| 2845 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 2846 | return 0; |
| 2847 | } |
| 2848 | #endif |
| 2849 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2850 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 2851 | .build_controls = stac92xx_build_controls, |
| 2852 | .build_pcms = stac92xx_build_pcms, |
| 2853 | .init = stac92xx_init, |
| 2854 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 2855 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2856 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 2857 | .resume = stac92xx_resume, |
| 2858 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2859 | }; |
| 2860 | |
| 2861 | static int patch_stac9200(struct hda_codec *codec) |
| 2862 | { |
| 2863 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2864 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2865 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 2866 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2867 | if (spec == NULL) |
| 2868 | return -ENOMEM; |
| 2869 | |
| 2870 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 2871 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2872 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2873 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 2874 | stac9200_models, |
| 2875 | stac9200_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2876 | if (spec->board_config < 0) { |
| 2877 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 2878 | err = stac92xx_save_bios_config_regs(codec); |
| 2879 | if (err < 0) { |
| 2880 | stac92xx_free(codec); |
| 2881 | return err; |
| 2882 | } |
| 2883 | spec->pin_configs = spec->bios_pin_configs; |
| 2884 | } else { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2885 | spec->pin_configs = stac9200_brd_tbl[spec->board_config]; |
| 2886 | stac92xx_set_config_regs(codec); |
| 2887 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2888 | |
| 2889 | spec->multiout.max_channels = 2; |
| 2890 | spec->multiout.num_dacs = 1; |
| 2891 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 2892 | spec->adc_nids = stac9200_adc_nids; |
| 2893 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2894 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2895 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2896 | spec->num_adcs = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2897 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 2898 | if (spec->board_config == STAC_9200_GATEWAY) |
| 2899 | spec->init = stac9200_eapd_init; |
| 2900 | else |
| 2901 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2902 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2903 | |
| 2904 | err = stac9200_parse_auto_config(codec); |
| 2905 | if (err < 0) { |
| 2906 | stac92xx_free(codec); |
| 2907 | return err; |
| 2908 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2909 | |
| 2910 | codec->patch_ops = stac92xx_patch_ops; |
| 2911 | |
| 2912 | return 0; |
| 2913 | } |
| 2914 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2915 | static int patch_stac925x(struct hda_codec *codec) |
| 2916 | { |
| 2917 | struct sigmatel_spec *spec; |
| 2918 | int err; |
| 2919 | |
| 2920 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2921 | if (spec == NULL) |
| 2922 | return -ENOMEM; |
| 2923 | |
| 2924 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 2925 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2926 | spec->pin_nids = stac925x_pin_nids; |
| 2927 | spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, |
| 2928 | stac925x_models, |
| 2929 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2930 | again: |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2931 | if (spec->board_config < 0) { |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 2932 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
| 2933 | "using BIOS defaults\n"); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2934 | err = stac92xx_save_bios_config_regs(codec); |
| 2935 | if (err < 0) { |
| 2936 | stac92xx_free(codec); |
| 2937 | return err; |
| 2938 | } |
| 2939 | spec->pin_configs = spec->bios_pin_configs; |
| 2940 | } else if (stac925x_brd_tbl[spec->board_config] != NULL){ |
| 2941 | spec->pin_configs = stac925x_brd_tbl[spec->board_config]; |
| 2942 | stac92xx_set_config_regs(codec); |
| 2943 | } |
| 2944 | |
| 2945 | spec->multiout.max_channels = 2; |
| 2946 | spec->multiout.num_dacs = 1; |
| 2947 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 2948 | spec->adc_nids = stac925x_adc_nids; |
| 2949 | spec->mux_nids = stac925x_mux_nids; |
| 2950 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2951 | spec->num_adcs = 1; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 2952 | switch (codec->vendor_id) { |
| 2953 | case 0x83847632: /* STAC9202 */ |
| 2954 | case 0x83847633: /* STAC9202D */ |
| 2955 | case 0x83847636: /* STAC9251 */ |
| 2956 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 2957 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 2958 | spec->dmic_nids = stac925x_dmic_nids; |
| 2959 | break; |
| 2960 | default: |
| 2961 | spec->num_dmics = 0; |
| 2962 | break; |
| 2963 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2964 | |
| 2965 | spec->init = stac925x_core_init; |
| 2966 | spec->mixer = stac925x_mixer; |
| 2967 | |
| 2968 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 2969 | if (!err) { |
| 2970 | if (spec->board_config < 0) { |
| 2971 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 2972 | "available, default to model=ref\n"); |
| 2973 | spec->board_config = STAC_925x_REF; |
| 2974 | goto again; |
| 2975 | } |
| 2976 | err = -EINVAL; |
| 2977 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 2978 | if (err < 0) { |
| 2979 | stac92xx_free(codec); |
| 2980 | return err; |
| 2981 | } |
| 2982 | |
| 2983 | codec->patch_ops = stac92xx_patch_ops; |
| 2984 | |
| 2985 | return 0; |
| 2986 | } |
| 2987 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 2988 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 2989 | .num_items = 4, |
| 2990 | .items = { |
| 2991 | { "Analog Inputs", 0x0b }, |
| 2992 | { "CD", 0x08 }, |
| 2993 | { "Digital Mic 1", 0x09 }, |
| 2994 | { "Digital Mic 2", 0x0a }, |
| 2995 | } |
| 2996 | }; |
| 2997 | |
| 2998 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 2999 | { |
| 3000 | struct sigmatel_spec *spec; |
| 3001 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 3002 | int err = 0; |
| 3003 | |
| 3004 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3005 | if (spec == NULL) |
| 3006 | return -ENOMEM; |
| 3007 | |
| 3008 | codec->spec = spec; |
| 3009 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 3010 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 3011 | spec->board_config = snd_hda_check_board_config(codec, |
| 3012 | STAC_92HD73XX_MODELS, |
| 3013 | stac92hd73xx_models, |
| 3014 | stac92hd73xx_cfg_tbl); |
| 3015 | again: |
| 3016 | if (spec->board_config < 0) { |
| 3017 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 3018 | " STAC92HD73XX, using BIOS defaults\n"); |
| 3019 | err = stac92xx_save_bios_config_regs(codec); |
| 3020 | if (err < 0) { |
| 3021 | stac92xx_free(codec); |
| 3022 | return err; |
| 3023 | } |
| 3024 | spec->pin_configs = spec->bios_pin_configs; |
| 3025 | } else { |
| 3026 | spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config]; |
| 3027 | stac92xx_set_config_regs(codec); |
| 3028 | } |
| 3029 | |
| 3030 | spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a, |
| 3031 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 3032 | |
| 3033 | if (spec->multiout.num_dacs < 0) { |
| 3034 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 3035 | "number of channels defaulting to DAC count\n"); |
| 3036 | spec->multiout.num_dacs = STAC92HD73_DAC_COUNT; |
| 3037 | } |
| 3038 | |
| 3039 | switch (spec->multiout.num_dacs) { |
| 3040 | case 0x3: /* 6 Channel */ |
| 3041 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 3042 | spec->init = stac92hd73xx_6ch_core_init; |
| 3043 | break; |
| 3044 | case 0x4: /* 8 Channel */ |
| 3045 | spec->multiout.hp_nid = 0x18; |
| 3046 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 3047 | spec->init = stac92hd73xx_8ch_core_init; |
| 3048 | break; |
| 3049 | case 0x5: /* 10 Channel */ |
| 3050 | spec->multiout.hp_nid = 0x19; |
| 3051 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 3052 | spec->init = stac92hd73xx_10ch_core_init; |
| 3053 | }; |
| 3054 | |
| 3055 | spec->multiout.dac_nids = stac92hd73xx_dac_nids; |
| 3056 | spec->aloopback_mask = 0x01; |
| 3057 | spec->aloopback_shift = 8; |
| 3058 | |
| 3059 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 3060 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 3061 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 3062 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
| 3063 | |
| 3064 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 3065 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
| 3066 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
| 3067 | spec->dinput_mux = &stac92hd73xx_dmux; |
| 3068 | /* GPIO0 High = Enable EAPD */ |
| 3069 | spec->gpio_mask = spec->gpio_data = 0x000001; |
| 3070 | stac92xx_enable_gpio_mask(codec); |
| 3071 | |
| 3072 | err = stac92xx_parse_auto_config(codec, 0x22, 0x24); |
| 3073 | |
| 3074 | if (!err) { |
| 3075 | if (spec->board_config < 0) { |
| 3076 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 3077 | "available, default to model=ref\n"); |
| 3078 | spec->board_config = STAC_92HD73XX_REF; |
| 3079 | goto again; |
| 3080 | } |
| 3081 | err = -EINVAL; |
| 3082 | } |
| 3083 | |
| 3084 | if (err < 0) { |
| 3085 | stac92xx_free(codec); |
| 3086 | return err; |
| 3087 | } |
| 3088 | |
| 3089 | codec->patch_ops = stac92xx_patch_ops; |
| 3090 | |
| 3091 | return 0; |
| 3092 | } |
| 3093 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 3094 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 3095 | { |
| 3096 | struct sigmatel_spec *spec; |
| 3097 | int err = 0; |
| 3098 | |
| 3099 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3100 | if (spec == NULL) |
| 3101 | return -ENOMEM; |
| 3102 | |
| 3103 | codec->spec = spec; |
| 3104 | spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids); |
| 3105 | spec->pin_nids = stac92hd71bxx_pin_nids; |
| 3106 | spec->board_config = snd_hda_check_board_config(codec, |
| 3107 | STAC_92HD71BXX_MODELS, |
| 3108 | stac92hd71bxx_models, |
| 3109 | stac92hd71bxx_cfg_tbl); |
| 3110 | again: |
| 3111 | if (spec->board_config < 0) { |
| 3112 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 3113 | " STAC92HD71BXX, using BIOS defaults\n"); |
| 3114 | err = stac92xx_save_bios_config_regs(codec); |
| 3115 | if (err < 0) { |
| 3116 | stac92xx_free(codec); |
| 3117 | return err; |
| 3118 | } |
| 3119 | spec->pin_configs = spec->bios_pin_configs; |
| 3120 | } else { |
| 3121 | spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config]; |
| 3122 | stac92xx_set_config_regs(codec); |
| 3123 | } |
| 3124 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 3125 | switch (codec->vendor_id) { |
| 3126 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 3127 | case 0x111d76b7: |
| 3128 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 3129 | case 0x111d76b5: |
| 3130 | spec->mixer = stac92hd71bxx_mixer; |
| 3131 | spec->init = stac92hd71bxx_core_init; |
| 3132 | break; |
| 3133 | default: |
| 3134 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 3135 | spec->init = stac92hd71bxx_analog_core_init; |
| 3136 | } |
| 3137 | |
| 3138 | spec->aloopback_mask = 0x20; |
| 3139 | spec->aloopback_shift = 0; |
| 3140 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 3141 | spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */ |
| 3142 | stac92xx_enable_gpio_mask(codec); |
| 3143 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 3144 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 3145 | spec->adc_nids = stac92hd71bxx_adc_nids; |
| 3146 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3147 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 3148 | |
| 3149 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 3150 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
| 3151 | spec->num_dmics = STAC92HD71BXX_NUM_DMICS; |
| 3152 | |
| 3153 | spec->multiout.num_dacs = 2; |
| 3154 | spec->multiout.hp_nid = 0x11; |
| 3155 | spec->multiout.dac_nids = stac92hd71bxx_dac_nids; |
| 3156 | |
| 3157 | err = stac92xx_parse_auto_config(codec, 0x21, 0x23); |
| 3158 | if (!err) { |
| 3159 | if (spec->board_config < 0) { |
| 3160 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 3161 | "available, default to model=ref\n"); |
| 3162 | spec->board_config = STAC_92HD71BXX_REF; |
| 3163 | goto again; |
| 3164 | } |
| 3165 | err = -EINVAL; |
| 3166 | } |
| 3167 | |
| 3168 | if (err < 0) { |
| 3169 | stac92xx_free(codec); |
| 3170 | return err; |
| 3171 | } |
| 3172 | |
| 3173 | codec->patch_ops = stac92xx_patch_ops; |
| 3174 | |
| 3175 | return 0; |
| 3176 | }; |
| 3177 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3178 | static int patch_stac922x(struct hda_codec *codec) |
| 3179 | { |
| 3180 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3181 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3182 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 3183 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3184 | if (spec == NULL) |
| 3185 | return -ENOMEM; |
| 3186 | |
| 3187 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 3188 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3189 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3190 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 3191 | stac922x_models, |
| 3192 | stac922x_cfg_tbl); |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 3193 | if (spec->board_config == STAC_INTEL_MAC_V3) { |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 3194 | spec->gpio_mute = 1; |
| 3195 | /* Intel Macs have all same PCI SSID, so we need to check |
| 3196 | * codec SSID to distinguish the exact models |
| 3197 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 3198 | 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] | 3199 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 3200 | |
| 3201 | case 0x106b0800: |
| 3202 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 3203 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 3204 | case 0x106b0600: |
| 3205 | case 0x106b0700: |
| 3206 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 3207 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 3208 | case 0x106b0e00: |
| 3209 | case 0x106b0f00: |
| 3210 | case 0x106b1600: |
| 3211 | case 0x106b1700: |
| 3212 | case 0x106b0200: |
| 3213 | case 0x106b1e00: |
| 3214 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 3215 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 3216 | case 0x106b1a00: |
| 3217 | case 0x00000100: |
| 3218 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 3219 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 3220 | case 0x106b0a00: |
| 3221 | case 0x106b2200: |
| 3222 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 3223 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 3224 | } |
| 3225 | } |
| 3226 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3227 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3228 | if (spec->board_config < 0) { |
| 3229 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 3230 | "using BIOS defaults\n"); |
| 3231 | err = stac92xx_save_bios_config_regs(codec); |
| 3232 | if (err < 0) { |
| 3233 | stac92xx_free(codec); |
| 3234 | return err; |
| 3235 | } |
| 3236 | spec->pin_configs = spec->bios_pin_configs; |
| 3237 | } else if (stac922x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3238 | spec->pin_configs = stac922x_brd_tbl[spec->board_config]; |
| 3239 | stac92xx_set_config_regs(codec); |
| 3240 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3241 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3242 | spec->adc_nids = stac922x_adc_nids; |
| 3243 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 3244 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3245 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3246 | spec->num_dmics = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3247 | |
| 3248 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3249 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3250 | |
| 3251 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3252 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3253 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3254 | if (!err) { |
| 3255 | if (spec->board_config < 0) { |
| 3256 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 3257 | "available, default to model=ref\n"); |
| 3258 | spec->board_config = STAC_D945_REF; |
| 3259 | goto again; |
| 3260 | } |
| 3261 | err = -EINVAL; |
| 3262 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3263 | if (err < 0) { |
| 3264 | stac92xx_free(codec); |
| 3265 | return err; |
| 3266 | } |
| 3267 | |
| 3268 | codec->patch_ops = stac92xx_patch_ops; |
| 3269 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 3270 | /* Fix Mux capture level; max to 2 */ |
| 3271 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 3272 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 3273 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 3274 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 3275 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 3276 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3277 | return 0; |
| 3278 | } |
| 3279 | |
| 3280 | static int patch_stac927x(struct hda_codec *codec) |
| 3281 | { |
| 3282 | struct sigmatel_spec *spec; |
| 3283 | int err; |
| 3284 | |
| 3285 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3286 | if (spec == NULL) |
| 3287 | return -ENOMEM; |
| 3288 | |
| 3289 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 3290 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3291 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3292 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 3293 | stac927x_models, |
| 3294 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3295 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3296 | if (spec->board_config < 0) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3297 | 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] | 3298 | err = stac92xx_save_bios_config_regs(codec); |
| 3299 | if (err < 0) { |
| 3300 | stac92xx_free(codec); |
| 3301 | return err; |
| 3302 | } |
| 3303 | spec->pin_configs = spec->bios_pin_configs; |
| 3304 | } else if (stac927x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3305 | spec->pin_configs = stac927x_brd_tbl[spec->board_config]; |
| 3306 | stac92xx_set_config_regs(codec); |
| 3307 | } |
| 3308 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3309 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3310 | case STAC_D965_3ST: |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3311 | spec->adc_nids = stac927x_adc_nids; |
| 3312 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 3313 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3314 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3315 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3316 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3317 | break; |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3318 | case STAC_D965_5ST: |
| 3319 | spec->adc_nids = stac927x_adc_nids; |
| 3320 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 3321 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3322 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3323 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3324 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3325 | break; |
| 3326 | default: |
| 3327 | spec->adc_nids = stac927x_adc_nids; |
| 3328 | spec->mux_nids = stac927x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 3329 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3330 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3331 | spec->init = stac927x_core_init; |
| 3332 | spec->mixer = stac927x_mixer; |
| 3333 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3334 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 3335 | switch (codec->subsystem_id) { |
Matthew Ranostay | b222fe5 | 2007-11-07 15:54:45 +0100 | [diff] [blame] | 3336 | case 0x10280242: /* STAC 9228 */ |
| 3337 | case 0x102801f3: |
| 3338 | case 0x1028020A: |
| 3339 | case 0x10280209: |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 3340 | spec->dmic_nids = stac927x_dmic_nids; |
| 3341 | spec->num_dmics = STAC927X_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3342 | spec->dmux_nids = stac927x_dmux_nids; |
Matthew Ranostay | f1f208d | 2007-11-05 15:30:13 +0100 | [diff] [blame] | 3343 | |
| 3344 | /* Enable DMIC0 */ |
| 3345 | stac92xx_set_config_reg(codec, 0x13, 0x90a60040); |
| 3346 | |
| 3347 | /* GPIO2 High = Enable EAPD */ |
| 3348 | spec->gpio_mask = spec->gpio_data = 0x00000004; |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 3349 | break; |
| 3350 | default: |
Matthew Ranostay | f1f208d | 2007-11-05 15:30:13 +0100 | [diff] [blame] | 3351 | spec->num_dmics = 0; |
| 3352 | |
| 3353 | /* GPIO0 High = Enable EAPD */ |
| 3354 | spec->gpio_mask = spec->gpio_data = 0x00000001; |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 3355 | } |
| 3356 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3357 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3358 | spec->aloopback_mask = 0x40; |
| 3359 | spec->aloopback_shift = 0; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 3360 | stac92xx_enable_gpio_mask(codec); |
Matthew Ranostay | 92a22be | 2007-06-19 16:48:28 +0200 | [diff] [blame] | 3361 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3362 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3363 | if (!err) { |
| 3364 | if (spec->board_config < 0) { |
| 3365 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 3366 | "available, default to model=ref\n"); |
| 3367 | spec->board_config = STAC_D965_REF; |
| 3368 | goto again; |
| 3369 | } |
| 3370 | err = -EINVAL; |
| 3371 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3372 | if (err < 0) { |
| 3373 | stac92xx_free(codec); |
| 3374 | return err; |
| 3375 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3376 | |
| 3377 | codec->patch_ops = stac92xx_patch_ops; |
| 3378 | |
| 3379 | return 0; |
| 3380 | } |
| 3381 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3382 | static int patch_stac9205(struct hda_codec *codec) |
| 3383 | { |
| 3384 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 3385 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3386 | |
| 3387 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3388 | if (spec == NULL) |
| 3389 | return -ENOMEM; |
| 3390 | |
| 3391 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 3392 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3393 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3394 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 3395 | stac9205_models, |
| 3396 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3397 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3398 | if (spec->board_config < 0) { |
| 3399 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
| 3400 | err = stac92xx_save_bios_config_regs(codec); |
| 3401 | if (err < 0) { |
| 3402 | stac92xx_free(codec); |
| 3403 | return err; |
| 3404 | } |
| 3405 | spec->pin_configs = spec->bios_pin_configs; |
| 3406 | } else { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3407 | spec->pin_configs = stac9205_brd_tbl[spec->board_config]; |
| 3408 | stac92xx_set_config_regs(codec); |
| 3409 | } |
| 3410 | |
| 3411 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3412 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3413 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 3414 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3415 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 3416 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3417 | spec->dmux_nids = stac9205_dmux_nids; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3418 | |
| 3419 | spec->init = stac9205_core_init; |
| 3420 | spec->mixer = stac9205_mixer; |
| 3421 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3422 | spec->aloopback_mask = 0x40; |
| 3423 | spec->aloopback_shift = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3424 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 3425 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3426 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3427 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 3428 | /* Enable SPDIF in/out */ |
| 3429 | stac92xx_set_config_reg(codec, 0x1f, 0x01441030); |
| 3430 | stac92xx_set_config_reg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 3431 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 3432 | spec->gpio_mask = 0x00000007; /* GPIO0-2 */ |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 3433 | /* GPIO0 High = EAPD, GPIO1 Low = DRM, |
| 3434 | * GPIO2 High = Headphone Mute |
| 3435 | */ |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 3436 | spec->gpio_data = 0x00000005; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3437 | break; |
| 3438 | default: |
| 3439 | /* GPIO0 High = EAPD */ |
| 3440 | spec->gpio_mask = spec->gpio_data = 0x00000001; |
| 3441 | break; |
| 3442 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 3443 | |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 3444 | stac92xx_enable_gpio_mask(codec); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3445 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3446 | if (!err) { |
| 3447 | if (spec->board_config < 0) { |
| 3448 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 3449 | "available, default to model=ref\n"); |
| 3450 | spec->board_config = STAC_9205_REF; |
| 3451 | goto again; |
| 3452 | } |
| 3453 | err = -EINVAL; |
| 3454 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3455 | if (err < 0) { |
| 3456 | stac92xx_free(codec); |
| 3457 | return err; |
| 3458 | } |
| 3459 | |
| 3460 | codec->patch_ops = stac92xx_patch_ops; |
| 3461 | |
| 3462 | return 0; |
| 3463 | } |
| 3464 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3465 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3466 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3467 | */ |
| 3468 | |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 3469 | /* static config for Sony VAIO FE550G and Sony VAIO AR */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3470 | static hda_nid_t vaio_dacs[] = { 0x2 }; |
| 3471 | #define VAIO_HP_DAC 0x5 |
| 3472 | static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; |
| 3473 | static hda_nid_t vaio_mux_nids[] = { 0x15 }; |
| 3474 | |
| 3475 | static struct hda_input_mux vaio_mux = { |
Takashi Iwai | a3a2f42 | 2007-10-11 11:21:21 +0200 | [diff] [blame] | 3476 | .num_items = 3, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3477 | .items = { |
Takashi Iwai | d773781 | 2006-04-25 13:05:43 +0200 | [diff] [blame] | 3478 | /* { "HP", 0x0 }, */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 3479 | { "Mic Jack", 0x1 }, |
| 3480 | { "Internal Mic", 0x2 }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3481 | { "PCM", 0x3 }, |
| 3482 | } |
| 3483 | }; |
| 3484 | |
| 3485 | static struct hda_verb vaio_init[] = { |
| 3486 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 3487 | {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT}, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3488 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 3489 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 3490 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 3491 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 3492 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3493 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 3494 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 3495 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 3496 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 3497 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 3498 | {} |
| 3499 | }; |
| 3500 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3501 | static struct hda_verb vaio_ar_init[] = { |
| 3502 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 3503 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 3504 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 3505 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 3506 | /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ |
| 3507 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 3508 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3509 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 3510 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 3511 | /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ |
| 3512 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 3513 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 3514 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 3515 | {} |
| 3516 | }; |
| 3517 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3518 | /* bind volumes of both NID 0x02 and 0x05 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 3519 | static struct hda_bind_ctls vaio_bind_master_vol = { |
| 3520 | .ops = &snd_hda_bind_vol, |
| 3521 | .values = { |
| 3522 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 3523 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 3524 | 0 |
| 3525 | }, |
| 3526 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3527 | |
| 3528 | /* bind volumes of both NID 0x02 and 0x05 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 3529 | static struct hda_bind_ctls vaio_bind_master_sw = { |
| 3530 | .ops = &snd_hda_bind_sw, |
| 3531 | .values = { |
| 3532 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 3533 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 3534 | 0, |
| 3535 | }, |
| 3536 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3537 | |
| 3538 | static struct snd_kcontrol_new vaio_mixer[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 3539 | HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), |
| 3540 | HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3541 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 3542 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 3543 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 3544 | { |
| 3545 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3546 | .name = "Capture Source", |
| 3547 | .count = 1, |
| 3548 | .info = stac92xx_mux_enum_info, |
| 3549 | .get = stac92xx_mux_enum_get, |
| 3550 | .put = stac92xx_mux_enum_put, |
| 3551 | }, |
| 3552 | {} |
| 3553 | }; |
| 3554 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3555 | static struct snd_kcontrol_new vaio_ar_mixer[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 3556 | HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), |
| 3557 | HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3558 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 3559 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 3560 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 3561 | /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT), |
| 3562 | HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/ |
| 3563 | { |
| 3564 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3565 | .name = "Capture Source", |
| 3566 | .count = 1, |
| 3567 | .info = stac92xx_mux_enum_info, |
| 3568 | .get = stac92xx_mux_enum_get, |
| 3569 | .put = stac92xx_mux_enum_put, |
| 3570 | }, |
| 3571 | {} |
| 3572 | }; |
| 3573 | |
| 3574 | static struct hda_codec_ops stac9872_patch_ops = { |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3575 | .build_controls = stac92xx_build_controls, |
| 3576 | .build_pcms = stac92xx_build_pcms, |
| 3577 | .init = stac92xx_init, |
| 3578 | .free = stac92xx_free, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3579 | #ifdef SND_HDA_NEEDS_RESUME |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3580 | .resume = stac92xx_resume, |
| 3581 | #endif |
| 3582 | }; |
| 3583 | |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 3584 | static int stac9872_vaio_init(struct hda_codec *codec) |
| 3585 | { |
| 3586 | int err; |
| 3587 | |
| 3588 | err = stac92xx_init(codec); |
| 3589 | if (err < 0) |
| 3590 | return err; |
| 3591 | if (codec->patch_ops.unsol_event) |
| 3592 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 3593 | return 0; |
| 3594 | } |
| 3595 | |
| 3596 | static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) |
| 3597 | { |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 3598 | if (get_hp_pin_presence(codec, 0x0a)) { |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 3599 | stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
| 3600 | stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
| 3601 | } else { |
| 3602 | stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
| 3603 | stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
| 3604 | } |
| 3605 | } |
| 3606 | |
| 3607 | static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res) |
| 3608 | { |
| 3609 | switch (res >> 26) { |
| 3610 | case STAC_HP_EVENT: |
| 3611 | stac9872_vaio_hp_detect(codec, res); |
| 3612 | break; |
| 3613 | } |
| 3614 | } |
| 3615 | |
| 3616 | static struct hda_codec_ops stac9872_vaio_patch_ops = { |
| 3617 | .build_controls = stac92xx_build_controls, |
| 3618 | .build_pcms = stac92xx_build_pcms, |
| 3619 | .init = stac9872_vaio_init, |
| 3620 | .free = stac92xx_free, |
| 3621 | .unsol_event = stac9872_vaio_unsol_event, |
| 3622 | #ifdef CONFIG_PM |
| 3623 | .resume = stac92xx_resume, |
| 3624 | #endif |
| 3625 | }; |
| 3626 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3627 | enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ |
| 3628 | CXD9872RD_VAIO, |
| 3629 | /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ |
| 3630 | STAC9872AK_VAIO, |
| 3631 | /* Unknown. id=0x83847661 and subsys=0x104D1200. */ |
| 3632 | STAC9872K_VAIO, |
| 3633 | /* AR Series. id=0x83847664 and subsys=104D1300 */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3634 | CXD9872AKD_VAIO, |
| 3635 | STAC_9872_MODELS, |
| 3636 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3637 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3638 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 3639 | [CXD9872RD_VAIO] = "vaio", |
| 3640 | [CXD9872AKD_VAIO] = "vaio-ar", |
| 3641 | }; |
| 3642 | |
| 3643 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 3644 | SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 3645 | SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 3646 | SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), |
Tobin Davis | 68e2254 | 2007-03-12 11:36:39 +0100 | [diff] [blame] | 3647 | SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3648 | {} |
| 3649 | }; |
| 3650 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3651 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3652 | { |
| 3653 | struct sigmatel_spec *spec; |
| 3654 | int board_config; |
| 3655 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3656 | board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 3657 | stac9872_models, |
| 3658 | stac9872_cfg_tbl); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3659 | if (board_config < 0) |
| 3660 | /* unknown config, let generic-parser do its job... */ |
| 3661 | return snd_hda_parse_generic_codec(codec); |
| 3662 | |
| 3663 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3664 | if (spec == NULL) |
| 3665 | return -ENOMEM; |
| 3666 | |
| 3667 | codec->spec = spec; |
| 3668 | switch (board_config) { |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3669 | case CXD9872RD_VAIO: |
| 3670 | case STAC9872AK_VAIO: |
| 3671 | case STAC9872K_VAIO: |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3672 | spec->mixer = vaio_mixer; |
| 3673 | spec->init = vaio_init; |
| 3674 | spec->multiout.max_channels = 2; |
| 3675 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 3676 | spec->multiout.dac_nids = vaio_dacs; |
| 3677 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 3678 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 3679 | spec->adc_nids = vaio_adcs; |
| 3680 | spec->input_mux = &vaio_mux; |
| 3681 | spec->mux_nids = vaio_mux_nids; |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 3682 | codec->patch_ops = stac9872_vaio_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3683 | break; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3684 | |
| 3685 | case CXD9872AKD_VAIO: |
| 3686 | spec->mixer = vaio_ar_mixer; |
| 3687 | spec->init = vaio_ar_init; |
| 3688 | spec->multiout.max_channels = 2; |
| 3689 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 3690 | spec->multiout.dac_nids = vaio_dacs; |
| 3691 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 3692 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 3693 | spec->adc_nids = vaio_adcs; |
| 3694 | spec->input_mux = &vaio_mux; |
| 3695 | spec->mux_nids = vaio_mux_nids; |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 3696 | codec->patch_ops = stac9872_patch_ops; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3697 | break; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3698 | } |
| 3699 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 3700 | return 0; |
| 3701 | } |
| 3702 | |
| 3703 | |
| 3704 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3705 | * patch entries |
| 3706 | */ |
| 3707 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
| 3708 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 3709 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 3710 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 3711 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 3712 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 3713 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 3714 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 3715 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 3716 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 3717 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 3718 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 3719 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 3720 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3721 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 3722 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 3723 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 3724 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 3725 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 3726 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 3727 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 3728 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 3729 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 3730 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 3731 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 3732 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 3733 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 3734 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 3735 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 3736 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 3737 | /* The following does not take into account .id=0x83847661 when subsys = |
| 3738 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 3739 | * currently not fully supported. |
| 3740 | */ |
| 3741 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 3742 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 3743 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3744 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 3745 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 3746 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 3747 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 3748 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 3749 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 3750 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 3751 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 3752 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 3753 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3754 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame^] | 3755 | { .id = 0x111d7608, .name = "92HD71BXX", .patch = patch_stac92hd71bxx }, |
| 3756 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 3757 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 3758 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 3759 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 3760 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 3761 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 3762 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 3763 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3764 | {} /* terminator */ |
| 3765 | }; |