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 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 27 | #include <linux/init.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/pci.h> |
| 31 | #include <sound/core.h> |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 32 | #include <sound/asoundef.h> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Harvey Harrison | 3c9a320 | 2008-02-29 11:59:26 +0100 | [diff] [blame] | 35 | #include "hda_patch.h" |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 36 | #include "hda_beep.h" |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 37 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 38 | #define NUM_CONTROL_ALLOC 32 |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 39 | #define STAC_PWR_EVENT 0x20 |
| 40 | #define STAC_HP_EVENT 0x30 |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 41 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 42 | enum { |
| 43 | STAC_REF, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 44 | STAC_9200_OQO, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 45 | STAC_9200_DELL_D21, |
| 46 | STAC_9200_DELL_D22, |
| 47 | STAC_9200_DELL_D23, |
| 48 | STAC_9200_DELL_M21, |
| 49 | STAC_9200_DELL_M22, |
| 50 | STAC_9200_DELL_M23, |
| 51 | STAC_9200_DELL_M24, |
| 52 | STAC_9200_DELL_M25, |
| 53 | STAC_9200_DELL_M26, |
| 54 | STAC_9200_DELL_M27, |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 55 | STAC_9200_GATEWAY, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 56 | STAC_9200_PANASONIC, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 57 | STAC_9200_MODELS |
| 58 | }; |
| 59 | |
| 60 | enum { |
| 61 | STAC_9205_REF, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 62 | STAC_9205_DELL_M42, |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 63 | STAC_9205_DELL_M43, |
| 64 | STAC_9205_DELL_M44, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 65 | STAC_9205_MODELS |
| 66 | }; |
| 67 | |
| 68 | enum { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 69 | STAC_92HD73XX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 70 | STAC_DELL_M6, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 71 | STAC_92HD73XX_MODELS |
| 72 | }; |
| 73 | |
| 74 | enum { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 75 | STAC_92HD83XXX_REF, |
| 76 | STAC_92HD83XXX_MODELS |
| 77 | }; |
| 78 | |
| 79 | enum { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 80 | STAC_92HD71BXX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 81 | STAC_DELL_M4_1, |
| 82 | STAC_DELL_M4_2, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 83 | STAC_HP_M4, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 84 | STAC_92HD71BXX_MODELS |
| 85 | }; |
| 86 | |
| 87 | enum { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 88 | STAC_925x_REF, |
| 89 | STAC_M2_2, |
| 90 | STAC_MA6, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 91 | STAC_PA6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 92 | STAC_925x_MODELS |
| 93 | }; |
| 94 | |
| 95 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 96 | STAC_D945_REF, |
| 97 | STAC_D945GTP3, |
| 98 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 99 | STAC_INTEL_MAC_V1, |
| 100 | STAC_INTEL_MAC_V2, |
| 101 | STAC_INTEL_MAC_V3, |
| 102 | STAC_INTEL_MAC_V4, |
| 103 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 104 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 105 | * is given, one of the above models will be |
| 106 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 107 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 108 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 109 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 110 | STAC_MACBOOK_PRO_V1, |
| 111 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 112 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 113 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 114 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 115 | STAC_922X_DELL_D81, |
| 116 | STAC_922X_DELL_D82, |
| 117 | STAC_922X_DELL_M81, |
| 118 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 119 | STAC_922X_MODELS |
| 120 | }; |
| 121 | |
| 122 | enum { |
| 123 | STAC_D965_REF, |
| 124 | STAC_D965_3ST, |
| 125 | STAC_D965_5ST, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 126 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 127 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 128 | STAC_927X_MODELS |
| 129 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 130 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 131 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 132 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 133 | unsigned int num_mixers; |
| 134 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 135 | int board_config; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 136 | unsigned int surr_switch: 1; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 137 | unsigned int line_switch: 1; |
| 138 | unsigned int mic_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 139 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 140 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 141 | unsigned int spdif_mute: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 142 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 143 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 144 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 145 | unsigned int gpio_mask; |
| 146 | unsigned int gpio_dir; |
| 147 | unsigned int gpio_data; |
| 148 | unsigned int gpio_mute; |
| 149 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 150 | /* stream */ |
| 151 | unsigned int stream_delay; |
| 152 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 153 | /* analog loopback */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 154 | unsigned char aloopback_mask; |
| 155 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 156 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 157 | /* power management */ |
| 158 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 159 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 160 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 161 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 162 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 163 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 164 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 165 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 166 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 167 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 168 | hda_nid_t dac_nids[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 169 | |
| 170 | /* capture */ |
| 171 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 172 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 173 | hda_nid_t *mux_nids; |
| 174 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 175 | hda_nid_t *dmic_nids; |
| 176 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 177 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 178 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 179 | hda_nid_t *smux_nids; |
| 180 | unsigned int num_smuxes; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 181 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 182 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 183 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 184 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 185 | hda_nid_t anabeep_nid; |
| 186 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 187 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 188 | /* pin widgets */ |
| 189 | hda_nid_t *pin_nids; |
| 190 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 191 | unsigned int *pin_configs; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 192 | unsigned int *bios_pin_configs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 193 | |
| 194 | /* codec specific stuff */ |
| 195 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 196 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 197 | |
| 198 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 199 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 200 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 201 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 202 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 203 | struct hda_input_mux *sinput_mux; |
| 204 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 205 | unsigned int cur_amux; |
| 206 | hda_nid_t *amp_nids; |
| 207 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 208 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 209 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 210 | /* i/o switches */ |
| 211 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 212 | unsigned int clfe_swap; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 213 | unsigned int hp_switch; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 214 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 215 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 216 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 217 | |
| 218 | /* dynamic controls and input_mux */ |
| 219 | struct auto_pin_cfg autocfg; |
| 220 | unsigned int num_kctl_alloc, num_kctl_used; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 221 | struct snd_kcontrol_new *kctl_alloc; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 222 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 223 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 224 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 225 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 226 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | static hda_nid_t stac9200_adc_nids[1] = { |
| 230 | 0x03, |
| 231 | }; |
| 232 | |
| 233 | static hda_nid_t stac9200_mux_nids[1] = { |
| 234 | 0x0c, |
| 235 | }; |
| 236 | |
| 237 | static hda_nid_t stac9200_dac_nids[1] = { |
| 238 | 0x02, |
| 239 | }; |
| 240 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 241 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 242 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 243 | 0x0f, 0x10, 0x11 |
| 244 | }; |
| 245 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 246 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 247 | 0x26, 0, |
| 248 | }; |
| 249 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 250 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 251 | 0x1a, 0x1b |
| 252 | }; |
| 253 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 254 | #define DELL_M6_AMP 2 |
| 255 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 256 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 257 | }; |
| 258 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 259 | #define STAC92HD73XX_NUM_DMICS 2 |
| 260 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 261 | 0x13, 0x14, 0 |
| 262 | }; |
| 263 | |
| 264 | #define STAC92HD73_DAC_COUNT 5 |
| 265 | static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = { |
| 266 | 0x15, 0x16, 0x17, 0x18, 0x19, |
| 267 | }; |
| 268 | |
| 269 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 270 | 0x28, 0x29, 0x2a, 0x2b, |
| 271 | }; |
| 272 | |
| 273 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 274 | 0x20, 0x21, |
| 275 | }; |
| 276 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 277 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 278 | 0x22, 0x23, |
| 279 | }; |
| 280 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 281 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 282 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 283 | 0x11, 0x12, 0 |
| 284 | }; |
| 285 | |
| 286 | #define STAC92HD81_DAC_COUNT 2 |
| 287 | #define STAC92HD83_DAC_COUNT 3 |
| 288 | static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = { |
| 289 | 0x13, 0x14, 0x22, |
| 290 | }; |
| 291 | |
| 292 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 293 | 0x17, 0x18, |
| 294 | }; |
| 295 | |
| 296 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 297 | 0x15, 0x16, |
| 298 | }; |
| 299 | |
| 300 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 301 | 0xa, 0xb, 0xd, 0xe, |
| 302 | }; |
| 303 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 304 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 305 | 0x1e, 0, |
| 306 | }; |
| 307 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 308 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
| 309 | 0x03, 0x0c, 0x10, 0x40, |
| 310 | }; |
| 311 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 312 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 313 | 0x0a, 0x0d, 0x0f |
| 314 | }; |
| 315 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 316 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 317 | 0x12, 0x13, |
| 318 | }; |
| 319 | |
| 320 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 321 | 0x1a, 0x1b |
| 322 | }; |
| 323 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 324 | static hda_nid_t stac92hd71bxx_dmux_nids[1] = { |
| 325 | 0x1c, |
| 326 | }; |
| 327 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 328 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 329 | 0x24, 0x25, |
| 330 | }; |
| 331 | |
Takashi Iwai | aea7bb0 | 2008-02-25 18:26:41 +0100 | [diff] [blame] | 332 | static hda_nid_t stac92hd71bxx_dac_nids[1] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 333 | 0x10, /*0x11, */ |
| 334 | }; |
| 335 | |
| 336 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 337 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 338 | 0x18, 0x19, 0 |
| 339 | }; |
| 340 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 341 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 342 | 0x22, 0 |
| 343 | }; |
| 344 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 345 | static hda_nid_t stac925x_adc_nids[1] = { |
| 346 | 0x03, |
| 347 | }; |
| 348 | |
| 349 | static hda_nid_t stac925x_mux_nids[1] = { |
| 350 | 0x0f, |
| 351 | }; |
| 352 | |
| 353 | static hda_nid_t stac925x_dac_nids[1] = { |
| 354 | 0x02, |
| 355 | }; |
| 356 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 357 | #define STAC925X_NUM_DMICS 1 |
| 358 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 359 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 360 | }; |
| 361 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 362 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 363 | 0x14, |
| 364 | }; |
| 365 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 366 | static hda_nid_t stac922x_adc_nids[2] = { |
| 367 | 0x06, 0x07, |
| 368 | }; |
| 369 | |
| 370 | static hda_nid_t stac922x_mux_nids[2] = { |
| 371 | 0x12, 0x13, |
| 372 | }; |
| 373 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 374 | static hda_nid_t stac927x_adc_nids[3] = { |
| 375 | 0x07, 0x08, 0x09 |
| 376 | }; |
| 377 | |
| 378 | static hda_nid_t stac927x_mux_nids[3] = { |
| 379 | 0x15, 0x16, 0x17 |
| 380 | }; |
| 381 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 382 | static hda_nid_t stac927x_smux_nids[1] = { |
| 383 | 0x21, |
| 384 | }; |
| 385 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 386 | static hda_nid_t stac927x_dac_nids[6] = { |
| 387 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 388 | }; |
| 389 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 390 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 391 | 0x1b, |
| 392 | }; |
| 393 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 394 | #define STAC927X_NUM_DMICS 2 |
| 395 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 396 | 0x13, 0x14, 0 |
| 397 | }; |
| 398 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 399 | static const char *stac927x_spdif_labels[5] = { |
| 400 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 401 | "Analog Mux 2", "Analog Mux 3" |
| 402 | }; |
| 403 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 404 | static hda_nid_t stac9205_adc_nids[2] = { |
| 405 | 0x12, 0x13 |
| 406 | }; |
| 407 | |
| 408 | static hda_nid_t stac9205_mux_nids[2] = { |
| 409 | 0x19, 0x1a |
| 410 | }; |
| 411 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 412 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 413 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 414 | }; |
| 415 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 416 | static hda_nid_t stac9205_smux_nids[1] = { |
| 417 | 0x21, |
| 418 | }; |
| 419 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 420 | #define STAC9205_NUM_DMICS 2 |
| 421 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 422 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 423 | }; |
| 424 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 425 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 426 | 0x08, 0x09, 0x0d, 0x0e, |
| 427 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 428 | }; |
| 429 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 430 | static hda_nid_t stac925x_pin_nids[8] = { |
| 431 | 0x07, 0x08, 0x0a, 0x0b, |
| 432 | 0x0c, 0x0d, 0x10, 0x11, |
| 433 | }; |
| 434 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 435 | static hda_nid_t stac922x_pin_nids[10] = { |
| 436 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 437 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 438 | }; |
| 439 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 440 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 441 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 442 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 443 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 444 | }; |
| 445 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 446 | static hda_nid_t stac92hd83xxx_pin_nids[14] = { |
| 447 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 448 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 449 | 0x1d, 0x1e, 0x1f, 0x20 |
| 450 | }; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 451 | static hda_nid_t stac92hd71bxx_pin_nids[11] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 452 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 453 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 454 | 0x1f, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 455 | }; |
| 456 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 457 | static hda_nid_t stac927x_pin_nids[14] = { |
| 458 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 459 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 460 | 0x14, 0x21, 0x22, 0x23, |
| 461 | }; |
| 462 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 463 | static hda_nid_t stac9205_pin_nids[12] = { |
| 464 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 465 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 466 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 467 | }; |
| 468 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 469 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 470 | |
| 471 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 472 | struct snd_ctl_elem_value *ucontrol) |
| 473 | { |
| 474 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 475 | struct sigmatel_spec *spec = codec->spec; |
| 476 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 477 | |
| 478 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 479 | kcontrol->private_value |= nid; |
| 480 | |
| 481 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 482 | } |
| 483 | |
| 484 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 485 | struct snd_ctl_elem_value *ucontrol) |
| 486 | { |
| 487 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 488 | struct sigmatel_spec *spec = codec->spec; |
| 489 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 490 | |
| 491 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 492 | kcontrol->private_value |= nid; |
| 493 | |
| 494 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 495 | } |
| 496 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 497 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 498 | struct snd_ctl_elem_info *uinfo) |
| 499 | { |
| 500 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 501 | struct sigmatel_spec *spec = codec->spec; |
| 502 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 503 | } |
| 504 | |
| 505 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 506 | struct snd_ctl_elem_value *ucontrol) |
| 507 | { |
| 508 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 509 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 510 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 511 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 512 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 517 | struct snd_ctl_elem_value *ucontrol) |
| 518 | { |
| 519 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 520 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 521 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 522 | |
| 523 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 524 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 525 | } |
| 526 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 527 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 528 | struct snd_ctl_elem_info *uinfo) |
| 529 | { |
| 530 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 531 | struct sigmatel_spec *spec = codec->spec; |
| 532 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 533 | } |
| 534 | |
| 535 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 536 | struct snd_ctl_elem_value *ucontrol) |
| 537 | { |
| 538 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 539 | struct sigmatel_spec *spec = codec->spec; |
| 540 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 541 | |
| 542 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 543 | return 0; |
| 544 | } |
| 545 | |
| 546 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 547 | struct snd_ctl_elem_value *ucontrol) |
| 548 | { |
| 549 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 550 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 551 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 552 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 553 | int err, val; |
| 554 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 555 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 556 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 557 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 558 | if (err < 0) |
| 559 | return err; |
| 560 | |
| 561 | if (spec->spdif_mute) { |
| 562 | if (smux_idx == 0) |
| 563 | nid = spec->multiout.dig_out_nid; |
| 564 | else |
| 565 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 566 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
| 567 | val = AMP_OUT_MUTE; |
| 568 | if (smux_idx == 0) |
| 569 | nid = spec->multiout.dig_out_nid; |
| 570 | else |
| 571 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 572 | /* un/mute SPDIF out */ |
| 573 | snd_hda_codec_write_cache(codec, nid, 0, |
| 574 | AC_VERB_SET_AMP_GAIN_MUTE, val); |
| 575 | } |
| 576 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 577 | } |
| 578 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 579 | 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] | 580 | { |
| 581 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 582 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 583 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 584 | } |
| 585 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 586 | 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] | 587 | { |
| 588 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 589 | struct sigmatel_spec *spec = codec->spec; |
| 590 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 591 | |
| 592 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 593 | return 0; |
| 594 | } |
| 595 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 596 | 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] | 597 | { |
| 598 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 599 | struct sigmatel_spec *spec = codec->spec; |
| 600 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 601 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 602 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 603 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 604 | } |
| 605 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 606 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 607 | struct snd_ctl_elem_info *uinfo) |
| 608 | { |
| 609 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 610 | struct sigmatel_spec *spec = codec->spec; |
| 611 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 612 | } |
| 613 | |
| 614 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 615 | struct snd_ctl_elem_value *ucontrol) |
| 616 | { |
| 617 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 618 | struct sigmatel_spec *spec = codec->spec; |
| 619 | |
| 620 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 621 | return 0; |
| 622 | } |
| 623 | |
| 624 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 625 | struct snd_ctl_elem_value *ucontrol) |
| 626 | { |
| 627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 628 | struct sigmatel_spec *spec = codec->spec; |
| 629 | |
| 630 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 631 | spec->mono_nid, &spec->cur_mmux); |
| 632 | } |
| 633 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 634 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 635 | struct snd_ctl_elem_info *uinfo) |
| 636 | { |
| 637 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 638 | struct sigmatel_spec *spec = codec->spec; |
| 639 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 640 | } |
| 641 | |
| 642 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 643 | struct snd_ctl_elem_value *ucontrol) |
| 644 | { |
| 645 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 646 | struct sigmatel_spec *spec = codec->spec; |
| 647 | |
| 648 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 653 | struct snd_ctl_elem_value *ucontrol) |
| 654 | { |
| 655 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 656 | struct sigmatel_spec *spec = codec->spec; |
| 657 | struct snd_kcontrol *ctl = |
| 658 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 659 | if (!ctl) |
| 660 | return -EINVAL; |
| 661 | |
| 662 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 663 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 664 | |
| 665 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 666 | 0, &spec->cur_amux); |
| 667 | } |
| 668 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 669 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 670 | |
| 671 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 672 | struct snd_ctl_elem_value *ucontrol) |
| 673 | { |
| 674 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 675 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 676 | struct sigmatel_spec *spec = codec->spec; |
| 677 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 678 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 679 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 684 | struct snd_ctl_elem_value *ucontrol) |
| 685 | { |
| 686 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 687 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 688 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 689 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 690 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 691 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 692 | idx_val = spec->aloopback_mask << idx; |
| 693 | if (ucontrol->value.integer.value[0]) |
| 694 | val = spec->aloopback | idx_val; |
| 695 | else |
| 696 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 697 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 698 | return 0; |
| 699 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 700 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 701 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 702 | /* Only return the bits defined by the shift value of the |
| 703 | * first two bytes of the mask |
| 704 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 705 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 706 | kcontrol->private_value & 0xFFFF, 0x0); |
| 707 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 708 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 709 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 710 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 711 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 712 | } else { |
| 713 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 714 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 718 | kcontrol->private_value >> 16, dac_mode); |
| 719 | |
| 720 | return 1; |
| 721 | } |
| 722 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 723 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 724 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 725 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 726 | {} |
| 727 | }; |
| 728 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 729 | static struct hda_verb stac9200_eapd_init[] = { |
| 730 | /* set dac0mux for dac converter */ |
| 731 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 732 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 733 | {} |
| 734 | }; |
| 735 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 736 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 737 | /* set master volume and direct control */ |
| 738 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 739 | /* setup audio connections */ |
| 740 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 741 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 742 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 743 | /* setup adcs to point to mixer */ |
| 744 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 745 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 746 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 747 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 748 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 749 | /* setup import muxs */ |
| 750 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 751 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 752 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 753 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 754 | {} |
| 755 | }; |
| 756 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 757 | static struct hda_verb dell_eq_core_init[] = { |
| 758 | /* set master volume to max value without distortion |
| 759 | * and direct control */ |
| 760 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
| 761 | /* setup audio connections */ |
| 762 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matthew Ranostay | f7cf0a7 | 2008-09-13 10:36:58 -0400 | [diff] [blame] | 763 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 764 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 765 | /* setup adcs to point to mixer */ |
| 766 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 767 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 768 | /* setup import muxs */ |
| 769 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 770 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 771 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 772 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 773 | {} |
| 774 | }; |
| 775 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 776 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 20f5f95 | 2008-09-01 08:17:56 +0200 | [diff] [blame] | 777 | /* set master volume to max value without distortion |
| 778 | * and direct control */ |
| 779 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 780 | /* setup audio connections */ |
Matthew Ranostay | 7747ecc | 2008-03-10 11:30:04 +0100 | [diff] [blame] | 781 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 782 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 783 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 784 | /* setup adcs to point to mixer */ |
| 785 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 786 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 787 | /* setup import muxs */ |
| 788 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 789 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 790 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 791 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 792 | {} |
| 793 | }; |
| 794 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 795 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 796 | /* set master volume and direct control */ |
| 797 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 798 | /* setup audio connections */ |
| 799 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 800 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 801 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 802 | /* connect hp ports to dac3 */ |
| 803 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 804 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 805 | /* setup adcs to point to mixer */ |
| 806 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 807 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 808 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 809 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 810 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 811 | /* setup import muxs */ |
| 812 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 813 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 814 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 815 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 816 | {} |
| 817 | }; |
| 818 | |
| 819 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 820 | /* set master volume and direct control */ |
| 821 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 822 | /* setup audio connections */ |
| 823 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 824 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 825 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 }, |
| 826 | /* dac3 is connected to import3 mux */ |
| 827 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
| 828 | /* connect hp ports to dac4 */ |
| 829 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04}, |
| 830 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04}, |
| 831 | /* setup adcs to point to mixer */ |
| 832 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 833 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 834 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 835 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 836 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 837 | /* setup import muxs */ |
| 838 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 839 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 840 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 841 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 842 | {} |
| 843 | }; |
| 844 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 845 | static struct hda_verb stac92hd83xxx_core_init[] = { |
| 846 | /* start of config #1 */ |
| 847 | { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3}, |
| 848 | |
| 849 | /* start of config #2 */ |
| 850 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 851 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 852 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 853 | |
| 854 | /* power state controls amps */ |
| 855 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
| 856 | }; |
| 857 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 858 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 859 | /* set master volume and direct control */ |
| 860 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 861 | /* connect headphone jack to dac1 */ |
| 862 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 863 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */ |
| 864 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ |
| 865 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 866 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 867 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 868 | }; |
| 869 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 870 | #define HD_DISABLE_PORTF 3 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 871 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 872 | /* start of config #1 */ |
| 873 | |
| 874 | /* connect port 0f to audio mixer */ |
| 875 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
| 876 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */ |
| 877 | /* unmute right and left channels for node 0x0f */ |
| 878 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 879 | /* start of config #2 */ |
| 880 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 881 | /* set master volume and direct control */ |
| 882 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 883 | /* connect headphone jack to dac1 */ |
| 884 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 885 | /* connect port 0d to audio mixer */ |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 886 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 887 | /* unmute dac0 input in audio mixer */ |
| 888 | { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 889 | /* unmute right and left channels for nodes 0x0a, 0xd */ |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 890 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 891 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 892 | {} |
| 893 | }; |
| 894 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 895 | static struct hda_verb stac925x_core_init[] = { |
| 896 | /* set dac0mux for dac converter */ |
| 897 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 898 | {} |
| 899 | }; |
| 900 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 901 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 902 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 903 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 904 | {} |
| 905 | }; |
| 906 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 907 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 908 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 909 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 910 | /* unmute node 0x1b */ |
| 911 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 912 | /* select node 0x03 as DAC */ |
| 913 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 914 | {} |
| 915 | }; |
| 916 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 917 | static struct hda_verb stac927x_core_init[] = { |
| 918 | /* set master volume and direct control */ |
| 919 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 920 | /* enable analog pc beep path */ |
| 921 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 922 | {} |
| 923 | }; |
| 924 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 925 | static struct hda_verb stac9205_core_init[] = { |
| 926 | /* set master volume and direct control */ |
| 927 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 928 | /* enable analog pc beep path */ |
| 929 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 930 | {} |
| 931 | }; |
| 932 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 933 | #define STAC_MONO_MUX \ |
| 934 | { \ |
| 935 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 936 | .name = "Mono Mux", \ |
| 937 | .count = 1, \ |
| 938 | .info = stac92xx_mono_mux_enum_info, \ |
| 939 | .get = stac92xx_mono_mux_enum_get, \ |
| 940 | .put = stac92xx_mono_mux_enum_put, \ |
| 941 | } |
| 942 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 943 | #define STAC_AMP_MUX \ |
| 944 | { \ |
| 945 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 946 | .name = "Amp Selector Capture Switch", \ |
| 947 | .count = 1, \ |
| 948 | .info = stac92xx_amp_mux_enum_info, \ |
| 949 | .get = stac92xx_amp_mux_enum_get, \ |
| 950 | .put = stac92xx_amp_mux_enum_put, \ |
| 951 | } |
| 952 | |
| 953 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 954 | { \ |
| 955 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 956 | .name = xname, \ |
| 957 | .index = 0, \ |
| 958 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 959 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 960 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 961 | .info = stac92xx_amp_volume_info, \ |
| 962 | .get = stac92xx_amp_volume_get, \ |
| 963 | .put = stac92xx_amp_volume_put, \ |
| 964 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 965 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 966 | } |
| 967 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 968 | #define STAC_INPUT_SOURCE(cnt) \ |
Maxim Levitsky | ca7c5a8 | 2007-08-31 12:52:19 +0200 | [diff] [blame] | 969 | { \ |
| 970 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 971 | .name = "Input Source", \ |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 972 | .count = cnt, \ |
Maxim Levitsky | ca7c5a8 | 2007-08-31 12:52:19 +0200 | [diff] [blame] | 973 | .info = stac92xx_mux_enum_info, \ |
| 974 | .get = stac92xx_mux_enum_get, \ |
| 975 | .put = stac92xx_mux_enum_put, \ |
| 976 | } |
| 977 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 978 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 979 | { \ |
| 980 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 981 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 982 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 983 | .info = stac92xx_aloopback_info, \ |
| 984 | .get = stac92xx_aloopback_get, \ |
| 985 | .put = stac92xx_aloopback_put, \ |
| 986 | .private_value = verb_read | (verb_write << 16), \ |
| 987 | } |
| 988 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 989 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 990 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 991 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 992 | STAC_INPUT_SOURCE(1), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 993 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 994 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 995 | { } /* end */ |
| 996 | }; |
| 997 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 998 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 999 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1000 | /* start of config #1 */ |
| 1001 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1002 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1003 | |
| 1004 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1005 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1006 | |
| 1007 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1008 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1009 | |
| 1010 | /* start of config #2 */ |
| 1011 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1012 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1013 | |
| 1014 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1015 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1016 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1017 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1018 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1019 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1020 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1021 | |
| 1022 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1023 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1024 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1025 | { } /* end */ |
| 1026 | }; |
| 1027 | |
| 1028 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1029 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1030 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1031 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1032 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1033 | |
| 1034 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1035 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1036 | |
| 1037 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1038 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1039 | |
| 1040 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1041 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1042 | |
| 1043 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1044 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1045 | |
| 1046 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1047 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1048 | |
| 1049 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1050 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1051 | { } /* end */ |
| 1052 | }; |
| 1053 | |
| 1054 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1055 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1056 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1057 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1058 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1059 | |
| 1060 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1061 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1062 | |
| 1063 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1064 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1065 | |
| 1066 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1067 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1068 | |
| 1069 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1070 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1071 | |
| 1072 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1073 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1074 | |
| 1075 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1076 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1077 | { } /* end */ |
| 1078 | }; |
| 1079 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1080 | |
| 1081 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1082 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1083 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1084 | |
| 1085 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1086 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1087 | |
| 1088 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT), |
| 1089 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT), |
| 1090 | |
| 1091 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1092 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT), |
| 1093 | |
| 1094 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1095 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT), |
| 1096 | |
| 1097 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1098 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT), |
| 1099 | |
| 1100 | /* |
| 1101 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1102 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT), |
| 1103 | */ |
| 1104 | { } /* end */ |
| 1105 | }; |
| 1106 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1107 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1108 | STAC_INPUT_SOURCE(2), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1109 | |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1110 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1111 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1112 | |
| 1113 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1114 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1115 | /* analog pc-beep replaced with digital beep support */ |
| 1116 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1117 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1118 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1119 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1120 | |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1121 | HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT), |
| 1122 | HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1123 | { } /* end */ |
| 1124 | }; |
| 1125 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1126 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1127 | STAC_INPUT_SOURCE(2), |
| 1128 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
| 1129 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1130 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1131 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1132 | |
| 1133 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1134 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1135 | { } /* end */ |
| 1136 | }; |
| 1137 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1138 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1139 | STAC_INPUT_SOURCE(1), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1140 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1141 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1142 | { } /* end */ |
| 1143 | }; |
| 1144 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1145 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1146 | STAC_INPUT_SOURCE(2), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1147 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1148 | |
| 1149 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1150 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1151 | |
| 1152 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1153 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1154 | { } /* end */ |
| 1155 | }; |
| 1156 | |
| 1157 | /* This needs to be generated dynamically based on sequence */ |
| 1158 | static struct snd_kcontrol_new stac922x_mixer[] = { |
| 1159 | STAC_INPUT_SOURCE(2), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1160 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1161 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1162 | |
| 1163 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1164 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1165 | { } /* end */ |
| 1166 | }; |
| 1167 | |
| 1168 | |
| 1169 | static struct snd_kcontrol_new stac927x_mixer[] = { |
| 1170 | STAC_INPUT_SOURCE(3), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1171 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1172 | |
| 1173 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1174 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1175 | |
| 1176 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1177 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1178 | |
| 1179 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1180 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1181 | { } /* end */ |
| 1182 | }; |
| 1183 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1184 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1185 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1186 | .name = "Digital Input Source", |
| 1187 | /* count set later */ |
| 1188 | .info = stac92xx_dmux_enum_info, |
| 1189 | .get = stac92xx_dmux_enum_get, |
| 1190 | .put = stac92xx_dmux_enum_put, |
| 1191 | }; |
| 1192 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1193 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1194 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1195 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1196 | /* count set later */ |
| 1197 | .info = stac92xx_smux_enum_info, |
| 1198 | .get = stac92xx_smux_enum_get, |
| 1199 | .put = stac92xx_smux_enum_put, |
| 1200 | }; |
| 1201 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1202 | static const char *slave_vols[] = { |
| 1203 | "Front Playback Volume", |
| 1204 | "Surround Playback Volume", |
| 1205 | "Center Playback Volume", |
| 1206 | "LFE Playback Volume", |
| 1207 | "Side Playback Volume", |
| 1208 | "Headphone Playback Volume", |
| 1209 | "Headphone Playback Volume", |
| 1210 | "Speaker Playback Volume", |
| 1211 | "External Speaker Playback Volume", |
| 1212 | "Speaker2 Playback Volume", |
| 1213 | NULL |
| 1214 | }; |
| 1215 | |
| 1216 | static const char *slave_sws[] = { |
| 1217 | "Front Playback Switch", |
| 1218 | "Surround Playback Switch", |
| 1219 | "Center Playback Switch", |
| 1220 | "LFE Playback Switch", |
| 1221 | "Side Playback Switch", |
| 1222 | "Headphone Playback Switch", |
| 1223 | "Headphone Playback Switch", |
| 1224 | "Speaker Playback Switch", |
| 1225 | "External Speaker Playback Switch", |
| 1226 | "Speaker2 Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1227 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1228 | NULL |
| 1229 | }; |
| 1230 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1231 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1232 | { |
| 1233 | struct sigmatel_spec *spec = codec->spec; |
| 1234 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1235 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1236 | |
| 1237 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1238 | if (err < 0) |
| 1239 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1240 | |
| 1241 | for (i = 0; i < spec->num_mixers; i++) { |
| 1242 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1243 | if (err < 0) |
| 1244 | return err; |
| 1245 | } |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1246 | if (spec->num_dmuxes > 0) { |
| 1247 | stac_dmux_mixer.count = spec->num_dmuxes; |
| 1248 | err = snd_ctl_add(codec->bus->card, |
| 1249 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1250 | if (err < 0) |
| 1251 | return err; |
| 1252 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1253 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1254 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1255 | struct hda_input_mux *smux = &spec->private_smux; |
| 1256 | /* check for mute support on SPDIF out */ |
| 1257 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1258 | smux->items[smux->num_items].label = "Off"; |
| 1259 | smux->items[smux->num_items].index = 0; |
| 1260 | smux->num_items++; |
| 1261 | spec->spdif_mute = 1; |
| 1262 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1263 | stac_smux_mixer.count = spec->num_smuxes; |
| 1264 | err = snd_ctl_add(codec->bus->card, |
| 1265 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1266 | if (err < 0) |
| 1267 | return err; |
| 1268 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1269 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1270 | if (spec->multiout.dig_out_nid) { |
| 1271 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1272 | if (err < 0) |
| 1273 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1274 | err = snd_hda_create_spdif_share_sw(codec, |
| 1275 | &spec->multiout); |
| 1276 | if (err < 0) |
| 1277 | return err; |
| 1278 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1279 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 1280 | if (spec->dig_in_nid && (!spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1281 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1282 | if (err < 0) |
| 1283 | return err; |
| 1284 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1285 | |
| 1286 | /* if we have no master control, let's create it */ |
| 1287 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1288 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1289 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1290 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1291 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1292 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1293 | if (err < 0) |
| 1294 | return err; |
| 1295 | } |
| 1296 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1297 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1298 | NULL, slave_sws); |
| 1299 | if (err < 0) |
| 1300 | return err; |
| 1301 | } |
| 1302 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1303 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1304 | } |
| 1305 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1306 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1307 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1308 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1309 | }; |
| 1310 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1311 | /* |
| 1312 | STAC 9200 pin configs for |
| 1313 | 102801A8 |
| 1314 | 102801DE |
| 1315 | 102801E8 |
| 1316 | */ |
| 1317 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1318 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1319 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1320 | }; |
| 1321 | |
| 1322 | /* |
| 1323 | STAC 9200 pin configs for |
| 1324 | 102801C0 |
| 1325 | 102801C1 |
| 1326 | */ |
| 1327 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1328 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1329 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1330 | }; |
| 1331 | |
| 1332 | /* |
| 1333 | STAC 9200 pin configs for |
| 1334 | 102801C4 (Dell Dimension E310) |
| 1335 | 102801C5 |
| 1336 | 102801C7 |
| 1337 | 102801D9 |
| 1338 | 102801DA |
| 1339 | 102801E3 |
| 1340 | */ |
| 1341 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1342 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1343 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1344 | }; |
| 1345 | |
| 1346 | |
| 1347 | /* |
| 1348 | STAC 9200-32 pin configs for |
| 1349 | 102801B5 (Dell Inspiron 630m) |
| 1350 | 102801D8 (Dell Inspiron 640m) |
| 1351 | */ |
| 1352 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1353 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1354 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1355 | }; |
| 1356 | |
| 1357 | /* |
| 1358 | STAC 9200-32 pin configs for |
| 1359 | 102801C2 (Dell Latitude D620) |
| 1360 | 102801C8 |
| 1361 | 102801CC (Dell Latitude D820) |
| 1362 | 102801D4 |
| 1363 | 102801D6 |
| 1364 | */ |
| 1365 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1366 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1367 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1368 | }; |
| 1369 | |
| 1370 | /* |
| 1371 | STAC 9200-32 pin configs for |
| 1372 | 102801CE (Dell XPS M1710) |
| 1373 | 102801CF (Dell Precision M90) |
| 1374 | */ |
| 1375 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1376 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1377 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1378 | }; |
| 1379 | |
| 1380 | /* |
| 1381 | STAC 9200-32 pin configs for |
| 1382 | 102801C9 |
| 1383 | 102801CA |
| 1384 | 102801CB (Dell Latitude 120L) |
| 1385 | 102801D3 |
| 1386 | */ |
| 1387 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1388 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1389 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1390 | }; |
| 1391 | |
| 1392 | /* |
| 1393 | STAC 9200-32 pin configs for |
| 1394 | 102801BD (Dell Inspiron E1505n) |
| 1395 | 102801EE |
| 1396 | 102801EF |
| 1397 | */ |
| 1398 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1399 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1400 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1401 | }; |
| 1402 | |
| 1403 | /* |
| 1404 | STAC 9200-32 pin configs for |
| 1405 | 102801F5 (Dell Inspiron 1501) |
| 1406 | 102801F6 |
| 1407 | */ |
| 1408 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1409 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1410 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1411 | }; |
| 1412 | |
| 1413 | /* |
| 1414 | STAC 9200-32 |
| 1415 | 102801CD (Dell Inspiron E1705/9400) |
| 1416 | */ |
| 1417 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1418 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1419 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1420 | }; |
| 1421 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1422 | static unsigned int oqo9200_pin_configs[8] = { |
| 1423 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1424 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1425 | }; |
| 1426 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1427 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1428 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1429 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1430 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1431 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1432 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1433 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1434 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1435 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1436 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1437 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1438 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1439 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1440 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1441 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1442 | }; |
| 1443 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1444 | static const char *stac9200_models[STAC_9200_MODELS] = { |
| 1445 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1446 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1447 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1448 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1449 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1450 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1451 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1452 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1453 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1454 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1455 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1456 | [STAC_9200_DELL_M27] = "dell-m27", |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1457 | [STAC_9200_GATEWAY] = "gateway", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1458 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1459 | }; |
| 1460 | |
| 1461 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1462 | /* SigmaTel reference board */ |
| 1463 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1464 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1465 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1466 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1467 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1468 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1469 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1470 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1471 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1472 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1473 | "unknown Dell", STAC_9200_DELL_D22), |
| 1474 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1475 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1476 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1477 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1478 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1479 | "unknown Dell", STAC_9200_DELL_D23), |
| 1480 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1481 | "unknown Dell", STAC_9200_DELL_D23), |
| 1482 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1483 | "unknown Dell", STAC_9200_DELL_M22), |
| 1484 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1485 | "unknown Dell", STAC_9200_DELL_M24), |
| 1486 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1487 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1488 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1489 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1490 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1491 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1492 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1493 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1494 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1495 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1496 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1497 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1498 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1499 | "unknown Dell", STAC_9200_DELL_M22), |
| 1500 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1501 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1502 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1503 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1504 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1505 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1506 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1507 | "unknown Dell", STAC_9200_DELL_D23), |
| 1508 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1509 | "unknown Dell", STAC_9200_DELL_D23), |
| 1510 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1511 | "unknown Dell", STAC_9200_DELL_D21), |
| 1512 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1513 | "unknown Dell", STAC_9200_DELL_D23), |
| 1514 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1515 | "unknown Dell", STAC_9200_DELL_D21), |
| 1516 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1517 | "unknown Dell", STAC_9200_DELL_M25), |
| 1518 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1519 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1520 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1521 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1522 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1523 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1524 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1525 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1526 | /* Gateway machines needs EAPD to be set on resume */ |
| 1527 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY), |
| 1528 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", |
| 1529 | STAC_9200_GATEWAY), |
| 1530 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", |
| 1531 | STAC_9200_GATEWAY), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1532 | /* OQO Mobile */ |
| 1533 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1534 | {} /* terminator */ |
| 1535 | }; |
| 1536 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1537 | static unsigned int ref925x_pin_configs[8] = { |
| 1538 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1539 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1540 | }; |
| 1541 | |
| 1542 | static unsigned int stac925x_MA6_pin_configs[8] = { |
| 1543 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1544 | 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, |
| 1545 | }; |
| 1546 | |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1547 | static unsigned int stac925x_PA6_pin_configs[8] = { |
| 1548 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1549 | 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e, |
| 1550 | }; |
| 1551 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1552 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Steve Longerbeam | 7353e14 | 2007-05-29 14:36:17 +0200 | [diff] [blame] | 1553 | 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020, |
| 1554 | 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1555 | }; |
| 1556 | |
| 1557 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1558 | [STAC_REF] = ref925x_pin_configs, |
| 1559 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
| 1560 | [STAC_MA6] = stac925x_MA6_pin_configs, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1561 | [STAC_PA6] = stac925x_PA6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1562 | }; |
| 1563 | |
| 1564 | static const char *stac925x_models[STAC_925x_MODELS] = { |
| 1565 | [STAC_REF] = "ref", |
| 1566 | [STAC_M2_2] = "m2-2", |
| 1567 | [STAC_MA6] = "m6", |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1568 | [STAC_PA6] = "pa6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1569 | }; |
| 1570 | |
| 1571 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1572 | /* SigmaTel reference board */ |
| 1573 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1574 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1575 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), |
| 1576 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), |
| 1577 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1578 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1579 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2), |
| 1580 | {} /* terminator */ |
| 1581 | }; |
| 1582 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1583 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1584 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1585 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1586 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1587 | 0x01452050, |
| 1588 | }; |
| 1589 | |
| 1590 | static unsigned int dell_m6_pin_configs[13] = { |
| 1591 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1592 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1593 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1594 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1595 | }; |
| 1596 | |
| 1597 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1598 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
| 1599 | [STAC_DELL_M6] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1600 | }; |
| 1601 | |
| 1602 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
| 1603 | [STAC_92HD73XX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1604 | [STAC_DELL_M6] = "dell-m6", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1605 | }; |
| 1606 | |
| 1607 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1608 | /* SigmaTel reference board */ |
| 1609 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1610 | "DFI LanParty", STAC_92HD73XX_REF), |
| 1611 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
| 1612 | "unknown Dell", STAC_DELL_M6), |
| 1613 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
| 1614 | "unknown Dell", STAC_DELL_M6), |
| 1615 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
| 1616 | "unknown Dell", STAC_DELL_M6), |
| 1617 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
| 1618 | "unknown Dell", STAC_DELL_M6), |
| 1619 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
| 1620 | "unknown Dell", STAC_DELL_M6), |
| 1621 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
| 1622 | "unknown Dell", STAC_DELL_M6), |
| 1623 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
| 1624 | "unknown Dell", STAC_DELL_M6), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1625 | {} /* terminator */ |
| 1626 | }; |
| 1627 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1628 | static unsigned int ref92hd83xxx_pin_configs[14] = { |
| 1629 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1630 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
| 1631 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0, |
| 1632 | 0x01451160, 0x98560170, |
| 1633 | }; |
| 1634 | |
| 1635 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1636 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
| 1637 | }; |
| 1638 | |
| 1639 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
| 1640 | [STAC_92HD83XXX_REF] = "ref", |
| 1641 | }; |
| 1642 | |
| 1643 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1644 | /* SigmaTel reference board */ |
| 1645 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1646 | "DFI LanParty", STAC_92HD71BXX_REF), |
| 1647 | }; |
| 1648 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1649 | static unsigned int ref92hd71bxx_pin_configs[11] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1650 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 1651 | 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1652 | 0x90a000f0, 0x01452050, 0x01452050, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1653 | }; |
| 1654 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1655 | static unsigned int dell_m4_1_pin_configs[11] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1656 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1657 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1658 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1659 | }; |
| 1660 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1661 | static unsigned int dell_m4_2_pin_configs[11] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1662 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1663 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1664 | 0x40f000f0, 0x044413b0, 0x044413b0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1665 | }; |
| 1666 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1667 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1668 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1669 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1670 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1671 | [STAC_HP_M4] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1672 | }; |
| 1673 | |
| 1674 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
| 1675 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1676 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1677 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1678 | [STAC_HP_M4] = "hp-m4", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1679 | }; |
| 1680 | |
| 1681 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1682 | /* SigmaTel reference board */ |
| 1683 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1684 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1685 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
| 1686 | "unknown HP", STAC_HP_M4), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1687 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1688 | "unknown Dell", STAC_DELL_M4_1), |
| 1689 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1690 | "unknown Dell", STAC_DELL_M4_1), |
| 1691 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1692 | "unknown Dell", STAC_DELL_M4_1), |
| 1693 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1694 | "unknown Dell", STAC_DELL_M4_1), |
| 1695 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1696 | "unknown Dell", STAC_DELL_M4_1), |
| 1697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1698 | "unknown Dell", STAC_DELL_M4_1), |
| 1699 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1700 | "unknown Dell", STAC_DELL_M4_1), |
| 1701 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1702 | "unknown Dell", STAC_DELL_M4_2), |
| 1703 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1704 | "unknown Dell", STAC_DELL_M4_2), |
| 1705 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1706 | "unknown Dell", STAC_DELL_M4_2), |
| 1707 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1708 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1709 | {} /* terminator */ |
| 1710 | }; |
| 1711 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1712 | static unsigned int ref922x_pin_configs[10] = { |
| 1713 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1714 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1715 | 0x40000100, 0x40000100, |
| 1716 | }; |
| 1717 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1718 | /* |
| 1719 | STAC 922X pin configs for |
| 1720 | 102801A7 |
| 1721 | 102801AB |
| 1722 | 102801A9 |
| 1723 | 102801D1 |
| 1724 | 102801D2 |
| 1725 | */ |
| 1726 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1727 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1728 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1729 | 0x01813122, 0x400001f2, |
| 1730 | }; |
| 1731 | |
| 1732 | /* |
| 1733 | STAC 922X pin configs for |
| 1734 | 102801AC |
| 1735 | 102801D0 |
| 1736 | */ |
| 1737 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1738 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1739 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1740 | 0x01813122, 0x400001f1, |
| 1741 | }; |
| 1742 | |
| 1743 | /* |
| 1744 | STAC 922X pin configs for |
| 1745 | 102801BF |
| 1746 | */ |
| 1747 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1748 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1749 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1750 | 0x40C003f1, 0x405003f0, |
| 1751 | }; |
| 1752 | |
| 1753 | /* |
| 1754 | STAC 9221 A1 pin configs for |
| 1755 | 102801D7 (Dell XPS M1210) |
| 1756 | */ |
| 1757 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1758 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1759 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1760 | 0x508003f3, 0x405003f4, |
| 1761 | }; |
| 1762 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1763 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1764 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1765 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1766 | 0x02a19120, 0x40000100, |
| 1767 | }; |
| 1768 | |
| 1769 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1770 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1771 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1772 | 0x02a19320, 0x40000100, |
| 1773 | }; |
| 1774 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1775 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1776 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1777 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1778 | 0x400000fc, 0x400000fb, |
| 1779 | }; |
| 1780 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1781 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1782 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1783 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1784 | 0x400000fc, 0x400000fb, |
| 1785 | }; |
| 1786 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1787 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1788 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1789 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 1790 | 0x400000fc, 0x400000fb, |
| 1791 | }; |
| 1792 | |
| 1793 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 1794 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1795 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1796 | 0x400000fc, 0x400000fb, |
| 1797 | }; |
| 1798 | |
| 1799 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 1800 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1801 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1802 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1803 | }; |
| 1804 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1805 | static unsigned int ecs202_pin_configs[10] = { |
| 1806 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 1807 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 1808 | 0x9037012e, 0x40e000f2, |
| 1809 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1810 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1811 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1812 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1813 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 1814 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1815 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 1816 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 1817 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 1818 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 1819 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1820 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1821 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1822 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 1823 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 1824 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 1825 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 1826 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 1827 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1828 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1829 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 1830 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 1831 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 1832 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1833 | }; |
| 1834 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1835 | static const char *stac922x_models[STAC_922X_MODELS] = { |
| 1836 | [STAC_D945_REF] = "ref", |
| 1837 | [STAC_D945GTP5] = "5stack", |
| 1838 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1839 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 1840 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 1841 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 1842 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 1843 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1844 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1845 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1846 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1847 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 1848 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 1849 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1850 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1851 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1852 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1853 | [STAC_922X_DELL_D81] = "dell-d81", |
| 1854 | [STAC_922X_DELL_D82] = "dell-d82", |
| 1855 | [STAC_922X_DELL_M81] = "dell-m81", |
| 1856 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1857 | }; |
| 1858 | |
| 1859 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 1860 | /* SigmaTel reference board */ |
| 1861 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1862 | "DFI LanParty", STAC_D945_REF), |
| 1863 | /* Intel 945G based systems */ |
| 1864 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 1865 | "Intel D945G", STAC_D945GTP3), |
| 1866 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 1867 | "Intel D945G", STAC_D945GTP3), |
| 1868 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 1869 | "Intel D945G", STAC_D945GTP3), |
| 1870 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 1871 | "Intel D945G", STAC_D945GTP3), |
| 1872 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 1873 | "Intel D945G", STAC_D945GTP3), |
| 1874 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 1875 | "Intel D945G", STAC_D945GTP3), |
| 1876 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 1877 | "Intel D945G", STAC_D945GTP3), |
| 1878 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 1879 | "Intel D945G", STAC_D945GTP3), |
| 1880 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 1881 | "Intel D945G", STAC_D945GTP3), |
| 1882 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 1883 | "Intel D945G", STAC_D945GTP3), |
| 1884 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 1885 | "Intel D945G", STAC_D945GTP3), |
| 1886 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 1887 | "Intel D945G", STAC_D945GTP3), |
| 1888 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 1889 | "Intel D945G", STAC_D945GTP3), |
| 1890 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 1891 | "Intel D945G", STAC_D945GTP3), |
| 1892 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 1893 | "Intel D945G", STAC_D945GTP3), |
| 1894 | /* Intel D945G 5-stack systems */ |
| 1895 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 1896 | "Intel D945G", STAC_D945GTP5), |
| 1897 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 1898 | "Intel D945G", STAC_D945GTP5), |
| 1899 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 1900 | "Intel D945G", STAC_D945GTP5), |
| 1901 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 1902 | "Intel D945G", STAC_D945GTP5), |
| 1903 | /* Intel 945P based systems */ |
| 1904 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 1905 | "Intel D945P", STAC_D945GTP3), |
| 1906 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 1907 | "Intel D945P", STAC_D945GTP3), |
| 1908 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 1909 | "Intel D945P", STAC_D945GTP3), |
| 1910 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 1911 | "Intel D945P", STAC_D945GTP3), |
| 1912 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 1913 | "Intel D945P", STAC_D945GTP3), |
| 1914 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 1915 | "Intel D945P", STAC_D945GTP5), |
| 1916 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1917 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1918 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1919 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1920 | /* Dell systems */ |
| 1921 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 1922 | "unknown Dell", STAC_922X_DELL_D81), |
| 1923 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 1924 | "unknown Dell", STAC_922X_DELL_D81), |
| 1925 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 1926 | "unknown Dell", STAC_922X_DELL_D81), |
| 1927 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 1928 | "unknown Dell", STAC_922X_DELL_D82), |
| 1929 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 1930 | "unknown Dell", STAC_922X_DELL_M81), |
| 1931 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 1932 | "unknown Dell", STAC_922X_DELL_D82), |
| 1933 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 1934 | "unknown Dell", STAC_922X_DELL_D81), |
| 1935 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 1936 | "unknown Dell", STAC_922X_DELL_D81), |
| 1937 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 1938 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1939 | /* ECS/PC Chips boards */ |
| 1940 | SND_PCI_QUIRK(0x1019, 0x2144, |
| 1941 | "ECS/PC chips", STAC_ECS_202), |
| 1942 | SND_PCI_QUIRK(0x1019, 0x2608, |
| 1943 | "ECS/PC chips", STAC_ECS_202), |
| 1944 | SND_PCI_QUIRK(0x1019, 0x2633, |
| 1945 | "ECS/PC chips P17G/1333", STAC_ECS_202), |
| 1946 | SND_PCI_QUIRK(0x1019, 0x2811, |
| 1947 | "ECS/PC chips", STAC_ECS_202), |
| 1948 | SND_PCI_QUIRK(0x1019, 0x2812, |
| 1949 | "ECS/PC chips", STAC_ECS_202), |
| 1950 | SND_PCI_QUIRK(0x1019, 0x2813, |
| 1951 | "ECS/PC chips", STAC_ECS_202), |
| 1952 | SND_PCI_QUIRK(0x1019, 0x2814, |
| 1953 | "ECS/PC chips", STAC_ECS_202), |
| 1954 | SND_PCI_QUIRK(0x1019, 0x2815, |
| 1955 | "ECS/PC chips", STAC_ECS_202), |
| 1956 | SND_PCI_QUIRK(0x1019, 0x2816, |
| 1957 | "ECS/PC chips", STAC_ECS_202), |
| 1958 | SND_PCI_QUIRK(0x1019, 0x2817, |
| 1959 | "ECS/PC chips", STAC_ECS_202), |
| 1960 | SND_PCI_QUIRK(0x1019, 0x2818, |
| 1961 | "ECS/PC chips", STAC_ECS_202), |
| 1962 | SND_PCI_QUIRK(0x1019, 0x2819, |
| 1963 | "ECS/PC chips", STAC_ECS_202), |
| 1964 | SND_PCI_QUIRK(0x1019, 0x2820, |
| 1965 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1966 | {} /* terminator */ |
| 1967 | }; |
| 1968 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1969 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1970 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 1971 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 1972 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 1973 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1974 | }; |
| 1975 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1976 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1977 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 1978 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 1979 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1980 | 0x40000100, 0x40000100 |
| 1981 | }; |
| 1982 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1983 | static unsigned int d965_5st_pin_configs[14] = { |
| 1984 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 1985 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 1986 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 1987 | 0x40000100, 0x40000100 |
| 1988 | }; |
| 1989 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1990 | static unsigned int dell_3st_pin_configs[14] = { |
| 1991 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 1992 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 1993 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1994 | 0x40c003fc, 0x40000100 |
| 1995 | }; |
| 1996 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1997 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 1998 | [STAC_D965_REF] = ref927x_pin_configs, |
| 1999 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2000 | [STAC_D965_5ST] = d965_5st_pin_configs, |
| 2001 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2002 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2003 | }; |
| 2004 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2005 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2006 | [STAC_D965_REF] = "ref", |
| 2007 | [STAC_D965_3ST] = "3stack", |
| 2008 | [STAC_D965_5ST] = "5stack", |
| 2009 | [STAC_DELL_3ST] = "dell-3stack", |
| 2010 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2011 | }; |
| 2012 | |
| 2013 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2014 | /* SigmaTel reference board */ |
| 2015 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2016 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2017 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2018 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2019 | 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] | 2020 | /* 965 based 3 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2021 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), |
| 2022 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), |
| 2023 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), |
| 2024 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), |
| 2025 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST), |
| 2026 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST), |
| 2027 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST), |
| 2028 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST), |
| 2029 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST), |
| 2030 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST), |
| 2031 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST), |
| 2032 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST), |
| 2033 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST), |
| 2034 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), |
| 2035 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), |
| 2036 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2037 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2039 | 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] | 2040 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2041 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2042 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2043 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2044 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2045 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2046 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2047 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2048 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2049 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2050 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2051 | /* 965 based 5 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2052 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), |
| 2053 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), |
| 2054 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), |
| 2055 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), |
| 2056 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST), |
| 2057 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST), |
| 2058 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST), |
| 2059 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST), |
| 2060 | 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] | 2061 | {} /* terminator */ |
| 2062 | }; |
| 2063 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2064 | static unsigned int ref9205_pin_configs[12] = { |
| 2065 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2066 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2067 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2068 | }; |
| 2069 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2070 | /* |
| 2071 | STAC 9205 pin configs for |
| 2072 | 102801F1 |
| 2073 | 102801F2 |
| 2074 | 102801FC |
| 2075 | 102801FD |
| 2076 | 10280204 |
| 2077 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2078 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2079 | */ |
| 2080 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2081 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2082 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2083 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2084 | }; |
| 2085 | |
| 2086 | /* |
| 2087 | STAC 9205 pin configs for |
| 2088 | 102801F9 |
| 2089 | 102801FA |
| 2090 | 102801FE |
| 2091 | 102801FF (Dell Precision M4300) |
| 2092 | 10280206 |
| 2093 | 10280200 |
| 2094 | 10280201 |
| 2095 | */ |
| 2096 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2097 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2098 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2099 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2100 | }; |
| 2101 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2102 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2103 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2104 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2105 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2106 | }; |
| 2107 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2108 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2109 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2110 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2111 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2112 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2113 | }; |
| 2114 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2115 | static const char *stac9205_models[STAC_9205_MODELS] = { |
| 2116 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2117 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2118 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2119 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2120 | }; |
| 2121 | |
| 2122 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2123 | /* SigmaTel reference board */ |
| 2124 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2125 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2126 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2127 | "unknown Dell", STAC_9205_DELL_M42), |
| 2128 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2129 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2131 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2132 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2133 | "Dell Precision", STAC_9205_DELL_M43), |
| 2134 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2135 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2136 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2137 | "unknown Dell", STAC_9205_DELL_M42), |
| 2138 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2139 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2140 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2141 | "Dell Precision", STAC_9205_DELL_M43), |
| 2142 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2143 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2144 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2145 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2146 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2147 | "Dell Precision", STAC_9205_DELL_M43), |
| 2148 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2149 | "Dell Precision", STAC_9205_DELL_M43), |
| 2150 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2151 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2152 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2153 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2154 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2155 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2156 | {} /* terminator */ |
| 2157 | }; |
| 2158 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2159 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) |
| 2160 | { |
| 2161 | int i; |
| 2162 | struct sigmatel_spec *spec = codec->spec; |
| 2163 | |
| 2164 | if (! spec->bios_pin_configs) { |
| 2165 | spec->bios_pin_configs = kcalloc(spec->num_pins, |
| 2166 | sizeof(*spec->bios_pin_configs), GFP_KERNEL); |
| 2167 | if (! spec->bios_pin_configs) |
| 2168 | return -ENOMEM; |
| 2169 | } |
| 2170 | |
| 2171 | for (i = 0; i < spec->num_pins; i++) { |
| 2172 | hda_nid_t nid = spec->pin_nids[i]; |
| 2173 | unsigned int pin_cfg; |
| 2174 | |
| 2175 | pin_cfg = snd_hda_codec_read(codec, nid, 0, |
| 2176 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); |
| 2177 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", |
| 2178 | nid, pin_cfg); |
| 2179 | spec->bios_pin_configs[i] = pin_cfg; |
| 2180 | } |
| 2181 | |
| 2182 | return 0; |
| 2183 | } |
| 2184 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2185 | static void stac92xx_set_config_reg(struct hda_codec *codec, |
| 2186 | hda_nid_t pin_nid, unsigned int pin_config) |
| 2187 | { |
| 2188 | int i; |
| 2189 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2190 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, |
| 2191 | pin_config & 0x000000ff); |
| 2192 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2193 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, |
| 2194 | (pin_config & 0x0000ff00) >> 8); |
| 2195 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2196 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, |
| 2197 | (pin_config & 0x00ff0000) >> 16); |
| 2198 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2199 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, |
| 2200 | pin_config >> 24); |
| 2201 | i = snd_hda_codec_read(codec, pin_nid, 0, |
| 2202 | AC_VERB_GET_CONFIG_DEFAULT, |
| 2203 | 0x00); |
| 2204 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", |
| 2205 | pin_nid, i); |
| 2206 | } |
| 2207 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2208 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
| 2209 | { |
| 2210 | int i; |
| 2211 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2212 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2213 | if (!spec->pin_configs) |
| 2214 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2215 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2216 | for (i = 0; i < spec->num_pins; i++) |
| 2217 | stac92xx_set_config_reg(codec, spec->pin_nids[i], |
| 2218 | spec->pin_configs[i]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2219 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2220 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2221 | /* |
| 2222 | * Analog playback callbacks |
| 2223 | */ |
| 2224 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2225 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2226 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2227 | { |
| 2228 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2229 | if (spec->stream_delay) |
| 2230 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2231 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2232 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2233 | } |
| 2234 | |
| 2235 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2236 | struct hda_codec *codec, |
| 2237 | unsigned int stream_tag, |
| 2238 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2239 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2240 | { |
| 2241 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2242 | 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] | 2243 | } |
| 2244 | |
| 2245 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2246 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2247 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2248 | { |
| 2249 | struct sigmatel_spec *spec = codec->spec; |
| 2250 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2251 | } |
| 2252 | |
| 2253 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2254 | * Digital playback callbacks |
| 2255 | */ |
| 2256 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2257 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2258 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2259 | { |
| 2260 | struct sigmatel_spec *spec = codec->spec; |
| 2261 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2262 | } |
| 2263 | |
| 2264 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2265 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2266 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2267 | { |
| 2268 | struct sigmatel_spec *spec = codec->spec; |
| 2269 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2270 | } |
| 2271 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2272 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2273 | struct hda_codec *codec, |
| 2274 | unsigned int stream_tag, |
| 2275 | unsigned int format, |
| 2276 | struct snd_pcm_substream *substream) |
| 2277 | { |
| 2278 | struct sigmatel_spec *spec = codec->spec; |
| 2279 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2280 | stream_tag, format, substream); |
| 2281 | } |
| 2282 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2283 | |
| 2284 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2285 | * Analog capture callbacks |
| 2286 | */ |
| 2287 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2288 | struct hda_codec *codec, |
| 2289 | unsigned int stream_tag, |
| 2290 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2291 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2292 | { |
| 2293 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2294 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2295 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2296 | if (spec->powerdown_adcs) { |
| 2297 | msleep(40); |
| 2298 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2299 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2300 | } |
| 2301 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2302 | return 0; |
| 2303 | } |
| 2304 | |
| 2305 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2306 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2307 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2308 | { |
| 2309 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2310 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2311 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2312 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2313 | if (spec->powerdown_adcs) |
| 2314 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2315 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2316 | return 0; |
| 2317 | } |
| 2318 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2319 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2320 | .substreams = 1, |
| 2321 | .channels_min = 2, |
| 2322 | .channels_max = 2, |
| 2323 | /* NID is set in stac92xx_build_pcms */ |
| 2324 | .ops = { |
| 2325 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2326 | .close = stac92xx_dig_playback_pcm_close, |
| 2327 | .prepare = stac92xx_dig_playback_pcm_prepare |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2328 | }, |
| 2329 | }; |
| 2330 | |
| 2331 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2332 | .substreams = 1, |
| 2333 | .channels_min = 2, |
| 2334 | .channels_max = 2, |
| 2335 | /* NID is set in stac92xx_build_pcms */ |
| 2336 | }; |
| 2337 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2338 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2339 | .substreams = 1, |
| 2340 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2341 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2342 | .nid = 0x02, /* NID to query formats and rates */ |
| 2343 | .ops = { |
| 2344 | .open = stac92xx_playback_pcm_open, |
| 2345 | .prepare = stac92xx_playback_pcm_prepare, |
| 2346 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2347 | }, |
| 2348 | }; |
| 2349 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2350 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2351 | .substreams = 1, |
| 2352 | .channels_min = 2, |
| 2353 | .channels_max = 2, |
| 2354 | .nid = 0x06, /* NID to query formats and rates */ |
| 2355 | .ops = { |
| 2356 | .open = stac92xx_playback_pcm_open, |
| 2357 | .prepare = stac92xx_playback_pcm_prepare, |
| 2358 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2359 | }, |
| 2360 | }; |
| 2361 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2362 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2363 | .channels_min = 2, |
| 2364 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2365 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2366 | .ops = { |
| 2367 | .prepare = stac92xx_capture_pcm_prepare, |
| 2368 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2369 | }, |
| 2370 | }; |
| 2371 | |
| 2372 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2373 | { |
| 2374 | struct sigmatel_spec *spec = codec->spec; |
| 2375 | struct hda_pcm *info = spec->pcm_rec; |
| 2376 | |
| 2377 | codec->num_pcms = 1; |
| 2378 | codec->pcm_info = info; |
| 2379 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2380 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2381 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2382 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2383 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2384 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2385 | |
| 2386 | if (spec->alt_switch) { |
| 2387 | codec->num_pcms++; |
| 2388 | info++; |
| 2389 | info->name = "STAC92xx Analog Alt"; |
| 2390 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2391 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2392 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2393 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2394 | codec->num_pcms++; |
| 2395 | info++; |
| 2396 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 2397 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2398 | if (spec->multiout.dig_out_nid) { |
| 2399 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2400 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2401 | } |
| 2402 | if (spec->dig_in_nid) { |
| 2403 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2404 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2405 | } |
| 2406 | } |
| 2407 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2408 | return 0; |
| 2409 | } |
| 2410 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2411 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 2412 | { |
| 2413 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 2414 | AC_PAR_PIN_CAP); |
| 2415 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2416 | if (pincap & AC_PINCAP_VREF_100) |
| 2417 | return AC_PINCTL_VREF_100; |
| 2418 | if (pincap & AC_PINCAP_VREF_80) |
| 2419 | return AC_PINCTL_VREF_80; |
| 2420 | if (pincap & AC_PINCAP_VREF_50) |
| 2421 | return AC_PINCTL_VREF_50; |
| 2422 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2423 | return AC_PINCTL_VREF_GRD; |
| 2424 | return 0; |
| 2425 | } |
| 2426 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2427 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2428 | |
| 2429 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2430 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2431 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2432 | } |
| 2433 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2434 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2435 | |
| 2436 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2437 | struct snd_ctl_elem_value *ucontrol) |
| 2438 | { |
| 2439 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2440 | struct sigmatel_spec *spec = codec->spec; |
| 2441 | |
| 2442 | ucontrol->value.integer.value[0] = spec->hp_switch; |
| 2443 | return 0; |
| 2444 | } |
| 2445 | |
| 2446 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2447 | struct snd_ctl_elem_value *ucontrol) |
| 2448 | { |
| 2449 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2450 | struct sigmatel_spec *spec = codec->spec; |
| 2451 | |
| 2452 | spec->hp_switch = ucontrol->value.integer.value[0]; |
| 2453 | |
| 2454 | /* check to be sure that the ports are upto date with |
| 2455 | * switch changes |
| 2456 | */ |
| 2457 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 2458 | |
| 2459 | return 1; |
| 2460 | } |
| 2461 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 2462 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2463 | |
| 2464 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2465 | { |
| 2466 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2467 | struct sigmatel_spec *spec = codec->spec; |
| 2468 | int io_idx = kcontrol-> private_value & 0xff; |
| 2469 | |
| 2470 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 2471 | return 0; |
| 2472 | } |
| 2473 | |
| 2474 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2475 | { |
| 2476 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2477 | struct sigmatel_spec *spec = codec->spec; |
| 2478 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 2479 | int io_idx = kcontrol-> private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2480 | unsigned short val = !!ucontrol->value.integer.value[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2481 | |
| 2482 | spec->io_switch[io_idx] = val; |
| 2483 | |
| 2484 | if (val) |
| 2485 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2486 | else { |
| 2487 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2488 | if (io_idx) /* set VREF for mic */ |
| 2489 | pinctl |= stac92xx_get_vref(codec, nid); |
| 2490 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2491 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2492 | |
| 2493 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2494 | * appropriately according to the pin direction |
| 2495 | */ |
| 2496 | if (spec->hp_detect) |
| 2497 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 2498 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2499 | return 1; |
| 2500 | } |
| 2501 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2502 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2503 | |
| 2504 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2505 | struct snd_ctl_elem_value *ucontrol) |
| 2506 | { |
| 2507 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2508 | struct sigmatel_spec *spec = codec->spec; |
| 2509 | |
| 2510 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2511 | return 0; |
| 2512 | } |
| 2513 | |
| 2514 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2515 | struct snd_ctl_elem_value *ucontrol) |
| 2516 | { |
| 2517 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2518 | struct sigmatel_spec *spec = codec->spec; |
| 2519 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2520 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2521 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2522 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2523 | return 0; |
| 2524 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2525 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2526 | |
| 2527 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2528 | spec->clfe_swap ? 0x4 : 0x0); |
| 2529 | |
| 2530 | return 1; |
| 2531 | } |
| 2532 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2533 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2534 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2535 | .name = xname, \ |
| 2536 | .index = 0, \ |
| 2537 | .info = stac92xx_hp_switch_info, \ |
| 2538 | .get = stac92xx_hp_switch_get, \ |
| 2539 | .put = stac92xx_hp_switch_put, \ |
| 2540 | } |
| 2541 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2542 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2543 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2544 | .name = xname, \ |
| 2545 | .index = 0, \ |
| 2546 | .info = stac92xx_io_switch_info, \ |
| 2547 | .get = stac92xx_io_switch_get, \ |
| 2548 | .put = stac92xx_io_switch_put, \ |
| 2549 | .private_value = xpval, \ |
| 2550 | } |
| 2551 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2552 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2553 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2554 | .name = xname, \ |
| 2555 | .index = 0, \ |
| 2556 | .info = stac92xx_clfe_switch_info, \ |
| 2557 | .get = stac92xx_clfe_switch_get, \ |
| 2558 | .put = stac92xx_clfe_switch_put, \ |
| 2559 | .private_value = xpval, \ |
| 2560 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2561 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2562 | enum { |
| 2563 | STAC_CTL_WIDGET_VOL, |
| 2564 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2565 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2566 | STAC_CTL_WIDGET_AMP_MUX, |
| 2567 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2568 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2569 | STAC_CTL_WIDGET_IO_SWITCH, |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2570 | STAC_CTL_WIDGET_CLFE_SWITCH |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2571 | }; |
| 2572 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2573 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2574 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2575 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2576 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2577 | STAC_AMP_MUX, |
| 2578 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2579 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2580 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2581 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2582 | }; |
| 2583 | |
| 2584 | /* add dynamic controls */ |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2585 | static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type, |
| 2586 | int idx, const char *name, unsigned long val) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2587 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2588 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2589 | |
| 2590 | if (spec->num_kctl_used >= spec->num_kctl_alloc) { |
| 2591 | int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; |
| 2592 | |
| 2593 | knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ |
| 2594 | if (! knew) |
| 2595 | return -ENOMEM; |
| 2596 | if (spec->kctl_alloc) { |
| 2597 | memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); |
| 2598 | kfree(spec->kctl_alloc); |
| 2599 | } |
| 2600 | spec->kctl_alloc = knew; |
| 2601 | spec->num_kctl_alloc = num; |
| 2602 | } |
| 2603 | |
| 2604 | knew = &spec->kctl_alloc[spec->num_kctl_used]; |
| 2605 | *knew = stac92xx_control_templates[type]; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2606 | knew->index = idx; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2607 | knew->name = kstrdup(name, GFP_KERNEL); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2608 | if (! knew->name) |
| 2609 | return -ENOMEM; |
| 2610 | knew->private_value = val; |
| 2611 | spec->num_kctl_used++; |
| 2612 | return 0; |
| 2613 | } |
| 2614 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2615 | |
| 2616 | /* add dynamic controls */ |
| 2617 | static int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2618 | const char *name, unsigned long val) |
| 2619 | { |
| 2620 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2621 | } |
| 2622 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2623 | /* flag inputs as additional dynamic lineouts */ |
| 2624 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 2625 | { |
| 2626 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2627 | unsigned int wcaps, wtype; |
| 2628 | int i, num_dacs = 0; |
| 2629 | |
| 2630 | /* use the wcaps cache to count all DACs available for line-outs */ |
| 2631 | for (i = 0; i < codec->num_nodes; i++) { |
| 2632 | wcaps = codec->wcaps[i]; |
| 2633 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2634 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2635 | if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) |
| 2636 | num_dacs++; |
| 2637 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2638 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2639 | snd_printdd("%s: total dac count=%d\n", __func__, num_dacs); |
| 2640 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2641 | switch (cfg->line_outs) { |
| 2642 | case 3: |
| 2643 | /* add line-in as side */ |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2644 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2645 | cfg->line_out_pins[cfg->line_outs] = |
| 2646 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2647 | spec->line_switch = 1; |
| 2648 | cfg->line_outs++; |
| 2649 | } |
| 2650 | break; |
| 2651 | case 2: |
| 2652 | /* add line-in as clfe and mic as side */ |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2653 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2654 | cfg->line_out_pins[cfg->line_outs] = |
| 2655 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2656 | spec->line_switch = 1; |
| 2657 | cfg->line_outs++; |
| 2658 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2659 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2660 | cfg->line_out_pins[cfg->line_outs] = |
| 2661 | cfg->input_pins[AUTO_PIN_MIC]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2662 | spec->mic_switch = 1; |
| 2663 | cfg->line_outs++; |
| 2664 | } |
| 2665 | break; |
| 2666 | case 1: |
| 2667 | /* add line-in as surr and mic as clfe */ |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2668 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2669 | cfg->line_out_pins[cfg->line_outs] = |
| 2670 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2671 | spec->line_switch = 1; |
| 2672 | cfg->line_outs++; |
| 2673 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2674 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2675 | cfg->line_out_pins[cfg->line_outs] = |
| 2676 | cfg->input_pins[AUTO_PIN_MIC]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2677 | spec->mic_switch = 1; |
| 2678 | cfg->line_outs++; |
| 2679 | } |
| 2680 | break; |
| 2681 | } |
| 2682 | |
| 2683 | return 0; |
| 2684 | } |
| 2685 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2686 | |
| 2687 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2688 | { |
| 2689 | int i; |
| 2690 | |
| 2691 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 2692 | if (spec->multiout.dac_nids[i] == nid) |
| 2693 | return 1; |
| 2694 | } |
| 2695 | |
| 2696 | return 0; |
| 2697 | } |
| 2698 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2699 | /* |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2700 | * Fill in the dac_nids table from the parsed pin configuration |
| 2701 | * This function only works when every pin in line_out_pins[] |
| 2702 | * contains atleast one DAC in its connection list. Some 92xx |
| 2703 | * codecs are not connected directly to a DAC, such as the 9200 |
| 2704 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2705 | */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2706 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2707 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2708 | { |
| 2709 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2710 | int i, j, conn_len = 0; |
| 2711 | hda_nid_t nid, conn[HDA_MAX_CONNECTIONS]; |
| 2712 | unsigned int wcaps, wtype; |
| 2713 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2714 | for (i = 0; i < cfg->line_outs; i++) { |
| 2715 | nid = cfg->line_out_pins[i]; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2716 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 2717 | HDA_MAX_CONNECTIONS); |
| 2718 | for (j = 0; j < conn_len; j++) { |
| 2719 | wcaps = snd_hda_param_read(codec, conn[j], |
| 2720 | AC_PAR_AUDIO_WIDGET_CAP); |
| 2721 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2722 | if (wtype != AC_WID_AUD_OUT || |
| 2723 | (wcaps & AC_WCAP_DIGITAL)) |
| 2724 | continue; |
| 2725 | /* conn[j] is a DAC routed to this line-out */ |
| 2726 | if (!is_in_dac_nids(spec, conn[j])) |
| 2727 | break; |
| 2728 | } |
| 2729 | |
| 2730 | if (j == conn_len) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2731 | if (spec->multiout.num_dacs > 0) { |
| 2732 | /* we have already working output pins, |
| 2733 | * so let's drop the broken ones again |
| 2734 | */ |
| 2735 | cfg->line_outs = spec->multiout.num_dacs; |
| 2736 | break; |
| 2737 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2738 | /* error out, no available DAC found */ |
| 2739 | snd_printk(KERN_ERR |
| 2740 | "%s: No available DAC for pin 0x%x\n", |
| 2741 | __func__, nid); |
| 2742 | return -ENODEV; |
| 2743 | } |
| 2744 | |
| 2745 | spec->multiout.dac_nids[i] = conn[j]; |
| 2746 | spec->multiout.num_dacs++; |
| 2747 | if (conn_len > 1) { |
| 2748 | /* select this DAC in the pin's input mux */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2749 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2750 | AC_VERB_SET_CONNECT_SEL, j); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2751 | |
| 2752 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2753 | } |
| 2754 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2755 | snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
| 2756 | spec->multiout.num_dacs, |
| 2757 | spec->multiout.dac_nids[0], |
| 2758 | spec->multiout.dac_nids[1], |
| 2759 | spec->multiout.dac_nids[2], |
| 2760 | spec->multiout.dac_nids[3], |
| 2761 | spec->multiout.dac_nids[4]); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2762 | return 0; |
| 2763 | } |
| 2764 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2765 | /* create volume control/switch for the given prefx type */ |
| 2766 | static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) |
| 2767 | { |
| 2768 | char name[32]; |
| 2769 | int err; |
| 2770 | |
| 2771 | sprintf(name, "%s Playback Volume", pfx); |
| 2772 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 2773 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2774 | if (err < 0) |
| 2775 | return err; |
| 2776 | sprintf(name, "%s Playback Switch", pfx); |
| 2777 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 2778 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2779 | if (err < 0) |
| 2780 | return err; |
| 2781 | return 0; |
| 2782 | } |
| 2783 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2784 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2785 | { |
| 2786 | if (!spec->multiout.hp_nid) |
| 2787 | spec->multiout.hp_nid = nid; |
| 2788 | else if (spec->multiout.num_dacs > 4) { |
| 2789 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 2790 | return 1; |
| 2791 | } else { |
| 2792 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 2793 | spec->multiout.num_dacs++; |
| 2794 | } |
| 2795 | return 0; |
| 2796 | } |
| 2797 | |
| 2798 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2799 | { |
| 2800 | if (is_in_dac_nids(spec, nid)) |
| 2801 | return 1; |
| 2802 | if (spec->multiout.hp_nid == nid) |
| 2803 | return 1; |
| 2804 | return 0; |
| 2805 | } |
| 2806 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2807 | /* add playback controls from the parsed DAC table */ |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2808 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2809 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2810 | { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2811 | static const char *chname[4] = { |
| 2812 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 2813 | }; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2814 | hda_nid_t nid; |
| 2815 | int i, err; |
| 2816 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2817 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 2818 | unsigned int wid_caps, pincap; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2819 | |
| 2820 | |
Takashi Iwai | 40ac8c4 | 2008-02-29 14:16:17 +0100 | [diff] [blame] | 2821 | for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2822 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2823 | continue; |
| 2824 | |
| 2825 | nid = spec->multiout.dac_nids[i]; |
| 2826 | |
| 2827 | if (i == 2) { |
| 2828 | /* Center/LFE */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2829 | err = create_controls(spec, "Center", nid, 1); |
| 2830 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2831 | return err; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2832 | err = create_controls(spec, "LFE", nid, 2); |
| 2833 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2834 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2835 | |
| 2836 | wid_caps = get_wcaps(codec, nid); |
| 2837 | |
| 2838 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 2839 | err = stac92xx_add_control(spec, |
| 2840 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2841 | "Swap Center/LFE Playback Switch", nid); |
| 2842 | |
| 2843 | if (err < 0) |
| 2844 | return err; |
| 2845 | } |
| 2846 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2847 | } else { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2848 | err = create_controls(spec, chname[i], nid, 3); |
| 2849 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2850 | return err; |
| 2851 | } |
| 2852 | } |
| 2853 | |
Matthew Ranostay | fedb756 | 2008-09-23 21:46:30 -0400 | [diff] [blame] | 2854 | if ((spec->multiout.num_dacs - cfg->line_outs) > 0 && |
| 2855 | cfg->hp_outs && !spec->multiout.hp_nid) |
| 2856 | spec->multiout.hp_nid = nid; |
| 2857 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2858 | if (cfg->hp_outs > 1) { |
| 2859 | err = stac92xx_add_control(spec, |
| 2860 | STAC_CTL_WIDGET_HP_SWITCH, |
| 2861 | "Headphone as Line Out Switch", 0); |
| 2862 | if (err < 0) |
| 2863 | return err; |
| 2864 | } |
| 2865 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 2866 | if (spec->line_switch) { |
| 2867 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
| 2868 | pincap = snd_hda_param_read(codec, nid, |
| 2869 | AC_PAR_PIN_CAP); |
| 2870 | if (pincap & AC_PINCAP_OUT) { |
| 2871 | err = stac92xx_add_control(spec, |
| 2872 | STAC_CTL_WIDGET_IO_SWITCH, |
| 2873 | "Line In as Output Switch", nid << 8); |
| 2874 | if (err < 0) |
| 2875 | return err; |
| 2876 | } |
| 2877 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2878 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 2879 | if (spec->mic_switch) { |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 2880 | unsigned int def_conf; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2881 | unsigned int mic_pin = AUTO_PIN_MIC; |
| 2882 | again: |
| 2883 | nid = cfg->input_pins[mic_pin]; |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 2884 | def_conf = snd_hda_codec_read(codec, nid, 0, |
| 2885 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 2886 | /* some laptops have an internal analog microphone |
| 2887 | * which can't be used as a output */ |
| 2888 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
| 2889 | pincap = snd_hda_param_read(codec, nid, |
| 2890 | AC_PAR_PIN_CAP); |
| 2891 | if (pincap & AC_PINCAP_OUT) { |
| 2892 | err = stac92xx_add_control(spec, |
| 2893 | STAC_CTL_WIDGET_IO_SWITCH, |
| 2894 | "Mic as Output Switch", (nid << 8) | 1); |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2895 | nid = snd_hda_codec_read(codec, nid, 0, |
| 2896 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2897 | if (!check_in_dac_nids(spec, nid)) |
| 2898 | add_spec_dacs(spec, nid); |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 2899 | if (err < 0) |
| 2900 | return err; |
| 2901 | } |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2902 | } else if (mic_pin == AUTO_PIN_MIC) { |
| 2903 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 2904 | goto again; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 2905 | } |
| 2906 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2907 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2908 | return 0; |
| 2909 | } |
| 2910 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2911 | /* add playback controls for Speaker and HP outputs */ |
| 2912 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 2913 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2914 | { |
| 2915 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2916 | hda_nid_t nid; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2917 | int i, old_num_dacs, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2918 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2919 | old_num_dacs = spec->multiout.num_dacs; |
| 2920 | for (i = 0; i < cfg->hp_outs; i++) { |
| 2921 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
| 2922 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 2923 | spec->hp_detect = 1; |
| 2924 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 2925 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2926 | if (check_in_dac_nids(spec, nid)) |
| 2927 | nid = 0; |
| 2928 | if (! nid) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2929 | continue; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2930 | add_spec_dacs(spec, nid); |
| 2931 | } |
| 2932 | for (i = 0; i < cfg->speaker_outs; i++) { |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2933 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2934 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2935 | if (check_in_dac_nids(spec, nid)) |
| 2936 | nid = 0; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2937 | if (! nid) |
| 2938 | continue; |
| 2939 | add_spec_dacs(spec, nid); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2940 | } |
Matthew Ranostay | 1b290a5 | 2007-07-12 15:17:34 +0200 | [diff] [blame] | 2941 | for (i = 0; i < cfg->line_outs; i++) { |
| 2942 | nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0, |
| 2943 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 2944 | if (check_in_dac_nids(spec, nid)) |
| 2945 | nid = 0; |
| 2946 | if (! nid) |
| 2947 | continue; |
| 2948 | add_spec_dacs(spec, nid); |
| 2949 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2950 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { |
| 2951 | static const char *pfxs[] = { |
| 2952 | "Speaker", "External Speaker", "Speaker2", |
| 2953 | }; |
| 2954 | err = create_controls(spec, pfxs[i - old_num_dacs], |
| 2955 | spec->multiout.dac_nids[i], 3); |
| 2956 | if (err < 0) |
| 2957 | return err; |
| 2958 | } |
| 2959 | if (spec->multiout.hp_nid) { |
Takashi Iwai | 2626a26 | 2008-03-14 09:18:32 +0100 | [diff] [blame] | 2960 | err = create_controls(spec, "Headphone", |
| 2961 | spec->multiout.hp_nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2962 | if (err < 0) |
| 2963 | return err; |
| 2964 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2965 | |
| 2966 | return 0; |
| 2967 | } |
| 2968 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 2969 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2970 | static const char *stac92xx_mono_labels[4] = { |
| 2971 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 2972 | }; |
| 2973 | |
| 2974 | /* create mono mux for mono out on capable codecs */ |
| 2975 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 2976 | { |
| 2977 | struct sigmatel_spec *spec = codec->spec; |
| 2978 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 2979 | int i, num_cons; |
| 2980 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 2981 | |
| 2982 | num_cons = snd_hda_get_connections(codec, |
| 2983 | spec->mono_nid, |
| 2984 | con_lst, |
| 2985 | HDA_MAX_NUM_INPUTS); |
| 2986 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 2987 | return -EINVAL; |
| 2988 | |
| 2989 | for (i = 0; i < num_cons; i++) { |
| 2990 | mono_mux->items[mono_mux->num_items].label = |
| 2991 | stac92xx_mono_labels[i]; |
| 2992 | mono_mux->items[mono_mux->num_items].index = i; |
| 2993 | mono_mux->num_items++; |
| 2994 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2995 | |
| 2996 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 2997 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 2998 | } |
| 2999 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3000 | /* labels for amp mux outputs */ |
| 3001 | static const char *stac92xx_amp_labels[3] = { |
| 3002 | "Front Microphone", "Microphone", "Line In" |
| 3003 | }; |
| 3004 | |
| 3005 | /* create amp out controls mux on capable codecs */ |
| 3006 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3007 | { |
| 3008 | struct sigmatel_spec *spec = codec->spec; |
| 3009 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3010 | int i, err; |
| 3011 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3012 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3013 | amp_mux->items[amp_mux->num_items].label = |
| 3014 | stac92xx_amp_labels[i]; |
| 3015 | amp_mux->items[amp_mux->num_items].index = i; |
| 3016 | amp_mux->num_items++; |
| 3017 | } |
| 3018 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3019 | if (spec->num_amps > 1) { |
| 3020 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3021 | "Amp Selector Capture Switch", 0); |
| 3022 | if (err < 0) |
| 3023 | return err; |
| 3024 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3025 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3026 | "Amp Capture Volume", |
| 3027 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3028 | } |
| 3029 | |
| 3030 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3031 | /* create PC beep volume controls */ |
| 3032 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3033 | hda_nid_t nid) |
| 3034 | { |
| 3035 | struct sigmatel_spec *spec = codec->spec; |
| 3036 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3037 | int err; |
| 3038 | |
| 3039 | /* check for mute support for the the amp */ |
| 3040 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3041 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3042 | "PC Beep Playback Switch", |
| 3043 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3044 | if (err < 0) |
| 3045 | return err; |
| 3046 | } |
| 3047 | |
| 3048 | /* check to see if there is volume support for the amp */ |
| 3049 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3050 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3051 | "PC Beep Playback Volume", |
| 3052 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3053 | if (err < 0) |
| 3054 | return err; |
| 3055 | } |
| 3056 | return 0; |
| 3057 | } |
| 3058 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3059 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3060 | { |
| 3061 | struct sigmatel_spec *spec = codec->spec; |
| 3062 | int wcaps, nid, i, err = 0; |
| 3063 | |
| 3064 | for (i = 0; i < spec->num_muxes; i++) { |
| 3065 | nid = spec->mux_nids[i]; |
| 3066 | wcaps = get_wcaps(codec, nid); |
| 3067 | |
| 3068 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3069 | err = stac92xx_add_control_idx(spec, |
| 3070 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3071 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3072 | if (err < 0) |
| 3073 | return err; |
| 3074 | } |
| 3075 | } |
| 3076 | return 0; |
| 3077 | }; |
| 3078 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3079 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3080 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3081 | }; |
| 3082 | |
| 3083 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3084 | { |
| 3085 | struct sigmatel_spec *spec = codec->spec; |
| 3086 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3087 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3088 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3089 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3090 | |
| 3091 | num_cons = snd_hda_get_connections(codec, |
| 3092 | spec->smux_nids[0], |
| 3093 | con_lst, |
| 3094 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3095 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3096 | return -EINVAL; |
| 3097 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3098 | if (!labels) |
| 3099 | labels = stac92xx_spdif_labels; |
| 3100 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3101 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3102 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3103 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3104 | spdif_mux->num_items++; |
| 3105 | } |
| 3106 | |
| 3107 | return 0; |
| 3108 | } |
| 3109 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3110 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3111 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3112 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3113 | "Digital Mic 3", "Digital Mic 4" |
| 3114 | }; |
| 3115 | |
| 3116 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3117 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3118 | const struct auto_pin_cfg *cfg) |
| 3119 | { |
| 3120 | struct sigmatel_spec *spec = codec->spec; |
| 3121 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3122 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3123 | int err, i, j; |
| 3124 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3125 | |
| 3126 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3127 | dimux->items[dimux->num_items].index = 0; |
| 3128 | dimux->num_items++; |
| 3129 | |
| 3130 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3131 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3132 | int index; |
| 3133 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3134 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3135 | unsigned int def_conf; |
| 3136 | |
| 3137 | def_conf = snd_hda_codec_read(codec, |
| 3138 | spec->dmic_nids[i], |
| 3139 | 0, |
| 3140 | AC_VERB_GET_CONFIG_DEFAULT, |
| 3141 | 0); |
| 3142 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3143 | continue; |
| 3144 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3145 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3146 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3147 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3148 | con_lst, |
| 3149 | HDA_MAX_NUM_INPUTS); |
| 3150 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3151 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3152 | index = j; |
| 3153 | goto found; |
| 3154 | } |
| 3155 | continue; |
| 3156 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3157 | wcaps = get_wcaps(codec, nid) & |
| 3158 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3159 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3160 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3161 | sprintf(name, "%s Capture Volume", |
| 3162 | stac92xx_dmic_labels[dimux->num_items]); |
| 3163 | |
| 3164 | err = stac92xx_add_control(spec, |
| 3165 | STAC_CTL_WIDGET_VOL, |
| 3166 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3167 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3168 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3169 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3170 | if (err < 0) |
| 3171 | return err; |
| 3172 | } |
| 3173 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3174 | dimux->items[dimux->num_items].label = |
| 3175 | stac92xx_dmic_labels[dimux->num_items]; |
| 3176 | dimux->items[dimux->num_items].index = index; |
| 3177 | dimux->num_items++; |
| 3178 | } |
| 3179 | |
| 3180 | return 0; |
| 3181 | } |
| 3182 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3183 | /* create playback/capture controls for input pins */ |
| 3184 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3185 | { |
| 3186 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3187 | struct hda_input_mux *imux = &spec->private_imux; |
| 3188 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3189 | int i, j, k; |
| 3190 | |
| 3191 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3192 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3193 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3194 | if (!cfg->input_pins[i]) |
| 3195 | continue; |
| 3196 | index = -1; |
| 3197 | for (j = 0; j < spec->num_muxes; j++) { |
| 3198 | int num_cons; |
| 3199 | num_cons = snd_hda_get_connections(codec, |
| 3200 | spec->mux_nids[j], |
| 3201 | con_lst, |
| 3202 | HDA_MAX_NUM_INPUTS); |
| 3203 | for (k = 0; k < num_cons; k++) |
| 3204 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3205 | index = k; |
| 3206 | goto found; |
| 3207 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3208 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3209 | continue; |
| 3210 | found: |
| 3211 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3212 | imux->items[imux->num_items].index = index; |
| 3213 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3214 | } |
| 3215 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3216 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3217 | /* |
| 3218 | * Set the current input for the muxes. |
| 3219 | * The STAC9221 has two input muxes with identical source |
| 3220 | * NID lists. Hopefully this won't get confused. |
| 3221 | */ |
| 3222 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3223 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3224 | AC_VERB_SET_CONNECT_SEL, |
| 3225 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3226 | } |
| 3227 | } |
| 3228 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3229 | return 0; |
| 3230 | } |
| 3231 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3232 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3233 | { |
| 3234 | struct sigmatel_spec *spec = codec->spec; |
| 3235 | int i; |
| 3236 | |
| 3237 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3238 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3239 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3240 | } |
| 3241 | } |
| 3242 | |
| 3243 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3244 | { |
| 3245 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3246 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3247 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3248 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3249 | hda_nid_t pin; |
| 3250 | pin = spec->autocfg.hp_pins[i]; |
| 3251 | if (pin) /* connect to front */ |
| 3252 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3253 | } |
| 3254 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3255 | hda_nid_t pin; |
| 3256 | pin = spec->autocfg.speaker_pins[i]; |
| 3257 | if (pin) /* connect to front */ |
| 3258 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3259 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3260 | } |
| 3261 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3262 | 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] | 3263 | { |
| 3264 | struct sigmatel_spec *spec = codec->spec; |
| 3265 | int err; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3266 | int hp_speaker_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3267 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3268 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3269 | &spec->autocfg, |
| 3270 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3271 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3272 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3273 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3274 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3275 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3276 | * be set up as multi-channel outputs. |
| 3277 | */ |
| 3278 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3279 | spec->autocfg.hp_outs > 1) { |
| 3280 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3281 | * speaker_outs so that the following routines can handle |
| 3282 | * HP pins as primary outputs. |
| 3283 | */ |
| 3284 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3285 | sizeof(spec->autocfg.line_out_pins)); |
| 3286 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3287 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3288 | sizeof(spec->autocfg.hp_pins)); |
| 3289 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
| 3290 | hp_speaker_swap = 1; |
| 3291 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3292 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3293 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3294 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3295 | u32 caps = query_amp_caps(codec, |
| 3296 | spec->autocfg.mono_out_pin, dir); |
| 3297 | hda_nid_t conn_list[1]; |
| 3298 | |
| 3299 | /* get the mixer node and then the mono mux if it exists */ |
| 3300 | if (snd_hda_get_connections(codec, |
| 3301 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3302 | snd_hda_get_connections(codec, conn_list[0], |
| 3303 | conn_list, 1)) { |
| 3304 | |
| 3305 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3306 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3307 | >> AC_WCAP_TYPE_SHIFT; |
| 3308 | /* LR swap check, some stac925x have a mux that |
| 3309 | * changes the DACs output path instead of the |
| 3310 | * mono-mux path. |
| 3311 | */ |
| 3312 | if (wid_type == AC_WID_AUD_SEL && |
| 3313 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3314 | spec->mono_nid = conn_list[0]; |
| 3315 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3316 | if (dir) { |
| 3317 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3318 | |
| 3319 | /* most mono outs have a least a mute/unmute switch */ |
| 3320 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3321 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3322 | "Mono Playback Switch", |
| 3323 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3324 | if (err < 0) |
| 3325 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3326 | /* check for volume support for the amp */ |
| 3327 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3328 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3329 | err = stac92xx_add_control(spec, |
| 3330 | STAC_CTL_WIDGET_VOL, |
| 3331 | "Mono Playback Volume", |
| 3332 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3333 | if (err < 0) |
| 3334 | return err; |
| 3335 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3336 | } |
| 3337 | |
| 3338 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3339 | AC_PINCTL_OUT_EN); |
| 3340 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3341 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3342 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 3343 | return err; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3344 | if (spec->multiout.num_dacs == 0) |
| 3345 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 3346 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3347 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3348 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); |
| 3349 | |
| 3350 | if (err < 0) |
| 3351 | return err; |
| 3352 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3353 | /* setup analog beep controls */ |
| 3354 | if (spec->anabeep_nid > 0) { |
| 3355 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3356 | spec->anabeep_nid); |
| 3357 | if (err < 0) |
| 3358 | return err; |
| 3359 | } |
| 3360 | |
| 3361 | /* setup digital beep controls and input device */ |
| 3362 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3363 | if (spec->digbeep_nid > 0) { |
| 3364 | hda_nid_t nid = spec->digbeep_nid; |
| 3365 | |
| 3366 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3367 | if (err < 0) |
| 3368 | return err; |
| 3369 | err = snd_hda_attach_beep_device(codec, nid); |
| 3370 | if (err < 0) |
| 3371 | return err; |
| 3372 | } |
| 3373 | #endif |
| 3374 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3375 | if (hp_speaker_swap == 1) { |
| 3376 | /* Restore the hp_outs and line_outs */ |
| 3377 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3378 | sizeof(spec->autocfg.line_out_pins)); |
| 3379 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3380 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins, |
| 3381 | sizeof(spec->autocfg.speaker_pins)); |
| 3382 | spec->autocfg.line_outs = spec->autocfg.speaker_outs; |
| 3383 | memset(spec->autocfg.speaker_pins, 0, |
| 3384 | sizeof(spec->autocfg.speaker_pins)); |
| 3385 | spec->autocfg.speaker_outs = 0; |
| 3386 | } |
| 3387 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3388 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
| 3389 | |
| 3390 | if (err < 0) |
| 3391 | return err; |
| 3392 | |
| 3393 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
| 3394 | |
| 3395 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3396 | return err; |
| 3397 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3398 | if (spec->mono_nid > 0) { |
| 3399 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3400 | if (err < 0) |
| 3401 | return err; |
| 3402 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3403 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3404 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3405 | if (err < 0) |
| 3406 | return err; |
| 3407 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3408 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3409 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3410 | &spec->autocfg)) < 0) |
| 3411 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3412 | if (spec->num_muxes > 0) { |
| 3413 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3414 | if (err < 0) |
| 3415 | return err; |
| 3416 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3417 | if (spec->num_smuxes > 0) { |
| 3418 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3419 | if (err < 0) |
| 3420 | return err; |
| 3421 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3422 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3423 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3424 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3425 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3426 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3427 | if (spec->autocfg.dig_out_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3428 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3429 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3430 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3431 | |
| 3432 | if (spec->kctl_alloc) |
| 3433 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 3434 | |
| 3435 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3436 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3437 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3438 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3439 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3440 | return 1; |
| 3441 | } |
| 3442 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3443 | /* add playback controls for HP output */ |
| 3444 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3445 | struct auto_pin_cfg *cfg) |
| 3446 | { |
| 3447 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3448 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3449 | unsigned int wid_caps; |
| 3450 | |
| 3451 | if (! pin) |
| 3452 | return 0; |
| 3453 | |
| 3454 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3455 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3456 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3457 | |
| 3458 | return 0; |
| 3459 | } |
| 3460 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3461 | /* add playback controls for LFE output */ |
| 3462 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3463 | struct auto_pin_cfg *cfg) |
| 3464 | { |
| 3465 | struct sigmatel_spec *spec = codec->spec; |
| 3466 | int err; |
| 3467 | hda_nid_t lfe_pin = 0x0; |
| 3468 | int i; |
| 3469 | |
| 3470 | /* |
| 3471 | * search speaker outs and line outs for a mono speaker pin |
| 3472 | * with an amp. If one is found, add LFE controls |
| 3473 | * for it. |
| 3474 | */ |
| 3475 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3476 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3477 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3478 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3479 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3480 | /* found a mono speaker with an amp, must be lfe */ |
| 3481 | lfe_pin = pin; |
| 3482 | } |
| 3483 | |
| 3484 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3485 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3486 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3487 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3488 | unsigned int defcfg; |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3489 | defcfg = snd_hda_codec_read(codec, pin, 0, |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3490 | AC_VERB_GET_CONFIG_DEFAULT, |
| 3491 | 0x00); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3492 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3493 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3494 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3495 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3496 | /* found a mono speaker with an amp, |
| 3497 | must be lfe */ |
| 3498 | lfe_pin = pin; |
| 3499 | } |
| 3500 | } |
| 3501 | } |
| 3502 | |
| 3503 | if (lfe_pin) { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3504 | err = create_controls(spec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3505 | if (err < 0) |
| 3506 | return err; |
| 3507 | } |
| 3508 | |
| 3509 | return 0; |
| 3510 | } |
| 3511 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3512 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3513 | { |
| 3514 | struct sigmatel_spec *spec = codec->spec; |
| 3515 | int err; |
| 3516 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3517 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3518 | return err; |
| 3519 | |
| 3520 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3521 | return err; |
| 3522 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3523 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3524 | return err; |
| 3525 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3526 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3527 | return err; |
| 3528 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3529 | if (spec->autocfg.dig_out_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3530 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3531 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3532 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3533 | |
| 3534 | if (spec->kctl_alloc) |
| 3535 | spec->mixers[spec->num_mixers++] = spec->kctl_alloc; |
| 3536 | |
| 3537 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3538 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3539 | |
| 3540 | return 1; |
| 3541 | } |
| 3542 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3543 | /* |
| 3544 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 3545 | * funky external mute control using GPIO pins. |
| 3546 | */ |
| 3547 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3548 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3549 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3550 | { |
| 3551 | unsigned int gpiostate, gpiomask, gpiodir; |
| 3552 | |
| 3553 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 3554 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3555 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3556 | |
| 3557 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 3558 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3559 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3560 | |
| 3561 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 3562 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3563 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3564 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3565 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3566 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 3567 | |
| 3568 | snd_hda_codec_write(codec, codec->afg, 0, |
| 3569 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3570 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3571 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3572 | |
| 3573 | msleep(1); |
| 3574 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3575 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3576 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3577 | } |
| 3578 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3579 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 3580 | unsigned int event) |
| 3581 | { |
| 3582 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 3583 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3584 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3585 | (AC_USRSP_EN | event)); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3586 | } |
| 3587 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3588 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3589 | { |
| 3590 | int i; |
| 3591 | for (i = 0; i < cfg->hp_outs; i++) |
| 3592 | if (cfg->hp_pins[i] == nid) |
| 3593 | return 1; /* nid is a HP-Out */ |
| 3594 | |
| 3595 | return 0; /* nid is not a HP-Out */ |
| 3596 | }; |
| 3597 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3598 | static void stac92xx_power_down(struct hda_codec *codec) |
| 3599 | { |
| 3600 | struct sigmatel_spec *spec = codec->spec; |
| 3601 | |
| 3602 | /* power down inactive DACs */ |
| 3603 | hda_nid_t *dac; |
| 3604 | for (dac = spec->dac_list; *dac; dac++) |
Matthew Ranostay | 4451089 | 2008-02-21 07:49:31 +0100 | [diff] [blame] | 3605 | if (!is_in_dac_nids(spec, *dac) && |
| 3606 | spec->multiout.hp_nid != *dac) |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3607 | snd_hda_codec_write_cache(codec, *dac, 0, |
| 3608 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3609 | } |
| 3610 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3611 | static int stac92xx_init(struct hda_codec *codec) |
| 3612 | { |
| 3613 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3614 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3615 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3616 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3617 | snd_hda_sequence_write(codec, spec->init); |
| 3618 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3619 | /* power down adcs initially */ |
| 3620 | if (spec->powerdown_adcs) |
| 3621 | for (i = 0; i < spec->num_adcs; i++) |
| 3622 | snd_hda_codec_write_cache(codec, |
| 3623 | spec->adc_nids[i], 0, |
| 3624 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3625 | /* set up pins */ |
| 3626 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3627 | /* Enable unsolicited responses on the HP widget */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3628 | for (i = 0; i < cfg->hp_outs; i++) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3629 | enable_pin_detect(codec, cfg->hp_pins[i], |
| 3630 | STAC_HP_EVENT); |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 3631 | /* force to enable the first line-out; the others are set up |
| 3632 | * in unsol_event |
| 3633 | */ |
| 3634 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
| 3635 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb995a8 | 2006-09-21 14:28:21 +0200 | [diff] [blame] | 3636 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3637 | /* fake event to set up pins */ |
| 3638 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 3639 | } else { |
| 3640 | stac92xx_auto_init_multi_out(codec); |
| 3641 | stac92xx_auto_init_hp_out(codec); |
| 3642 | } |
| 3643 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3644 | hda_nid_t nid = cfg->input_pins[i]; |
| 3645 | if (nid) { |
Matthew Ranostay | b9aea715 | 2008-10-09 08:37:28 -0400 | [diff] [blame^] | 3646 | unsigned int pinctl = snd_hda_codec_read(codec, nid, |
| 3647 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3648 | /* if PINCTL already set then skip */ |
| 3649 | if (pinctl & AC_PINCAP_IN) |
| 3650 | continue; |
| 3651 | pinctl = AC_PINCTL_IN_EN; |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3652 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) |
| 3653 | pinctl |= stac92xx_get_vref(codec, nid); |
| 3654 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 3655 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3656 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3657 | for (i = 0; i < spec->num_dmics; i++) |
| 3658 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 3659 | AC_PINCTL_IN_EN); |
| 3660 | for (i = 0; i < spec->num_pwrs; i++) { |
| 3661 | int event = is_nid_hp_pin(cfg, spec->pwr_nids[i]) |
| 3662 | ? STAC_HP_EVENT : STAC_PWR_EVENT; |
| 3663 | int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i], |
| 3664 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Matthew Ranostay | bce6c2b | 2008-02-29 12:07:43 +0100 | [diff] [blame] | 3665 | int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i], |
| 3666 | 0, AC_VERB_GET_CONFIG_DEFAULT, 0); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 3667 | def_conf = get_defcfg_connect(def_conf); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3668 | /* outputs are only ports capable of power management |
| 3669 | * any attempts on powering down a input port cause the |
| 3670 | * referenced VREF to act quirky. |
| 3671 | */ |
| 3672 | if (pinctl & AC_PINCTL_IN_EN) |
| 3673 | continue; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 3674 | /* skip any ports that don't have jacks since presence |
| 3675 | * detection is useless */ |
| 3676 | if (def_conf && def_conf != AC_JACK_PORT_FIXED) |
Matthew Ranostay | bce6c2b | 2008-02-29 12:07:43 +0100 | [diff] [blame] | 3677 | continue; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3678 | enable_pin_detect(codec, spec->pwr_nids[i], event | i); |
| 3679 | codec->patch_ops.unsol_event(codec, (event | i) << 26); |
| 3680 | } |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3681 | if (spec->dac_list) |
| 3682 | stac92xx_power_down(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3683 | if (cfg->dig_out_pin) |
| 3684 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, |
| 3685 | AC_PINCTL_OUT_EN); |
| 3686 | if (cfg->dig_in_pin) |
| 3687 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 3688 | AC_PINCTL_IN_EN); |
| 3689 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3690 | stac_gpio_set(codec, spec->gpio_mask, |
| 3691 | spec->gpio_dir, spec->gpio_data); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3692 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3693 | return 0; |
| 3694 | } |
| 3695 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3696 | static void stac92xx_free(struct hda_codec *codec) |
| 3697 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3698 | struct sigmatel_spec *spec = codec->spec; |
| 3699 | int i; |
| 3700 | |
| 3701 | if (! spec) |
| 3702 | return; |
| 3703 | |
| 3704 | if (spec->kctl_alloc) { |
| 3705 | for (i = 0; i < spec->num_kctl_used; i++) |
| 3706 | kfree(spec->kctl_alloc[i].name); |
| 3707 | kfree(spec->kctl_alloc); |
| 3708 | } |
| 3709 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3710 | if (spec->bios_pin_configs) |
| 3711 | kfree(spec->bios_pin_configs); |
| 3712 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3713 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3714 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3715 | } |
| 3716 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3717 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 3718 | unsigned int flag) |
| 3719 | { |
| 3720 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 3721 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3722 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 3723 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 3724 | /* |
| 3725 | * we need to check the current set-up direction of |
| 3726 | * shared input pins since they can be switched via |
| 3727 | * "xxx as Output" mixer switch |
| 3728 | */ |
| 3729 | struct sigmatel_spec *spec = codec->spec; |
| 3730 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3731 | if ((nid == cfg->input_pins[AUTO_PIN_LINE] && |
| 3732 | spec->line_switch) || |
| 3733 | (nid == cfg->input_pins[AUTO_PIN_MIC] && |
| 3734 | spec->mic_switch)) |
| 3735 | return; |
| 3736 | } |
| 3737 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3738 | /* if setting pin direction bits, clear the current |
| 3739 | direction bits first */ |
| 3740 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 3741 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 3742 | |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3743 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3744 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3745 | pin_ctl | flag); |
| 3746 | } |
| 3747 | |
| 3748 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 3749 | unsigned int flag) |
| 3750 | { |
| 3751 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 3752 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3753 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3754 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3755 | pin_ctl & ~flag); |
| 3756 | } |
| 3757 | |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 3758 | 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] | 3759 | { |
| 3760 | if (!nid) |
| 3761 | return 0; |
| 3762 | 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] | 3763 | & (1 << 31)) { |
| 3764 | unsigned int pinctl; |
| 3765 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 3766 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3767 | if (pinctl & AC_PINCTL_IN_EN) |
| 3768 | return 0; /* mic- or line-input */ |
| 3769 | else |
| 3770 | return 1; /* HP-output */ |
| 3771 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3772 | return 0; |
| 3773 | } |
| 3774 | |
| 3775 | static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3776 | { |
| 3777 | struct sigmatel_spec *spec = codec->spec; |
| 3778 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3779 | int nid = cfg->hp_pins[cfg->hp_outs - 1]; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3780 | int i, presence; |
| 3781 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3782 | presence = 0; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3783 | if (spec->gpio_mute) |
| 3784 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 3785 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 3786 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3787 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3788 | if (presence) |
| 3789 | break; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3790 | if (spec->hp_switch && cfg->hp_pins[i] == nid) |
| 3791 | break; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3792 | presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3793 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3794 | |
| 3795 | if (presence) { |
| 3796 | /* disable lineouts, enable hp */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3797 | if (spec->hp_switch) |
| 3798 | stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3799 | for (i = 0; i < cfg->line_outs; i++) |
| 3800 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 3801 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3802 | for (i = 0; i < cfg->speaker_outs; i++) |
| 3803 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 3804 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 3805 | if (spec->eapd_mask) |
| 3806 | stac_gpio_set(codec, spec->gpio_mask, |
| 3807 | spec->gpio_dir, spec->gpio_data & |
| 3808 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3809 | } else { |
| 3810 | /* enable lineouts, disable hp */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3811 | if (spec->hp_switch) |
| 3812 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3813 | for (i = 0; i < cfg->line_outs; i++) |
| 3814 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 3815 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3816 | for (i = 0; i < cfg->speaker_outs; i++) |
| 3817 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 3818 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 3819 | if (spec->eapd_mask) |
| 3820 | stac_gpio_set(codec, spec->gpio_mask, |
| 3821 | spec->gpio_dir, spec->gpio_data | |
| 3822 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3823 | } |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3824 | if (!spec->hp_switch && cfg->hp_outs > 1 && presence) |
| 3825 | stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3826 | } |
| 3827 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3828 | static void stac92xx_pin_sense(struct hda_codec *codec, int idx) |
| 3829 | { |
| 3830 | struct sigmatel_spec *spec = codec->spec; |
| 3831 | hda_nid_t nid = spec->pwr_nids[idx]; |
| 3832 | int presence, val; |
| 3833 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) |
| 3834 | & 0x000000ff; |
| 3835 | presence = get_hp_pin_presence(codec, nid); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3836 | |
| 3837 | /* several codecs have two power down bits */ |
| 3838 | if (spec->pwr_mapping) |
| 3839 | idx = spec->pwr_mapping[idx]; |
| 3840 | else |
| 3841 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3842 | |
| 3843 | if (presence) |
| 3844 | val &= ~idx; |
| 3845 | else |
| 3846 | val |= idx; |
| 3847 | |
| 3848 | /* power down unused output ports */ |
| 3849 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
| 3850 | }; |
| 3851 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3852 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 3853 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3854 | struct sigmatel_spec *spec = codec->spec; |
| 3855 | int idx = res >> 26 & 0x0f; |
| 3856 | |
| 3857 | switch ((res >> 26) & 0x30) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3858 | case STAC_HP_EVENT: |
| 3859 | stac92xx_hp_detect(codec, res); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3860 | /* fallthru */ |
| 3861 | case STAC_PWR_EVENT: |
| 3862 | if (spec->num_pwrs > 0) |
| 3863 | stac92xx_pin_sense(codec, idx); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3864 | } |
| 3865 | } |
| 3866 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3867 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 3868 | static int stac92xx_resume(struct hda_codec *codec) |
| 3869 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 3870 | struct sigmatel_spec *spec = codec->spec; |
| 3871 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3872 | stac92xx_set_config_regs(codec); |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 3873 | snd_hda_sequence_write(codec, spec->init); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3874 | stac_gpio_set(codec, spec->gpio_mask, |
| 3875 | spec->gpio_dir, spec->gpio_data); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3876 | snd_hda_codec_resume_amp(codec); |
| 3877 | snd_hda_codec_resume_cache(codec); |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3878 | /* power down inactive DACs */ |
| 3879 | if (spec->dac_list) |
| 3880 | stac92xx_power_down(codec); |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 3881 | /* invoke unsolicited event to reset the HP state */ |
| 3882 | if (spec->hp_detect) |
| 3883 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 3884 | return 0; |
| 3885 | } |
| 3886 | #endif |
| 3887 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3888 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 3889 | .build_controls = stac92xx_build_controls, |
| 3890 | .build_pcms = stac92xx_build_pcms, |
| 3891 | .init = stac92xx_init, |
| 3892 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 3893 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 3894 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 3895 | .resume = stac92xx_resume, |
| 3896 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3897 | }; |
| 3898 | |
| 3899 | static int patch_stac9200(struct hda_codec *codec) |
| 3900 | { |
| 3901 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3902 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3903 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 3904 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3905 | if (spec == NULL) |
| 3906 | return -ENOMEM; |
| 3907 | |
| 3908 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 3909 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3910 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3911 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 3912 | stac9200_models, |
| 3913 | stac9200_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3914 | if (spec->board_config < 0) { |
| 3915 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 3916 | err = stac92xx_save_bios_config_regs(codec); |
| 3917 | if (err < 0) { |
| 3918 | stac92xx_free(codec); |
| 3919 | return err; |
| 3920 | } |
| 3921 | spec->pin_configs = spec->bios_pin_configs; |
| 3922 | } else { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3923 | spec->pin_configs = stac9200_brd_tbl[spec->board_config]; |
| 3924 | stac92xx_set_config_regs(codec); |
| 3925 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3926 | |
| 3927 | spec->multiout.max_channels = 2; |
| 3928 | spec->multiout.num_dacs = 1; |
| 3929 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 3930 | spec->adc_nids = stac9200_adc_nids; |
| 3931 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3932 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3933 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3934 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3935 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3936 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 3937 | if (spec->board_config == STAC_9200_GATEWAY || |
| 3938 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 3939 | spec->init = stac9200_eapd_init; |
| 3940 | else |
| 3941 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3942 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3943 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 3944 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 3945 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 3946 | spec->gpio_data = 0x00; |
| 3947 | } |
| 3948 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3949 | err = stac9200_parse_auto_config(codec); |
| 3950 | if (err < 0) { |
| 3951 | stac92xx_free(codec); |
| 3952 | return err; |
| 3953 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3954 | |
| 3955 | codec->patch_ops = stac92xx_patch_ops; |
| 3956 | |
| 3957 | return 0; |
| 3958 | } |
| 3959 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 3960 | static int patch_stac925x(struct hda_codec *codec) |
| 3961 | { |
| 3962 | struct sigmatel_spec *spec; |
| 3963 | int err; |
| 3964 | |
| 3965 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 3966 | if (spec == NULL) |
| 3967 | return -ENOMEM; |
| 3968 | |
| 3969 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 3970 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 3971 | spec->pin_nids = stac925x_pin_nids; |
| 3972 | spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS, |
| 3973 | stac925x_models, |
| 3974 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 3975 | again: |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 3976 | if (spec->board_config < 0) { |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 3977 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
| 3978 | "using BIOS defaults\n"); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 3979 | err = stac92xx_save_bios_config_regs(codec); |
| 3980 | if (err < 0) { |
| 3981 | stac92xx_free(codec); |
| 3982 | return err; |
| 3983 | } |
| 3984 | spec->pin_configs = spec->bios_pin_configs; |
| 3985 | } else if (stac925x_brd_tbl[spec->board_config] != NULL){ |
| 3986 | spec->pin_configs = stac925x_brd_tbl[spec->board_config]; |
| 3987 | stac92xx_set_config_regs(codec); |
| 3988 | } |
| 3989 | |
| 3990 | spec->multiout.max_channels = 2; |
| 3991 | spec->multiout.num_dacs = 1; |
| 3992 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 3993 | spec->adc_nids = stac925x_adc_nids; |
| 3994 | spec->mux_nids = stac925x_mux_nids; |
| 3995 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3996 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3997 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 3998 | switch (codec->vendor_id) { |
| 3999 | case 0x83847632: /* STAC9202 */ |
| 4000 | case 0x83847633: /* STAC9202D */ |
| 4001 | case 0x83847636: /* STAC9251 */ |
| 4002 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4003 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4004 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4005 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4006 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4007 | break; |
| 4008 | default: |
| 4009 | spec->num_dmics = 0; |
| 4010 | break; |
| 4011 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4012 | |
| 4013 | spec->init = stac925x_core_init; |
| 4014 | spec->mixer = stac925x_mixer; |
| 4015 | |
| 4016 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4017 | if (!err) { |
| 4018 | if (spec->board_config < 0) { |
| 4019 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4020 | "available, default to model=ref\n"); |
| 4021 | spec->board_config = STAC_925x_REF; |
| 4022 | goto again; |
| 4023 | } |
| 4024 | err = -EINVAL; |
| 4025 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4026 | if (err < 0) { |
| 4027 | stac92xx_free(codec); |
| 4028 | return err; |
| 4029 | } |
| 4030 | |
| 4031 | codec->patch_ops = stac92xx_patch_ops; |
| 4032 | |
| 4033 | return 0; |
| 4034 | } |
| 4035 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4036 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4037 | .num_items = 4, |
| 4038 | .items = { |
| 4039 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4040 | { "Digital Mic 1", 0x09 }, |
| 4041 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4042 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4043 | } |
| 4044 | }; |
| 4045 | |
| 4046 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4047 | { |
| 4048 | struct sigmatel_spec *spec; |
| 4049 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4050 | int err = 0; |
| 4051 | |
| 4052 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4053 | if (spec == NULL) |
| 4054 | return -ENOMEM; |
| 4055 | |
| 4056 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4057 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4058 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4059 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4060 | spec->board_config = snd_hda_check_board_config(codec, |
| 4061 | STAC_92HD73XX_MODELS, |
| 4062 | stac92hd73xx_models, |
| 4063 | stac92hd73xx_cfg_tbl); |
| 4064 | again: |
| 4065 | if (spec->board_config < 0) { |
| 4066 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4067 | " STAC92HD73XX, using BIOS defaults\n"); |
| 4068 | err = stac92xx_save_bios_config_regs(codec); |
| 4069 | if (err < 0) { |
| 4070 | stac92xx_free(codec); |
| 4071 | return err; |
| 4072 | } |
| 4073 | spec->pin_configs = spec->bios_pin_configs; |
| 4074 | } else { |
| 4075 | spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config]; |
| 4076 | stac92xx_set_config_regs(codec); |
| 4077 | } |
| 4078 | |
| 4079 | spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a, |
| 4080 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4081 | |
| 4082 | if (spec->multiout.num_dacs < 0) { |
| 4083 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4084 | "number of channels defaulting to DAC count\n"); |
| 4085 | spec->multiout.num_dacs = STAC92HD73_DAC_COUNT; |
| 4086 | } |
| 4087 | |
| 4088 | switch (spec->multiout.num_dacs) { |
| 4089 | case 0x3: /* 6 Channel */ |
| 4090 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4091 | spec->init = stac92hd73xx_6ch_core_init; |
| 4092 | break; |
| 4093 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4094 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4095 | spec->init = stac92hd73xx_8ch_core_init; |
| 4096 | break; |
| 4097 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4098 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4099 | spec->init = stac92hd73xx_10ch_core_init; |
| 4100 | }; |
| 4101 | |
| 4102 | spec->multiout.dac_nids = stac92hd73xx_dac_nids; |
| 4103 | spec->aloopback_mask = 0x01; |
| 4104 | spec->aloopback_shift = 8; |
| 4105 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4106 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4107 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4108 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4109 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4110 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4111 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4112 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4113 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4114 | |
| 4115 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4116 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4117 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4118 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 4119 | sizeof(stac92hd73xx_dmux)); |
| 4120 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4121 | switch (spec->board_config) { |
| 4122 | case STAC_DELL_M6: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4123 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4124 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4125 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 4126 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
| 4127 | spec->num_amps = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4128 | switch (codec->subsystem_id) { |
| 4129 | case 0x1028025e: /* Analog Mics */ |
| 4130 | case 0x1028025f: |
| 4131 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); |
| 4132 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4133 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4134 | break; |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4135 | case 0x10280271: /* Digital Mics */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4136 | case 0x10280272: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4137 | spec->init = dell_m6_core_init; |
| 4138 | /* fall-through */ |
| 4139 | case 0x10280254: |
| 4140 | case 0x10280255: |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4141 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); |
| 4142 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4143 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4144 | break; |
| 4145 | case 0x10280256: /* Both */ |
| 4146 | case 0x10280057: |
| 4147 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); |
| 4148 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); |
| 4149 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4150 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4151 | break; |
| 4152 | } |
| 4153 | break; |
| 4154 | default: |
| 4155 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4156 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4157 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4158 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 4159 | /* GPIO0 High = Enable EAPD */ |
| 4160 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 4161 | spec->gpio_data = 0x01; |
| 4162 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4163 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4164 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4165 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 4166 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 4167 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4168 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4169 | |
| 4170 | if (!err) { |
| 4171 | if (spec->board_config < 0) { |
| 4172 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4173 | "available, default to model=ref\n"); |
| 4174 | spec->board_config = STAC_92HD73XX_REF; |
| 4175 | goto again; |
| 4176 | } |
| 4177 | err = -EINVAL; |
| 4178 | } |
| 4179 | |
| 4180 | if (err < 0) { |
| 4181 | stac92xx_free(codec); |
| 4182 | return err; |
| 4183 | } |
| 4184 | |
| 4185 | codec->patch_ops = stac92xx_patch_ops; |
| 4186 | |
| 4187 | return 0; |
| 4188 | } |
| 4189 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4190 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 4191 | .num_items = 3, |
| 4192 | .items = { |
| 4193 | { "Analog Inputs", 0x03 }, |
| 4194 | { "Digital Mic 1", 0x04 }, |
| 4195 | { "Digital Mic 2", 0x05 }, |
| 4196 | } |
| 4197 | }; |
| 4198 | |
| 4199 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 4200 | { |
| 4201 | struct sigmatel_spec *spec; |
| 4202 | int err; |
| 4203 | |
| 4204 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4205 | if (spec == NULL) |
| 4206 | return -ENOMEM; |
| 4207 | |
| 4208 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4209 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4210 | spec->mono_nid = 0x19; |
| 4211 | spec->digbeep_nid = 0x21; |
| 4212 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 4213 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 4214 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 4215 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
| 4216 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 4217 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
| 4218 | spec->multiout.dac_nids = stac92hd83xxx_dac_nids; |
| 4219 | |
| 4220 | spec->init = stac92hd83xxx_core_init; |
| 4221 | switch (codec->vendor_id) { |
| 4222 | case 0x111d7605: |
| 4223 | spec->multiout.num_dacs = STAC92HD81_DAC_COUNT; |
| 4224 | break; |
| 4225 | default: |
| 4226 | spec->num_pwrs--; |
| 4227 | spec->init++; /* switch to config #2 */ |
| 4228 | spec->multiout.num_dacs = STAC92HD83_DAC_COUNT; |
| 4229 | } |
| 4230 | |
| 4231 | spec->mixer = stac92hd83xxx_mixer; |
| 4232 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 4233 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 4234 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
| 4235 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 4236 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 4237 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 4238 | spec->board_config = snd_hda_check_board_config(codec, |
| 4239 | STAC_92HD83XXX_MODELS, |
| 4240 | stac92hd83xxx_models, |
| 4241 | stac92hd83xxx_cfg_tbl); |
| 4242 | again: |
| 4243 | if (spec->board_config < 0) { |
| 4244 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4245 | " STAC92HD83XXX, using BIOS defaults\n"); |
| 4246 | err = stac92xx_save_bios_config_regs(codec); |
| 4247 | if (err < 0) { |
| 4248 | stac92xx_free(codec); |
| 4249 | return err; |
| 4250 | } |
| 4251 | spec->pin_configs = spec->bios_pin_configs; |
| 4252 | } else { |
| 4253 | spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config]; |
| 4254 | stac92xx_set_config_regs(codec); |
| 4255 | } |
| 4256 | |
| 4257 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 4258 | if (!err) { |
| 4259 | if (spec->board_config < 0) { |
| 4260 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4261 | "available, default to model=ref\n"); |
| 4262 | spec->board_config = STAC_92HD83XXX_REF; |
| 4263 | goto again; |
| 4264 | } |
| 4265 | err = -EINVAL; |
| 4266 | } |
| 4267 | |
| 4268 | if (err < 0) { |
| 4269 | stac92xx_free(codec); |
| 4270 | return err; |
| 4271 | } |
| 4272 | |
| 4273 | codec->patch_ops = stac92xx_patch_ops; |
| 4274 | |
| 4275 | return 0; |
| 4276 | } |
| 4277 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4278 | #ifdef SND_HDA_NEEDS_RESUME |
| 4279 | static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr) |
| 4280 | { |
| 4281 | struct sigmatel_spec *spec = codec->spec; |
| 4282 | int i; |
| 4283 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 4284 | AC_VERB_SET_POWER_STATE, pwr); |
| 4285 | |
| 4286 | msleep(1); |
| 4287 | for (i = 0; i < spec->num_adcs; i++) { |
| 4288 | snd_hda_codec_write_cache(codec, |
| 4289 | spec->adc_nids[i], 0, |
| 4290 | AC_VERB_SET_POWER_STATE, pwr); |
| 4291 | } |
| 4292 | }; |
| 4293 | |
| 4294 | static int stac92hd71xx_resume(struct hda_codec *codec) |
| 4295 | { |
| 4296 | stac92hd71xx_set_power_state(codec, AC_PWRST_D0); |
| 4297 | return stac92xx_resume(codec); |
| 4298 | } |
| 4299 | |
| 4300 | static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4301 | { |
| 4302 | stac92hd71xx_set_power_state(codec, AC_PWRST_D3); |
| 4303 | return 0; |
| 4304 | }; |
| 4305 | |
| 4306 | #endif |
| 4307 | |
| 4308 | static struct hda_codec_ops stac92hd71bxx_patch_ops = { |
| 4309 | .build_controls = stac92xx_build_controls, |
| 4310 | .build_pcms = stac92xx_build_pcms, |
| 4311 | .init = stac92xx_init, |
| 4312 | .free = stac92xx_free, |
| 4313 | .unsol_event = stac92xx_unsol_event, |
| 4314 | #ifdef SND_HDA_NEEDS_RESUME |
| 4315 | .resume = stac92hd71xx_resume, |
| 4316 | .suspend = stac92hd71xx_suspend, |
| 4317 | #endif |
| 4318 | }; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4319 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4320 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 4321 | { |
| 4322 | struct sigmatel_spec *spec; |
| 4323 | int err = 0; |
| 4324 | |
| 4325 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4326 | if (spec == NULL) |
| 4327 | return -ENOMEM; |
| 4328 | |
| 4329 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4330 | codec->patch_ops = stac92xx_patch_ops; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4331 | spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4332 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4333 | spec->pin_nids = stac92hd71bxx_pin_nids; |
| 4334 | spec->board_config = snd_hda_check_board_config(codec, |
| 4335 | STAC_92HD71BXX_MODELS, |
| 4336 | stac92hd71bxx_models, |
| 4337 | stac92hd71bxx_cfg_tbl); |
| 4338 | again: |
| 4339 | if (spec->board_config < 0) { |
| 4340 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4341 | " STAC92HD71BXX, using BIOS defaults\n"); |
| 4342 | err = stac92xx_save_bios_config_regs(codec); |
| 4343 | if (err < 0) { |
| 4344 | stac92xx_free(codec); |
| 4345 | return err; |
| 4346 | } |
| 4347 | spec->pin_configs = spec->bios_pin_configs; |
| 4348 | } else { |
| 4349 | spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config]; |
| 4350 | stac92xx_set_config_regs(codec); |
| 4351 | } |
| 4352 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4353 | switch (codec->vendor_id) { |
| 4354 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 4355 | case 0x111d76b7: |
| 4356 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 4357 | case 0x111d76b5: |
| 4358 | spec->mixer = stac92hd71bxx_mixer; |
| 4359 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4360 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4361 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4362 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4363 | if ((codec->revision_id & 0xf) == 0 || |
| 4364 | (codec->revision_id & 0xf) == 1) { |
| 4365 | #ifdef SND_HDA_NEEDS_RESUME |
| 4366 | codec->patch_ops = stac92hd71bxx_patch_ops; |
| 4367 | #endif |
| 4368 | spec->stream_delay = 40; /* 40 milliseconds */ |
| 4369 | } |
| 4370 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4371 | /* no output amps */ |
| 4372 | spec->num_pwrs = 0; |
| 4373 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 4374 | |
| 4375 | /* disable VSW */ |
| 4376 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
| 4377 | stac92xx_set_config_reg(codec, 0xf, 0x40f000f0); |
| 4378 | break; |
| 4379 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4380 | if ((codec->revision_id & 0xf) == 1) { |
| 4381 | #ifdef SND_HDA_NEEDS_RESUME |
| 4382 | codec->patch_ops = stac92hd71bxx_patch_ops; |
| 4383 | #endif |
| 4384 | spec->stream_delay = 40; /* 40 milliseconds */ |
| 4385 | } |
| 4386 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4387 | /* no output amps */ |
| 4388 | spec->num_pwrs = 0; |
| 4389 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4390 | default: |
| 4391 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 4392 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4393 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4394 | } |
| 4395 | |
| 4396 | spec->aloopback_mask = 0x20; |
| 4397 | spec->aloopback_shift = 0; |
| 4398 | |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4399 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 4400 | /* GPIO0 = EAPD */ |
| 4401 | spec->gpio_mask = 0x01; |
| 4402 | spec->gpio_dir = 0x01; |
| 4403 | spec->gpio_data = 0x01; |
| 4404 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4405 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4406 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4407 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4408 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 4409 | spec->adc_nids = stac92hd71bxx_adc_nids; |
| 4410 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4411 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4412 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4413 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4414 | |
| 4415 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 4416 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4417 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 4418 | switch (spec->board_config) { |
| 4419 | case STAC_HP_M4: |
| 4420 | spec->num_dmics = 0; |
Matthew Ranostay | b9aea715 | 2008-10-09 08:37:28 -0400 | [diff] [blame^] | 4421 | spec->num_smuxes = 0; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 4422 | spec->num_dmuxes = 0; |
| 4423 | |
| 4424 | /* enable internal microphone */ |
Matthew Ranostay | b9aea715 | 2008-10-09 08:37:28 -0400 | [diff] [blame^] | 4425 | stac92xx_set_config_reg(codec, 0x0e, 0x01813040); |
| 4426 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 4427 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 4428 | break; |
| 4429 | default: |
| 4430 | spec->num_dmics = STAC92HD71BXX_NUM_DMICS; |
| 4431 | spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids); |
| 4432 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 4433 | }; |
| 4434 | |
Takashi Iwai | aea7bb0 | 2008-02-25 18:26:41 +0100 | [diff] [blame] | 4435 | spec->multiout.num_dacs = 1; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4436 | spec->multiout.hp_nid = 0x11; |
| 4437 | spec->multiout.dac_nids = stac92hd71bxx_dac_nids; |
| 4438 | |
| 4439 | err = stac92xx_parse_auto_config(codec, 0x21, 0x23); |
| 4440 | if (!err) { |
| 4441 | if (spec->board_config < 0) { |
| 4442 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4443 | "available, default to model=ref\n"); |
| 4444 | spec->board_config = STAC_92HD71BXX_REF; |
| 4445 | goto again; |
| 4446 | } |
| 4447 | err = -EINVAL; |
| 4448 | } |
| 4449 | |
| 4450 | if (err < 0) { |
| 4451 | stac92xx_free(codec); |
| 4452 | return err; |
| 4453 | } |
| 4454 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4455 | return 0; |
| 4456 | }; |
| 4457 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4458 | static int patch_stac922x(struct hda_codec *codec) |
| 4459 | { |
| 4460 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4461 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4462 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4463 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4464 | if (spec == NULL) |
| 4465 | return -ENOMEM; |
| 4466 | |
| 4467 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4468 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4469 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4470 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 4471 | stac922x_models, |
| 4472 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 4473 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4474 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 4475 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 4476 | /* Intel Macs have all same PCI SSID, so we need to check |
| 4477 | * codec SSID to distinguish the exact models |
| 4478 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 4479 | 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] | 4480 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4481 | |
| 4482 | case 0x106b0800: |
| 4483 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 4484 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4485 | case 0x106b0600: |
| 4486 | case 0x106b0700: |
| 4487 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 4488 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4489 | case 0x106b0e00: |
| 4490 | case 0x106b0f00: |
| 4491 | case 0x106b1600: |
| 4492 | case 0x106b1700: |
| 4493 | case 0x106b0200: |
| 4494 | case 0x106b1e00: |
| 4495 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 4496 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4497 | case 0x106b1a00: |
| 4498 | case 0x00000100: |
| 4499 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 4500 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4501 | case 0x106b0a00: |
| 4502 | case 0x106b2200: |
| 4503 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 4504 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 4505 | default: |
| 4506 | spec->board_config = STAC_INTEL_MAC_V3; |
| 4507 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 4508 | } |
| 4509 | } |
| 4510 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4511 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4512 | if (spec->board_config < 0) { |
| 4513 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 4514 | "using BIOS defaults\n"); |
| 4515 | err = stac92xx_save_bios_config_regs(codec); |
| 4516 | if (err < 0) { |
| 4517 | stac92xx_free(codec); |
| 4518 | return err; |
| 4519 | } |
| 4520 | spec->pin_configs = spec->bios_pin_configs; |
| 4521 | } else if (stac922x_brd_tbl[spec->board_config] != NULL) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4522 | spec->pin_configs = stac922x_brd_tbl[spec->board_config]; |
| 4523 | stac92xx_set_config_regs(codec); |
| 4524 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4525 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4526 | spec->adc_nids = stac922x_adc_nids; |
| 4527 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 4528 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4529 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4530 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4531 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4532 | |
| 4533 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4534 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4535 | |
| 4536 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 4537 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4538 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4539 | if (!err) { |
| 4540 | if (spec->board_config < 0) { |
| 4541 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4542 | "available, default to model=ref\n"); |
| 4543 | spec->board_config = STAC_D945_REF; |
| 4544 | goto again; |
| 4545 | } |
| 4546 | err = -EINVAL; |
| 4547 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4548 | if (err < 0) { |
| 4549 | stac92xx_free(codec); |
| 4550 | return err; |
| 4551 | } |
| 4552 | |
| 4553 | codec->patch_ops = stac92xx_patch_ops; |
| 4554 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 4555 | /* Fix Mux capture level; max to 2 */ |
| 4556 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 4557 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 4558 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 4559 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 4560 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 4561 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4562 | return 0; |
| 4563 | } |
| 4564 | |
| 4565 | static int patch_stac927x(struct hda_codec *codec) |
| 4566 | { |
| 4567 | struct sigmatel_spec *spec; |
| 4568 | int err; |
| 4569 | |
| 4570 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4571 | if (spec == NULL) |
| 4572 | return -ENOMEM; |
| 4573 | |
| 4574 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4575 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4576 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4577 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 4578 | stac927x_models, |
| 4579 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4580 | again: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4581 | if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) { |
| 4582 | if (spec->board_config < 0) |
| 4583 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4584 | "STAC927x, using BIOS defaults\n"); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4585 | err = stac92xx_save_bios_config_regs(codec); |
| 4586 | if (err < 0) { |
| 4587 | stac92xx_free(codec); |
| 4588 | return err; |
| 4589 | } |
| 4590 | spec->pin_configs = spec->bios_pin_configs; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4591 | } else { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4592 | spec->pin_configs = stac927x_brd_tbl[spec->board_config]; |
| 4593 | stac92xx_set_config_regs(codec); |
| 4594 | } |
| 4595 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4596 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4597 | spec->adc_nids = stac927x_adc_nids; |
| 4598 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 4599 | spec->mux_nids = stac927x_mux_nids; |
| 4600 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4601 | spec->smux_nids = stac927x_smux_nids; |
| 4602 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4603 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4604 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4605 | spec->multiout.dac_nids = spec->dac_nids; |
| 4606 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 4607 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 4608 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4609 | case STAC_D965_5ST: |
| 4610 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4611 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4612 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4613 | spec->num_dmics = 0; |
| 4614 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 4615 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4616 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 4617 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4618 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 4619 | switch (codec->subsystem_id) { |
| 4620 | case 0x10280209: |
| 4621 | case 0x1028022e: |
| 4622 | /* correct the device field to SPDIF out */ |
| 4623 | stac92xx_set_config_reg(codec, 0x21, 0x01442070); |
| 4624 | break; |
| 4625 | }; |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 4626 | /* configure the analog microphone on some laptops */ |
| 4627 | stac92xx_set_config_reg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 4628 | /* correct the front output jack as a hp out */ |
Matthew Ranostay | 7989fba | 2008-02-21 07:50:12 +0100 | [diff] [blame] | 4629 | stac92xx_set_config_reg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 4630 | /* correct the front input jack as a mic */ |
| 4631 | stac92xx_set_config_reg(codec, 0x0e, 0x02a79130); |
| 4632 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4633 | case STAC_DELL_3ST: |
| 4634 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4635 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4636 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4637 | spec->dmic_nids = stac927x_dmic_nids; |
| 4638 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 4639 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 4640 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4641 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4642 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4643 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 4644 | break; |
| 4645 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4646 | if (spec->board_config > STAC_D965_REF) { |
| 4647 | /* GPIO0 High = Enable EAPD */ |
| 4648 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 4649 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 4650 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4651 | spec->num_dmics = 0; |
| 4652 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 4653 | spec->init = stac927x_core_init; |
| 4654 | spec->mixer = stac927x_mixer; |
| 4655 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4656 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4657 | spec->num_pwrs = 0; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4658 | spec->aloopback_mask = 0x40; |
| 4659 | spec->aloopback_shift = 0; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4660 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4661 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4662 | if (!err) { |
| 4663 | if (spec->board_config < 0) { |
| 4664 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4665 | "available, default to model=ref\n"); |
| 4666 | spec->board_config = STAC_D965_REF; |
| 4667 | goto again; |
| 4668 | } |
| 4669 | err = -EINVAL; |
| 4670 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4671 | if (err < 0) { |
| 4672 | stac92xx_free(codec); |
| 4673 | return err; |
| 4674 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4675 | |
| 4676 | codec->patch_ops = stac92xx_patch_ops; |
| 4677 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 4678 | /* |
| 4679 | * !!FIXME!! |
| 4680 | * The STAC927x seem to require fairly long delays for certain |
| 4681 | * command sequences. With too short delays (even if the answer |
| 4682 | * is set to RIRB properly), it results in the silence output |
| 4683 | * on some hardwares like Dell. |
| 4684 | * |
| 4685 | * The below flag enables the longer delay (see get_response |
| 4686 | * in hda_intel.c). |
| 4687 | */ |
| 4688 | codec->bus->needs_damn_long_delay = 1; |
| 4689 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4690 | return 0; |
| 4691 | } |
| 4692 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4693 | static int patch_stac9205(struct hda_codec *codec) |
| 4694 | { |
| 4695 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 4696 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4697 | |
| 4698 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4699 | if (spec == NULL) |
| 4700 | return -ENOMEM; |
| 4701 | |
| 4702 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4703 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4704 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4705 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 4706 | stac9205_models, |
| 4707 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4708 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4709 | if (spec->board_config < 0) { |
| 4710 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
| 4711 | err = stac92xx_save_bios_config_regs(codec); |
| 4712 | if (err < 0) { |
| 4713 | stac92xx_free(codec); |
| 4714 | return err; |
| 4715 | } |
| 4716 | spec->pin_configs = spec->bios_pin_configs; |
| 4717 | } else { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4718 | spec->pin_configs = stac9205_brd_tbl[spec->board_config]; |
| 4719 | stac92xx_set_config_regs(codec); |
| 4720 | } |
| 4721 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4722 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4723 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4724 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4725 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 4726 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4727 | spec->smux_nids = stac9205_smux_nids; |
| 4728 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4729 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4730 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4731 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4732 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4733 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4734 | |
| 4735 | spec->init = stac9205_core_init; |
| 4736 | spec->mixer = stac9205_mixer; |
| 4737 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4738 | spec->aloopback_mask = 0x40; |
| 4739 | spec->aloopback_shift = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4740 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 4741 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 4742 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 4743 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 4744 | /* Enable SPDIF in/out */ |
| 4745 | stac92xx_set_config_reg(codec, 0x1f, 0x01441030); |
| 4746 | stac92xx_set_config_reg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 4747 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4748 | /* Enable unsol response for GPIO4/Dock HP connection */ |
| 4749 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4750 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 4751 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 4752 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4753 | (AC_USRSP_EN | STAC_HP_EVENT)); |
| 4754 | |
| 4755 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4756 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4757 | spec->gpio_mask = 0x1b; |
| 4758 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 4759 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4760 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 4761 | */ |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4762 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 4763 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4764 | case STAC_9205_REF: |
| 4765 | /* SPDIF-In enabled */ |
| 4766 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 4767 | default: |
| 4768 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4769 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4770 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 4771 | break; |
| 4772 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 4773 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4774 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4775 | if (!err) { |
| 4776 | if (spec->board_config < 0) { |
| 4777 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4778 | "available, default to model=ref\n"); |
| 4779 | spec->board_config = STAC_9205_REF; |
| 4780 | goto again; |
| 4781 | } |
| 4782 | err = -EINVAL; |
| 4783 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 4784 | if (err < 0) { |
| 4785 | stac92xx_free(codec); |
| 4786 | return err; |
| 4787 | } |
| 4788 | |
| 4789 | codec->patch_ops = stac92xx_patch_ops; |
| 4790 | |
| 4791 | return 0; |
| 4792 | } |
| 4793 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4794 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4795 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4796 | */ |
| 4797 | |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 4798 | /* static config for Sony VAIO FE550G and Sony VAIO AR */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4799 | static hda_nid_t vaio_dacs[] = { 0x2 }; |
| 4800 | #define VAIO_HP_DAC 0x5 |
| 4801 | static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; |
| 4802 | static hda_nid_t vaio_mux_nids[] = { 0x15 }; |
| 4803 | |
| 4804 | static struct hda_input_mux vaio_mux = { |
Takashi Iwai | a3a2f42 | 2007-10-11 11:21:21 +0200 | [diff] [blame] | 4805 | .num_items = 3, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4806 | .items = { |
Takashi Iwai | d773781 | 2006-04-25 13:05:43 +0200 | [diff] [blame] | 4807 | /* { "HP", 0x0 }, */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 4808 | { "Mic Jack", 0x1 }, |
| 4809 | { "Internal Mic", 0x2 }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4810 | { "PCM", 0x3 }, |
| 4811 | } |
| 4812 | }; |
| 4813 | |
| 4814 | static struct hda_verb vaio_init[] = { |
| 4815 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 4816 | {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT}, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4817 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 4818 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 4819 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 4820 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 4821 | {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] | 4822 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 4823 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 4824 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 4825 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 4826 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 4827 | {} |
| 4828 | }; |
| 4829 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4830 | static struct hda_verb vaio_ar_init[] = { |
| 4831 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 4832 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 4833 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 4834 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 4835 | /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ |
| 4836 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 4837 | {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] | 4838 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 4839 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 4840 | /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ |
| 4841 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 4842 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 4843 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 4844 | {} |
| 4845 | }; |
| 4846 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4847 | /* bind volumes of both NID 0x02 and 0x05 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 4848 | static struct hda_bind_ctls vaio_bind_master_vol = { |
| 4849 | .ops = &snd_hda_bind_vol, |
| 4850 | .values = { |
| 4851 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 4852 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 4853 | 0 |
| 4854 | }, |
| 4855 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4856 | |
| 4857 | /* bind volumes of both NID 0x02 and 0x05 */ |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 4858 | static struct hda_bind_ctls vaio_bind_master_sw = { |
| 4859 | .ops = &snd_hda_bind_sw, |
| 4860 | .values = { |
| 4861 | HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT), |
| 4862 | HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT), |
| 4863 | 0, |
| 4864 | }, |
| 4865 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4866 | |
| 4867 | static struct snd_kcontrol_new vaio_mixer[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 4868 | HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), |
| 4869 | HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4870 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 4871 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 4872 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 4873 | { |
| 4874 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4875 | .name = "Capture Source", |
| 4876 | .count = 1, |
| 4877 | .info = stac92xx_mux_enum_info, |
| 4878 | .get = stac92xx_mux_enum_get, |
| 4879 | .put = stac92xx_mux_enum_put, |
| 4880 | }, |
| 4881 | {} |
| 4882 | }; |
| 4883 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4884 | static struct snd_kcontrol_new vaio_ar_mixer[] = { |
Takashi Iwai | cca3b37 | 2007-08-10 17:12:15 +0200 | [diff] [blame] | 4885 | HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol), |
| 4886 | HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw), |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4887 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 4888 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 4889 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 4890 | /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT), |
| 4891 | HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/ |
| 4892 | { |
| 4893 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4894 | .name = "Capture Source", |
| 4895 | .count = 1, |
| 4896 | .info = stac92xx_mux_enum_info, |
| 4897 | .get = stac92xx_mux_enum_get, |
| 4898 | .put = stac92xx_mux_enum_put, |
| 4899 | }, |
| 4900 | {} |
| 4901 | }; |
| 4902 | |
| 4903 | static struct hda_codec_ops stac9872_patch_ops = { |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4904 | .build_controls = stac92xx_build_controls, |
| 4905 | .build_pcms = stac92xx_build_pcms, |
| 4906 | .init = stac92xx_init, |
| 4907 | .free = stac92xx_free, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4908 | #ifdef SND_HDA_NEEDS_RESUME |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4909 | .resume = stac92xx_resume, |
| 4910 | #endif |
| 4911 | }; |
| 4912 | |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 4913 | static int stac9872_vaio_init(struct hda_codec *codec) |
| 4914 | { |
| 4915 | int err; |
| 4916 | |
| 4917 | err = stac92xx_init(codec); |
| 4918 | if (err < 0) |
| 4919 | return err; |
| 4920 | if (codec->patch_ops.unsol_event) |
| 4921 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 4922 | return 0; |
| 4923 | } |
| 4924 | |
| 4925 | static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) |
| 4926 | { |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 4927 | if (get_hp_pin_presence(codec, 0x0a)) { |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 4928 | stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
| 4929 | stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
| 4930 | } else { |
| 4931 | stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
| 4932 | stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
| 4933 | } |
| 4934 | } |
| 4935 | |
| 4936 | static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4937 | { |
| 4938 | switch (res >> 26) { |
| 4939 | case STAC_HP_EVENT: |
| 4940 | stac9872_vaio_hp_detect(codec, res); |
| 4941 | break; |
| 4942 | } |
| 4943 | } |
| 4944 | |
| 4945 | static struct hda_codec_ops stac9872_vaio_patch_ops = { |
| 4946 | .build_controls = stac92xx_build_controls, |
| 4947 | .build_pcms = stac92xx_build_pcms, |
| 4948 | .init = stac9872_vaio_init, |
| 4949 | .free = stac92xx_free, |
| 4950 | .unsol_event = stac9872_vaio_unsol_event, |
| 4951 | #ifdef CONFIG_PM |
| 4952 | .resume = stac92xx_resume, |
| 4953 | #endif |
| 4954 | }; |
| 4955 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4956 | enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ |
| 4957 | CXD9872RD_VAIO, |
| 4958 | /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ |
| 4959 | STAC9872AK_VAIO, |
| 4960 | /* Unknown. id=0x83847661 and subsys=0x104D1200. */ |
| 4961 | STAC9872K_VAIO, |
| 4962 | /* AR Series. id=0x83847664 and subsys=104D1300 */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4963 | CXD9872AKD_VAIO, |
| 4964 | STAC_9872_MODELS, |
| 4965 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4966 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4967 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 4968 | [CXD9872RD_VAIO] = "vaio", |
| 4969 | [CXD9872AKD_VAIO] = "vaio-ar", |
| 4970 | }; |
| 4971 | |
| 4972 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 4973 | SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 4974 | SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 4975 | SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), |
Tobin Davis | 68e2254 | 2007-03-12 11:36:39 +0100 | [diff] [blame] | 4976 | SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4977 | {} |
| 4978 | }; |
| 4979 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4980 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4981 | { |
| 4982 | struct sigmatel_spec *spec; |
| 4983 | int board_config; |
| 4984 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4985 | board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 4986 | stac9872_models, |
| 4987 | stac9872_cfg_tbl); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 4988 | if (board_config < 0) |
| 4989 | /* unknown config, let generic-parser do its job... */ |
| 4990 | return snd_hda_parse_generic_codec(codec); |
| 4991 | |
| 4992 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4993 | if (spec == NULL) |
| 4994 | return -ENOMEM; |
| 4995 | |
| 4996 | codec->spec = spec; |
| 4997 | switch (board_config) { |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 4998 | case CXD9872RD_VAIO: |
| 4999 | case STAC9872AK_VAIO: |
| 5000 | case STAC9872K_VAIO: |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5001 | spec->mixer = vaio_mixer; |
| 5002 | spec->init = vaio_init; |
| 5003 | spec->multiout.max_channels = 2; |
| 5004 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 5005 | spec->multiout.dac_nids = vaio_dacs; |
| 5006 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 5007 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 5008 | spec->adc_nids = vaio_adcs; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5009 | spec->num_pwrs = 0; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5010 | spec->input_mux = &vaio_mux; |
| 5011 | spec->mux_nids = vaio_mux_nids; |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5012 | codec->patch_ops = stac9872_vaio_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5013 | break; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5014 | |
| 5015 | case CXD9872AKD_VAIO: |
| 5016 | spec->mixer = vaio_ar_mixer; |
| 5017 | spec->init = vaio_ar_init; |
| 5018 | spec->multiout.max_channels = 2; |
| 5019 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 5020 | spec->multiout.dac_nids = vaio_dacs; |
| 5021 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 5022 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5023 | spec->num_pwrs = 0; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5024 | spec->adc_nids = vaio_adcs; |
| 5025 | spec->input_mux = &vaio_mux; |
| 5026 | spec->mux_nids = vaio_mux_nids; |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5027 | codec->patch_ops = stac9872_patch_ops; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5028 | break; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5029 | } |
| 5030 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5031 | return 0; |
| 5032 | } |
| 5033 | |
| 5034 | |
| 5035 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5036 | * patch entries |
| 5037 | */ |
| 5038 | struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
| 5039 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5040 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5041 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5042 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5043 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5044 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5045 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5046 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5047 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5048 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5049 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5050 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5051 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5052 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5053 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5054 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5055 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5056 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5057 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5058 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5059 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5060 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5061 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5062 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5063 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5064 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5065 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5066 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5067 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5068 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5069 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5070 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5071 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5072 | * currently not fully supported. |
| 5073 | */ |
| 5074 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5075 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5076 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5077 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5078 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5079 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5080 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5081 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5082 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5083 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5084 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5085 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5086 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5087 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5088 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5089 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5090 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5091 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5092 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5093 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5094 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5095 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5096 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5097 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5098 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5099 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5100 | {} /* terminator */ |
| 5101 | }; |