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" |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 36 | #include "hda_beep.h" |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 37 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 38 | enum { |
| 39 | STAC_VREF_EVENT = 1, |
| 40 | STAC_INSERT_EVENT, |
| 41 | STAC_PWR_EVENT, |
| 42 | STAC_HP_EVENT, |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 43 | STAC_LO_EVENT, |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 44 | STAC_MIC_EVENT, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 45 | }; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 46 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 47 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 48 | STAC_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 49 | STAC_REF, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 50 | STAC_9200_OQO, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 51 | STAC_9200_DELL_D21, |
| 52 | STAC_9200_DELL_D22, |
| 53 | STAC_9200_DELL_D23, |
| 54 | STAC_9200_DELL_M21, |
| 55 | STAC_9200_DELL_M22, |
| 56 | STAC_9200_DELL_M23, |
| 57 | STAC_9200_DELL_M24, |
| 58 | STAC_9200_DELL_M25, |
| 59 | STAC_9200_DELL_M26, |
| 60 | STAC_9200_DELL_M27, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 61 | STAC_9200_M4, |
| 62 | STAC_9200_M4_2, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 63 | STAC_9200_PANASONIC, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 64 | STAC_9200_MODELS |
| 65 | }; |
| 66 | |
| 67 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 68 | STAC_9205_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 69 | STAC_9205_REF, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 70 | STAC_9205_DELL_M42, |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 71 | STAC_9205_DELL_M43, |
| 72 | STAC_9205_DELL_M44, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 73 | STAC_9205_EAPD, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 74 | STAC_9205_MODELS |
| 75 | }; |
| 76 | |
| 77 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 78 | STAC_92HD73XX_AUTO, |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 79 | STAC_92HD73XX_NO_JD, /* no jack-detection */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 80 | STAC_92HD73XX_REF, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 81 | STAC_DELL_M6_AMIC, |
| 82 | STAC_DELL_M6_DMIC, |
| 83 | STAC_DELL_M6_BOTH, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 84 | STAC_DELL_EQ, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 85 | STAC_92HD73XX_MODELS |
| 86 | }; |
| 87 | |
| 88 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 89 | STAC_92HD83XXX_AUTO, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 90 | STAC_92HD83XXX_REF, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 91 | STAC_92HD83XXX_PWR_REF, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 92 | STAC_DELL_S14, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 93 | STAC_92HD83XXX_MODELS |
| 94 | }; |
| 95 | |
| 96 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 97 | STAC_92HD71BXX_AUTO, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 98 | STAC_92HD71BXX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 99 | STAC_DELL_M4_1, |
| 100 | STAC_DELL_M4_2, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 101 | STAC_DELL_M4_3, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 102 | STAC_HP_M4, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 103 | STAC_HP_DV5, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 104 | STAC_HP_HDX, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 105 | STAC_HP_DV4_1222NR, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 106 | STAC_92HD71BXX_MODELS |
| 107 | }; |
| 108 | |
| 109 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 110 | STAC_925x_AUTO, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 111 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 112 | STAC_M1, |
| 113 | STAC_M1_2, |
| 114 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 115 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 116 | STAC_M3, |
| 117 | STAC_M5, |
| 118 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 119 | STAC_925x_MODELS |
| 120 | }; |
| 121 | |
| 122 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 123 | STAC_922X_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 124 | STAC_D945_REF, |
| 125 | STAC_D945GTP3, |
| 126 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 127 | STAC_INTEL_MAC_V1, |
| 128 | STAC_INTEL_MAC_V2, |
| 129 | STAC_INTEL_MAC_V3, |
| 130 | STAC_INTEL_MAC_V4, |
| 131 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 132 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 133 | * is given, one of the above models will be |
| 134 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 135 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 136 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 137 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 138 | STAC_MACBOOK_PRO_V1, |
| 139 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 140 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 141 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 142 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 143 | STAC_922X_DELL_D81, |
| 144 | STAC_922X_DELL_D82, |
| 145 | STAC_922X_DELL_M81, |
| 146 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 147 | STAC_922X_MODELS |
| 148 | }; |
| 149 | |
| 150 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 151 | STAC_927X_AUTO, |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 152 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 153 | STAC_D965_REF, |
| 154 | STAC_D965_3ST, |
| 155 | STAC_D965_5ST, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 156 | STAC_D965_5ST_NO_FP, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 157 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 158 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 159 | STAC_927X_MODELS |
| 160 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 161 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 162 | enum { |
| 163 | STAC_9872_AUTO, |
| 164 | STAC_9872_VAIO, |
| 165 | STAC_9872_MODELS |
| 166 | }; |
| 167 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 168 | struct sigmatel_event { |
| 169 | hda_nid_t nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 170 | unsigned char type; |
| 171 | unsigned char tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 172 | int data; |
| 173 | }; |
| 174 | |
| 175 | struct sigmatel_jack { |
| 176 | hda_nid_t nid; |
| 177 | int type; |
| 178 | struct snd_jack *jack; |
| 179 | }; |
| 180 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 181 | struct sigmatel_mic_route { |
| 182 | hda_nid_t pin; |
| 183 | unsigned char mux_idx; |
| 184 | unsigned char dmux_idx; |
| 185 | }; |
| 186 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 187 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 188 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 189 | unsigned int num_mixers; |
| 190 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 191 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 192 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 193 | unsigned int surr_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 194 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 195 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 196 | unsigned int spdif_mute: 1; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 197 | unsigned int check_volume_offset:1; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 198 | unsigned int auto_mic:1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 199 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 200 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 201 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 202 | unsigned int gpio_mask; |
| 203 | unsigned int gpio_dir; |
| 204 | unsigned int gpio_data; |
| 205 | unsigned int gpio_mute; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 206 | unsigned int gpio_led; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 207 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 208 | /* stream */ |
| 209 | unsigned int stream_delay; |
| 210 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 211 | /* analog loopback */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 212 | struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 213 | unsigned char aloopback_mask; |
| 214 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 215 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 216 | /* power management */ |
| 217 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 218 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 219 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 220 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 221 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 222 | /* jack detection */ |
| 223 | struct snd_array jacks; |
| 224 | |
| 225 | /* events */ |
| 226 | struct snd_array events; |
| 227 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 228 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 229 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 230 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 231 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 232 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 233 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 234 | hda_nid_t hp_dacs[5]; |
| 235 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 236 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 237 | int volume_offset; |
| 238 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 239 | /* capture */ |
| 240 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 241 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 242 | hda_nid_t *mux_nids; |
| 243 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 244 | hda_nid_t *dmic_nids; |
| 245 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 246 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 247 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 248 | hda_nid_t *smux_nids; |
| 249 | unsigned int num_smuxes; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 250 | |
| 251 | unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ |
| 252 | unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ |
| 253 | unsigned int num_caps; /* number of capture volume/switch elements */ |
| 254 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 255 | struct sigmatel_mic_route ext_mic; |
| 256 | struct sigmatel_mic_route int_mic; |
| 257 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 258 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 259 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 260 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 261 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 262 | hda_nid_t anabeep_nid; |
| 263 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 264 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 265 | /* pin widgets */ |
| 266 | hda_nid_t *pin_nids; |
| 267 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 268 | |
| 269 | /* codec specific stuff */ |
| 270 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 271 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 272 | |
| 273 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 274 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 275 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 276 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 277 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 278 | struct hda_input_mux *sinput_mux; |
| 279 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 280 | unsigned int cur_amux; |
| 281 | hda_nid_t *amp_nids; |
| 282 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 283 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 284 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 285 | /* i/o switches */ |
| 286 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 287 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 288 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 289 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 290 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 291 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 292 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 293 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 294 | |
| 295 | /* dynamic controls and input_mux */ |
| 296 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 297 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 298 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 299 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 300 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 301 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 302 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | static hda_nid_t stac9200_adc_nids[1] = { |
| 306 | 0x03, |
| 307 | }; |
| 308 | |
| 309 | static hda_nid_t stac9200_mux_nids[1] = { |
| 310 | 0x0c, |
| 311 | }; |
| 312 | |
| 313 | static hda_nid_t stac9200_dac_nids[1] = { |
| 314 | 0x02, |
| 315 | }; |
| 316 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 317 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 318 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 319 | 0x0f, 0x10, 0x11 |
| 320 | }; |
| 321 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 322 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 323 | 0x26, 0, |
| 324 | }; |
| 325 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 326 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 327 | 0x1a, 0x1b |
| 328 | }; |
| 329 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 330 | #define DELL_M6_AMP 2 |
| 331 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 332 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 333 | }; |
| 334 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 335 | #define STAC92HD73XX_NUM_DMICS 2 |
| 336 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 337 | 0x13, 0x14, 0 |
| 338 | }; |
| 339 | |
| 340 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 341 | |
| 342 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 343 | 0x28, 0x29, 0x2a, 0x2b, |
| 344 | }; |
| 345 | |
| 346 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 347 | 0x20, 0x21, |
| 348 | }; |
| 349 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 350 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 351 | 0x22, 0x23, |
| 352 | }; |
| 353 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 354 | #define STAC92HD73XX_NUM_CAPS 2 |
| 355 | static unsigned long stac92hd73xx_capvols[] = { |
| 356 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
| 357 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 358 | }; |
| 359 | #define stac92hd73xx_capsws stac92hd73xx_capvols |
| 360 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 361 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 362 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 363 | 0x11, 0x12, 0 |
| 364 | }; |
| 365 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 366 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 367 | |
| 368 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 369 | 0x17, 0x18, |
| 370 | }; |
| 371 | |
| 372 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 373 | 0x15, 0x16, |
| 374 | }; |
| 375 | |
| 376 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 377 | 0xa, 0xb, 0xd, 0xe, |
| 378 | }; |
| 379 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 380 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 381 | 0x1e, 0, |
| 382 | }; |
| 383 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 384 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 385 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 386 | }; |
| 387 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 388 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 389 | 0xc, |
| 390 | }; |
| 391 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 392 | #define STAC92HD83XXX_NUM_CAPS 2 |
| 393 | static unsigned long stac92hd83xxx_capvols[] = { |
| 394 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), |
| 395 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), |
| 396 | }; |
| 397 | #define stac92hd83xxx_capsws stac92hd83xxx_capvols |
| 398 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 399 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 400 | 0x0a, 0x0d, 0x0f |
| 401 | }; |
| 402 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 403 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 404 | 0x12, 0x13, |
| 405 | }; |
| 406 | |
| 407 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 408 | 0x1a, 0x1b |
| 409 | }; |
| 410 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 411 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 412 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 413 | }; |
| 414 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 415 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 416 | 0x24, 0x25, |
| 417 | }; |
| 418 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 419 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 420 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 421 | 0x18, 0x19, 0 |
| 422 | }; |
| 423 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 424 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 425 | 0x22, 0 |
| 426 | }; |
| 427 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 428 | #define STAC92HD71BXX_NUM_CAPS 2 |
| 429 | static unsigned long stac92hd71bxx_capvols[] = { |
| 430 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 431 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 432 | }; |
| 433 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols |
| 434 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 435 | static hda_nid_t stac925x_adc_nids[1] = { |
| 436 | 0x03, |
| 437 | }; |
| 438 | |
| 439 | static hda_nid_t stac925x_mux_nids[1] = { |
| 440 | 0x0f, |
| 441 | }; |
| 442 | |
| 443 | static hda_nid_t stac925x_dac_nids[1] = { |
| 444 | 0x02, |
| 445 | }; |
| 446 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 447 | #define STAC925X_NUM_DMICS 1 |
| 448 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 449 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 450 | }; |
| 451 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 452 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 453 | 0x14, |
| 454 | }; |
| 455 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 456 | static unsigned long stac925x_capvols[] = { |
| 457 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), |
| 458 | }; |
| 459 | static unsigned long stac925x_capsws[] = { |
| 460 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 461 | }; |
| 462 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 463 | static hda_nid_t stac922x_adc_nids[2] = { |
| 464 | 0x06, 0x07, |
| 465 | }; |
| 466 | |
| 467 | static hda_nid_t stac922x_mux_nids[2] = { |
| 468 | 0x12, 0x13, |
| 469 | }; |
| 470 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 471 | #define STAC922X_NUM_CAPS 2 |
| 472 | static unsigned long stac922x_capvols[] = { |
| 473 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), |
| 474 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 475 | }; |
| 476 | #define stac922x_capsws stac922x_capvols |
| 477 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 478 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 479 | 0x1f, 0, |
| 480 | }; |
| 481 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 482 | static hda_nid_t stac927x_adc_nids[3] = { |
| 483 | 0x07, 0x08, 0x09 |
| 484 | }; |
| 485 | |
| 486 | static hda_nid_t stac927x_mux_nids[3] = { |
| 487 | 0x15, 0x16, 0x17 |
| 488 | }; |
| 489 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 490 | static hda_nid_t stac927x_smux_nids[1] = { |
| 491 | 0x21, |
| 492 | }; |
| 493 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 494 | static hda_nid_t stac927x_dac_nids[6] = { |
| 495 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 496 | }; |
| 497 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 498 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 499 | 0x1b, |
| 500 | }; |
| 501 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 502 | #define STAC927X_NUM_DMICS 2 |
| 503 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 504 | 0x13, 0x14, 0 |
| 505 | }; |
| 506 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 507 | #define STAC927X_NUM_CAPS 3 |
| 508 | static unsigned long stac927x_capvols[] = { |
| 509 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 510 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), |
| 511 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), |
| 512 | }; |
| 513 | static unsigned long stac927x_capsws[] = { |
| 514 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 515 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 516 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 517 | }; |
| 518 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 519 | static const char *stac927x_spdif_labels[5] = { |
| 520 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 521 | "Analog Mux 2", "Analog Mux 3" |
| 522 | }; |
| 523 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 524 | static hda_nid_t stac9205_adc_nids[2] = { |
| 525 | 0x12, 0x13 |
| 526 | }; |
| 527 | |
| 528 | static hda_nid_t stac9205_mux_nids[2] = { |
| 529 | 0x19, 0x1a |
| 530 | }; |
| 531 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 532 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 533 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 534 | }; |
| 535 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 536 | static hda_nid_t stac9205_smux_nids[1] = { |
| 537 | 0x21, |
| 538 | }; |
| 539 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 540 | #define STAC9205_NUM_DMICS 2 |
| 541 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 542 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 543 | }; |
| 544 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 545 | #define STAC9205_NUM_CAPS 2 |
| 546 | static unsigned long stac9205_capvols[] = { |
| 547 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), |
| 548 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), |
| 549 | }; |
| 550 | static unsigned long stac9205_capsws[] = { |
| 551 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 552 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), |
| 553 | }; |
| 554 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 555 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 556 | 0x08, 0x09, 0x0d, 0x0e, |
| 557 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 558 | }; |
| 559 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 560 | static hda_nid_t stac925x_pin_nids[8] = { |
| 561 | 0x07, 0x08, 0x0a, 0x0b, |
| 562 | 0x0c, 0x0d, 0x10, 0x11, |
| 563 | }; |
| 564 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 565 | static hda_nid_t stac922x_pin_nids[10] = { |
| 566 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 567 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 568 | }; |
| 569 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 570 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 571 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 572 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 573 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 574 | }; |
| 575 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 576 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 577 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 578 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 579 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 580 | |
| 581 | #define STAC92HD71BXX_NUM_PINS 13 |
| 582 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 583 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 584 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 585 | 0x1f, 0x20, 0x27 |
| 586 | }; |
| 587 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 588 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 589 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 590 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 591 | }; |
| 592 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 593 | static hda_nid_t stac927x_pin_nids[14] = { |
| 594 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 595 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 596 | 0x14, 0x21, 0x22, 0x23, |
| 597 | }; |
| 598 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 599 | static hda_nid_t stac9205_pin_nids[12] = { |
| 600 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 601 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 602 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 603 | }; |
| 604 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 605 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 606 | |
| 607 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 608 | struct snd_ctl_elem_value *ucontrol) |
| 609 | { |
| 610 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 611 | struct sigmatel_spec *spec = codec->spec; |
| 612 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 613 | |
| 614 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 615 | kcontrol->private_value |= nid; |
| 616 | |
| 617 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 618 | } |
| 619 | |
| 620 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 621 | struct snd_ctl_elem_value *ucontrol) |
| 622 | { |
| 623 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 624 | struct sigmatel_spec *spec = codec->spec; |
| 625 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 626 | |
| 627 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 628 | kcontrol->private_value |= nid; |
| 629 | |
| 630 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 631 | } |
| 632 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 633 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 634 | struct snd_ctl_elem_info *uinfo) |
| 635 | { |
| 636 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 637 | struct sigmatel_spec *spec = codec->spec; |
| 638 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 639 | } |
| 640 | |
| 641 | static int stac92xx_dmux_enum_get(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; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 646 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 647 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 648 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 653 | struct snd_ctl_elem_value *ucontrol) |
| 654 | { |
| 655 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 656 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 657 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 658 | |
| 659 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 660 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 661 | } |
| 662 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 663 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 664 | struct snd_ctl_elem_info *uinfo) |
| 665 | { |
| 666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 667 | struct sigmatel_spec *spec = codec->spec; |
| 668 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 669 | } |
| 670 | |
| 671 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 672 | struct snd_ctl_elem_value *ucontrol) |
| 673 | { |
| 674 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 675 | struct sigmatel_spec *spec = codec->spec; |
| 676 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 677 | |
| 678 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 679 | return 0; |
| 680 | } |
| 681 | |
| 682 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 683 | struct snd_ctl_elem_value *ucontrol) |
| 684 | { |
| 685 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 686 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 687 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 688 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 689 | int err, val; |
| 690 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 691 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 692 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 693 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 694 | if (err < 0) |
| 695 | return err; |
| 696 | |
| 697 | if (spec->spdif_mute) { |
| 698 | if (smux_idx == 0) |
| 699 | nid = spec->multiout.dig_out_nid; |
| 700 | else |
| 701 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 702 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 703 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 704 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 705 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 706 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 707 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 708 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 709 | } |
| 710 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 711 | } |
| 712 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 713 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 714 | hda_nid_t nid, unsigned int new_vref) |
| 715 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 716 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 717 | unsigned int pincfg; |
| 718 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 719 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 720 | |
| 721 | pincfg &= 0xff; |
| 722 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 723 | pincfg |= new_vref; |
| 724 | |
| 725 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 726 | pincfg |= AC_PINCTL_OUT_EN; |
| 727 | else |
| 728 | pincfg |= AC_PINCTL_IN_EN; |
| 729 | |
| 730 | error = snd_hda_codec_write_cache(codec, nid, 0, |
| 731 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); |
| 732 | if (error < 0) |
| 733 | return error; |
| 734 | else |
| 735 | return 1; |
| 736 | } |
| 737 | |
| 738 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 739 | { |
| 740 | unsigned int vref; |
| 741 | vref = snd_hda_codec_read(codec, nid, 0, |
| 742 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 743 | vref &= AC_PINCTL_VREFEN; |
| 744 | return vref; |
| 745 | } |
| 746 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 747 | 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] | 748 | { |
| 749 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 750 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 751 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 752 | } |
| 753 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 754 | 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] | 755 | { |
| 756 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 757 | struct sigmatel_spec *spec = codec->spec; |
| 758 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 759 | |
| 760 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 761 | return 0; |
| 762 | } |
| 763 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 764 | 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] | 765 | { |
| 766 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 767 | struct sigmatel_spec *spec = codec->spec; |
| 768 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 769 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 770 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 771 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 772 | } |
| 773 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 774 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 775 | struct snd_ctl_elem_info *uinfo) |
| 776 | { |
| 777 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 778 | struct sigmatel_spec *spec = codec->spec; |
| 779 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 780 | } |
| 781 | |
| 782 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 783 | struct snd_ctl_elem_value *ucontrol) |
| 784 | { |
| 785 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 786 | struct sigmatel_spec *spec = codec->spec; |
| 787 | |
| 788 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 789 | return 0; |
| 790 | } |
| 791 | |
| 792 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 793 | struct snd_ctl_elem_value *ucontrol) |
| 794 | { |
| 795 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 796 | struct sigmatel_spec *spec = codec->spec; |
| 797 | |
| 798 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 799 | spec->mono_nid, &spec->cur_mmux); |
| 800 | } |
| 801 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 802 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 803 | struct snd_ctl_elem_info *uinfo) |
| 804 | { |
| 805 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 806 | struct sigmatel_spec *spec = codec->spec; |
| 807 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 808 | } |
| 809 | |
| 810 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 811 | struct snd_ctl_elem_value *ucontrol) |
| 812 | { |
| 813 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 814 | struct sigmatel_spec *spec = codec->spec; |
| 815 | |
| 816 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 821 | struct snd_ctl_elem_value *ucontrol) |
| 822 | { |
| 823 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 824 | struct sigmatel_spec *spec = codec->spec; |
| 825 | struct snd_kcontrol *ctl = |
| 826 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 827 | if (!ctl) |
| 828 | return -EINVAL; |
| 829 | |
| 830 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 831 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 832 | |
| 833 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 834 | 0, &spec->cur_amux); |
| 835 | } |
| 836 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 837 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 838 | |
| 839 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 840 | struct snd_ctl_elem_value *ucontrol) |
| 841 | { |
| 842 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 843 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 844 | struct sigmatel_spec *spec = codec->spec; |
| 845 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 846 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 847 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 848 | return 0; |
| 849 | } |
| 850 | |
| 851 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 852 | struct snd_ctl_elem_value *ucontrol) |
| 853 | { |
| 854 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 855 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 856 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 857 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 858 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 859 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 860 | idx_val = spec->aloopback_mask << idx; |
| 861 | if (ucontrol->value.integer.value[0]) |
| 862 | val = spec->aloopback | idx_val; |
| 863 | else |
| 864 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 865 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 866 | return 0; |
| 867 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 868 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 869 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 870 | /* Only return the bits defined by the shift value of the |
| 871 | * first two bytes of the mask |
| 872 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 873 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 874 | kcontrol->private_value & 0xFFFF, 0x0); |
| 875 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 876 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 877 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 878 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 879 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 880 | } else { |
| 881 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 882 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 886 | kcontrol->private_value >> 16, dac_mode); |
| 887 | |
| 888 | return 1; |
| 889 | } |
| 890 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 891 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 892 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 893 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 894 | {} |
| 895 | }; |
| 896 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 897 | static struct hda_verb stac9200_eapd_init[] = { |
| 898 | /* set dac0mux for dac converter */ |
| 899 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 900 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 901 | {} |
| 902 | }; |
| 903 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 904 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 905 | /* set master volume and direct control */ |
| 906 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 907 | /* setup adcs to point to mixer */ |
| 908 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 909 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 910 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 911 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 912 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 913 | /* setup import muxs */ |
| 914 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 915 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 916 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 917 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 918 | {} |
| 919 | }; |
| 920 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 921 | static struct hda_verb dell_eq_core_init[] = { |
| 922 | /* set master volume to max value without distortion |
| 923 | * and direct control */ |
| 924 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 925 | /* setup adcs to point to mixer */ |
| 926 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 927 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 928 | /* setup import muxs */ |
| 929 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 930 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 931 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 932 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 933 | {} |
| 934 | }; |
| 935 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 936 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 937 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 938 | /* setup adcs to point to mixer */ |
| 939 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 940 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 941 | /* setup import muxs */ |
| 942 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 943 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 944 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 945 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 946 | {} |
| 947 | }; |
| 948 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 949 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 950 | /* set master volume and direct control */ |
| 951 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 952 | /* setup adcs to point to mixer */ |
| 953 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 954 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 955 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 956 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 957 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 958 | /* setup import muxs */ |
| 959 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 960 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 961 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 962 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 963 | {} |
| 964 | }; |
| 965 | |
| 966 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 967 | /* set master volume and direct control */ |
| 968 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 969 | /* dac3 is connected to import3 mux */ |
| 970 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 971 | /* setup adcs to point to mixer */ |
| 972 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 973 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 974 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 975 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 976 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 977 | /* setup import muxs */ |
| 978 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 979 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 980 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 981 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 982 | {} |
| 983 | }; |
| 984 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 985 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 986 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 987 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 988 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 989 | |
| 990 | /* power state controls amps */ |
| 991 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 992 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 993 | }; |
| 994 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 995 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 996 | /* set master volume and direct control */ |
| 997 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 998 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 999 | }; |
| 1000 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 1001 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 1002 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 1003 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1004 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1005 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1006 | {} |
| 1007 | }; |
| 1008 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1009 | static struct hda_verb stac925x_core_init[] = { |
| 1010 | /* set dac0mux for dac converter */ |
| 1011 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1012 | /* mute the master volume */ |
| 1013 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1014 | {} |
| 1015 | }; |
| 1016 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1017 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1018 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1019 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1020 | {} |
| 1021 | }; |
| 1022 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1023 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1024 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1025 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1026 | /* unmute node 0x1b */ |
| 1027 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1028 | /* select node 0x03 as DAC */ |
| 1029 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1030 | {} |
| 1031 | }; |
| 1032 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1033 | static struct hda_verb stac927x_core_init[] = { |
| 1034 | /* set master volume and direct control */ |
| 1035 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1036 | /* enable analog pc beep path */ |
| 1037 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1038 | {} |
| 1039 | }; |
| 1040 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1041 | static struct hda_verb stac9205_core_init[] = { |
| 1042 | /* set master volume and direct control */ |
| 1043 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1044 | /* enable analog pc beep path */ |
| 1045 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1046 | {} |
| 1047 | }; |
| 1048 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 1049 | #define STAC_MONO_MUX \ |
| 1050 | { \ |
| 1051 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1052 | .name = "Mono Mux", \ |
| 1053 | .count = 1, \ |
| 1054 | .info = stac92xx_mono_mux_enum_info, \ |
| 1055 | .get = stac92xx_mono_mux_enum_get, \ |
| 1056 | .put = stac92xx_mono_mux_enum_put, \ |
| 1057 | } |
| 1058 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 1059 | #define STAC_AMP_MUX \ |
| 1060 | { \ |
| 1061 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1062 | .name = "Amp Selector Capture Switch", \ |
| 1063 | .count = 1, \ |
| 1064 | .info = stac92xx_amp_mux_enum_info, \ |
| 1065 | .get = stac92xx_amp_mux_enum_get, \ |
| 1066 | .put = stac92xx_amp_mux_enum_put, \ |
| 1067 | } |
| 1068 | |
| 1069 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 1070 | { \ |
| 1071 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1072 | .name = xname, \ |
| 1073 | .index = 0, \ |
| 1074 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1075 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1076 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 1077 | .info = stac92xx_amp_volume_info, \ |
| 1078 | .get = stac92xx_amp_volume_get, \ |
| 1079 | .put = stac92xx_amp_volume_put, \ |
| 1080 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 1081 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 1082 | } |
| 1083 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1084 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1085 | { \ |
| 1086 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1087 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1088 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1089 | .info = stac92xx_aloopback_info, \ |
| 1090 | .get = stac92xx_aloopback_get, \ |
| 1091 | .put = stac92xx_aloopback_put, \ |
| 1092 | .private_value = verb_read | (verb_write << 16), \ |
| 1093 | } |
| 1094 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1095 | #define DC_BIAS(xname, idx, nid) \ |
| 1096 | { \ |
| 1097 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1098 | .name = xname, \ |
| 1099 | .index = idx, \ |
| 1100 | .info = stac92xx_dc_bias_info, \ |
| 1101 | .get = stac92xx_dc_bias_get, \ |
| 1102 | .put = stac92xx_dc_bias_put, \ |
| 1103 | .private_value = nid, \ |
| 1104 | } |
| 1105 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1106 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1107 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1108 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1109 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1110 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1111 | { } /* end */ |
| 1112 | }; |
| 1113 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1114 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1115 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1116 | /* start of config #1 */ |
| 1117 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1118 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1119 | |
| 1120 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1121 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1122 | |
| 1123 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1124 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1125 | |
| 1126 | /* start of config #2 */ |
| 1127 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1128 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1129 | |
| 1130 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1131 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1132 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1133 | { } /* end */ |
| 1134 | }; |
| 1135 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1136 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1137 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1138 | {} |
| 1139 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1140 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1141 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1142 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1143 | {} |
| 1144 | }; |
| 1145 | |
| 1146 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1147 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1148 | {} |
| 1149 | }; |
| 1150 | |
| 1151 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1152 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1153 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1154 | |
| 1155 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1156 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1157 | |
| 1158 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1159 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1160 | |
| 1161 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1162 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1163 | |
| 1164 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1165 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1166 | { } /* end */ |
| 1167 | }; |
| 1168 | |
| 1169 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1170 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1171 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1172 | |
| 1173 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1174 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1175 | |
| 1176 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1177 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1178 | |
| 1179 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1180 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1181 | |
| 1182 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1183 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1184 | { } /* end */ |
| 1185 | }; |
| 1186 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1187 | |
| 1188 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1189 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1190 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1191 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1192 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1193 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1194 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1195 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1196 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1197 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1198 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1199 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1200 | |
| 1201 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1202 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1203 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1204 | */ |
| 1205 | { } /* end */ |
| 1206 | }; |
| 1207 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1208 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1209 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1210 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1211 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1212 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1213 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1214 | |
| 1215 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1216 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1217 | |
| 1218 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1219 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1220 | { } /* end */ |
| 1221 | }; |
| 1222 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1223 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1224 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1225 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1226 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1227 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1228 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1229 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1230 | { } /* end */ |
| 1231 | }; |
| 1232 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1233 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1234 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1235 | {} |
| 1236 | }; |
| 1237 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1238 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1239 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1240 | {} |
| 1241 | }; |
| 1242 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1243 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1244 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1245 | .name = "Digital Input Source", |
| 1246 | /* count set later */ |
| 1247 | .info = stac92xx_dmux_enum_info, |
| 1248 | .get = stac92xx_dmux_enum_get, |
| 1249 | .put = stac92xx_dmux_enum_put, |
| 1250 | }; |
| 1251 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1252 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1253 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1254 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1255 | /* count set later */ |
| 1256 | .info = stac92xx_smux_enum_info, |
| 1257 | .get = stac92xx_smux_enum_get, |
| 1258 | .put = stac92xx_smux_enum_put, |
| 1259 | }; |
| 1260 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1261 | static const char *slave_vols[] = { |
| 1262 | "Front Playback Volume", |
| 1263 | "Surround Playback Volume", |
| 1264 | "Center Playback Volume", |
| 1265 | "LFE Playback Volume", |
| 1266 | "Side Playback Volume", |
| 1267 | "Headphone Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1268 | "Speaker Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1269 | NULL |
| 1270 | }; |
| 1271 | |
| 1272 | static const char *slave_sws[] = { |
| 1273 | "Front Playback Switch", |
| 1274 | "Surround Playback Switch", |
| 1275 | "Center Playback Switch", |
| 1276 | "LFE Playback Switch", |
| 1277 | "Side Playback Switch", |
| 1278 | "Headphone Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1279 | "Speaker Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1280 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1281 | NULL |
| 1282 | }; |
| 1283 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1284 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1285 | 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] | 1286 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1287 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1288 | { |
| 1289 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1290 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1291 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1292 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1293 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1294 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 1295 | if (spec->mixer) { |
| 1296 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1297 | if (err < 0) |
| 1298 | return err; |
| 1299 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1300 | |
| 1301 | for (i = 0; i < spec->num_mixers; i++) { |
| 1302 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1303 | if (err < 0) |
| 1304 | return err; |
| 1305 | } |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 1306 | if (!spec->auto_mic && spec->num_dmuxes > 0) { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1307 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1308 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1309 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1310 | if (err < 0) |
| 1311 | return err; |
| 1312 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1313 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1314 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1315 | struct hda_input_mux *smux = &spec->private_smux; |
| 1316 | /* check for mute support on SPDIF out */ |
| 1317 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1318 | smux->items[smux->num_items].label = "Off"; |
| 1319 | smux->items[smux->num_items].index = 0; |
| 1320 | smux->num_items++; |
| 1321 | spec->spdif_mute = 1; |
| 1322 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1323 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1324 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1325 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1326 | if (err < 0) |
| 1327 | return err; |
| 1328 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1329 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1330 | if (spec->multiout.dig_out_nid) { |
| 1331 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1332 | if (err < 0) |
| 1333 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1334 | err = snd_hda_create_spdif_share_sw(codec, |
| 1335 | &spec->multiout); |
| 1336 | if (err < 0) |
| 1337 | return err; |
| 1338 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1339 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1340 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1341 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1342 | if (err < 0) |
| 1343 | return err; |
| 1344 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1345 | |
| 1346 | /* if we have no master control, let's create it */ |
| 1347 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1348 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1349 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1350 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1351 | /* correct volume offset */ |
| 1352 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1353 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1354 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1355 | if (err < 0) |
| 1356 | return err; |
| 1357 | } |
| 1358 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1359 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1360 | NULL, slave_sws); |
| 1361 | if (err < 0) |
| 1362 | return err; |
| 1363 | } |
| 1364 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1365 | if (spec->aloopback_ctl && |
| 1366 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1367 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1368 | if (err < 0) |
| 1369 | return err; |
| 1370 | } |
| 1371 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1372 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1373 | |
| 1374 | /* create jack input elements */ |
| 1375 | if (spec->hp_detect) { |
| 1376 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1377 | int type = SND_JACK_HEADPHONE; |
| 1378 | nid = cfg->hp_pins[i]; |
| 1379 | /* jack detection */ |
| 1380 | if (cfg->hp_outs == i) |
| 1381 | type |= SND_JACK_LINEOUT; |
| 1382 | err = stac92xx_add_jack(codec, nid, type); |
| 1383 | if (err < 0) |
| 1384 | return err; |
| 1385 | } |
| 1386 | } |
| 1387 | for (i = 0; i < cfg->line_outs; i++) { |
| 1388 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1389 | SND_JACK_LINEOUT); |
| 1390 | if (err < 0) |
| 1391 | return err; |
| 1392 | } |
| 1393 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1394 | nid = cfg->input_pins[i]; |
| 1395 | if (nid) { |
| 1396 | err = stac92xx_add_jack(codec, nid, |
| 1397 | SND_JACK_MICROPHONE); |
| 1398 | if (err < 0) |
| 1399 | return err; |
| 1400 | } |
| 1401 | } |
| 1402 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1403 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1404 | } |
| 1405 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1406 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1407 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1408 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1409 | }; |
| 1410 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1411 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1412 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1413 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1414 | }; |
| 1415 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1416 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1417 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1418 | }; |
| 1419 | |
| 1420 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1421 | STAC 9200 pin configs for |
| 1422 | 102801A8 |
| 1423 | 102801DE |
| 1424 | 102801E8 |
| 1425 | */ |
| 1426 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1427 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1428 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1429 | }; |
| 1430 | |
| 1431 | /* |
| 1432 | STAC 9200 pin configs for |
| 1433 | 102801C0 |
| 1434 | 102801C1 |
| 1435 | */ |
| 1436 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1437 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1438 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1439 | }; |
| 1440 | |
| 1441 | /* |
| 1442 | STAC 9200 pin configs for |
| 1443 | 102801C4 (Dell Dimension E310) |
| 1444 | 102801C5 |
| 1445 | 102801C7 |
| 1446 | 102801D9 |
| 1447 | 102801DA |
| 1448 | 102801E3 |
| 1449 | */ |
| 1450 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1451 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1452 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1453 | }; |
| 1454 | |
| 1455 | |
| 1456 | /* |
| 1457 | STAC 9200-32 pin configs for |
| 1458 | 102801B5 (Dell Inspiron 630m) |
| 1459 | 102801D8 (Dell Inspiron 640m) |
| 1460 | */ |
| 1461 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1462 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1463 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1464 | }; |
| 1465 | |
| 1466 | /* |
| 1467 | STAC 9200-32 pin configs for |
| 1468 | 102801C2 (Dell Latitude D620) |
| 1469 | 102801C8 |
| 1470 | 102801CC (Dell Latitude D820) |
| 1471 | 102801D4 |
| 1472 | 102801D6 |
| 1473 | */ |
| 1474 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1475 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1476 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1477 | }; |
| 1478 | |
| 1479 | /* |
| 1480 | STAC 9200-32 pin configs for |
| 1481 | 102801CE (Dell XPS M1710) |
| 1482 | 102801CF (Dell Precision M90) |
| 1483 | */ |
| 1484 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1485 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1486 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1487 | }; |
| 1488 | |
| 1489 | /* |
| 1490 | STAC 9200-32 pin configs for |
| 1491 | 102801C9 |
| 1492 | 102801CA |
| 1493 | 102801CB (Dell Latitude 120L) |
| 1494 | 102801D3 |
| 1495 | */ |
| 1496 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1497 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1498 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1499 | }; |
| 1500 | |
| 1501 | /* |
| 1502 | STAC 9200-32 pin configs for |
| 1503 | 102801BD (Dell Inspiron E1505n) |
| 1504 | 102801EE |
| 1505 | 102801EF |
| 1506 | */ |
| 1507 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1508 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1509 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1510 | }; |
| 1511 | |
| 1512 | /* |
| 1513 | STAC 9200-32 pin configs for |
| 1514 | 102801F5 (Dell Inspiron 1501) |
| 1515 | 102801F6 |
| 1516 | */ |
| 1517 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1518 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1519 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1520 | }; |
| 1521 | |
| 1522 | /* |
| 1523 | STAC 9200-32 |
| 1524 | 102801CD (Dell Inspiron E1705/9400) |
| 1525 | */ |
| 1526 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1527 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1528 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1529 | }; |
| 1530 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1531 | static unsigned int oqo9200_pin_configs[8] = { |
| 1532 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1533 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1534 | }; |
| 1535 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1536 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1537 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1538 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1539 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1540 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1541 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1542 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1543 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1544 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1545 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1546 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1547 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1548 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1549 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1550 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1551 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1552 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1553 | }; |
| 1554 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1555 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1556 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1557 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1558 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1559 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1560 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1561 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1562 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1563 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1564 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1565 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1566 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1567 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1568 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1569 | [STAC_9200_M4] = "gateway-m4", |
| 1570 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1571 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1572 | }; |
| 1573 | |
| 1574 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1575 | /* SigmaTel reference board */ |
| 1576 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1577 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1578 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1579 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1580 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1581 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1582 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1583 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1584 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1585 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1586 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1587 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1588 | "unknown Dell", STAC_9200_DELL_D22), |
| 1589 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1590 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1591 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1592 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1593 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1594 | "unknown Dell", STAC_9200_DELL_D23), |
| 1595 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1596 | "unknown Dell", STAC_9200_DELL_D23), |
| 1597 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1598 | "unknown Dell", STAC_9200_DELL_M22), |
| 1599 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1600 | "unknown Dell", STAC_9200_DELL_M24), |
| 1601 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1602 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1603 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1604 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1605 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1606 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1607 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1608 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1609 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1610 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1611 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1612 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1613 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1614 | "unknown Dell", STAC_9200_DELL_M22), |
| 1615 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1616 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1617 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1618 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1619 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1620 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1621 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1622 | "unknown Dell", STAC_9200_DELL_D23), |
| 1623 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1624 | "unknown Dell", STAC_9200_DELL_D23), |
| 1625 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1626 | "unknown Dell", STAC_9200_DELL_D21), |
| 1627 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1628 | "unknown Dell", STAC_9200_DELL_D23), |
| 1629 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1630 | "unknown Dell", STAC_9200_DELL_D21), |
| 1631 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1632 | "unknown Dell", STAC_9200_DELL_M25), |
| 1633 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1634 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1635 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1636 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1637 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1638 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1639 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1640 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1641 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1642 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1643 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1644 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1645 | /* OQO Mobile */ |
| 1646 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1647 | {} /* terminator */ |
| 1648 | }; |
| 1649 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1650 | static unsigned int ref925x_pin_configs[8] = { |
| 1651 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1652 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1653 | }; |
| 1654 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1655 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1656 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1657 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1658 | }; |
| 1659 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1660 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1661 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1662 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1663 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1664 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1665 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1666 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1667 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1668 | }; |
| 1669 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1670 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1671 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1672 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1673 | }; |
| 1674 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1675 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1676 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1677 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1678 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1679 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1681 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1682 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1683 | }; |
| 1684 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1685 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1686 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1687 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1688 | }; |
| 1689 | |
| 1690 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1691 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1692 | [STAC_M1] = stac925xM1_pin_configs, |
| 1693 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1694 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1695 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1696 | [STAC_M3] = stac925xM3_pin_configs, |
| 1697 | [STAC_M5] = stac925xM5_pin_configs, |
| 1698 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1699 | }; |
| 1700 | |
| 1701 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1702 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1703 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1704 | [STAC_M1] = "m1", |
| 1705 | [STAC_M1_2] = "m1-2", |
| 1706 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1707 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1708 | [STAC_M3] = "m3", |
| 1709 | [STAC_M5] = "m5", |
| 1710 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1711 | }; |
| 1712 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1713 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1714 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1715 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1716 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1717 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1718 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1719 | /* Not sure about the brand name for those */ |
| 1720 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1721 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1722 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1723 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1724 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1725 | }; |
| 1726 | |
| 1727 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1728 | /* SigmaTel reference board */ |
| 1729 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1730 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1731 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1732 | |
| 1733 | /* Default table for unknown ID */ |
| 1734 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1735 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1736 | {} /* terminator */ |
| 1737 | }; |
| 1738 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1739 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1740 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1741 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1742 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1743 | 0x01452050, |
| 1744 | }; |
| 1745 | |
| 1746 | static unsigned int dell_m6_pin_configs[13] = { |
| 1747 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1748 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1749 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1750 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1751 | }; |
| 1752 | |
| 1753 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1754 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1755 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1756 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1757 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1758 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1759 | }; |
| 1760 | |
| 1761 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1762 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1763 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1764 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1765 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1766 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1767 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1768 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1769 | }; |
| 1770 | |
| 1771 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1772 | /* SigmaTel reference board */ |
| 1773 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1774 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1775 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1776 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1777 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1778 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1779 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1780 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1781 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1782 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1783 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1784 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1785 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1786 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1787 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1788 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1789 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1790 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1791 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1792 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1793 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1794 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1795 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1796 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Takashi Iwai | 626f5ce | 2009-07-28 00:54:39 +0200 | [diff] [blame] | 1797 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, |
| 1798 | "Dell Studio 1555", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1799 | {} /* terminator */ |
| 1800 | }; |
| 1801 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1802 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1803 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1804 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1805 | 0x01451160, 0x98560170, |
| 1806 | }; |
| 1807 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1808 | static unsigned int dell_s14_pin_configs[10] = { |
| 1809 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1810 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1811 | 0x40f000f0, 0x40f000f0, |
| 1812 | }; |
| 1813 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1814 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1815 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1816 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1817 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1818 | }; |
| 1819 | |
| 1820 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1821 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1822 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1823 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1824 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1825 | }; |
| 1826 | |
| 1827 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1828 | /* SigmaTel reference board */ |
| 1829 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1830 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1831 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1832 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1833 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1834 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1835 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1836 | }; |
| 1837 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1838 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1839 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1840 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1841 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1842 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1843 | }; |
| 1844 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1845 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1846 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1847 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1848 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1849 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1850 | }; |
| 1851 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1852 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1853 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1854 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1855 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1856 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1857 | }; |
| 1858 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1859 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1860 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1861 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1862 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1863 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1864 | }; |
| 1865 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1866 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1867 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1868 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1869 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1870 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1871 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1872 | [STAC_HP_DV5] = NULL, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1873 | [STAC_HP_HDX] = NULL, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1874 | [STAC_HP_DV4_1222NR] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1875 | }; |
| 1876 | |
| 1877 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1878 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1879 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1880 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1881 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1882 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1883 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1884 | [STAC_HP_DV5] = "hp-dv5", |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1885 | [STAC_HP_HDX] = "hp-hdx", |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1886 | [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1887 | }; |
| 1888 | |
| 1889 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1890 | /* SigmaTel reference board */ |
| 1891 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1892 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1893 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1894 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1895 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 1896 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1897 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 1898 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1899 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1900 | "HP dv4-7", STAC_HP_DV5), |
| 1901 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1902 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1903 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 1904 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1905 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1906 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1907 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1908 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Takashi Iwai | 1972d02 | 2009-08-06 08:44:43 +0200 | [diff] [blame] | 1909 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, |
| 1910 | "HP", STAC_HP_DV5), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1911 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1912 | "unknown Dell", STAC_DELL_M4_1), |
| 1913 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1914 | "unknown Dell", STAC_DELL_M4_1), |
| 1915 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1916 | "unknown Dell", STAC_DELL_M4_1), |
| 1917 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1918 | "unknown Dell", STAC_DELL_M4_1), |
| 1919 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1920 | "unknown Dell", STAC_DELL_M4_1), |
| 1921 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1922 | "unknown Dell", STAC_DELL_M4_1), |
| 1923 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1924 | "unknown Dell", STAC_DELL_M4_1), |
| 1925 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1926 | "unknown Dell", STAC_DELL_M4_2), |
| 1927 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1928 | "unknown Dell", STAC_DELL_M4_2), |
| 1929 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1930 | "unknown Dell", STAC_DELL_M4_2), |
| 1931 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1932 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1933 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1934 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1935 | {} /* terminator */ |
| 1936 | }; |
| 1937 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1938 | static unsigned int ref922x_pin_configs[10] = { |
| 1939 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1940 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1941 | 0x40000100, 0x40000100, |
| 1942 | }; |
| 1943 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1944 | /* |
| 1945 | STAC 922X pin configs for |
| 1946 | 102801A7 |
| 1947 | 102801AB |
| 1948 | 102801A9 |
| 1949 | 102801D1 |
| 1950 | 102801D2 |
| 1951 | */ |
| 1952 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1953 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1954 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1955 | 0x01813122, 0x400001f2, |
| 1956 | }; |
| 1957 | |
| 1958 | /* |
| 1959 | STAC 922X pin configs for |
| 1960 | 102801AC |
| 1961 | 102801D0 |
| 1962 | */ |
| 1963 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1964 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1965 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1966 | 0x01813122, 0x400001f1, |
| 1967 | }; |
| 1968 | |
| 1969 | /* |
| 1970 | STAC 922X pin configs for |
| 1971 | 102801BF |
| 1972 | */ |
| 1973 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1974 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1975 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1976 | 0x40C003f1, 0x405003f0, |
| 1977 | }; |
| 1978 | |
| 1979 | /* |
| 1980 | STAC 9221 A1 pin configs for |
| 1981 | 102801D7 (Dell XPS M1210) |
| 1982 | */ |
| 1983 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1984 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1985 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1986 | 0x508003f3, 0x405003f4, |
| 1987 | }; |
| 1988 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1989 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1990 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1991 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1992 | 0x02a19120, 0x40000100, |
| 1993 | }; |
| 1994 | |
| 1995 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1996 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1997 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1998 | 0x02a19320, 0x40000100, |
| 1999 | }; |
| 2000 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2001 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 2002 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 2003 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2004 | 0x400000fc, 0x400000fb, |
| 2005 | }; |
| 2006 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2007 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 2008 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2009 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2010 | 0x400000fc, 0x400000fb, |
| 2011 | }; |
| 2012 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2013 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 2014 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2015 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 2016 | 0x400000fc, 0x400000fb, |
| 2017 | }; |
| 2018 | |
| 2019 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 2020 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2021 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2022 | 0x400000fc, 0x400000fb, |
| 2023 | }; |
| 2024 | |
| 2025 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 2026 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2027 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2028 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2029 | }; |
| 2030 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2031 | static unsigned int ecs202_pin_configs[10] = { |
| 2032 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 2033 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 2034 | 0x9037012e, 0x40e000f2, |
| 2035 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2036 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2037 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2038 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2039 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 2040 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2041 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 2042 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 2043 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 2044 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 2045 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2046 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2047 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2048 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 2049 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2050 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2051 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2052 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2053 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2054 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2055 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2056 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2057 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2058 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2059 | }; |
| 2060 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2061 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2062 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2063 | [STAC_D945_REF] = "ref", |
| 2064 | [STAC_D945GTP5] = "5stack", |
| 2065 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2066 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2067 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2068 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2069 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2070 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2071 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2072 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2073 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2074 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2075 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2076 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2077 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2078 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2079 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2080 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2081 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2082 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2083 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2084 | }; |
| 2085 | |
| 2086 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2087 | /* SigmaTel reference board */ |
| 2088 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2089 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2090 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2091 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2092 | /* Intel 945G based systems */ |
| 2093 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2094 | "Intel D945G", STAC_D945GTP3), |
| 2095 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2096 | "Intel D945G", STAC_D945GTP3), |
| 2097 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2098 | "Intel D945G", STAC_D945GTP3), |
| 2099 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2100 | "Intel D945G", STAC_D945GTP3), |
| 2101 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2102 | "Intel D945G", STAC_D945GTP3), |
| 2103 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2104 | "Intel D945G", STAC_D945GTP3), |
| 2105 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2106 | "Intel D945G", STAC_D945GTP3), |
| 2107 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2108 | "Intel D945G", STAC_D945GTP3), |
| 2109 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2110 | "Intel D945G", STAC_D945GTP3), |
| 2111 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2112 | "Intel D945G", STAC_D945GTP3), |
| 2113 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2114 | "Intel D945G", STAC_D945GTP3), |
| 2115 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2116 | "Intel D945G", STAC_D945GTP3), |
| 2117 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2118 | "Intel D945G", STAC_D945GTP3), |
| 2119 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2120 | "Intel D945G", STAC_D945GTP3), |
| 2121 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2122 | "Intel D945G", STAC_D945GTP3), |
| 2123 | /* Intel D945G 5-stack systems */ |
| 2124 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2125 | "Intel D945G", STAC_D945GTP5), |
| 2126 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2127 | "Intel D945G", STAC_D945GTP5), |
| 2128 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2129 | "Intel D945G", STAC_D945GTP5), |
| 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2131 | "Intel D945G", STAC_D945GTP5), |
| 2132 | /* Intel 945P based systems */ |
| 2133 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2134 | "Intel D945P", STAC_D945GTP3), |
| 2135 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2136 | "Intel D945P", STAC_D945GTP3), |
| 2137 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2138 | "Intel D945P", STAC_D945GTP3), |
| 2139 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2140 | "Intel D945P", STAC_D945GTP3), |
| 2141 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2142 | "Intel D945P", STAC_D945GTP3), |
| 2143 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2144 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2145 | /* other intel */ |
| 2146 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2147 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2148 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2149 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2150 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2151 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2152 | /* Dell systems */ |
| 2153 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2154 | "unknown Dell", STAC_922X_DELL_D81), |
| 2155 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2156 | "unknown Dell", STAC_922X_DELL_D81), |
| 2157 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2158 | "unknown Dell", STAC_922X_DELL_D81), |
| 2159 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2160 | "unknown Dell", STAC_922X_DELL_D82), |
| 2161 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2162 | "unknown Dell", STAC_922X_DELL_M81), |
| 2163 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2164 | "unknown Dell", STAC_922X_DELL_D82), |
| 2165 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2166 | "unknown Dell", STAC_922X_DELL_D81), |
| 2167 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2168 | "unknown Dell", STAC_922X_DELL_D81), |
| 2169 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2170 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2171 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2172 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2173 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2174 | {} /* terminator */ |
| 2175 | }; |
| 2176 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2177 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2178 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2179 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2180 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2181 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2182 | }; |
| 2183 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2184 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2185 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2186 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2187 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2188 | 0x40000100, 0x40000100 |
| 2189 | }; |
| 2190 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2191 | static unsigned int d965_5st_pin_configs[14] = { |
| 2192 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2193 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2194 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2195 | 0x40000100, 0x40000100 |
| 2196 | }; |
| 2197 | |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2198 | static unsigned int d965_5st_no_fp_pin_configs[14] = { |
| 2199 | 0x40000100, 0x40000100, 0x0181304e, 0x01014010, |
| 2200 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2201 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2202 | 0x40000100, 0x40000100 |
| 2203 | }; |
| 2204 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2205 | static unsigned int dell_3st_pin_configs[14] = { |
| 2206 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2207 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2208 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2209 | 0x40c003fc, 0x40000100 |
| 2210 | }; |
| 2211 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2212 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2213 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2214 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2215 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2216 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2217 | [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2218 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2219 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2220 | }; |
| 2221 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2222 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2223 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2224 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2225 | [STAC_D965_REF] = "ref", |
| 2226 | [STAC_D965_3ST] = "3stack", |
| 2227 | [STAC_D965_5ST] = "5stack", |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2228 | [STAC_D965_5ST_NO_FP] = "5stack-no-fp", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2229 | [STAC_DELL_3ST] = "dell-3stack", |
| 2230 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2231 | }; |
| 2232 | |
| 2233 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2234 | /* SigmaTel reference board */ |
| 2235 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2236 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2237 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2238 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2239 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2240 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2241 | 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] | 2242 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2243 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2244 | "Intel D965", STAC_D965_3ST), |
| 2245 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2246 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2247 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2248 | 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] | 2249 | 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] | 2250 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2251 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2252 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2253 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2254 | 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] | 2255 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 2256 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2257 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2258 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2259 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2260 | 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] | 2261 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2262 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2263 | "Intel D965", STAC_D965_5ST), |
| 2264 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2265 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2266 | {} /* terminator */ |
| 2267 | }; |
| 2268 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2269 | static unsigned int ref9205_pin_configs[12] = { |
| 2270 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2271 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2272 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2273 | }; |
| 2274 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2275 | /* |
| 2276 | STAC 9205 pin configs for |
| 2277 | 102801F1 |
| 2278 | 102801F2 |
| 2279 | 102801FC |
| 2280 | 102801FD |
| 2281 | 10280204 |
| 2282 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2283 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2284 | */ |
| 2285 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2286 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2287 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2288 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2289 | }; |
| 2290 | |
| 2291 | /* |
| 2292 | STAC 9205 pin configs for |
| 2293 | 102801F9 |
| 2294 | 102801FA |
| 2295 | 102801FE |
| 2296 | 102801FF (Dell Precision M4300) |
| 2297 | 10280206 |
| 2298 | 10280200 |
| 2299 | 10280201 |
| 2300 | */ |
| 2301 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2302 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2303 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2304 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2305 | }; |
| 2306 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2307 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2308 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2309 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2310 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2311 | }; |
| 2312 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2313 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2314 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2315 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2316 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2317 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2318 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2319 | }; |
| 2320 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2321 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2322 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2323 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2324 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2325 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2326 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2327 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2328 | }; |
| 2329 | |
| 2330 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2331 | /* SigmaTel reference board */ |
| 2332 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2333 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 2334 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 2335 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2336 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2337 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2338 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2339 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2340 | "unknown Dell", STAC_9205_DELL_M42), |
| 2341 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2342 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2343 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2344 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2345 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2346 | "Dell Precision", STAC_9205_DELL_M43), |
| 2347 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2348 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2349 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2350 | "unknown Dell", STAC_9205_DELL_M42), |
| 2351 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2352 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2353 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2354 | "Dell Precision", STAC_9205_DELL_M43), |
| 2355 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2356 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2357 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2358 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2359 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2360 | "Dell Precision", STAC_9205_DELL_M43), |
| 2361 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2362 | "Dell Precision", STAC_9205_DELL_M43), |
| 2363 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2364 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2365 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2366 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2367 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2368 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2369 | /* Gateway */ |
Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 2370 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2371 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2372 | {} /* terminator */ |
| 2373 | }; |
| 2374 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2375 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2376 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2377 | { |
| 2378 | int i; |
| 2379 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2380 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2381 | if (!pincfgs) |
| 2382 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2383 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2384 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2385 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2386 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2387 | pincfgs[i]); |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2388 | } |
| 2389 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2390 | /* |
| 2391 | * Analog playback callbacks |
| 2392 | */ |
| 2393 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2394 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2395 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2396 | { |
| 2397 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2398 | if (spec->stream_delay) |
| 2399 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2400 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2401 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2402 | } |
| 2403 | |
| 2404 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2405 | struct hda_codec *codec, |
| 2406 | unsigned int stream_tag, |
| 2407 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2408 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2409 | { |
| 2410 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2411 | 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] | 2412 | } |
| 2413 | |
| 2414 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2415 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2416 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2417 | { |
| 2418 | struct sigmatel_spec *spec = codec->spec; |
| 2419 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2420 | } |
| 2421 | |
| 2422 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2423 | * Digital playback callbacks |
| 2424 | */ |
| 2425 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2426 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2427 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2428 | { |
| 2429 | struct sigmatel_spec *spec = codec->spec; |
| 2430 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2431 | } |
| 2432 | |
| 2433 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2434 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2435 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2436 | { |
| 2437 | struct sigmatel_spec *spec = codec->spec; |
| 2438 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2439 | } |
| 2440 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2441 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2442 | struct hda_codec *codec, |
| 2443 | unsigned int stream_tag, |
| 2444 | unsigned int format, |
| 2445 | struct snd_pcm_substream *substream) |
| 2446 | { |
| 2447 | struct sigmatel_spec *spec = codec->spec; |
| 2448 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2449 | stream_tag, format, substream); |
| 2450 | } |
| 2451 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2452 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2453 | struct hda_codec *codec, |
| 2454 | struct snd_pcm_substream *substream) |
| 2455 | { |
| 2456 | struct sigmatel_spec *spec = codec->spec; |
| 2457 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2458 | } |
| 2459 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2460 | |
| 2461 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2462 | * Analog capture callbacks |
| 2463 | */ |
| 2464 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2465 | struct hda_codec *codec, |
| 2466 | unsigned int stream_tag, |
| 2467 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2468 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2469 | { |
| 2470 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2471 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2472 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2473 | if (spec->powerdown_adcs) { |
| 2474 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2475 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2476 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2477 | } |
| 2478 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2479 | return 0; |
| 2480 | } |
| 2481 | |
| 2482 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2483 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2484 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2485 | { |
| 2486 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2487 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2488 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2489 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2490 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2491 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2492 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2493 | return 0; |
| 2494 | } |
| 2495 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2496 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2497 | .substreams = 1, |
| 2498 | .channels_min = 2, |
| 2499 | .channels_max = 2, |
| 2500 | /* NID is set in stac92xx_build_pcms */ |
| 2501 | .ops = { |
| 2502 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2503 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2504 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2505 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2506 | }, |
| 2507 | }; |
| 2508 | |
| 2509 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2510 | .substreams = 1, |
| 2511 | .channels_min = 2, |
| 2512 | .channels_max = 2, |
| 2513 | /* NID is set in stac92xx_build_pcms */ |
| 2514 | }; |
| 2515 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2516 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2517 | .substreams = 1, |
| 2518 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2519 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2520 | .nid = 0x02, /* NID to query formats and rates */ |
| 2521 | .ops = { |
| 2522 | .open = stac92xx_playback_pcm_open, |
| 2523 | .prepare = stac92xx_playback_pcm_prepare, |
| 2524 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2525 | }, |
| 2526 | }; |
| 2527 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2528 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2529 | .substreams = 1, |
| 2530 | .channels_min = 2, |
| 2531 | .channels_max = 2, |
| 2532 | .nid = 0x06, /* NID to query formats and rates */ |
| 2533 | .ops = { |
| 2534 | .open = stac92xx_playback_pcm_open, |
| 2535 | .prepare = stac92xx_playback_pcm_prepare, |
| 2536 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2537 | }, |
| 2538 | }; |
| 2539 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2540 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2541 | .channels_min = 2, |
| 2542 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2543 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2544 | .ops = { |
| 2545 | .prepare = stac92xx_capture_pcm_prepare, |
| 2546 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2547 | }, |
| 2548 | }; |
| 2549 | |
| 2550 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2551 | { |
| 2552 | struct sigmatel_spec *spec = codec->spec; |
| 2553 | struct hda_pcm *info = spec->pcm_rec; |
| 2554 | |
| 2555 | codec->num_pcms = 1; |
| 2556 | codec->pcm_info = info; |
| 2557 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2558 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2559 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2560 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2561 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2562 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2563 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2564 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2565 | |
| 2566 | if (spec->alt_switch) { |
| 2567 | codec->num_pcms++; |
| 2568 | info++; |
| 2569 | info->name = "STAC92xx Analog Alt"; |
| 2570 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2571 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2572 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2573 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2574 | codec->num_pcms++; |
| 2575 | info++; |
| 2576 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2577 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2578 | if (spec->multiout.dig_out_nid) { |
| 2579 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2580 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2581 | } |
| 2582 | if (spec->dig_in_nid) { |
| 2583 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2584 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2585 | } |
| 2586 | } |
| 2587 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2588 | return 0; |
| 2589 | } |
| 2590 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2591 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, |
| 2592 | hda_nid_t nid) |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2593 | { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2594 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2595 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2596 | if (pincap & AC_PINCAP_VREF_100) |
| 2597 | return AC_PINCTL_VREF_100; |
| 2598 | if (pincap & AC_PINCAP_VREF_80) |
| 2599 | return AC_PINCTL_VREF_80; |
| 2600 | if (pincap & AC_PINCAP_VREF_50) |
| 2601 | return AC_PINCTL_VREF_50; |
| 2602 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2603 | return AC_PINCTL_VREF_GRD; |
| 2604 | return 0; |
| 2605 | } |
| 2606 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2607 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2608 | |
| 2609 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2610 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2611 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2612 | } |
| 2613 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2614 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2615 | |
| 2616 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2617 | struct snd_ctl_elem_value *ucontrol) |
| 2618 | { |
| 2619 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2620 | struct sigmatel_spec *spec = codec->spec; |
| 2621 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2622 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2623 | return 0; |
| 2624 | } |
| 2625 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2626 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2627 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2628 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2629 | struct snd_ctl_elem_value *ucontrol) |
| 2630 | { |
| 2631 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2632 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2633 | int nid = kcontrol->private_value; |
| 2634 | |
| 2635 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2636 | |
| 2637 | /* check to be sure that the ports are upto date with |
| 2638 | * switch changes |
| 2639 | */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2640 | stac_issue_unsol_event(codec, nid); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2641 | |
| 2642 | return 1; |
| 2643 | } |
| 2644 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2645 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 2646 | struct snd_ctl_elem_info *uinfo) |
| 2647 | { |
| 2648 | int i; |
| 2649 | static char *texts[] = { |
| 2650 | "Mic In", "Line In", "Line Out" |
| 2651 | }; |
| 2652 | |
| 2653 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2654 | struct sigmatel_spec *spec = codec->spec; |
| 2655 | hda_nid_t nid = kcontrol->private_value; |
| 2656 | |
| 2657 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 2658 | i = 3; |
| 2659 | else |
| 2660 | i = 2; |
| 2661 | |
| 2662 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2663 | uinfo->value.enumerated.items = i; |
| 2664 | uinfo->count = 1; |
| 2665 | if (uinfo->value.enumerated.item >= i) |
| 2666 | uinfo->value.enumerated.item = i-1; |
| 2667 | strcpy(uinfo->value.enumerated.name, |
| 2668 | texts[uinfo->value.enumerated.item]); |
| 2669 | |
| 2670 | return 0; |
| 2671 | } |
| 2672 | |
| 2673 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 2674 | struct snd_ctl_elem_value *ucontrol) |
| 2675 | { |
| 2676 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2677 | hda_nid_t nid = kcontrol->private_value; |
| 2678 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 2679 | |
| 2680 | if (vref == stac92xx_get_default_vref(codec, nid)) |
| 2681 | ucontrol->value.enumerated.item[0] = 0; |
| 2682 | else if (vref == AC_PINCTL_VREF_GRD) |
| 2683 | ucontrol->value.enumerated.item[0] = 1; |
| 2684 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 2685 | ucontrol->value.enumerated.item[0] = 2; |
| 2686 | |
| 2687 | return 0; |
| 2688 | } |
| 2689 | |
| 2690 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 2691 | struct snd_ctl_elem_value *ucontrol) |
| 2692 | { |
| 2693 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2694 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 2695 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2696 | hda_nid_t nid = kcontrol->private_value; |
| 2697 | |
| 2698 | if (ucontrol->value.enumerated.item[0] == 0) |
| 2699 | new_vref = stac92xx_get_default_vref(codec, nid); |
| 2700 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 2701 | new_vref = AC_PINCTL_VREF_GRD; |
| 2702 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 2703 | new_vref = AC_PINCTL_VREF_HIZ; |
| 2704 | else |
| 2705 | return 0; |
| 2706 | |
| 2707 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 2708 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 2709 | return error; |
| 2710 | } |
| 2711 | |
| 2712 | return 0; |
| 2713 | } |
| 2714 | |
| 2715 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 2716 | struct snd_ctl_elem_info *uinfo) |
| 2717 | { |
| 2718 | static char *texts[2]; |
| 2719 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2720 | struct sigmatel_spec *spec = codec->spec; |
| 2721 | |
| 2722 | if (kcontrol->private_value == spec->line_switch) |
| 2723 | texts[0] = "Line In"; |
| 2724 | else |
| 2725 | texts[0] = "Mic In"; |
| 2726 | texts[1] = "Line Out"; |
| 2727 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2728 | uinfo->value.enumerated.items = 2; |
| 2729 | uinfo->count = 1; |
| 2730 | |
| 2731 | if (uinfo->value.enumerated.item >= 2) |
| 2732 | uinfo->value.enumerated.item = 1; |
| 2733 | strcpy(uinfo->value.enumerated.name, |
| 2734 | texts[uinfo->value.enumerated.item]); |
| 2735 | |
| 2736 | return 0; |
| 2737 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2738 | |
| 2739 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2740 | { |
| 2741 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2742 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2743 | hda_nid_t nid = kcontrol->private_value; |
| 2744 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2745 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2746 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2747 | return 0; |
| 2748 | } |
| 2749 | |
| 2750 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2751 | { |
| 2752 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2753 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2754 | hda_nid_t nid = kcontrol->private_value; |
| 2755 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 2756 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2757 | |
| 2758 | spec->io_switch[io_idx] = val; |
| 2759 | |
| 2760 | if (val) |
| 2761 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2762 | else { |
| 2763 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2764 | if (io_idx) /* set VREF for mic */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2765 | pinctl |= stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2766 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2767 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2768 | |
| 2769 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2770 | * appropriately according to the pin direction |
| 2771 | */ |
| 2772 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2773 | stac_issue_unsol_event(codec, nid); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2774 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2775 | return 1; |
| 2776 | } |
| 2777 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2778 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2779 | |
| 2780 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2781 | struct snd_ctl_elem_value *ucontrol) |
| 2782 | { |
| 2783 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2784 | struct sigmatel_spec *spec = codec->spec; |
| 2785 | |
| 2786 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2787 | return 0; |
| 2788 | } |
| 2789 | |
| 2790 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2791 | struct snd_ctl_elem_value *ucontrol) |
| 2792 | { |
| 2793 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2794 | struct sigmatel_spec *spec = codec->spec; |
| 2795 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2796 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2797 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2798 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2799 | return 0; |
| 2800 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2801 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2802 | |
| 2803 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2804 | spec->clfe_swap ? 0x4 : 0x0); |
| 2805 | |
| 2806 | return 1; |
| 2807 | } |
| 2808 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2809 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2810 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2811 | .name = xname, \ |
| 2812 | .index = 0, \ |
| 2813 | .info = stac92xx_hp_switch_info, \ |
| 2814 | .get = stac92xx_hp_switch_get, \ |
| 2815 | .put = stac92xx_hp_switch_put, \ |
| 2816 | } |
| 2817 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2818 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2819 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2820 | .name = xname, \ |
| 2821 | .index = 0, \ |
| 2822 | .info = stac92xx_io_switch_info, \ |
| 2823 | .get = stac92xx_io_switch_get, \ |
| 2824 | .put = stac92xx_io_switch_put, \ |
| 2825 | .private_value = xpval, \ |
| 2826 | } |
| 2827 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2828 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2829 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2830 | .name = xname, \ |
| 2831 | .index = 0, \ |
| 2832 | .info = stac92xx_clfe_switch_info, \ |
| 2833 | .get = stac92xx_clfe_switch_get, \ |
| 2834 | .put = stac92xx_clfe_switch_put, \ |
| 2835 | .private_value = xpval, \ |
| 2836 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2837 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2838 | enum { |
| 2839 | STAC_CTL_WIDGET_VOL, |
| 2840 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2841 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2842 | STAC_CTL_WIDGET_AMP_MUX, |
| 2843 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2844 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2845 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2846 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2847 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2848 | }; |
| 2849 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2850 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2851 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2852 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2853 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2854 | STAC_AMP_MUX, |
| 2855 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2856 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2857 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2858 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2859 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2860 | }; |
| 2861 | |
| 2862 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2863 | static struct snd_kcontrol_new * |
| 2864 | stac_control_new(struct sigmatel_spec *spec, |
| 2865 | struct snd_kcontrol_new *ktemp, |
| 2866 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2867 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2868 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2869 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2870 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2871 | knew = snd_array_new(&spec->kctls); |
| 2872 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2873 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2874 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2875 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2876 | if (!knew->name) { |
| 2877 | /* roolback */ |
| 2878 | memset(knew, 0, sizeof(*knew)); |
| 2879 | spec->kctls.alloced--; |
| 2880 | return NULL; |
| 2881 | } |
| 2882 | return knew; |
| 2883 | } |
| 2884 | |
| 2885 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2886 | struct snd_kcontrol_new *ktemp, |
| 2887 | int idx, const char *name, |
| 2888 | unsigned long val) |
| 2889 | { |
| 2890 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2891 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2892 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2893 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2894 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2895 | return 0; |
| 2896 | } |
| 2897 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2898 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2899 | int type, int idx, const char *name, |
| 2900 | unsigned long val) |
| 2901 | { |
| 2902 | return stac92xx_add_control_temp(spec, |
| 2903 | &stac92xx_control_templates[type], |
| 2904 | idx, name, val); |
| 2905 | } |
| 2906 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2907 | |
| 2908 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2909 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2910 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2911 | { |
| 2912 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2913 | } |
| 2914 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2915 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2916 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2917 | .name = "Input Source", |
| 2918 | .info = stac92xx_mux_enum_info, |
| 2919 | .get = stac92xx_mux_enum_get, |
| 2920 | .put = stac92xx_mux_enum_put, |
| 2921 | }; |
| 2922 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2923 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 2924 | hda_nid_t nid, int idx) |
| 2925 | { |
| 2926 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 2927 | int control = 0; |
| 2928 | struct sigmatel_spec *spec = codec->spec; |
| 2929 | char name[22]; |
| 2930 | |
| 2931 | if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { |
| 2932 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
| 2933 | && nid == spec->line_switch) |
| 2934 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2935 | else if (snd_hda_query_pin_caps(codec, nid) |
| 2936 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 2937 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 2938 | else if (nid == spec->mic_switch) |
| 2939 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2940 | } |
| 2941 | |
| 2942 | if (control) { |
| 2943 | strcpy(name, auto_pin_cfg_labels[idx]); |
| 2944 | return stac92xx_add_control(codec->spec, control, |
| 2945 | strcat(name, " Jack Mode"), nid); |
| 2946 | } |
| 2947 | |
| 2948 | return 0; |
| 2949 | } |
| 2950 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2951 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2952 | { |
| 2953 | struct snd_kcontrol_new *knew; |
| 2954 | struct hda_input_mux *imux = &spec->private_imux; |
| 2955 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 2956 | if (spec->auto_mic) |
| 2957 | return 0; /* no need for input source */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2958 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2959 | return 0; /* no need for input source control */ |
| 2960 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2961 | stac_input_src_temp.name); |
| 2962 | if (!knew) |
| 2963 | return -ENOMEM; |
| 2964 | knew->count = spec->num_adcs; |
| 2965 | return 0; |
| 2966 | } |
| 2967 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2968 | /* check whether the line-input can be used as line-out */ |
| 2969 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2970 | { |
| 2971 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2972 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2973 | hda_nid_t nid; |
| 2974 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2975 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2976 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2977 | return 0; |
| 2978 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2979 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2980 | if (pincap & AC_PINCAP_OUT) |
| 2981 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2982 | return 0; |
| 2983 | } |
| 2984 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2985 | /* check whether the mic-input can be used as line-out */ |
| 2986 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2987 | { |
| 2988 | struct sigmatel_spec *spec = codec->spec; |
| 2989 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2990 | unsigned int def_conf, pincap; |
| 2991 | unsigned int mic_pin; |
| 2992 | |
| 2993 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2994 | return 0; |
| 2995 | mic_pin = AUTO_PIN_MIC; |
| 2996 | for (;;) { |
| 2997 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2998 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2999 | /* some laptops have an internal analog microphone |
| 3000 | * which can't be used as a output */ |
| 3001 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 3002 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3003 | if (pincap & AC_PINCAP_OUT) |
| 3004 | return nid; |
| 3005 | } |
| 3006 | if (mic_pin == AUTO_PIN_MIC) |
| 3007 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 3008 | else |
| 3009 | break; |
| 3010 | } |
| 3011 | return 0; |
| 3012 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3013 | |
| 3014 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3015 | { |
| 3016 | int i; |
| 3017 | |
| 3018 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 3019 | if (spec->multiout.dac_nids[i] == nid) |
| 3020 | return 1; |
| 3021 | } |
| 3022 | |
| 3023 | return 0; |
| 3024 | } |
| 3025 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3026 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3027 | { |
| 3028 | int i; |
| 3029 | if (is_in_dac_nids(spec, nid)) |
| 3030 | return 1; |
| 3031 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 3032 | if (spec->hp_dacs[i] == nid) |
| 3033 | return 1; |
| 3034 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 3035 | if (spec->speaker_dacs[i] == nid) |
| 3036 | return 1; |
| 3037 | return 0; |
| 3038 | } |
| 3039 | |
| 3040 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 3041 | { |
| 3042 | struct sigmatel_spec *spec = codec->spec; |
| 3043 | int j, conn_len; |
| 3044 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 3045 | unsigned int wcaps, wtype; |
| 3046 | |
| 3047 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 3048 | HDA_MAX_CONNECTIONS); |
| 3049 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 3050 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3051 | wtype = get_wcaps_type(wcaps); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3052 | /* we check only analog outputs */ |
| 3053 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 3054 | continue; |
| 3055 | /* if this route has a free DAC, assign it */ |
| 3056 | if (!check_all_dac_nids(spec, conn[j])) { |
| 3057 | if (conn_len > 1) { |
| 3058 | /* select this DAC in the pin's input mux */ |
| 3059 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3060 | AC_VERB_SET_CONNECT_SEL, j); |
| 3061 | } |
| 3062 | return conn[j]; |
| 3063 | } |
| 3064 | } |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 3065 | /* if all DACs are already assigned, connect to the primary DAC */ |
| 3066 | if (conn_len > 1) { |
| 3067 | for (j = 0; j < conn_len; j++) { |
| 3068 | if (conn[j] == spec->multiout.dac_nids[0]) { |
| 3069 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3070 | AC_VERB_SET_CONNECT_SEL, j); |
| 3071 | break; |
| 3072 | } |
| 3073 | } |
| 3074 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3075 | return 0; |
| 3076 | } |
| 3077 | |
| 3078 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3079 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3080 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3081 | /* |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3082 | * Fill in the dac_nids table from the parsed pin configuration |
| 3083 | * This function only works when every pin in line_out_pins[] |
| 3084 | * contains atleast one DAC in its connection list. Some 92xx |
| 3085 | * codecs are not connected directly to a DAC, such as the 9200 |
| 3086 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3087 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3088 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3089 | { |
| 3090 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3091 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3092 | int i; |
| 3093 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3094 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3095 | for (i = 0; i < cfg->line_outs; i++) { |
| 3096 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3097 | dac = get_unassigned_dac(codec, nid); |
| 3098 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 3099 | if (spec->multiout.num_dacs > 0) { |
| 3100 | /* we have already working output pins, |
| 3101 | * so let's drop the broken ones again |
| 3102 | */ |
| 3103 | cfg->line_outs = spec->multiout.num_dacs; |
| 3104 | break; |
| 3105 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3106 | /* error out, no available DAC found */ |
| 3107 | snd_printk(KERN_ERR |
| 3108 | "%s: No available DAC for pin 0x%x\n", |
| 3109 | __func__, nid); |
| 3110 | return -ENODEV; |
| 3111 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3112 | add_spec_dacs(spec, dac); |
| 3113 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3114 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 3115 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3116 | nid = cfg->hp_pins[i]; |
| 3117 | dac = get_unassigned_dac(codec, nid); |
| 3118 | if (dac) { |
| 3119 | if (!spec->multiout.hp_nid) |
| 3120 | spec->multiout.hp_nid = dac; |
| 3121 | else |
| 3122 | add_spec_extra_dacs(spec, dac); |
| 3123 | } |
| 3124 | spec->hp_dacs[i] = dac; |
| 3125 | } |
| 3126 | |
| 3127 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 3128 | nid = cfg->speaker_pins[i]; |
| 3129 | dac = get_unassigned_dac(codec, nid); |
| 3130 | if (dac) |
| 3131 | add_spec_extra_dacs(spec, dac); |
| 3132 | spec->speaker_dacs[i] = dac; |
| 3133 | } |
| 3134 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3135 | /* add line-in as output */ |
| 3136 | nid = check_line_out_switch(codec); |
| 3137 | if (nid) { |
| 3138 | dac = get_unassigned_dac(codec, nid); |
| 3139 | if (dac) { |
| 3140 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 3141 | nid, cfg->line_outs); |
| 3142 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3143 | cfg->line_outs++; |
| 3144 | spec->line_switch = nid; |
| 3145 | add_spec_dacs(spec, dac); |
| 3146 | } |
| 3147 | } |
| 3148 | /* add mic as output */ |
| 3149 | nid = check_mic_out_switch(codec); |
| 3150 | if (nid) { |
| 3151 | dac = get_unassigned_dac(codec, nid); |
| 3152 | if (dac) { |
| 3153 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 3154 | nid, cfg->line_outs); |
| 3155 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3156 | cfg->line_outs++; |
| 3157 | spec->mic_switch = nid; |
| 3158 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3159 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3160 | } |
| 3161 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3162 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3163 | spec->multiout.num_dacs, |
| 3164 | spec->multiout.dac_nids[0], |
| 3165 | spec->multiout.dac_nids[1], |
| 3166 | spec->multiout.dac_nids[2], |
| 3167 | spec->multiout.dac_nids[3], |
| 3168 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3169 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3170 | return 0; |
| 3171 | } |
| 3172 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3173 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3174 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 3175 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3176 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3177 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3178 | char name[32]; |
| 3179 | int err; |
| 3180 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3181 | if (!spec->check_volume_offset) { |
| 3182 | unsigned int caps, step, nums, db_scale; |
| 3183 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3184 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 3185 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 3186 | step = (step + 1) * 25; /* in .01dB unit */ |
| 3187 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 3188 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3189 | db_scale = nums * step; |
| 3190 | /* if dB scale is over -64dB, and finer enough, |
| 3191 | * let's reduce it to half |
| 3192 | */ |
| 3193 | if (db_scale > 6400 && nums >= 0x1f) |
| 3194 | spec->volume_offset = nums / 2; |
| 3195 | spec->check_volume_offset = 1; |
| 3196 | } |
| 3197 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3198 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3199 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3200 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3201 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3202 | if (err < 0) |
| 3203 | return err; |
| 3204 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3205 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3206 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3207 | if (err < 0) |
| 3208 | return err; |
| 3209 | return 0; |
| 3210 | } |
| 3211 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3212 | #define create_controls(codec, pfx, nid, chs) \ |
| 3213 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 3214 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3215 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3216 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3217 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3218 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3219 | return 1; |
| 3220 | } else { |
| 3221 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3222 | spec->multiout.num_dacs++; |
| 3223 | } |
| 3224 | return 0; |
| 3225 | } |
| 3226 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3227 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3228 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3229 | int i; |
| 3230 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3231 | if (!spec->multiout.extra_out_nid[i]) { |
| 3232 | spec->multiout.extra_out_nid[i] = nid; |
| 3233 | return 0; |
| 3234 | } |
| 3235 | } |
| 3236 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3237 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3238 | } |
| 3239 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3240 | /* Create output controls |
| 3241 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3242 | */ |
| 3243 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3244 | const hda_nid_t *pins, |
| 3245 | const hda_nid_t *dac_nids, |
| 3246 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3247 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3248 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3249 | static const char *chname[4] = { |
| 3250 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3251 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3252 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3253 | int i, err; |
| 3254 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3255 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3256 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 3257 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3258 | wid_caps = get_wcaps(codec, pins[i]); |
| 3259 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3260 | spec->hp_detect = 1; |
| 3261 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3262 | nid = dac_nids[i]; |
| 3263 | if (!nid) |
| 3264 | continue; |
| 3265 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3266 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3267 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3268 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3269 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3270 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3271 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3272 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3273 | |
| 3274 | wid_caps = get_wcaps(codec, nid); |
| 3275 | |
| 3276 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3277 | err = stac92xx_add_control(spec, |
| 3278 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3279 | "Swap Center/LFE Playback Switch", nid); |
| 3280 | |
| 3281 | if (err < 0) |
| 3282 | return err; |
| 3283 | } |
| 3284 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3285 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3286 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3287 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3288 | switch (type) { |
| 3289 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3290 | name = "Headphone"; |
| 3291 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3292 | break; |
| 3293 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3294 | name = "Speaker"; |
| 3295 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3296 | break; |
| 3297 | default: |
| 3298 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3299 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3300 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3301 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3302 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3303 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3304 | return err; |
| 3305 | } |
| 3306 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3307 | return 0; |
| 3308 | } |
| 3309 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3310 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, |
| 3311 | unsigned long sw, int idx) |
| 3312 | { |
| 3313 | int err; |
| 3314 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, |
Takashi Iwai | bf677bd8 | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 3315 | "Capture Volume", vol); |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3316 | if (err < 0) |
| 3317 | return err; |
| 3318 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, |
Takashi Iwai | bf677bd8 | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 3319 | "Capture Switch", sw); |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3320 | if (err < 0) |
| 3321 | return err; |
| 3322 | return 0; |
| 3323 | } |
| 3324 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3325 | /* add playback controls from the parsed DAC table */ |
| 3326 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3327 | const struct auto_pin_cfg *cfg) |
| 3328 | { |
| 3329 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3330 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3331 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3332 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3333 | |
| 3334 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3335 | spec->multiout.dac_nids, |
| 3336 | cfg->line_out_type); |
| 3337 | if (err < 0) |
| 3338 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3339 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3340 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3341 | err = stac92xx_add_control(spec, |
| 3342 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3343 | "Headphone as Line Out Switch", |
| 3344 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3345 | if (err < 0) |
| 3346 | return err; |
| 3347 | } |
| 3348 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3349 | for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { |
| 3350 | nid = cfg->input_pins[idx]; |
| 3351 | if (nid) { |
| 3352 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 3353 | if (err < 0) |
| 3354 | return err; |
| 3355 | } |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3356 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3357 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3358 | return 0; |
| 3359 | } |
| 3360 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3361 | /* add playback controls for Speaker and HP outputs */ |
| 3362 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3363 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3364 | { |
| 3365 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3366 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3367 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3368 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3369 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3370 | if (err < 0) |
| 3371 | return err; |
| 3372 | |
| 3373 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3374 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3375 | if (err < 0) |
| 3376 | return err; |
| 3377 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3378 | return 0; |
| 3379 | } |
| 3380 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3381 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3382 | static const char *stac92xx_mono_labels[4] = { |
| 3383 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3384 | }; |
| 3385 | |
| 3386 | /* create mono mux for mono out on capable codecs */ |
| 3387 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3388 | { |
| 3389 | struct sigmatel_spec *spec = codec->spec; |
| 3390 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3391 | int i, num_cons; |
| 3392 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3393 | |
| 3394 | num_cons = snd_hda_get_connections(codec, |
| 3395 | spec->mono_nid, |
| 3396 | con_lst, |
| 3397 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3398 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3399 | return -EINVAL; |
| 3400 | |
| 3401 | for (i = 0; i < num_cons; i++) { |
| 3402 | mono_mux->items[mono_mux->num_items].label = |
| 3403 | stac92xx_mono_labels[i]; |
| 3404 | mono_mux->items[mono_mux->num_items].index = i; |
| 3405 | mono_mux->num_items++; |
| 3406 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3407 | |
| 3408 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3409 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3410 | } |
| 3411 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3412 | /* labels for amp mux outputs */ |
| 3413 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3414 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3415 | }; |
| 3416 | |
| 3417 | /* create amp out controls mux on capable codecs */ |
| 3418 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3419 | { |
| 3420 | struct sigmatel_spec *spec = codec->spec; |
| 3421 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3422 | int i, err; |
| 3423 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3424 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3425 | amp_mux->items[amp_mux->num_items].label = |
| 3426 | stac92xx_amp_labels[i]; |
| 3427 | amp_mux->items[amp_mux->num_items].index = i; |
| 3428 | amp_mux->num_items++; |
| 3429 | } |
| 3430 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3431 | if (spec->num_amps > 1) { |
| 3432 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3433 | "Amp Selector Capture Switch", 0); |
| 3434 | if (err < 0) |
| 3435 | return err; |
| 3436 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3437 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3438 | "Amp Capture Volume", |
| 3439 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3440 | } |
| 3441 | |
| 3442 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3443 | /* create PC beep volume controls */ |
| 3444 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3445 | hda_nid_t nid) |
| 3446 | { |
| 3447 | struct sigmatel_spec *spec = codec->spec; |
| 3448 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3449 | int err; |
| 3450 | |
| 3451 | /* check for mute support for the the amp */ |
| 3452 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3453 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3454 | "PC Beep Playback Switch", |
| 3455 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3456 | if (err < 0) |
| 3457 | return err; |
| 3458 | } |
| 3459 | |
| 3460 | /* check to see if there is volume support for the amp */ |
| 3461 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3462 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3463 | "PC Beep Playback Volume", |
| 3464 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3465 | if (err < 0) |
| 3466 | return err; |
| 3467 | } |
| 3468 | return 0; |
| 3469 | } |
| 3470 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3471 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3472 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3473 | |
| 3474 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3475 | struct snd_ctl_elem_value *ucontrol) |
| 3476 | { |
| 3477 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3478 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3479 | return 0; |
| 3480 | } |
| 3481 | |
| 3482 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3483 | struct snd_ctl_elem_value *ucontrol) |
| 3484 | { |
| 3485 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3486 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3487 | if (codec->beep->enabled != enabled) { |
| 3488 | codec->beep->enabled = enabled; |
| 3489 | return 1; |
| 3490 | } |
| 3491 | return 0; |
| 3492 | } |
| 3493 | |
| 3494 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3495 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3496 | .info = stac92xx_dig_beep_switch_info, |
| 3497 | .get = stac92xx_dig_beep_switch_get, |
| 3498 | .put = stac92xx_dig_beep_switch_put, |
| 3499 | }; |
| 3500 | |
| 3501 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3502 | { |
| 3503 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3504 | 0, "PC Beep Playback Switch", 0); |
| 3505 | } |
| 3506 | #endif |
| 3507 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3508 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3509 | { |
| 3510 | struct sigmatel_spec *spec = codec->spec; |
| 3511 | int wcaps, nid, i, err = 0; |
| 3512 | |
| 3513 | for (i = 0; i < spec->num_muxes; i++) { |
| 3514 | nid = spec->mux_nids[i]; |
| 3515 | wcaps = get_wcaps(codec, nid); |
| 3516 | |
| 3517 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3518 | err = stac92xx_add_control_idx(spec, |
| 3519 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3520 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3521 | if (err < 0) |
| 3522 | return err; |
| 3523 | } |
| 3524 | } |
| 3525 | return 0; |
| 3526 | }; |
| 3527 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3528 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3529 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3530 | }; |
| 3531 | |
| 3532 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3533 | { |
| 3534 | struct sigmatel_spec *spec = codec->spec; |
| 3535 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3536 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3537 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3538 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3539 | |
| 3540 | num_cons = snd_hda_get_connections(codec, |
| 3541 | spec->smux_nids[0], |
| 3542 | con_lst, |
| 3543 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3544 | if (num_cons <= 0) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3545 | return -EINVAL; |
| 3546 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3547 | if (!labels) |
| 3548 | labels = stac92xx_spdif_labels; |
| 3549 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3550 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3551 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3552 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3553 | spdif_mux->num_items++; |
| 3554 | } |
| 3555 | |
| 3556 | return 0; |
| 3557 | } |
| 3558 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3559 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3560 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3561 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3562 | "Digital Mic 3", "Digital Mic 4" |
| 3563 | }; |
| 3564 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3565 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
| 3566 | hda_nid_t nid) |
| 3567 | { |
| 3568 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
| 3569 | int i, nums; |
| 3570 | |
| 3571 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 3572 | for (i = 0; i < nums; i++) |
| 3573 | if (conn[i] == nid) |
| 3574 | return i; |
| 3575 | return -1; |
| 3576 | } |
| 3577 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3578 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3579 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3580 | const struct auto_pin_cfg *cfg) |
| 3581 | { |
| 3582 | struct sigmatel_spec *spec = codec->spec; |
| 3583 | struct hda_input_mux *dimux = &spec->private_dimux; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3584 | int err, i; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3585 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3586 | |
| 3587 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3588 | dimux->items[dimux->num_items].index = 0; |
| 3589 | dimux->num_items++; |
| 3590 | |
| 3591 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3592 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3593 | int index; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3594 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3595 | unsigned int def_conf; |
| 3596 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3597 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3598 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3599 | continue; |
| 3600 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3601 | nid = spec->dmic_nids[i]; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3602 | index = get_connection_index(codec, spec->dmux_nids[0], nid); |
| 3603 | if (index < 0) |
| 3604 | continue; |
| 3605 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3606 | wcaps = get_wcaps(codec, nid) & |
| 3607 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3608 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3609 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3610 | sprintf(name, "%s Capture Volume", |
| 3611 | stac92xx_dmic_labels[dimux->num_items]); |
| 3612 | |
| 3613 | err = stac92xx_add_control(spec, |
| 3614 | STAC_CTL_WIDGET_VOL, |
| 3615 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3616 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3617 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3618 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3619 | if (err < 0) |
| 3620 | return err; |
| 3621 | } |
| 3622 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3623 | dimux->items[dimux->num_items].label = |
| 3624 | stac92xx_dmic_labels[dimux->num_items]; |
| 3625 | dimux->items[dimux->num_items].index = index; |
| 3626 | dimux->num_items++; |
| 3627 | } |
| 3628 | |
| 3629 | return 0; |
| 3630 | } |
| 3631 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3632 | static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, |
| 3633 | hda_nid_t *fixed, hda_nid_t *ext) |
| 3634 | { |
| 3635 | unsigned int cfg; |
| 3636 | |
| 3637 | if (!nid) |
| 3638 | return 0; |
| 3639 | cfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3640 | switch (get_defcfg_connect(cfg)) { |
| 3641 | case AC_JACK_PORT_FIXED: |
| 3642 | if (*fixed) |
| 3643 | return 1; /* already occupied */ |
| 3644 | *fixed = nid; |
| 3645 | break; |
| 3646 | case AC_JACK_PORT_COMPLEX: |
| 3647 | if (*ext) |
| 3648 | return 1; /* already occupied */ |
| 3649 | *ext = nid; |
| 3650 | break; |
| 3651 | } |
| 3652 | return 0; |
| 3653 | } |
| 3654 | |
| 3655 | static int set_mic_route(struct hda_codec *codec, |
| 3656 | struct sigmatel_mic_route *mic, |
| 3657 | hda_nid_t pin) |
| 3658 | { |
| 3659 | struct sigmatel_spec *spec = codec->spec; |
| 3660 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3661 | int i; |
| 3662 | |
| 3663 | mic->pin = pin; |
| 3664 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) |
| 3665 | if (pin == cfg->input_pins[i]) |
| 3666 | break; |
| 3667 | if (i <= AUTO_PIN_FRONT_MIC) { |
| 3668 | /* analog pin */ |
| 3669 | mic->dmux_idx = 0; |
| 3670 | i = get_connection_index(codec, spec->mux_nids[0], pin); |
| 3671 | if (i < 0) |
| 3672 | return -1; |
| 3673 | mic->mux_idx = i; |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame^] | 3674 | } else if (spec->dmux_nids) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3675 | /* digital pin */ |
| 3676 | mic->mux_idx = 0; |
| 3677 | i = get_connection_index(codec, spec->dmux_nids[0], pin); |
| 3678 | if (i < 0) |
| 3679 | return -1; |
| 3680 | mic->dmux_idx = i; |
| 3681 | } |
| 3682 | return 0; |
| 3683 | } |
| 3684 | |
| 3685 | /* return non-zero if the device is for automatic mic switch */ |
| 3686 | static int stac_check_auto_mic(struct hda_codec *codec) |
| 3687 | { |
| 3688 | struct sigmatel_spec *spec = codec->spec; |
| 3689 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3690 | hda_nid_t fixed, ext; |
| 3691 | int i; |
| 3692 | |
| 3693 | for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { |
| 3694 | if (cfg->input_pins[i]) |
| 3695 | return 0; /* must be exclusively mics */ |
| 3696 | } |
| 3697 | fixed = ext = 0; |
| 3698 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) |
| 3699 | if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) |
| 3700 | return 0; |
| 3701 | for (i = 0; i < spec->num_dmics; i++) |
| 3702 | if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) |
| 3703 | return 0; |
| 3704 | if (!fixed || !ext) |
| 3705 | return 0; |
| 3706 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) |
| 3707 | return 0; /* no unsol support */ |
| 3708 | if (set_mic_route(codec, &spec->ext_mic, ext) || |
| 3709 | set_mic_route(codec, &spec->int_mic, fixed)) |
| 3710 | return 0; /* something is wrong */ |
| 3711 | return 1; |
| 3712 | } |
| 3713 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3714 | /* create playback/capture controls for input pins */ |
| 3715 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3716 | { |
| 3717 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3718 | struct hda_input_mux *imux = &spec->private_imux; |
| 3719 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3720 | int i, j, k; |
| 3721 | |
| 3722 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3723 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3724 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3725 | if (!cfg->input_pins[i]) |
| 3726 | continue; |
| 3727 | index = -1; |
| 3728 | for (j = 0; j < spec->num_muxes; j++) { |
| 3729 | int num_cons; |
| 3730 | num_cons = snd_hda_get_connections(codec, |
| 3731 | spec->mux_nids[j], |
| 3732 | con_lst, |
| 3733 | HDA_MAX_NUM_INPUTS); |
| 3734 | for (k = 0; k < num_cons; k++) |
| 3735 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3736 | index = k; |
| 3737 | goto found; |
| 3738 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3739 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3740 | continue; |
| 3741 | found: |
| 3742 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3743 | imux->items[imux->num_items].index = index; |
| 3744 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3745 | } |
| 3746 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3747 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3748 | /* |
| 3749 | * Set the current input for the muxes. |
| 3750 | * The STAC9221 has two input muxes with identical source |
| 3751 | * NID lists. Hopefully this won't get confused. |
| 3752 | */ |
| 3753 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3754 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3755 | AC_VERB_SET_CONNECT_SEL, |
| 3756 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3757 | } |
| 3758 | } |
| 3759 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3760 | return 0; |
| 3761 | } |
| 3762 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3763 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3764 | { |
| 3765 | struct sigmatel_spec *spec = codec->spec; |
| 3766 | int i; |
| 3767 | |
| 3768 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3769 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3770 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3771 | } |
| 3772 | } |
| 3773 | |
| 3774 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3775 | { |
| 3776 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3777 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3778 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3779 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3780 | hda_nid_t pin; |
| 3781 | pin = spec->autocfg.hp_pins[i]; |
| 3782 | if (pin) /* connect to front */ |
| 3783 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3784 | } |
| 3785 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3786 | hda_nid_t pin; |
| 3787 | pin = spec->autocfg.speaker_pins[i]; |
| 3788 | if (pin) /* connect to front */ |
| 3789 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3790 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3791 | } |
| 3792 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3793 | 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] | 3794 | { |
| 3795 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3796 | int hp_swap = 0; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3797 | int i, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3798 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3799 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3800 | &spec->autocfg, |
| 3801 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3802 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3803 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3804 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3805 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3806 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3807 | * be set up as multi-channel outputs. |
| 3808 | */ |
| 3809 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3810 | spec->autocfg.hp_outs > 1) { |
| 3811 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3812 | * speaker_outs so that the following routines can handle |
| 3813 | * HP pins as primary outputs. |
| 3814 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3815 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3816 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3817 | sizeof(spec->autocfg.line_out_pins)); |
| 3818 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3819 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3820 | sizeof(spec->autocfg.hp_pins)); |
| 3821 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3822 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3823 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3824 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3825 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3826 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3827 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3828 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3829 | u32 caps = query_amp_caps(codec, |
| 3830 | spec->autocfg.mono_out_pin, dir); |
| 3831 | hda_nid_t conn_list[1]; |
| 3832 | |
| 3833 | /* get the mixer node and then the mono mux if it exists */ |
| 3834 | if (snd_hda_get_connections(codec, |
| 3835 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3836 | snd_hda_get_connections(codec, conn_list[0], |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3837 | conn_list, 1) > 0) { |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3838 | |
| 3839 | int wcaps = get_wcaps(codec, conn_list[0]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3840 | int wid_type = get_wcaps_type(wcaps); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3841 | /* LR swap check, some stac925x have a mux that |
| 3842 | * changes the DACs output path instead of the |
| 3843 | * mono-mux path. |
| 3844 | */ |
| 3845 | if (wid_type == AC_WID_AUD_SEL && |
| 3846 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3847 | spec->mono_nid = conn_list[0]; |
| 3848 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3849 | if (dir) { |
| 3850 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3851 | |
| 3852 | /* most mono outs have a least a mute/unmute switch */ |
| 3853 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3854 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3855 | "Mono Playback Switch", |
| 3856 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3857 | if (err < 0) |
| 3858 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3859 | /* check for volume support for the amp */ |
| 3860 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3861 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3862 | err = stac92xx_add_control(spec, |
| 3863 | STAC_CTL_WIDGET_VOL, |
| 3864 | "Mono Playback Volume", |
| 3865 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3866 | if (err < 0) |
| 3867 | return err; |
| 3868 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3869 | } |
| 3870 | |
| 3871 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3872 | AC_PINCTL_OUT_EN); |
| 3873 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3874 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3875 | if (!spec->multiout.num_dacs) { |
| 3876 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3877 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3878 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3879 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3880 | &spec->autocfg); |
| 3881 | if (err < 0) |
| 3882 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3883 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3884 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3885 | /* setup analog beep controls */ |
| 3886 | if (spec->anabeep_nid > 0) { |
| 3887 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3888 | spec->anabeep_nid); |
| 3889 | if (err < 0) |
| 3890 | return err; |
| 3891 | } |
| 3892 | |
| 3893 | /* setup digital beep controls and input device */ |
| 3894 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3895 | if (spec->digbeep_nid > 0) { |
| 3896 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3897 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3898 | |
| 3899 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3900 | if (err < 0) |
| 3901 | return err; |
| 3902 | err = snd_hda_attach_beep_device(codec, nid); |
| 3903 | if (err < 0) |
| 3904 | return err; |
Takashi Iwai | fa79796 | 2009-05-19 12:50:04 +0200 | [diff] [blame] | 3905 | /* IDT/STAC codecs have linear beep tone parameter */ |
| 3906 | codec->beep->linear_tone = 1; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3907 | /* if no beep switch is available, make its own one */ |
| 3908 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3909 | if (codec->beep && |
| 3910 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3911 | err = stac92xx_beep_switch_ctl(codec); |
| 3912 | if (err < 0) |
| 3913 | return err; |
| 3914 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3915 | } |
| 3916 | #endif |
| 3917 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3918 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3919 | if (err < 0) |
| 3920 | return err; |
| 3921 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3922 | /* All output parsing done, now restore the swapped hp pins */ |
| 3923 | if (hp_swap) { |
| 3924 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3925 | sizeof(spec->autocfg.hp_pins)); |
| 3926 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3927 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3928 | spec->autocfg.line_outs = 0; |
| 3929 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3930 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3931 | if (stac_check_auto_mic(codec)) { |
| 3932 | spec->auto_mic = 1; |
| 3933 | /* only one capture for auto-mic */ |
| 3934 | spec->num_adcs = 1; |
| 3935 | spec->num_caps = 1; |
| 3936 | spec->num_muxes = 1; |
| 3937 | } |
| 3938 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3939 | for (i = 0; i < spec->num_caps; i++) { |
| 3940 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], |
| 3941 | spec->capsws[i], i); |
| 3942 | if (err < 0) |
| 3943 | return err; |
| 3944 | } |
| 3945 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3946 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3947 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3948 | return err; |
| 3949 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3950 | if (spec->mono_nid > 0) { |
| 3951 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3952 | if (err < 0) |
| 3953 | return err; |
| 3954 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3955 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3956 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3957 | if (err < 0) |
| 3958 | return err; |
| 3959 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3960 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3961 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3962 | &spec->autocfg)) < 0) |
| 3963 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3964 | if (spec->num_muxes > 0) { |
| 3965 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3966 | if (err < 0) |
| 3967 | return err; |
| 3968 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3969 | if (spec->num_smuxes > 0) { |
| 3970 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3971 | if (err < 0) |
| 3972 | return err; |
| 3973 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3974 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3975 | err = stac92xx_add_input_source(spec); |
| 3976 | if (err < 0) |
| 3977 | return err; |
| 3978 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3979 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3980 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3981 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3982 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3983 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3984 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3985 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3986 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3987 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3988 | if (spec->kctls.list) |
| 3989 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3990 | |
| 3991 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3992 | if (!spec->dinput_mux) |
| 3993 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3994 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3995 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3996 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3997 | return 1; |
| 3998 | } |
| 3999 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4000 | /* add playback controls for HP output */ |
| 4001 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 4002 | struct auto_pin_cfg *cfg) |
| 4003 | { |
| 4004 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4005 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4006 | unsigned int wid_caps; |
| 4007 | |
| 4008 | if (! pin) |
| 4009 | return 0; |
| 4010 | |
| 4011 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4012 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4013 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4014 | |
| 4015 | return 0; |
| 4016 | } |
| 4017 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4018 | /* add playback controls for LFE output */ |
| 4019 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 4020 | struct auto_pin_cfg *cfg) |
| 4021 | { |
| 4022 | struct sigmatel_spec *spec = codec->spec; |
| 4023 | int err; |
| 4024 | hda_nid_t lfe_pin = 0x0; |
| 4025 | int i; |
| 4026 | |
| 4027 | /* |
| 4028 | * search speaker outs and line outs for a mono speaker pin |
| 4029 | * with an amp. If one is found, add LFE controls |
| 4030 | * for it. |
| 4031 | */ |
| 4032 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 4033 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 4034 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4035 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 4036 | if (wcaps == AC_WCAP_OUT_AMP) |
| 4037 | /* found a mono speaker with an amp, must be lfe */ |
| 4038 | lfe_pin = pin; |
| 4039 | } |
| 4040 | |
| 4041 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 4042 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 4043 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 4044 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 4045 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4046 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 4047 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 4048 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4049 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 4050 | if (wcaps == AC_WCAP_OUT_AMP) |
| 4051 | /* found a mono speaker with an amp, |
| 4052 | must be lfe */ |
| 4053 | lfe_pin = pin; |
| 4054 | } |
| 4055 | } |
| 4056 | } |
| 4057 | |
| 4058 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4059 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4060 | if (err < 0) |
| 4061 | return err; |
| 4062 | } |
| 4063 | |
| 4064 | return 0; |
| 4065 | } |
| 4066 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4067 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 4068 | { |
| 4069 | struct sigmatel_spec *spec = codec->spec; |
| 4070 | int err; |
| 4071 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4072 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4073 | return err; |
| 4074 | |
| 4075 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 4076 | return err; |
| 4077 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4078 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 4079 | return err; |
| 4080 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4081 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 4082 | return err; |
| 4083 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 4084 | if (spec->num_muxes > 0) { |
| 4085 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 4086 | if (err < 0) |
| 4087 | return err; |
| 4088 | } |
| 4089 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4090 | err = stac92xx_add_input_source(spec); |
| 4091 | if (err < 0) |
| 4092 | return err; |
| 4093 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4094 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4095 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4096 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4097 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4098 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4099 | if (spec->kctls.list) |
| 4100 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4101 | |
| 4102 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4103 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4104 | |
| 4105 | return 1; |
| 4106 | } |
| 4107 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4108 | /* |
| 4109 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 4110 | * funky external mute control using GPIO pins. |
| 4111 | */ |
| 4112 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4113 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4114 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4115 | { |
| 4116 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4117 | |
| 4118 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4119 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4120 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4121 | |
| 4122 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4123 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4124 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4125 | |
| 4126 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4127 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4128 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4129 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4130 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4131 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 4132 | |
| 4133 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4134 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4135 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4136 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4137 | |
| 4138 | msleep(1); |
| 4139 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4140 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4141 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4142 | } |
| 4143 | |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4144 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4145 | static void stac92xx_free_jack_priv(struct snd_jack *jack) |
| 4146 | { |
| 4147 | struct sigmatel_jack *jacks = jack->private_data; |
| 4148 | jacks->nid = 0; |
| 4149 | jacks->jack = NULL; |
| 4150 | } |
| 4151 | #endif |
| 4152 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4153 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 4154 | hda_nid_t nid, int type) |
| 4155 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4156 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4157 | struct sigmatel_spec *spec = codec->spec; |
| 4158 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4159 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4160 | int connectivity = get_defcfg_connect(def_conf); |
| 4161 | char name[32]; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4162 | int err; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4163 | |
| 4164 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 4165 | return 0; |
| 4166 | |
| 4167 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 4168 | jack = snd_array_new(&spec->jacks); |
| 4169 | if (!jack) |
| 4170 | return -ENOMEM; |
| 4171 | jack->nid = nid; |
| 4172 | jack->type = type; |
| 4173 | |
Takashi Iwai | 86de741 | 2009-07-22 16:02:46 +0200 | [diff] [blame] | 4174 | snprintf(name, sizeof(name), "%s at %s %s Jack", |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4175 | snd_hda_get_jack_type(def_conf), |
| 4176 | snd_hda_get_jack_connectivity(def_conf), |
| 4177 | snd_hda_get_jack_location(def_conf)); |
| 4178 | |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4179 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
| 4180 | if (err < 0) { |
| 4181 | jack->nid = 0; |
| 4182 | return err; |
| 4183 | } |
| 4184 | jack->jack->private_data = jack; |
| 4185 | jack->jack->private_free = stac92xx_free_jack_priv; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4186 | #endif |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4187 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4188 | } |
| 4189 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4190 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 4191 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4192 | { |
| 4193 | struct sigmatel_event *event; |
| 4194 | |
| 4195 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 4196 | event = snd_array_new(&spec->events); |
| 4197 | if (!event) |
| 4198 | return -ENOMEM; |
| 4199 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4200 | event->type = type; |
| 4201 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4202 | event->data = data; |
| 4203 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4204 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4205 | } |
| 4206 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4207 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4208 | hda_nid_t nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4209 | { |
| 4210 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4211 | struct sigmatel_event *event = spec->events.list; |
| 4212 | int i; |
| 4213 | |
| 4214 | for (i = 0; i < spec->events.used; i++, event++) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4215 | if (event->nid == nid) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4216 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4217 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4218 | return NULL; |
| 4219 | } |
| 4220 | |
| 4221 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 4222 | unsigned char tag) |
| 4223 | { |
| 4224 | struct sigmatel_spec *spec = codec->spec; |
| 4225 | struct sigmatel_event *event = spec->events.list; |
| 4226 | int i; |
| 4227 | |
| 4228 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4229 | if (event->tag == tag) |
| 4230 | return event; |
| 4231 | } |
| 4232 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4233 | } |
| 4234 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4235 | /* check if given nid is a valid pin and no other events are assigned |
| 4236 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
| 4237 | * Otherwise, returns zero. |
| 4238 | */ |
| 4239 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 4240 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4241 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4242 | struct sigmatel_event *event; |
| 4243 | int tag; |
| 4244 | |
| 4245 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4246 | return 0; |
| 4247 | event = stac_get_event(codec, nid); |
| 4248 | if (event) { |
| 4249 | if (event->type != type) |
| 4250 | return 0; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4251 | tag = event->tag; |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4252 | } else { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4253 | tag = stac_add_event(codec->spec, nid, type, 0); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4254 | if (tag < 0) |
| 4255 | return 0; |
| 4256 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4257 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4258 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4259 | AC_USRSP_EN | tag); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4260 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4261 | } |
| 4262 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4263 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 4264 | { |
| 4265 | int i; |
| 4266 | for (i = 0; i < cfg->hp_outs; i++) |
| 4267 | if (cfg->hp_pins[i] == nid) |
| 4268 | return 1; /* nid is a HP-Out */ |
| 4269 | |
| 4270 | return 0; /* nid is not a HP-Out */ |
| 4271 | }; |
| 4272 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4273 | static void stac92xx_power_down(struct hda_codec *codec) |
| 4274 | { |
| 4275 | struct sigmatel_spec *spec = codec->spec; |
| 4276 | |
| 4277 | /* power down inactive DACs */ |
| 4278 | hda_nid_t *dac; |
| 4279 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4280 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4281 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4282 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4283 | } |
| 4284 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4285 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4286 | int enable); |
| 4287 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4288 | /* override some hints from the hwdep entry */ |
| 4289 | static void stac_store_hints(struct hda_codec *codec) |
| 4290 | { |
| 4291 | struct sigmatel_spec *spec = codec->spec; |
| 4292 | const char *p; |
| 4293 | int val; |
| 4294 | |
| 4295 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 4296 | if (val >= 0) |
| 4297 | spec->hp_detect = val; |
| 4298 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 4299 | if (p) { |
| 4300 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 4301 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 4302 | spec->gpio_mask; |
| 4303 | } |
| 4304 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 4305 | if (p) |
| 4306 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4307 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 4308 | if (p) |
| 4309 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4310 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 4311 | if (p) |
| 4312 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4313 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 4314 | if (val >= 0) |
| 4315 | spec->eapd_switch = val; |
| 4316 | } |
| 4317 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4318 | static int stac92xx_init(struct hda_codec *codec) |
| 4319 | { |
| 4320 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4321 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4322 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4323 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4324 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4325 | snd_hda_sequence_write(codec, spec->init); |
| 4326 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4327 | /* power down adcs initially */ |
| 4328 | if (spec->powerdown_adcs) |
| 4329 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4330 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4331 | spec->adc_nids[i], 0, |
| 4332 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4333 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4334 | /* override some hints */ |
| 4335 | stac_store_hints(codec); |
| 4336 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4337 | /* set up GPIO */ |
| 4338 | gpio = spec->gpio_data; |
| 4339 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4340 | * otherwise, unsol event will turn it on/off dynamically |
| 4341 | */ |
| 4342 | if (!spec->eapd_switch) |
| 4343 | gpio |= spec->eapd_mask; |
| 4344 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4345 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4346 | /* set up pins */ |
| 4347 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4348 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4349 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4350 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4351 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4352 | } |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4353 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT) { |
| 4354 | /* enable pin-detect for line-outs as well */ |
Takashi Iwai | 15cfa2b | 2009-08-03 14:23:33 +0200 | [diff] [blame] | 4355 | for (i = 0; i < cfg->line_outs; i++) { |
| 4356 | hda_nid_t nid = cfg->line_out_pins[i]; |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4357 | enable_pin_detect(codec, nid, STAC_LO_EVENT); |
| 4358 | } |
| 4359 | } |
| 4360 | |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4361 | /* force to enable the first line-out; the others are set up |
| 4362 | * in unsol_event |
| 4363 | */ |
| 4364 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4365 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4366 | /* fake event to set up pins */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4367 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4368 | } else { |
| 4369 | stac92xx_auto_init_multi_out(codec); |
| 4370 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4371 | for (i = 0; i < cfg->hp_outs; i++) |
| 4372 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4373 | } |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4374 | if (spec->auto_mic) { |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 4375 | /* initialize connection to analog input */ |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame^] | 4376 | if (spec->dmux_nids) |
| 4377 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 4378 | AC_VERB_SET_CONNECT_SEL, 0); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4379 | if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) |
| 4380 | stac_issue_unsol_event(codec, spec->ext_mic.pin); |
| 4381 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4382 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4383 | hda_nid_t nid = cfg->input_pins[i]; |
| 4384 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4385 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4386 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4387 | /* for mic pins, force to initialize */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4388 | pinctl = stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4389 | pinctl |= AC_PINCTL_IN_EN; |
| 4390 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4391 | } else { |
| 4392 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4393 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4394 | /* if PINCTL already set then skip */ |
Takashi Iwai | 5dd17cb | 2009-05-07 16:22:53 +0200 | [diff] [blame] | 4395 | /* Also, if both INPUT and OUTPUT are set, |
| 4396 | * it must be a BIOS bug; need to override, too |
| 4397 | */ |
| 4398 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 4399 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 4400 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4401 | pinctl |= AC_PINCTL_IN_EN; |
| 4402 | stac92xx_auto_set_pinctl(codec, nid, |
| 4403 | pinctl); |
| 4404 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4405 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4406 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4407 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4408 | if (enable_pin_detect(codec, nid, |
| 4409 | STAC_INSERT_EVENT)) |
| 4410 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4411 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4412 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4413 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4414 | for (i = 0; i < spec->num_dmics; i++) |
| 4415 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4416 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4417 | if (cfg->dig_out_pins[0]) |
| 4418 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4419 | AC_PINCTL_OUT_EN); |
| 4420 | if (cfg->dig_in_pin) |
| 4421 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4422 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4423 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4424 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4425 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4426 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4427 | /* power on when no jack detection is available */ |
| 4428 | if (!spec->hp_detect) { |
| 4429 | stac_toggle_power_map(codec, nid, 1); |
| 4430 | continue; |
| 4431 | } |
| 4432 | |
| 4433 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4434 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4435 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4436 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4437 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4438 | /* outputs are only ports capable of power management |
| 4439 | * any attempts on powering down a input port cause the |
| 4440 | * referenced VREF to act quirky. |
| 4441 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4442 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4443 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4444 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4445 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4446 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4447 | def_conf = get_defcfg_connect(def_conf); |
| 4448 | /* skip any ports that don't have jacks since presence |
| 4449 | * detection is useless */ |
| 4450 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4451 | if (def_conf != AC_JACK_PORT_NONE) |
| 4452 | stac_toggle_power_map(codec, nid, 1); |
| 4453 | continue; |
| 4454 | } |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4455 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) |
| 4456 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4457 | } |
| 4458 | if (spec->dac_list) |
| 4459 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4460 | return 0; |
| 4461 | } |
| 4462 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4463 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4464 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4465 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4466 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4467 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4468 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4469 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4470 | int i; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4471 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
| 4472 | if (jacks->jack) |
| 4473 | snd_device_free(codec->bus->card, jacks->jack); |
| 4474 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4475 | } |
| 4476 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4477 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4478 | } |
| 4479 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4480 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4481 | { |
| 4482 | struct sigmatel_spec *spec = codec->spec; |
| 4483 | |
| 4484 | if (spec->kctls.list) { |
| 4485 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4486 | int i; |
| 4487 | for (i = 0; i < spec->kctls.used; i++) |
| 4488 | kfree(kctl[i].name); |
| 4489 | } |
| 4490 | snd_array_free(&spec->kctls); |
| 4491 | } |
| 4492 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4493 | static void stac92xx_free(struct hda_codec *codec) |
| 4494 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4495 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4496 | |
| 4497 | if (! spec) |
| 4498 | return; |
| 4499 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4500 | stac92xx_free_jacks(codec); |
| 4501 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4502 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4503 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4504 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4505 | } |
| 4506 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4507 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4508 | unsigned int flag) |
| 4509 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4510 | unsigned int old_ctl, pin_ctl; |
| 4511 | |
| 4512 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4513 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4514 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4515 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4516 | /* |
| 4517 | * we need to check the current set-up direction of |
| 4518 | * shared input pins since they can be switched via |
| 4519 | * "xxx as Output" mixer switch |
| 4520 | */ |
| 4521 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4522 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4523 | return; |
| 4524 | } |
| 4525 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4526 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4527 | /* if setting pin direction bits, clear the current |
| 4528 | direction bits first */ |
| 4529 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4530 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4531 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4532 | pin_ctl |= flag; |
| 4533 | if (old_ctl != pin_ctl) |
| 4534 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4535 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4536 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4537 | } |
| 4538 | |
| 4539 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4540 | unsigned int flag) |
| 4541 | { |
| 4542 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4543 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4544 | if (pin_ctl & flag) |
| 4545 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4546 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4547 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4548 | } |
| 4549 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4550 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4551 | { |
| 4552 | if (!nid) |
| 4553 | return 0; |
| 4554 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4555 | & (1 << 31)) |
| 4556 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4557 | return 0; |
| 4558 | } |
| 4559 | |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4560 | static void stac92xx_line_out_detect(struct hda_codec *codec, |
| 4561 | int presence) |
| 4562 | { |
| 4563 | struct sigmatel_spec *spec = codec->spec; |
| 4564 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4565 | int i; |
| 4566 | |
| 4567 | for (i = 0; i < cfg->line_outs; i++) { |
| 4568 | if (presence) |
| 4569 | break; |
| 4570 | presence = get_pin_presence(codec, cfg->line_out_pins[i]); |
| 4571 | if (presence) { |
| 4572 | unsigned int pinctl; |
| 4573 | pinctl = snd_hda_codec_read(codec, |
| 4574 | cfg->line_out_pins[i], 0, |
| 4575 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4576 | if (pinctl & AC_PINCTL_IN_EN) |
| 4577 | presence = 0; /* mic- or line-input */ |
| 4578 | } |
| 4579 | } |
| 4580 | |
| 4581 | if (presence) { |
| 4582 | /* disable speakers */ |
| 4583 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4584 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4585 | AC_PINCTL_OUT_EN); |
| 4586 | if (spec->eapd_mask && spec->eapd_switch) |
| 4587 | stac_gpio_set(codec, spec->gpio_mask, |
| 4588 | spec->gpio_dir, spec->gpio_data & |
| 4589 | ~spec->eapd_mask); |
| 4590 | } else { |
| 4591 | /* enable speakers */ |
| 4592 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4593 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4594 | AC_PINCTL_OUT_EN); |
| 4595 | if (spec->eapd_mask && spec->eapd_switch) |
| 4596 | stac_gpio_set(codec, spec->gpio_mask, |
| 4597 | spec->gpio_dir, spec->gpio_data | |
| 4598 | spec->eapd_mask); |
| 4599 | } |
| 4600 | } |
| 4601 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4602 | /* return non-zero if the hp-pin of the given array index isn't |
| 4603 | * a jack-detection target |
| 4604 | */ |
| 4605 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4606 | { |
| 4607 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4608 | |
| 4609 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4610 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4611 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4612 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4613 | return 1; |
| 4614 | /* ignore if the pin is set as line-out */ |
| 4615 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4616 | return 1; |
| 4617 | return 0; |
| 4618 | } |
| 4619 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4620 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4621 | { |
| 4622 | struct sigmatel_spec *spec = codec->spec; |
| 4623 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4624 | int i, presence; |
| 4625 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4626 | presence = 0; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4627 | if (spec->gpio_mute) |
| 4628 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4629 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4630 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4631 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4632 | if (presence) |
| 4633 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4634 | if (no_hp_sensing(spec, i)) |
| 4635 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4636 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4637 | if (presence) { |
| 4638 | unsigned int pinctl; |
| 4639 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4640 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4641 | if (pinctl & AC_PINCTL_IN_EN) |
| 4642 | presence = 0; /* mic- or line-input */ |
| 4643 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4644 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4645 | |
| 4646 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4647 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4648 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4649 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4650 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4651 | for (i = 0; i < cfg->line_outs; i++) |
| 4652 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4653 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4654 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4655 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4656 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4657 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4658 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4659 | for (i = 0; i < cfg->line_outs; i++) |
| 4660 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4661 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4662 | } |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4663 | stac92xx_line_out_detect(codec, presence); |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4664 | /* toggle hp outs */ |
| 4665 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4666 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4667 | if (no_hp_sensing(spec, i)) |
| 4668 | continue; |
| 4669 | if (presence) |
| 4670 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4671 | #if 0 /* FIXME */ |
| 4672 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4673 | * on some devices since they use the HP pin actually for line/speaker |
| 4674 | * outs although the default pin config shows a different pin (that is |
| 4675 | * wrong and useless). |
| 4676 | * |
| 4677 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4678 | * But, disabling the code below just works around it, and I'm too tired of |
| 4679 | * bug reports with such devices... |
| 4680 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4681 | else |
| 4682 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4683 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4684 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4685 | } |
| 4686 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4687 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4688 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4689 | { |
| 4690 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4691 | unsigned int idx, val; |
| 4692 | |
| 4693 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4694 | if (spec->pwr_nids[idx] == nid) |
| 4695 | break; |
| 4696 | } |
| 4697 | if (idx >= spec->num_pwrs) |
| 4698 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4699 | |
| 4700 | /* several codecs have two power down bits */ |
| 4701 | if (spec->pwr_mapping) |
| 4702 | idx = spec->pwr_mapping[idx]; |
| 4703 | else |
| 4704 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4705 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4706 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4707 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4708 | val &= ~idx; |
| 4709 | else |
| 4710 | val |= idx; |
| 4711 | |
| 4712 | /* power down unused output ports */ |
| 4713 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4714 | } |
| 4715 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4716 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4717 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4718 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4719 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4720 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4721 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4722 | { |
| 4723 | struct sigmatel_spec *spec = codec->spec; |
| 4724 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4725 | |
| 4726 | if (jacks) { |
| 4727 | int i; |
| 4728 | for (i = 0; i < spec->jacks.used; i++) { |
| 4729 | if (jacks->nid == nid) { |
| 4730 | unsigned int pin_ctl = |
| 4731 | snd_hda_codec_read(codec, nid, |
| 4732 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4733 | 0x00); |
| 4734 | int type = jacks->type; |
| 4735 | if (type == (SND_JACK_LINEOUT |
| 4736 | | SND_JACK_HEADPHONE)) |
| 4737 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4738 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4739 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4740 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4741 | ? type : 0); |
| 4742 | } |
| 4743 | jacks++; |
| 4744 | } |
| 4745 | } |
| 4746 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4747 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4748 | static void stac92xx_mic_detect(struct hda_codec *codec) |
| 4749 | { |
| 4750 | struct sigmatel_spec *spec = codec->spec; |
| 4751 | struct sigmatel_mic_route *mic; |
| 4752 | |
| 4753 | if (get_pin_presence(codec, spec->ext_mic.pin)) |
| 4754 | mic = &spec->ext_mic; |
| 4755 | else |
| 4756 | mic = &spec->int_mic; |
| 4757 | if (mic->dmux_idx) |
| 4758 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
| 4759 | AC_VERB_SET_CONNECT_SEL, |
| 4760 | mic->dmux_idx); |
| 4761 | else |
| 4762 | snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, |
| 4763 | AC_VERB_SET_CONNECT_SEL, |
| 4764 | mic->mux_idx); |
| 4765 | } |
| 4766 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4767 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4768 | { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4769 | struct sigmatel_event *event = stac_get_event(codec, nid); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4770 | if (!event) |
| 4771 | return; |
| 4772 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4773 | } |
| 4774 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4775 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4776 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4777 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4778 | struct sigmatel_event *event; |
| 4779 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4780 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4781 | tag = (res >> 26) & 0x7f; |
| 4782 | event = stac_get_event_from_tag(codec, tag); |
| 4783 | if (!event) |
| 4784 | return; |
| 4785 | |
| 4786 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4787 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4788 | case STAC_LO_EVENT: |
Takashi Iwai | 16ffe32 | 2009-08-04 13:40:54 +0200 | [diff] [blame] | 4789 | stac92xx_hp_detect(codec); |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4790 | break; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4791 | case STAC_MIC_EVENT: |
| 4792 | stac92xx_mic_detect(codec); |
| 4793 | break; |
| 4794 | } |
| 4795 | |
| 4796 | switch (event->type) { |
| 4797 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4798 | case STAC_LO_EVENT: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4799 | case STAC_MIC_EVENT: |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4800 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4801 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4802 | if (spec->num_pwrs > 0) |
| 4803 | stac92xx_pin_sense(codec, event->nid); |
| 4804 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 4805 | |
| 4806 | switch (codec->subsystem_id) { |
| 4807 | case 0x103c308f: |
| 4808 | if (event->nid == 0xb) { |
| 4809 | int pin = AC_PINCTL_IN_EN; |
| 4810 | |
| 4811 | if (get_pin_presence(codec, 0xa) |
| 4812 | && get_pin_presence(codec, 0xb)) |
| 4813 | pin |= AC_PINCTL_VREF_80; |
| 4814 | if (!get_pin_presence(codec, 0xb)) |
| 4815 | pin |= AC_PINCTL_VREF_80; |
| 4816 | |
| 4817 | /* toggle VREF state based on mic + hp pin |
| 4818 | * status |
| 4819 | */ |
| 4820 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 4821 | } |
| 4822 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4823 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4824 | case STAC_VREF_EVENT: |
| 4825 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4826 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4827 | /* toggle VREF state based on GPIOx status */ |
| 4828 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4829 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4830 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4831 | } |
| 4832 | } |
| 4833 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4834 | #ifdef CONFIG_PROC_FS |
| 4835 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4836 | struct hda_codec *codec, hda_nid_t nid) |
| 4837 | { |
| 4838 | if (nid == codec->afg) |
| 4839 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4840 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4841 | } |
| 4842 | |
| 4843 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4844 | struct hda_codec *codec, |
| 4845 | unsigned int verb) |
| 4846 | { |
| 4847 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4848 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4849 | } |
| 4850 | |
| 4851 | /* stac92hd71bxx, stac92hd73xx */ |
| 4852 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4853 | struct hda_codec *codec, hda_nid_t nid) |
| 4854 | { |
| 4855 | stac92hd_proc_hook(buffer, codec, nid); |
| 4856 | if (nid == codec->afg) |
| 4857 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4858 | } |
| 4859 | |
| 4860 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4861 | struct hda_codec *codec, hda_nid_t nid) |
| 4862 | { |
| 4863 | if (nid == codec->afg) |
| 4864 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4865 | } |
| 4866 | |
| 4867 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4868 | struct hda_codec *codec, hda_nid_t nid) |
| 4869 | { |
| 4870 | if (nid == codec->afg) |
| 4871 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4872 | } |
| 4873 | #else |
| 4874 | #define stac92hd_proc_hook NULL |
| 4875 | #define stac92hd7x_proc_hook NULL |
| 4876 | #define stac9205_proc_hook NULL |
| 4877 | #define stac927x_proc_hook NULL |
| 4878 | #endif |
| 4879 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4880 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4881 | static int stac92xx_resume(struct hda_codec *codec) |
| 4882 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4883 | struct sigmatel_spec *spec = codec->spec; |
| 4884 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4885 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4886 | snd_hda_codec_resume_amp(codec); |
| 4887 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4888 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4889 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4890 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4891 | return 0; |
| 4892 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4893 | |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4894 | /* |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4895 | * using power check for controlling mute led of HP notebooks |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4896 | * check for mute state only on Speakers (nid = 0x10) |
| 4897 | * |
| 4898 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
| 4899 | * the LED is NOT working properly ! |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4900 | * |
| 4901 | * Changed name to reflect that it now works for any designated |
| 4902 | * model, not just HP HDX. |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4903 | */ |
| 4904 | |
| 4905 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4906 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4907 | hda_nid_t nid) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4908 | { |
| 4909 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4910 | |
| 4911 | if (nid == 0x10) { |
| 4912 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4913 | HDA_AMP_MUTE) |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 4914 | spec->gpio_data &= ~spec->gpio_led; /* orange */ |
Takashi Iwai | ba84bfc | 2009-05-30 08:59:03 +0200 | [diff] [blame] | 4915 | else |
| 4916 | spec->gpio_data |= spec->gpio_led; /* white */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4917 | |
| 4918 | stac_gpio_set(codec, spec->gpio_mask, |
| 4919 | spec->gpio_dir, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4920 | spec->gpio_data); |
| 4921 | } |
| 4922 | |
| 4923 | return 0; |
| 4924 | } |
| 4925 | #endif |
| 4926 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4927 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4928 | { |
| 4929 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4930 | int i; |
| 4931 | hda_nid_t nid; |
| 4932 | |
| 4933 | /* reset each pin before powering down DAC/ADC to avoid click noise */ |
| 4934 | nid = codec->start_nid; |
| 4935 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 4936 | unsigned int wcaps = get_wcaps(codec, nid); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 4937 | unsigned int wid_type = get_wcaps_type(wcaps); |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4938 | if (wid_type == AC_WID_PIN) |
| 4939 | snd_hda_codec_read(codec, nid, 0, |
| 4940 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); |
| 4941 | } |
| 4942 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4943 | if (spec->eapd_mask) |
| 4944 | stac_gpio_set(codec, spec->gpio_mask, |
| 4945 | spec->gpio_dir, spec->gpio_data & |
| 4946 | ~spec->eapd_mask); |
| 4947 | return 0; |
| 4948 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4949 | #endif |
| 4950 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4951 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4952 | .build_controls = stac92xx_build_controls, |
| 4953 | .build_pcms = stac92xx_build_pcms, |
| 4954 | .init = stac92xx_init, |
| 4955 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4956 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4957 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4958 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4959 | .resume = stac92xx_resume, |
| 4960 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4961 | }; |
| 4962 | |
| 4963 | static int patch_stac9200(struct hda_codec *codec) |
| 4964 | { |
| 4965 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4966 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4967 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4968 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4969 | if (spec == NULL) |
| 4970 | return -ENOMEM; |
| 4971 | |
| 4972 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4973 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4974 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4975 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4976 | stac9200_models, |
| 4977 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4978 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4979 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4980 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4981 | else |
| 4982 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4983 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4984 | |
| 4985 | spec->multiout.max_channels = 2; |
| 4986 | spec->multiout.num_dacs = 1; |
| 4987 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4988 | spec->adc_nids = stac9200_adc_nids; |
| 4989 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4990 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4991 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4992 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4993 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4994 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4995 | if (spec->board_config == STAC_9200_M4 || |
| 4996 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4997 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4998 | spec->init = stac9200_eapd_init; |
| 4999 | else |
| 5000 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5001 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5002 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 5003 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 5004 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 5005 | spec->gpio_data = 0x00; |
| 5006 | } |
| 5007 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5008 | err = stac9200_parse_auto_config(codec); |
| 5009 | if (err < 0) { |
| 5010 | stac92xx_free(codec); |
| 5011 | return err; |
| 5012 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5013 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 5014 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 5015 | * do detection and HP/speaker toggle because the hardware does it. |
| 5016 | */ |
| 5017 | if (spec->board_config == STAC_9200_PANASONIC) |
| 5018 | spec->hp_detect = 0; |
| 5019 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5020 | codec->patch_ops = stac92xx_patch_ops; |
| 5021 | |
| 5022 | return 0; |
| 5023 | } |
| 5024 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5025 | static int patch_stac925x(struct hda_codec *codec) |
| 5026 | { |
| 5027 | struct sigmatel_spec *spec; |
| 5028 | int err; |
| 5029 | |
| 5030 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5031 | if (spec == NULL) |
| 5032 | return -ENOMEM; |
| 5033 | |
| 5034 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5035 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5036 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 5037 | |
| 5038 | /* Check first for codec ID */ |
| 5039 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 5040 | STAC_925x_MODELS, |
| 5041 | stac925x_models, |
| 5042 | stac925x_codec_id_cfg_tbl); |
| 5043 | |
| 5044 | /* Now checks for PCI ID, if codec ID is not found */ |
| 5045 | if (spec->board_config < 0) |
| 5046 | spec->board_config = snd_hda_check_board_config(codec, |
| 5047 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5048 | stac925x_models, |
| 5049 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5050 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5051 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5052 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5053 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5054 | else |
| 5055 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5056 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5057 | |
| 5058 | spec->multiout.max_channels = 2; |
| 5059 | spec->multiout.num_dacs = 1; |
| 5060 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 5061 | spec->adc_nids = stac925x_adc_nids; |
| 5062 | spec->mux_nids = stac925x_mux_nids; |
| 5063 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5064 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5065 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 5066 | switch (codec->vendor_id) { |
| 5067 | case 0x83847632: /* STAC9202 */ |
| 5068 | case 0x83847633: /* STAC9202D */ |
| 5069 | case 0x83847636: /* STAC9251 */ |
| 5070 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5071 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 5072 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5073 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 5074 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 5075 | break; |
| 5076 | default: |
| 5077 | spec->num_dmics = 0; |
| 5078 | break; |
| 5079 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5080 | |
| 5081 | spec->init = stac925x_core_init; |
| 5082 | spec->mixer = stac925x_mixer; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5083 | spec->num_caps = 1; |
| 5084 | spec->capvols = stac925x_capvols; |
| 5085 | spec->capsws = stac925x_capsws; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5086 | |
| 5087 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5088 | if (!err) { |
| 5089 | if (spec->board_config < 0) { |
| 5090 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5091 | "available, default to model=ref\n"); |
| 5092 | spec->board_config = STAC_925x_REF; |
| 5093 | goto again; |
| 5094 | } |
| 5095 | err = -EINVAL; |
| 5096 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5097 | if (err < 0) { |
| 5098 | stac92xx_free(codec); |
| 5099 | return err; |
| 5100 | } |
| 5101 | |
| 5102 | codec->patch_ops = stac92xx_patch_ops; |
| 5103 | |
| 5104 | return 0; |
| 5105 | } |
| 5106 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5107 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 5108 | .num_items = 4, |
| 5109 | .items = { |
| 5110 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5111 | { "Digital Mic 1", 0x09 }, |
| 5112 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5113 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5114 | } |
| 5115 | }; |
| 5116 | |
| 5117 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 5118 | { |
| 5119 | struct sigmatel_spec *spec; |
| 5120 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 5121 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5122 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5123 | |
| 5124 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5125 | if (spec == NULL) |
| 5126 | return -ENOMEM; |
| 5127 | |
| 5128 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 5129 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5130 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 5131 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 5132 | spec->board_config = snd_hda_check_board_config(codec, |
| 5133 | STAC_92HD73XX_MODELS, |
| 5134 | stac92hd73xx_models, |
| 5135 | stac92hd73xx_cfg_tbl); |
| 5136 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5137 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5138 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5139 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5140 | else |
| 5141 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5142 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5143 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5144 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5145 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 5146 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5147 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5148 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 5149 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5150 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5151 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5152 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5153 | case 0x3: /* 6 Channel */ |
| 5154 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 5155 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5156 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5157 | break; |
| 5158 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5159 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 5160 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5161 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5162 | break; |
| 5163 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5164 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 5165 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5166 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 5167 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5168 | } |
| 5169 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5170 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5171 | spec->aloopback_mask = 0x01; |
| 5172 | spec->aloopback_shift = 8; |
| 5173 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5174 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5175 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 5176 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 5177 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 5178 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5179 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 5180 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5181 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5182 | |
| 5183 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 5184 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5185 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5186 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 5187 | sizeof(stac92hd73xx_dmux)); |
| 5188 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5189 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
| 5190 | spec->capvols = stac92hd73xx_capvols; |
| 5191 | spec->capsws = stac92hd73xx_capsws; |
| 5192 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5193 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5194 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 5195 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5196 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5197 | case STAC_DELL_M6_AMIC: |
| 5198 | case STAC_DELL_M6_DMIC: |
| 5199 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5200 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5201 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 5202 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5203 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5204 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5205 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5206 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5207 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5208 | switch (spec->board_config) { |
| 5209 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5210 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5211 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5212 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5213 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5214 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5215 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5216 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5217 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5218 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5219 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5220 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 5221 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5222 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5223 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5224 | break; |
| 5225 | } |
| 5226 | break; |
| 5227 | default: |
| 5228 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5229 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5230 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5231 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5232 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 5233 | /* GPIO0 High = Enable EAPD */ |
| 5234 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 5235 | spec->gpio_data = 0x01; |
| 5236 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5237 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5238 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5239 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 5240 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 5241 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5242 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5243 | |
| 5244 | if (!err) { |
| 5245 | if (spec->board_config < 0) { |
| 5246 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5247 | "available, default to model=ref\n"); |
| 5248 | spec->board_config = STAC_92HD73XX_REF; |
| 5249 | goto again; |
| 5250 | } |
| 5251 | err = -EINVAL; |
| 5252 | } |
| 5253 | |
| 5254 | if (err < 0) { |
| 5255 | stac92xx_free(codec); |
| 5256 | return err; |
| 5257 | } |
| 5258 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 5259 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 5260 | spec->hp_detect = 0; |
| 5261 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5262 | codec->patch_ops = stac92xx_patch_ops; |
| 5263 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5264 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5265 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5266 | return 0; |
| 5267 | } |
| 5268 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5269 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 5270 | .num_items = 3, |
| 5271 | .items = { |
| 5272 | { "Analog Inputs", 0x03 }, |
| 5273 | { "Digital Mic 1", 0x04 }, |
| 5274 | { "Digital Mic 2", 0x05 }, |
| 5275 | } |
| 5276 | }; |
| 5277 | |
| 5278 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 5279 | { |
| 5280 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5281 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5282 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5283 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5284 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5285 | |
| 5286 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5287 | if (spec == NULL) |
| 5288 | return -ENOMEM; |
| 5289 | |
| 5290 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5291 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5292 | spec->mono_nid = 0x19; |
| 5293 | spec->digbeep_nid = 0x21; |
| 5294 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 5295 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 5296 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 5297 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5298 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5299 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 5300 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5301 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5302 | |
| 5303 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5304 | spec->mixer = stac92hd83xxx_mixer; |
| 5305 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 5306 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 5307 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5308 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5309 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 5310 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 5311 | spec->pin_nids = stac92hd83xxx_pin_nids; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5312 | spec->num_caps = STAC92HD83XXX_NUM_CAPS; |
| 5313 | spec->capvols = stac92hd83xxx_capvols; |
| 5314 | spec->capsws = stac92hd83xxx_capsws; |
| 5315 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5316 | spec->board_config = snd_hda_check_board_config(codec, |
| 5317 | STAC_92HD83XXX_MODELS, |
| 5318 | stac92hd83xxx_models, |
| 5319 | stac92hd83xxx_cfg_tbl); |
| 5320 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5321 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5322 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5323 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5324 | else |
| 5325 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5326 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5327 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5328 | switch (codec->vendor_id) { |
| 5329 | case 0x111d7604: |
| 5330 | case 0x111d7605: |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5331 | case 0x111d76d5: |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5332 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 5333 | break; |
| 5334 | spec->num_pwrs = 0; |
| 5335 | break; |
| 5336 | } |
| 5337 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5338 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 5339 | if (!err) { |
| 5340 | if (spec->board_config < 0) { |
| 5341 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5342 | "available, default to model=ref\n"); |
| 5343 | spec->board_config = STAC_92HD83XXX_REF; |
| 5344 | goto again; |
| 5345 | } |
| 5346 | err = -EINVAL; |
| 5347 | } |
| 5348 | |
| 5349 | if (err < 0) { |
| 5350 | stac92xx_free(codec); |
| 5351 | return err; |
| 5352 | } |
| 5353 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5354 | switch (spec->board_config) { |
| 5355 | case STAC_DELL_S14: |
| 5356 | nid = 0xf; |
| 5357 | break; |
| 5358 | default: |
| 5359 | nid = 0xe; |
| 5360 | break; |
| 5361 | } |
| 5362 | |
| 5363 | num_dacs = snd_hda_get_connections(codec, nid, |
| 5364 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 5365 | if (num_dacs < 0) |
| 5366 | num_dacs = STAC92HD83_DAC_COUNT; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5367 | |
| 5368 | /* set port X to select the last DAC |
| 5369 | */ |
| 5370 | snd_hda_codec_write_cache(codec, nid, 0, |
| 5371 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 5372 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5373 | codec->patch_ops = stac92xx_patch_ops; |
| 5374 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5375 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 5376 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5377 | return 0; |
| 5378 | } |
| 5379 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5380 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 5381 | .num_items = 3, |
| 5382 | .items = { |
| 5383 | { "Analog Inputs", 0x00 }, |
| 5384 | { "Digital Mic 1", 0x02 }, |
| 5385 | { "Digital Mic 2", 0x03 }, |
| 5386 | } |
| 5387 | }; |
| 5388 | |
| 5389 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5390 | .num_items = 4, |
| 5391 | .items = { |
| 5392 | { "Analog Inputs", 0x00 }, |
| 5393 | { "Mixer", 0x01 }, |
| 5394 | { "Digital Mic 1", 0x02 }, |
| 5395 | { "Digital Mic 2", 0x03 }, |
| 5396 | } |
| 5397 | }; |
| 5398 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5399 | /* get the pin connection (fixed, none, etc) */ |
| 5400 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 5401 | { |
| 5402 | struct sigmatel_spec *spec = codec->spec; |
| 5403 | unsigned int cfg; |
| 5404 | |
| 5405 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 5406 | return get_defcfg_connect(cfg); |
| 5407 | } |
| 5408 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5409 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 5410 | hda_nid_t *nids, int num_nids) |
| 5411 | { |
| 5412 | struct sigmatel_spec *spec = codec->spec; |
| 5413 | int idx, num; |
| 5414 | unsigned int def_conf; |
| 5415 | |
| 5416 | for (num = 0; num < num_nids; num++) { |
| 5417 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5418 | if (spec->pin_nids[idx] == nids[num]) |
| 5419 | break; |
| 5420 | if (idx >= spec->num_pins) |
| 5421 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5422 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5423 | if (def_conf == AC_JACK_PORT_NONE) |
| 5424 | break; |
| 5425 | } |
| 5426 | return num; |
| 5427 | } |
| 5428 | |
| 5429 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 5430 | hda_nid_t dig0pin) |
| 5431 | { |
| 5432 | struct sigmatel_spec *spec = codec->spec; |
| 5433 | int idx; |
| 5434 | |
| 5435 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5436 | if (spec->pin_nids[idx] == dig0pin) |
| 5437 | break; |
| 5438 | if ((idx + 2) >= spec->num_pins) |
| 5439 | return 0; |
| 5440 | |
| 5441 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5442 | if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5443 | return 2; |
| 5444 | |
| 5445 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5446 | if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5447 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5448 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5449 | return 1; |
| 5450 | else |
| 5451 | return 0; |
| 5452 | } |
| 5453 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5454 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 5455 | { |
| 5456 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5457 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5458 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5459 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5460 | |
| 5461 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5462 | if (spec == NULL) |
| 5463 | return -ENOMEM; |
| 5464 | |
| 5465 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5466 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5467 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 5468 | switch (codec->vendor_id) { |
| 5469 | case 0x111d76b6: |
| 5470 | case 0x111d76b7: |
| 5471 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 5472 | break; |
| 5473 | case 0x111d7603: |
| 5474 | case 0x111d7608: |
| 5475 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 5476 | spec->num_pins--; |
| 5477 | /* fallthrough */ |
| 5478 | default: |
| 5479 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 5480 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5481 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5482 | spec->board_config = snd_hda_check_board_config(codec, |
| 5483 | STAC_92HD71BXX_MODELS, |
| 5484 | stac92hd71bxx_models, |
| 5485 | stac92hd71bxx_cfg_tbl); |
| 5486 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5487 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5488 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5489 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5490 | else |
| 5491 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5492 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5493 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5494 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5495 | /* GPIO0 = EAPD */ |
| 5496 | spec->gpio_mask = 0x01; |
| 5497 | spec->gpio_dir = 0x01; |
| 5498 | spec->gpio_data = 0x01; |
| 5499 | } |
| 5500 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5501 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5502 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5503 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5504 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; |
| 5505 | spec->capvols = stac92hd71bxx_capvols; |
| 5506 | spec->capsws = stac92hd71bxx_capsws; |
| 5507 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5508 | switch (codec->vendor_id) { |
| 5509 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5510 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5511 | unmute_init++; |
| 5512 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5513 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5514 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5515 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 5516 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5517 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5518 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5519 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5520 | stac92hd71bxx_dmic_nids, |
| 5521 | STAC92HD71BXX_NUM_DMICS); |
| 5522 | if (spec->num_dmics) { |
| 5523 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5524 | spec->dinput_mux = &spec->private_dimux; |
| 5525 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5526 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5527 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5528 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5529 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5530 | switch (spec->board_config) { |
| 5531 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5532 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5533 | err = stac_add_event(spec, codec->afg, |
| 5534 | STAC_VREF_EVENT, 0x02); |
| 5535 | if (err < 0) |
| 5536 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5537 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5538 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5539 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5540 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5541 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5542 | spec->gpio_mask |= 0x02; |
| 5543 | break; |
| 5544 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5545 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5546 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5547 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5548 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5549 | /* no output amps */ |
| 5550 | spec->num_pwrs = 0; |
Takashi Iwai | 71443b0 | 2009-07-29 18:41:29 +0200 | [diff] [blame] | 5551 | if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1) { |
Takashi Iwai | 50c62f0 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 5552 | spec->mixer = stac92hd71bxx_analog_mixer; |
Takashi Iwai | 71443b0 | 2009-07-29 18:41:29 +0200 | [diff] [blame] | 5553 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5554 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5555 | } else { |
| 5556 | memcpy(&spec->private_dimux, |
| 5557 | &stac92hd71bxx_dmux_nomixer, |
| 5558 | sizeof(stac92hd71bxx_dmux_nomixer)); |
| 5559 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5560 | /* disable VSW */ |
Takashi Iwai | 26a2798 | 2009-07-29 16:28:09 +0200 | [diff] [blame] | 5561 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5562 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5563 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5564 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5565 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5566 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5567 | stac92hd71bxx_dmic_nids, |
| 5568 | STAC92HD71BXX_NUM_DMICS - 1); |
Takashi Iwai | 4417932 | 2009-07-28 17:03:49 +0200 | [diff] [blame] | 5569 | if (spec->num_dmics) { |
| 5570 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5571 | spec->dinput_mux = &spec->private_dimux; |
| 5572 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
| 5573 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5574 | break; |
| 5575 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5576 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5577 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5578 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5579 | /* no output amps */ |
| 5580 | spec->num_pwrs = 0; |
| 5581 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5582 | default: |
Takashi Iwai | 71443b0 | 2009-07-29 18:41:29 +0200 | [diff] [blame] | 5583 | if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1) { |
Takashi Iwai | 50c62f0 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 5584 | spec->mixer = stac92hd71bxx_analog_mixer; |
Takashi Iwai | 71443b0 | 2009-07-29 18:41:29 +0200 | [diff] [blame] | 5585 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5586 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5587 | } else { |
| 5588 | memcpy(&spec->private_dimux, |
| 5589 | &stac92hd71bxx_dmux_nomixer, |
| 5590 | sizeof(stac92hd71bxx_dmux_nomixer)); |
| 5591 | } |
Takashi Iwai | 26a2798 | 2009-07-29 16:28:09 +0200 | [diff] [blame] | 5592 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5593 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5594 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5595 | stac92hd71bxx_dmic_nids, |
| 5596 | STAC92HD71BXX_NUM_DMICS); |
Takashi Iwai | 4417932 | 2009-07-28 17:03:49 +0200 | [diff] [blame] | 5597 | if (spec->num_dmics) { |
| 5598 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5599 | spec->dinput_mux = &spec->private_dimux; |
| 5600 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5601 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5602 | } |
| 5603 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5604 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5605 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5606 | |
Takashi Iwai | b20f3b8 | 2009-06-02 01:20:22 +0200 | [diff] [blame] | 5607 | /* Some HP machines seem to have unstable codec communications |
| 5608 | * especially with ATI fglrx driver. For recovering from the |
| 5609 | * CORB/RIRB stall, allow the BUS reset and keep always sync |
| 5610 | */ |
| 5611 | if (spec->board_config == STAC_HP_DV5) { |
| 5612 | codec->bus->sync_write = 1; |
| 5613 | codec->bus->allow_bus_reset = 1; |
| 5614 | } |
| 5615 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5616 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5617 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5618 | spec->aloopback_shift = 0; |
| 5619 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5620 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5621 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5622 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5623 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5624 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5625 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5626 | |
| 5627 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5628 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5629 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5630 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5631 | switch (spec->board_config) { |
| 5632 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5633 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5634 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea715 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5635 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5636 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5637 | /* fallthru */ |
| 5638 | case STAC_DELL_M4_2: |
| 5639 | spec->num_dmics = 0; |
| 5640 | spec->num_smuxes = 0; |
| 5641 | spec->num_dmuxes = 0; |
| 5642 | break; |
| 5643 | case STAC_DELL_M4_1: |
| 5644 | case STAC_DELL_M4_3: |
| 5645 | spec->num_dmics = 1; |
| 5646 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5647 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5648 | break; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5649 | case STAC_HP_DV4_1222NR: |
| 5650 | spec->num_dmics = 1; |
| 5651 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 5652 | * bug reports to fix if needed |
| 5653 | */ |
| 5654 | spec->num_smuxes = 1; |
| 5655 | spec->num_dmuxes = 1; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5656 | spec->gpio_led = 0x01; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5657 | /* fallthrough */ |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5658 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5659 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5660 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5661 | break; |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5662 | case STAC_HP_HDX: |
| 5663 | spec->num_dmics = 1; |
| 5664 | spec->num_dmuxes = 1; |
| 5665 | spec->num_smuxes = 1; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5666 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5667 | spec->gpio_led = 0x08; |
| 5668 | break; |
| 5669 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5670 | |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5671 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5672 | if (spec->gpio_led) { |
| 5673 | spec->gpio_mask |= spec->gpio_led; |
| 5674 | spec->gpio_dir |= spec->gpio_led; |
| 5675 | spec->gpio_data |= spec->gpio_led; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5676 | /* register check_power_status callback. */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5677 | codec->patch_ops.check_power_status = |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5678 | stac92xx_hp_check_power_status; |
| 5679 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5680 | #endif |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5681 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5682 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5683 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5684 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5685 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5686 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5687 | if (!err) { |
| 5688 | if (spec->board_config < 0) { |
| 5689 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5690 | "available, default to model=ref\n"); |
| 5691 | spec->board_config = STAC_92HD71BXX_REF; |
| 5692 | goto again; |
| 5693 | } |
| 5694 | err = -EINVAL; |
| 5695 | } |
| 5696 | |
| 5697 | if (err < 0) { |
| 5698 | stac92xx_free(codec); |
| 5699 | return err; |
| 5700 | } |
| 5701 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5702 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5703 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5704 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5705 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5706 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5707 | static int patch_stac922x(struct hda_codec *codec) |
| 5708 | { |
| 5709 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5710 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5711 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5712 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5713 | if (spec == NULL) |
| 5714 | return -ENOMEM; |
| 5715 | |
| 5716 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5717 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5718 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5719 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5720 | stac922x_models, |
| 5721 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5722 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5723 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5724 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5725 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5726 | * codec SSID to distinguish the exact models |
| 5727 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5728 | 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] | 5729 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5730 | |
| 5731 | case 0x106b0800: |
| 5732 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5733 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5734 | case 0x106b0600: |
| 5735 | case 0x106b0700: |
| 5736 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5737 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5738 | case 0x106b0e00: |
| 5739 | case 0x106b0f00: |
| 5740 | case 0x106b1600: |
| 5741 | case 0x106b1700: |
| 5742 | case 0x106b0200: |
| 5743 | case 0x106b1e00: |
| 5744 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5745 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5746 | case 0x106b1a00: |
| 5747 | case 0x00000100: |
| 5748 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5749 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5750 | case 0x106b0a00: |
| 5751 | case 0x106b2200: |
| 5752 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5753 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5754 | default: |
| 5755 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5756 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5757 | } |
| 5758 | } |
| 5759 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5760 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5761 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5762 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5763 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5764 | else |
| 5765 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5766 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5767 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5768 | spec->adc_nids = stac922x_adc_nids; |
| 5769 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5770 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5771 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5772 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5773 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5774 | |
| 5775 | spec->init = stac922x_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5776 | |
| 5777 | spec->num_caps = STAC922X_NUM_CAPS; |
| 5778 | spec->capvols = stac922x_capvols; |
| 5779 | spec->capsws = stac922x_capsws; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5780 | |
| 5781 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5782 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5783 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5784 | if (!err) { |
| 5785 | if (spec->board_config < 0) { |
| 5786 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5787 | "available, default to model=ref\n"); |
| 5788 | spec->board_config = STAC_D945_REF; |
| 5789 | goto again; |
| 5790 | } |
| 5791 | err = -EINVAL; |
| 5792 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5793 | if (err < 0) { |
| 5794 | stac92xx_free(codec); |
| 5795 | return err; |
| 5796 | } |
| 5797 | |
| 5798 | codec->patch_ops = stac92xx_patch_ops; |
| 5799 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5800 | /* Fix Mux capture level; max to 2 */ |
| 5801 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5802 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5803 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5804 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5805 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5806 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5807 | return 0; |
| 5808 | } |
| 5809 | |
| 5810 | static int patch_stac927x(struct hda_codec *codec) |
| 5811 | { |
| 5812 | struct sigmatel_spec *spec; |
| 5813 | int err; |
| 5814 | |
| 5815 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5816 | if (spec == NULL) |
| 5817 | return -ENOMEM; |
| 5818 | |
| 5819 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5820 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5821 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5822 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5823 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5824 | stac927x_models, |
| 5825 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5826 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5827 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5828 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5829 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5830 | else |
| 5831 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5832 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5833 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5834 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5835 | spec->adc_nids = stac927x_adc_nids; |
| 5836 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5837 | spec->mux_nids = stac927x_mux_nids; |
| 5838 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5839 | spec->smux_nids = stac927x_smux_nids; |
| 5840 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5841 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5842 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5843 | spec->multiout.dac_nids = spec->dac_nids; |
| 5844 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5845 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5846 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5847 | case STAC_D965_5ST: |
| 5848 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5849 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5850 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5851 | spec->num_dmics = 0; |
| 5852 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5853 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5854 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5855 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5856 | switch (codec->subsystem_id) { |
| 5857 | case 0x10280209: |
| 5858 | case 0x1028022e: |
| 5859 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5860 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5861 | break; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5862 | } |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5863 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5864 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5865 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5866 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5867 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5868 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5869 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5870 | case STAC_DELL_3ST: |
| 5871 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5872 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5873 | spec->gpio_data = 0x04; |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 5874 | switch (codec->subsystem_id) { |
| 5875 | case 0x1028022f: |
| 5876 | /* correct EAPD to be GPIO0 */ |
| 5877 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5878 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5879 | break; |
| 5880 | }; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5881 | spec->dmic_nids = stac927x_dmic_nids; |
| 5882 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5883 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5884 | spec->init = d965_core_init; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5885 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5886 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5887 | break; |
| 5888 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5889 | if (spec->board_config > STAC_D965_REF) { |
| 5890 | /* GPIO0 High = Enable EAPD */ |
| 5891 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5892 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5893 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5894 | spec->num_dmics = 0; |
| 5895 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5896 | spec->init = stac927x_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5897 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5898 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5899 | spec->num_caps = STAC927X_NUM_CAPS; |
| 5900 | spec->capvols = stac927x_capvols; |
| 5901 | spec->capsws = stac927x_capsws; |
| 5902 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5903 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5904 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5905 | spec->aloopback_mask = 0x40; |
| 5906 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5907 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5908 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5909 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5910 | if (!err) { |
| 5911 | if (spec->board_config < 0) { |
| 5912 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5913 | "available, default to model=ref\n"); |
| 5914 | spec->board_config = STAC_D965_REF; |
| 5915 | goto again; |
| 5916 | } |
| 5917 | err = -EINVAL; |
| 5918 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5919 | if (err < 0) { |
| 5920 | stac92xx_free(codec); |
| 5921 | return err; |
| 5922 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5923 | |
| 5924 | codec->patch_ops = stac92xx_patch_ops; |
| 5925 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5926 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5927 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5928 | /* |
| 5929 | * !!FIXME!! |
| 5930 | * The STAC927x seem to require fairly long delays for certain |
| 5931 | * command sequences. With too short delays (even if the answer |
| 5932 | * is set to RIRB properly), it results in the silence output |
| 5933 | * on some hardwares like Dell. |
| 5934 | * |
| 5935 | * The below flag enables the longer delay (see get_response |
| 5936 | * in hda_intel.c). |
| 5937 | */ |
| 5938 | codec->bus->needs_damn_long_delay = 1; |
| 5939 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5940 | /* no jack detecion for ref-no-jd model */ |
| 5941 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5942 | spec->hp_detect = 0; |
| 5943 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5944 | return 0; |
| 5945 | } |
| 5946 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5947 | static int patch_stac9205(struct hda_codec *codec) |
| 5948 | { |
| 5949 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5950 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5951 | |
| 5952 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5953 | if (spec == NULL) |
| 5954 | return -ENOMEM; |
| 5955 | |
| 5956 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5957 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5958 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5959 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5960 | stac9205_models, |
| 5961 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5962 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5963 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5964 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5965 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5966 | else |
| 5967 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5968 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5969 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5970 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5971 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5972 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5973 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5974 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5975 | spec->smux_nids = stac9205_smux_nids; |
| 5976 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5977 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5978 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5979 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5980 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5981 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5982 | |
| 5983 | spec->init = stac9205_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5984 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5985 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5986 | spec->num_caps = STAC9205_NUM_CAPS; |
| 5987 | spec->capvols = stac9205_capvols; |
| 5988 | spec->capsws = stac9205_capsws; |
| 5989 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5990 | spec->aloopback_mask = 0x40; |
| 5991 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5992 | /* Turn on/off EAPD per HP plugging */ |
| 5993 | if (spec->board_config != STAC_9205_EAPD) |
| 5994 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5995 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5996 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5997 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5998 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5999 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6000 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 6001 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 6002 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6003 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 6004 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 6005 | if (err < 0) |
| 6006 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 6007 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6008 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 6009 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 6010 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 6011 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6012 | |
| 6013 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 6014 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6015 | spec->gpio_mask = 0x1b; |
| 6016 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 6017 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6018 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 6019 | */ |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6020 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 6021 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 6022 | case STAC_9205_REF: |
| 6023 | /* SPDIF-In enabled */ |
| 6024 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 6025 | default: |
| 6026 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 6027 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 6028 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 6029 | break; |
| 6030 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 6031 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 6032 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 6033 | if (!err) { |
| 6034 | if (spec->board_config < 0) { |
| 6035 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 6036 | "available, default to model=ref\n"); |
| 6037 | spec->board_config = STAC_9205_REF; |
| 6038 | goto again; |
| 6039 | } |
| 6040 | err = -EINVAL; |
| 6041 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 6042 | if (err < 0) { |
| 6043 | stac92xx_free(codec); |
| 6044 | return err; |
| 6045 | } |
| 6046 | |
| 6047 | codec->patch_ops = stac92xx_patch_ops; |
| 6048 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6049 | codec->proc_widget_hook = stac9205_proc_hook; |
| 6050 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 6051 | return 0; |
| 6052 | } |
| 6053 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6054 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 6055 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6056 | */ |
| 6057 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6058 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 6059 | {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] | 6060 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 6061 | {} |
| 6062 | }; |
| 6063 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6064 | static hda_nid_t stac9872_pin_nids[] = { |
| 6065 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 6066 | 0x11, 0x13, 0x14, |
| 6067 | }; |
| 6068 | |
| 6069 | static hda_nid_t stac9872_adc_nids[] = { |
| 6070 | 0x8 /*,0x6*/ |
| 6071 | }; |
| 6072 | |
| 6073 | static hda_nid_t stac9872_mux_nids[] = { |
| 6074 | 0x15 |
| 6075 | }; |
| 6076 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6077 | static unsigned long stac9872_capvols[] = { |
| 6078 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), |
| 6079 | }; |
| 6080 | #define stac9872_capsws stac9872_capvols |
| 6081 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6082 | static unsigned int stac9872_vaio_pin_configs[9] = { |
| 6083 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
| 6084 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
| 6085 | 0x90a7013e |
| 6086 | }; |
| 6087 | |
| 6088 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 6089 | [STAC_9872_AUTO] = "auto", |
| 6090 | [STAC_9872_VAIO] = "vaio", |
| 6091 | }; |
| 6092 | |
| 6093 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { |
| 6094 | [STAC_9872_VAIO] = stac9872_vaio_pin_configs, |
| 6095 | }; |
| 6096 | |
| 6097 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 6098 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, |
| 6099 | "Sony VAIO F/S", STAC_9872_VAIO), |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6100 | {} /* terminator */ |
| 6101 | }; |
| 6102 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 6103 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6104 | { |
| 6105 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6106 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6107 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6108 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6109 | if (spec == NULL) |
| 6110 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6111 | codec->spec = spec; |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 6112 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 6113 | spec->pin_nids = stac9872_pin_nids; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6114 | |
| 6115 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 6116 | stac9872_models, |
| 6117 | stac9872_cfg_tbl); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6118 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 6119 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 6120 | codec->chip_name); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6121 | else |
| 6122 | stac92xx_set_config_regs(codec, |
| 6123 | stac9872_brd_tbl[spec->board_config]); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6124 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6125 | spec->multiout.dac_nids = spec->dac_nids; |
| 6126 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 6127 | spec->adc_nids = stac9872_adc_nids; |
| 6128 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 6129 | spec->mux_nids = stac9872_mux_nids; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6130 | spec->init = stac9872_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6131 | spec->num_caps = 1; |
| 6132 | spec->capvols = stac9872_capvols; |
| 6133 | spec->capsws = stac9872_capsws; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6134 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6135 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 6136 | if (err < 0) { |
| 6137 | stac92xx_free(codec); |
| 6138 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6139 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6140 | spec->input_mux = &spec->private_imux; |
| 6141 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6142 | return 0; |
| 6143 | } |
| 6144 | |
| 6145 | |
| 6146 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6147 | * patch entries |
| 6148 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6149 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6150 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 6151 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 6152 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 6153 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 6154 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 6155 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 6156 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 6157 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 6158 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 6159 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 6160 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 6161 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 6162 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 6163 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 6164 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 6165 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 6166 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 6167 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 6168 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 6169 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 6170 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 6171 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 6172 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6173 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 6174 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 6175 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 6176 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 6177 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 6178 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 6179 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 6180 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 6181 | /* The following does not take into account .id=0x83847661 when subsys = |
| 6182 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 6183 | * currently not fully supported. |
| 6184 | */ |
| 6185 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 6186 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 6187 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 6188 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 6189 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 6190 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 6191 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 6192 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 6193 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 6194 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 6195 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 6196 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6197 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6198 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 6199 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 6200 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6201 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6202 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 6203 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6204 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6205 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 6206 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 6207 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 6208 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 6209 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 6210 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 6211 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 6212 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6213 | {} /* terminator */ |
| 6214 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6215 | |
| 6216 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 6217 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 6218 | |
| 6219 | MODULE_LICENSE("GPL"); |
| 6220 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 6221 | |
| 6222 | static struct hda_codec_preset_list sigmatel_list = { |
| 6223 | .preset = snd_hda_preset_sigmatel, |
| 6224 | .owner = THIS_MODULE, |
| 6225 | }; |
| 6226 | |
| 6227 | static int __init patch_sigmatel_init(void) |
| 6228 | { |
| 6229 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 6230 | } |
| 6231 | |
| 6232 | static void __exit patch_sigmatel_exit(void) |
| 6233 | { |
| 6234 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 6235 | } |
| 6236 | |
| 6237 | module_init(patch_sigmatel_init) |
| 6238 | module_exit(patch_sigmatel_exit) |