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