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 | c8b6bf9b | 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 | 4fe5195 | 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 | 4fe5195 | 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 | 4fe5195 | 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 | 4fe5195 | 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 | 1697055 | 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 | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 250 | unsigned int num_analog_muxes; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 251 | |
| 252 | unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ |
| 253 | unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ |
| 254 | unsigned int num_caps; /* number of capture volume/switch elements */ |
| 255 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 256 | struct sigmatel_mic_route ext_mic; |
| 257 | struct sigmatel_mic_route int_mic; |
| 258 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 259 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 260 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 261 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 262 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 263 | hda_nid_t anabeep_nid; |
| 264 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 265 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 266 | /* pin widgets */ |
| 267 | hda_nid_t *pin_nids; |
| 268 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 269 | |
| 270 | /* codec specific stuff */ |
| 271 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 272 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 273 | |
| 274 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 275 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 276 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 277 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 278 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 279 | struct hda_input_mux *sinput_mux; |
| 280 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 281 | unsigned int cur_amux; |
| 282 | hda_nid_t *amp_nids; |
| 283 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 284 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 285 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 286 | /* i/o switches */ |
| 287 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 288 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 289 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 290 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 291 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 292 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 293 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 294 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 295 | |
| 296 | /* dynamic controls and input_mux */ |
| 297 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 298 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 299 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 300 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 301 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 302 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 303 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | static hda_nid_t stac9200_adc_nids[1] = { |
| 307 | 0x03, |
| 308 | }; |
| 309 | |
| 310 | static hda_nid_t stac9200_mux_nids[1] = { |
| 311 | 0x0c, |
| 312 | }; |
| 313 | |
| 314 | static hda_nid_t stac9200_dac_nids[1] = { |
| 315 | 0x02, |
| 316 | }; |
| 317 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 318 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 319 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 320 | 0x0f, 0x10, 0x11 |
| 321 | }; |
| 322 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 323 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 324 | 0x26, 0, |
| 325 | }; |
| 326 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 327 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 328 | 0x1a, 0x1b |
| 329 | }; |
| 330 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 331 | #define DELL_M6_AMP 2 |
| 332 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 333 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 334 | }; |
| 335 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 336 | #define STAC92HD73XX_NUM_DMICS 2 |
| 337 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 338 | 0x13, 0x14, 0 |
| 339 | }; |
| 340 | |
| 341 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 342 | |
| 343 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 344 | 0x28, 0x29, 0x2a, 0x2b, |
| 345 | }; |
| 346 | |
| 347 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 348 | 0x20, 0x21, |
| 349 | }; |
| 350 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 351 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 352 | 0x22, 0x23, |
| 353 | }; |
| 354 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 355 | #define STAC92HD73XX_NUM_CAPS 2 |
| 356 | static unsigned long stac92hd73xx_capvols[] = { |
| 357 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
| 358 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 359 | }; |
| 360 | #define stac92hd73xx_capsws stac92hd73xx_capvols |
| 361 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 362 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 363 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 364 | static hda_nid_t stac92hd83xxx_mux_nids[2] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 365 | 0x17, 0x18, |
| 366 | }; |
| 367 | |
| 368 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 369 | 0x15, 0x16, |
| 370 | }; |
| 371 | |
| 372 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 373 | 0xa, 0xb, 0xd, 0xe, |
| 374 | }; |
| 375 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 376 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 377 | 0x1e, 0, |
| 378 | }; |
| 379 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 380 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 381 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 382 | }; |
| 383 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 384 | #define STAC92HD83XXX_NUM_CAPS 2 |
| 385 | static unsigned long stac92hd83xxx_capvols[] = { |
| 386 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), |
| 387 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), |
| 388 | }; |
| 389 | #define stac92hd83xxx_capsws stac92hd83xxx_capvols |
| 390 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 391 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 392 | 0x0a, 0x0d, 0x0f |
| 393 | }; |
| 394 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 395 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 396 | 0x12, 0x13, |
| 397 | }; |
| 398 | |
| 399 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 400 | 0x1a, 0x1b |
| 401 | }; |
| 402 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 403 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 404 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 405 | }; |
| 406 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 407 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 408 | 0x24, 0x25, |
| 409 | }; |
| 410 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 411 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 412 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 413 | 0x18, 0x19, 0 |
| 414 | }; |
| 415 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 416 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 417 | 0x22, 0 |
| 418 | }; |
| 419 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 420 | #define STAC92HD71BXX_NUM_CAPS 2 |
| 421 | static unsigned long stac92hd71bxx_capvols[] = { |
| 422 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 423 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 424 | }; |
| 425 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols |
| 426 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 427 | static hda_nid_t stac925x_adc_nids[1] = { |
| 428 | 0x03, |
| 429 | }; |
| 430 | |
| 431 | static hda_nid_t stac925x_mux_nids[1] = { |
| 432 | 0x0f, |
| 433 | }; |
| 434 | |
| 435 | static hda_nid_t stac925x_dac_nids[1] = { |
| 436 | 0x02, |
| 437 | }; |
| 438 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 439 | #define STAC925X_NUM_DMICS 1 |
| 440 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 441 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 442 | }; |
| 443 | |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 444 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 445 | 0x14, |
| 446 | }; |
| 447 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 448 | static unsigned long stac925x_capvols[] = { |
| 449 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), |
| 450 | }; |
| 451 | static unsigned long stac925x_capsws[] = { |
| 452 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 453 | }; |
| 454 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 455 | static hda_nid_t stac922x_adc_nids[2] = { |
| 456 | 0x06, 0x07, |
| 457 | }; |
| 458 | |
| 459 | static hda_nid_t stac922x_mux_nids[2] = { |
| 460 | 0x12, 0x13, |
| 461 | }; |
| 462 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 463 | #define STAC922X_NUM_CAPS 2 |
| 464 | static unsigned long stac922x_capvols[] = { |
| 465 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), |
| 466 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 467 | }; |
| 468 | #define stac922x_capsws stac922x_capvols |
| 469 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 470 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 471 | 0x1f, 0, |
| 472 | }; |
| 473 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 474 | static hda_nid_t stac927x_adc_nids[3] = { |
| 475 | 0x07, 0x08, 0x09 |
| 476 | }; |
| 477 | |
| 478 | static hda_nid_t stac927x_mux_nids[3] = { |
| 479 | 0x15, 0x16, 0x17 |
| 480 | }; |
| 481 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 482 | static hda_nid_t stac927x_smux_nids[1] = { |
| 483 | 0x21, |
| 484 | }; |
| 485 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 486 | static hda_nid_t stac927x_dac_nids[6] = { |
| 487 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 488 | }; |
| 489 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 490 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 491 | 0x1b, |
| 492 | }; |
| 493 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 494 | #define STAC927X_NUM_DMICS 2 |
| 495 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 496 | 0x13, 0x14, 0 |
| 497 | }; |
| 498 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 499 | #define STAC927X_NUM_CAPS 3 |
| 500 | static unsigned long stac927x_capvols[] = { |
| 501 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 502 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), |
| 503 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), |
| 504 | }; |
| 505 | static unsigned long stac927x_capsws[] = { |
| 506 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 507 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 508 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 509 | }; |
| 510 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 511 | static const char *stac927x_spdif_labels[5] = { |
| 512 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 513 | "Analog Mux 2", "Analog Mux 3" |
| 514 | }; |
| 515 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 516 | static hda_nid_t stac9205_adc_nids[2] = { |
| 517 | 0x12, 0x13 |
| 518 | }; |
| 519 | |
| 520 | static hda_nid_t stac9205_mux_nids[2] = { |
| 521 | 0x19, 0x1a |
| 522 | }; |
| 523 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 524 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 525 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 526 | }; |
| 527 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 528 | static hda_nid_t stac9205_smux_nids[1] = { |
| 529 | 0x21, |
| 530 | }; |
| 531 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 532 | #define STAC9205_NUM_DMICS 2 |
| 533 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 534 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 535 | }; |
| 536 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 537 | #define STAC9205_NUM_CAPS 2 |
| 538 | static unsigned long stac9205_capvols[] = { |
| 539 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), |
| 540 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), |
| 541 | }; |
| 542 | static unsigned long stac9205_capsws[] = { |
| 543 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 544 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), |
| 545 | }; |
| 546 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 547 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 548 | 0x08, 0x09, 0x0d, 0x0e, |
| 549 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 550 | }; |
| 551 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 552 | static hda_nid_t stac925x_pin_nids[8] = { |
| 553 | 0x07, 0x08, 0x0a, 0x0b, |
| 554 | 0x0c, 0x0d, 0x10, 0x11, |
| 555 | }; |
| 556 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 557 | static hda_nid_t stac922x_pin_nids[10] = { |
| 558 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 559 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 560 | }; |
| 561 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 562 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 563 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 564 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 565 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 566 | }; |
| 567 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 568 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 569 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 570 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 571 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 572 | |
| 573 | #define STAC92HD71BXX_NUM_PINS 13 |
| 574 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 575 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 576 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 577 | 0x1f, 0x20, 0x27 |
| 578 | }; |
| 579 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 580 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 581 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 582 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 583 | }; |
| 584 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 585 | static hda_nid_t stac927x_pin_nids[14] = { |
| 586 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 587 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 588 | 0x14, 0x21, 0x22, 0x23, |
| 589 | }; |
| 590 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 591 | static hda_nid_t stac9205_pin_nids[12] = { |
| 592 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 593 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 594 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 595 | }; |
| 596 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 597 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 598 | |
| 599 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 600 | struct snd_ctl_elem_value *ucontrol) |
| 601 | { |
| 602 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 603 | struct sigmatel_spec *spec = codec->spec; |
| 604 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 605 | |
| 606 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 607 | kcontrol->private_value |= nid; |
| 608 | |
| 609 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 610 | } |
| 611 | |
| 612 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 613 | struct snd_ctl_elem_value *ucontrol) |
| 614 | { |
| 615 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 616 | struct sigmatel_spec *spec = codec->spec; |
| 617 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 618 | |
| 619 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 620 | kcontrol->private_value |= nid; |
| 621 | |
| 622 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 623 | } |
| 624 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 625 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 626 | struct snd_ctl_elem_info *uinfo) |
| 627 | { |
| 628 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 629 | struct sigmatel_spec *spec = codec->spec; |
| 630 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 631 | } |
| 632 | |
| 633 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 634 | struct snd_ctl_elem_value *ucontrol) |
| 635 | { |
| 636 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 637 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 638 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 639 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 640 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 641 | return 0; |
| 642 | } |
| 643 | |
| 644 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 645 | struct snd_ctl_elem_value *ucontrol) |
| 646 | { |
| 647 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 648 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 649 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 650 | |
| 651 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 652 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 653 | } |
| 654 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 655 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 656 | struct snd_ctl_elem_info *uinfo) |
| 657 | { |
| 658 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 659 | struct sigmatel_spec *spec = codec->spec; |
| 660 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 661 | } |
| 662 | |
| 663 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 664 | struct snd_ctl_elem_value *ucontrol) |
| 665 | { |
| 666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 667 | struct sigmatel_spec *spec = codec->spec; |
| 668 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 669 | |
| 670 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 675 | struct snd_ctl_elem_value *ucontrol) |
| 676 | { |
| 677 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 678 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 679 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 680 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 681 | int err, val; |
| 682 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 683 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 684 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 685 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 686 | if (err < 0) |
| 687 | return err; |
| 688 | |
| 689 | if (spec->spdif_mute) { |
| 690 | if (smux_idx == 0) |
| 691 | nid = spec->multiout.dig_out_nid; |
| 692 | else |
| 693 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 694 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 695 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 696 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 697 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 698 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 699 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 700 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 701 | } |
| 702 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 703 | } |
| 704 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 705 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 706 | hda_nid_t nid, unsigned int new_vref) |
| 707 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 708 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 709 | unsigned int pincfg; |
| 710 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 711 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 712 | |
| 713 | pincfg &= 0xff; |
| 714 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 715 | pincfg |= new_vref; |
| 716 | |
| 717 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 718 | pincfg |= AC_PINCTL_OUT_EN; |
| 719 | else |
| 720 | pincfg |= AC_PINCTL_IN_EN; |
| 721 | |
| 722 | error = snd_hda_codec_write_cache(codec, nid, 0, |
| 723 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); |
| 724 | if (error < 0) |
| 725 | return error; |
| 726 | else |
| 727 | return 1; |
| 728 | } |
| 729 | |
| 730 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 731 | { |
| 732 | unsigned int vref; |
| 733 | vref = snd_hda_codec_read(codec, nid, 0, |
| 734 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 735 | vref &= AC_PINCTL_VREFEN; |
| 736 | return vref; |
| 737 | } |
| 738 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 739 | 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] | 740 | { |
| 741 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 742 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 743 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 744 | } |
| 745 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 746 | 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] | 747 | { |
| 748 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 749 | struct sigmatel_spec *spec = codec->spec; |
| 750 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 751 | |
| 752 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 753 | return 0; |
| 754 | } |
| 755 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 756 | 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] | 757 | { |
| 758 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 759 | struct sigmatel_spec *spec = codec->spec; |
| 760 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 761 | const struct hda_input_mux *imux = spec->input_mux; |
| 762 | unsigned int idx, prev_idx; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 763 | |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 764 | idx = ucontrol->value.enumerated.item[0]; |
| 765 | if (idx >= imux->num_items) |
| 766 | idx = imux->num_items - 1; |
| 767 | prev_idx = spec->cur_mux[adc_idx]; |
| 768 | if (prev_idx == idx) |
| 769 | return 0; |
| 770 | if (idx < spec->num_analog_muxes) { |
| 771 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, |
| 772 | AC_VERB_SET_CONNECT_SEL, |
| 773 | imux->items[idx].index); |
| 774 | if (prev_idx >= spec->num_analog_muxes) { |
| 775 | imux = spec->dinput_mux; |
| 776 | /* 0 = analog */ |
| 777 | snd_hda_codec_write_cache(codec, |
| 778 | spec->dmux_nids[adc_idx], 0, |
| 779 | AC_VERB_SET_CONNECT_SEL, |
| 780 | imux->items[0].index); |
| 781 | } |
| 782 | } else { |
| 783 | imux = spec->dinput_mux; |
| 784 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, |
| 785 | AC_VERB_SET_CONNECT_SEL, |
| 786 | imux->items[idx - 1].index); |
| 787 | } |
| 788 | spec->cur_mux[adc_idx] = idx; |
| 789 | return 1; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 790 | } |
| 791 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 792 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 793 | struct snd_ctl_elem_info *uinfo) |
| 794 | { |
| 795 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 796 | struct sigmatel_spec *spec = codec->spec; |
| 797 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 798 | } |
| 799 | |
| 800 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 801 | struct snd_ctl_elem_value *ucontrol) |
| 802 | { |
| 803 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 804 | struct sigmatel_spec *spec = codec->spec; |
| 805 | |
| 806 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 807 | return 0; |
| 808 | } |
| 809 | |
| 810 | static int stac92xx_mono_mux_enum_put(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 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 817 | spec->mono_nid, &spec->cur_mmux); |
| 818 | } |
| 819 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 820 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 821 | struct snd_ctl_elem_info *uinfo) |
| 822 | { |
| 823 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 824 | struct sigmatel_spec *spec = codec->spec; |
| 825 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 826 | } |
| 827 | |
| 828 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 829 | struct snd_ctl_elem_value *ucontrol) |
| 830 | { |
| 831 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 832 | struct sigmatel_spec *spec = codec->spec; |
| 833 | |
| 834 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 835 | return 0; |
| 836 | } |
| 837 | |
| 838 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 839 | struct snd_ctl_elem_value *ucontrol) |
| 840 | { |
| 841 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 842 | struct sigmatel_spec *spec = codec->spec; |
| 843 | struct snd_kcontrol *ctl = |
| 844 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 845 | if (!ctl) |
| 846 | return -EINVAL; |
| 847 | |
| 848 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 849 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 850 | |
| 851 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 852 | 0, &spec->cur_amux); |
| 853 | } |
| 854 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 855 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 856 | |
| 857 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 858 | struct snd_ctl_elem_value *ucontrol) |
| 859 | { |
| 860 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 861 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 862 | struct sigmatel_spec *spec = codec->spec; |
| 863 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 864 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 865 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 866 | return 0; |
| 867 | } |
| 868 | |
| 869 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 870 | struct snd_ctl_elem_value *ucontrol) |
| 871 | { |
| 872 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 873 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 874 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 875 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 876 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 877 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 878 | idx_val = spec->aloopback_mask << idx; |
| 879 | if (ucontrol->value.integer.value[0]) |
| 880 | val = spec->aloopback | idx_val; |
| 881 | else |
| 882 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 883 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 884 | return 0; |
| 885 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 886 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 887 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 888 | /* Only return the bits defined by the shift value of the |
| 889 | * first two bytes of the mask |
| 890 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 891 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 892 | kcontrol->private_value & 0xFFFF, 0x0); |
| 893 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 894 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 895 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 896 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 897 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 898 | } else { |
| 899 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 900 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 904 | kcontrol->private_value >> 16, dac_mode); |
| 905 | |
| 906 | return 1; |
| 907 | } |
| 908 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 909 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 910 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 911 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 912 | {} |
| 913 | }; |
| 914 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 915 | static struct hda_verb stac9200_eapd_init[] = { |
| 916 | /* set dac0mux for dac converter */ |
| 917 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 918 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 919 | {} |
| 920 | }; |
| 921 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 922 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 923 | /* set master volume and direct control */ |
| 924 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +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}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 928 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 929 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 930 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 931 | /* setup import muxs */ |
| 932 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 933 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 934 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 935 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 936 | {} |
| 937 | }; |
| 938 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 939 | static struct hda_verb dell_eq_core_init[] = { |
| 940 | /* set master volume to max value without distortion |
| 941 | * and direct control */ |
| 942 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 943 | /* setup adcs to point to mixer */ |
| 944 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 945 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 946 | /* setup import muxs */ |
| 947 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 948 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 949 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 950 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 951 | {} |
| 952 | }; |
| 953 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 954 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 955 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 956 | /* setup adcs to point to mixer */ |
| 957 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 958 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 959 | /* setup import muxs */ |
| 960 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 961 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 962 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 963 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 964 | {} |
| 965 | }; |
| 966 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 967 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 968 | /* set master volume and direct control */ |
| 969 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 970 | /* setup adcs to point to mixer */ |
| 971 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 972 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 973 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 974 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 975 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 976 | /* setup import muxs */ |
| 977 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 978 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 979 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 980 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 981 | {} |
| 982 | }; |
| 983 | |
| 984 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 985 | /* set master volume and direct control */ |
| 986 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 987 | /* dac3 is connected to import3 mux */ |
| 988 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 989 | /* setup adcs to point to mixer */ |
| 990 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 991 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 992 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 993 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 994 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 995 | /* setup import muxs */ |
| 996 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 997 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 998 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 999 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 1000 | {} |
| 1001 | }; |
| 1002 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1003 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1004 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1005 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 1006 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1007 | |
| 1008 | /* power state controls amps */ |
| 1009 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1010 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1011 | }; |
| 1012 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1013 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 1014 | /* set master volume and direct control */ |
| 1015 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1016 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1017 | }; |
| 1018 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 1019 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 1020 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 1021 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1022 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1023 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1024 | {} |
| 1025 | }; |
| 1026 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1027 | static struct hda_verb stac925x_core_init[] = { |
| 1028 | /* set dac0mux for dac converter */ |
| 1029 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1030 | /* mute the master volume */ |
| 1031 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1032 | {} |
| 1033 | }; |
| 1034 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1035 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1036 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1037 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1038 | {} |
| 1039 | }; |
| 1040 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1041 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1042 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1043 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1044 | /* unmute node 0x1b */ |
| 1045 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1046 | /* select node 0x03 as DAC */ |
| 1047 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1048 | {} |
| 1049 | }; |
| 1050 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1051 | static struct hda_verb stac927x_core_init[] = { |
| 1052 | /* set master volume and direct control */ |
| 1053 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1054 | /* enable analog pc beep path */ |
| 1055 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1056 | {} |
| 1057 | }; |
| 1058 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1059 | static struct hda_verb stac9205_core_init[] = { |
| 1060 | /* set master volume and direct control */ |
| 1061 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1062 | /* enable analog pc beep path */ |
| 1063 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1064 | {} |
| 1065 | }; |
| 1066 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 1067 | #define STAC_MONO_MUX \ |
| 1068 | { \ |
| 1069 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1070 | .name = "Mono Mux", \ |
| 1071 | .count = 1, \ |
| 1072 | .info = stac92xx_mono_mux_enum_info, \ |
| 1073 | .get = stac92xx_mono_mux_enum_get, \ |
| 1074 | .put = stac92xx_mono_mux_enum_put, \ |
| 1075 | } |
| 1076 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 1077 | #define STAC_AMP_MUX \ |
| 1078 | { \ |
| 1079 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1080 | .name = "Amp Selector Capture Switch", \ |
| 1081 | .count = 1, \ |
| 1082 | .info = stac92xx_amp_mux_enum_info, \ |
| 1083 | .get = stac92xx_amp_mux_enum_get, \ |
| 1084 | .put = stac92xx_amp_mux_enum_put, \ |
| 1085 | } |
| 1086 | |
| 1087 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 1088 | { \ |
| 1089 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1090 | .name = xname, \ |
| 1091 | .index = 0, \ |
| 1092 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1093 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1094 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 1095 | .info = stac92xx_amp_volume_info, \ |
| 1096 | .get = stac92xx_amp_volume_get, \ |
| 1097 | .put = stac92xx_amp_volume_put, \ |
| 1098 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 1099 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 1100 | } |
| 1101 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1102 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1103 | { \ |
| 1104 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1105 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1106 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1107 | .info = stac92xx_aloopback_info, \ |
| 1108 | .get = stac92xx_aloopback_get, \ |
| 1109 | .put = stac92xx_aloopback_put, \ |
| 1110 | .private_value = verb_read | (verb_write << 16), \ |
| 1111 | } |
| 1112 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1113 | #define DC_BIAS(xname, idx, nid) \ |
| 1114 | { \ |
| 1115 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1116 | .name = xname, \ |
| 1117 | .index = idx, \ |
| 1118 | .info = stac92xx_dc_bias_info, \ |
| 1119 | .get = stac92xx_dc_bias_get, \ |
| 1120 | .put = stac92xx_dc_bias_put, \ |
| 1121 | .private_value = nid, \ |
| 1122 | } |
| 1123 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1124 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1125 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1126 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1127 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1128 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1129 | { } /* end */ |
| 1130 | }; |
| 1131 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1132 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1133 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1134 | /* start of config #1 */ |
| 1135 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1136 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1137 | |
| 1138 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1139 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1140 | |
| 1141 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1142 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1143 | |
| 1144 | /* start of config #2 */ |
| 1145 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1146 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1147 | |
| 1148 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1149 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1150 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1151 | { } /* end */ |
| 1152 | }; |
| 1153 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1154 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1155 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1156 | {} |
| 1157 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1158 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1159 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1160 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1161 | {} |
| 1162 | }; |
| 1163 | |
| 1164 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1165 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1166 | {} |
| 1167 | }; |
| 1168 | |
| 1169 | static struct snd_kcontrol_new stac92hd73xx_8ch_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 | |
| 1187 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1188 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1189 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1190 | |
| 1191 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1192 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1193 | |
| 1194 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1195 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1196 | |
| 1197 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1198 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1199 | |
| 1200 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1201 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1202 | { } /* end */ |
| 1203 | }; |
| 1204 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1205 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1206 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1207 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1208 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1209 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1210 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1211 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1212 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1213 | { } /* end */ |
| 1214 | }; |
| 1215 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1216 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1217 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1218 | {} |
| 1219 | }; |
| 1220 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1221 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1222 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1223 | {} |
| 1224 | }; |
| 1225 | |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1226 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1227 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1228 | .name = "Digital Input Source", |
| 1229 | /* count set later */ |
| 1230 | .info = stac92xx_dmux_enum_info, |
| 1231 | .get = stac92xx_dmux_enum_get, |
| 1232 | .put = stac92xx_dmux_enum_put, |
| 1233 | }; |
| 1234 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1235 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1236 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1237 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1238 | /* count set later */ |
| 1239 | .info = stac92xx_smux_enum_info, |
| 1240 | .get = stac92xx_smux_enum_get, |
| 1241 | .put = stac92xx_smux_enum_put, |
| 1242 | }; |
| 1243 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1244 | static const char *slave_vols[] = { |
| 1245 | "Front Playback Volume", |
| 1246 | "Surround Playback Volume", |
| 1247 | "Center Playback Volume", |
| 1248 | "LFE Playback Volume", |
| 1249 | "Side Playback Volume", |
| 1250 | "Headphone Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1251 | "Speaker Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1252 | NULL |
| 1253 | }; |
| 1254 | |
| 1255 | static const char *slave_sws[] = { |
| 1256 | "Front Playback Switch", |
| 1257 | "Surround Playback Switch", |
| 1258 | "Center Playback Switch", |
| 1259 | "LFE Playback Switch", |
| 1260 | "Side Playback Switch", |
| 1261 | "Headphone Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1262 | "Speaker Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1263 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1264 | NULL |
| 1265 | }; |
| 1266 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1267 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1268 | 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] | 1269 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1270 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1271 | { |
| 1272 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1273 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1274 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1275 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1276 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1277 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 1278 | if (spec->mixer) { |
| 1279 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1280 | if (err < 0) |
| 1281 | return err; |
| 1282 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1283 | |
| 1284 | for (i = 0; i < spec->num_mixers; i++) { |
| 1285 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1286 | if (err < 0) |
| 1287 | return err; |
| 1288 | } |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 1289 | if (!spec->auto_mic && spec->num_dmuxes > 0 && |
| 1290 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1291 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1292 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1293 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1294 | if (err < 0) |
| 1295 | return err; |
| 1296 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1297 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1298 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1299 | struct hda_input_mux *smux = &spec->private_smux; |
| 1300 | /* check for mute support on SPDIF out */ |
| 1301 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1302 | smux->items[smux->num_items].label = "Off"; |
| 1303 | smux->items[smux->num_items].index = 0; |
| 1304 | smux->num_items++; |
| 1305 | spec->spdif_mute = 1; |
| 1306 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1307 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1308 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1309 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1310 | if (err < 0) |
| 1311 | return err; |
| 1312 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1313 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1314 | if (spec->multiout.dig_out_nid) { |
| 1315 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1316 | if (err < 0) |
| 1317 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1318 | err = snd_hda_create_spdif_share_sw(codec, |
| 1319 | &spec->multiout); |
| 1320 | if (err < 0) |
| 1321 | return err; |
| 1322 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1323 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1324 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1325 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1326 | if (err < 0) |
| 1327 | return err; |
| 1328 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1329 | |
| 1330 | /* if we have no master control, let's create it */ |
| 1331 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1332 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1333 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1334 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1335 | /* correct volume offset */ |
| 1336 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1337 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1338 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1339 | if (err < 0) |
| 1340 | return err; |
| 1341 | } |
| 1342 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1343 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1344 | NULL, slave_sws); |
| 1345 | if (err < 0) |
| 1346 | return err; |
| 1347 | } |
| 1348 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1349 | if (spec->aloopback_ctl && |
| 1350 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1351 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1352 | if (err < 0) |
| 1353 | return err; |
| 1354 | } |
| 1355 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1356 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1357 | |
| 1358 | /* create jack input elements */ |
| 1359 | if (spec->hp_detect) { |
| 1360 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1361 | int type = SND_JACK_HEADPHONE; |
| 1362 | nid = cfg->hp_pins[i]; |
| 1363 | /* jack detection */ |
| 1364 | if (cfg->hp_outs == i) |
| 1365 | type |= SND_JACK_LINEOUT; |
| 1366 | err = stac92xx_add_jack(codec, nid, type); |
| 1367 | if (err < 0) |
| 1368 | return err; |
| 1369 | } |
| 1370 | } |
| 1371 | for (i = 0; i < cfg->line_outs; i++) { |
| 1372 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1373 | SND_JACK_LINEOUT); |
| 1374 | if (err < 0) |
| 1375 | return err; |
| 1376 | } |
| 1377 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1378 | nid = cfg->input_pins[i]; |
| 1379 | if (nid) { |
| 1380 | err = stac92xx_add_jack(codec, nid, |
| 1381 | SND_JACK_MICROPHONE); |
| 1382 | if (err < 0) |
| 1383 | return err; |
| 1384 | } |
| 1385 | } |
| 1386 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1387 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1388 | } |
| 1389 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1390 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1391 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1392 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1393 | }; |
| 1394 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1395 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1396 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1397 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1398 | }; |
| 1399 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1400 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1401 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1402 | }; |
| 1403 | |
| 1404 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1405 | STAC 9200 pin configs for |
| 1406 | 102801A8 |
| 1407 | 102801DE |
| 1408 | 102801E8 |
| 1409 | */ |
| 1410 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1411 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1412 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1413 | }; |
| 1414 | |
| 1415 | /* |
| 1416 | STAC 9200 pin configs for |
| 1417 | 102801C0 |
| 1418 | 102801C1 |
| 1419 | */ |
| 1420 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1421 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1422 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1423 | }; |
| 1424 | |
| 1425 | /* |
| 1426 | STAC 9200 pin configs for |
| 1427 | 102801C4 (Dell Dimension E310) |
| 1428 | 102801C5 |
| 1429 | 102801C7 |
| 1430 | 102801D9 |
| 1431 | 102801DA |
| 1432 | 102801E3 |
| 1433 | */ |
| 1434 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1435 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1436 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1437 | }; |
| 1438 | |
| 1439 | |
| 1440 | /* |
| 1441 | STAC 9200-32 pin configs for |
| 1442 | 102801B5 (Dell Inspiron 630m) |
| 1443 | 102801D8 (Dell Inspiron 640m) |
| 1444 | */ |
| 1445 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1446 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1447 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1448 | }; |
| 1449 | |
| 1450 | /* |
| 1451 | STAC 9200-32 pin configs for |
| 1452 | 102801C2 (Dell Latitude D620) |
| 1453 | 102801C8 |
| 1454 | 102801CC (Dell Latitude D820) |
| 1455 | 102801D4 |
| 1456 | 102801D6 |
| 1457 | */ |
| 1458 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1459 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1460 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1461 | }; |
| 1462 | |
| 1463 | /* |
| 1464 | STAC 9200-32 pin configs for |
| 1465 | 102801CE (Dell XPS M1710) |
| 1466 | 102801CF (Dell Precision M90) |
| 1467 | */ |
| 1468 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1469 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1470 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1471 | }; |
| 1472 | |
| 1473 | /* |
| 1474 | STAC 9200-32 pin configs for |
| 1475 | 102801C9 |
| 1476 | 102801CA |
| 1477 | 102801CB (Dell Latitude 120L) |
| 1478 | 102801D3 |
| 1479 | */ |
| 1480 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1481 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1482 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1483 | }; |
| 1484 | |
| 1485 | /* |
| 1486 | STAC 9200-32 pin configs for |
| 1487 | 102801BD (Dell Inspiron E1505n) |
| 1488 | 102801EE |
| 1489 | 102801EF |
| 1490 | */ |
| 1491 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1492 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1493 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1494 | }; |
| 1495 | |
| 1496 | /* |
| 1497 | STAC 9200-32 pin configs for |
| 1498 | 102801F5 (Dell Inspiron 1501) |
| 1499 | 102801F6 |
| 1500 | */ |
| 1501 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1502 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1503 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1504 | }; |
| 1505 | |
| 1506 | /* |
| 1507 | STAC 9200-32 |
| 1508 | 102801CD (Dell Inspiron E1705/9400) |
| 1509 | */ |
| 1510 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1511 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1512 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1513 | }; |
| 1514 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1515 | static unsigned int oqo9200_pin_configs[8] = { |
| 1516 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1517 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1518 | }; |
| 1519 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1520 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1521 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1522 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1523 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1524 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1525 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1526 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1527 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1528 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1529 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1530 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1531 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1532 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1533 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1534 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1535 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1536 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1537 | }; |
| 1538 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1539 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1540 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1541 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1542 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1543 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1544 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1545 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1546 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1547 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1548 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1549 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1550 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1551 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1552 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1553 | [STAC_9200_M4] = "gateway-m4", |
| 1554 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1555 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1556 | }; |
| 1557 | |
| 1558 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1559 | /* SigmaTel reference board */ |
| 1560 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1561 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1562 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1563 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1564 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1565 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1566 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1567 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1568 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1569 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1570 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1571 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1572 | "unknown Dell", STAC_9200_DELL_D22), |
| 1573 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1574 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1575 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1576 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1577 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1578 | "unknown Dell", STAC_9200_DELL_D23), |
| 1579 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1580 | "unknown Dell", STAC_9200_DELL_D23), |
| 1581 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1582 | "unknown Dell", STAC_9200_DELL_M22), |
| 1583 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1584 | "unknown Dell", STAC_9200_DELL_M24), |
| 1585 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1586 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1587 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1588 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1589 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1590 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1591 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1592 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1593 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1594 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1595 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1596 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1597 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1598 | "unknown Dell", STAC_9200_DELL_M22), |
| 1599 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1600 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1601 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1602 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1603 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1604 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1605 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1606 | "unknown Dell", STAC_9200_DELL_D23), |
| 1607 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1608 | "unknown Dell", STAC_9200_DELL_D23), |
| 1609 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1610 | "unknown Dell", STAC_9200_DELL_D21), |
| 1611 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1612 | "unknown Dell", STAC_9200_DELL_D23), |
| 1613 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1614 | "unknown Dell", STAC_9200_DELL_D21), |
| 1615 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1616 | "unknown Dell", STAC_9200_DELL_M25), |
| 1617 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1618 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1619 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1620 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1621 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1622 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1623 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1624 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1625 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1626 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1627 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1628 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1629 | /* OQO Mobile */ |
| 1630 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1631 | {} /* terminator */ |
| 1632 | }; |
| 1633 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1634 | static unsigned int ref925x_pin_configs[8] = { |
| 1635 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1636 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1637 | }; |
| 1638 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1639 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1640 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1641 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1642 | }; |
| 1643 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1644 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1645 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1646 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1647 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1648 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1649 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1650 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1651 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1652 | }; |
| 1653 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1654 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1655 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1656 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1657 | }; |
| 1658 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1659 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1660 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1661 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1662 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1663 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1664 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1665 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1666 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1667 | }; |
| 1668 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1669 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1670 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1671 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1672 | }; |
| 1673 | |
| 1674 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1675 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1676 | [STAC_M1] = stac925xM1_pin_configs, |
| 1677 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1678 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1679 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | [STAC_M3] = stac925xM3_pin_configs, |
| 1681 | [STAC_M5] = stac925xM5_pin_configs, |
| 1682 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1683 | }; |
| 1684 | |
| 1685 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1686 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1687 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1688 | [STAC_M1] = "m1", |
| 1689 | [STAC_M1_2] = "m1-2", |
| 1690 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1691 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1692 | [STAC_M3] = "m3", |
| 1693 | [STAC_M5] = "m5", |
| 1694 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1695 | }; |
| 1696 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1697 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1698 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1699 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1700 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1701 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1702 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1703 | /* Not sure about the brand name for those */ |
| 1704 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1705 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1706 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1707 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1708 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1709 | }; |
| 1710 | |
| 1711 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1712 | /* SigmaTel reference board */ |
| 1713 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1714 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1715 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1716 | |
| 1717 | /* Default table for unknown ID */ |
| 1718 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1719 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1720 | {} /* terminator */ |
| 1721 | }; |
| 1722 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1723 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1724 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1725 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1726 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1727 | 0x01452050, |
| 1728 | }; |
| 1729 | |
| 1730 | static unsigned int dell_m6_pin_configs[13] = { |
| 1731 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1732 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1733 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1734 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1735 | }; |
| 1736 | |
| 1737 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1738 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1739 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1740 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1741 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1742 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1743 | }; |
| 1744 | |
| 1745 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1746 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1747 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1748 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1749 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1750 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1751 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1752 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1753 | }; |
| 1754 | |
| 1755 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1756 | /* SigmaTel reference board */ |
| 1757 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1758 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1759 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1760 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1761 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1762 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1763 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1764 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1765 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1766 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1767 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1768 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1769 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1770 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1771 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1772 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1773 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1774 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1775 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1776 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1777 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1778 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1779 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1780 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Takashi Iwai | 626f5ce | 2009-07-28 00:54:39 +0200 | [diff] [blame] | 1781 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, |
| 1782 | "Dell Studio 1555", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1783 | {} /* terminator */ |
| 1784 | }; |
| 1785 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1786 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1787 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1788 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1789 | 0x01451160, 0x98560170, |
| 1790 | }; |
| 1791 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1792 | static unsigned int dell_s14_pin_configs[10] = { |
| 1793 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1794 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1795 | 0x40f000f0, 0x40f000f0, |
| 1796 | }; |
| 1797 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1798 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1799 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1800 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1801 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1802 | }; |
| 1803 | |
| 1804 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1805 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1806 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1807 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1808 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1809 | }; |
| 1810 | |
| 1811 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1812 | /* SigmaTel reference board */ |
| 1813 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1814 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1815 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1816 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1817 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1818 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1819 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1820 | }; |
| 1821 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1822 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1823 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1824 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1825 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1826 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1827 | }; |
| 1828 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1829 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1830 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1831 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1832 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1833 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1834 | }; |
| 1835 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1836 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1837 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1838 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1839 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1840 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1841 | }; |
| 1842 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1843 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1844 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1845 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1846 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1847 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1848 | }; |
| 1849 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1850 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1851 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1852 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1853 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1854 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1855 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1856 | [STAC_HP_DV5] = NULL, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1857 | [STAC_HP_HDX] = NULL, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1858 | [STAC_HP_DV4_1222NR] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1859 | }; |
| 1860 | |
| 1861 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1862 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1863 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1864 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1865 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1866 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1867 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1868 | [STAC_HP_DV5] = "hp-dv5", |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1869 | [STAC_HP_HDX] = "hp-hdx", |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1870 | [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1871 | }; |
| 1872 | |
| 1873 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1874 | /* SigmaTel reference board */ |
| 1875 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1876 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1877 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1878 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1879 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 1880 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1881 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 1882 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1883 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1884 | "HP dv4-7", STAC_HP_DV5), |
| 1885 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1886 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1887 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 1888 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1889 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1890 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1891 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1892 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Takashi Iwai | 1972d02 | 2009-08-06 08:44:43 +0200 | [diff] [blame] | 1893 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, |
| 1894 | "HP", STAC_HP_DV5), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1895 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1896 | "unknown Dell", STAC_DELL_M4_1), |
| 1897 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1898 | "unknown Dell", STAC_DELL_M4_1), |
| 1899 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1900 | "unknown Dell", STAC_DELL_M4_1), |
| 1901 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1902 | "unknown Dell", STAC_DELL_M4_1), |
| 1903 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1904 | "unknown Dell", STAC_DELL_M4_1), |
| 1905 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1906 | "unknown Dell", STAC_DELL_M4_1), |
| 1907 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1908 | "unknown Dell", STAC_DELL_M4_1), |
| 1909 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1910 | "unknown Dell", STAC_DELL_M4_2), |
| 1911 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1912 | "unknown Dell", STAC_DELL_M4_2), |
| 1913 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1914 | "unknown Dell", STAC_DELL_M4_2), |
| 1915 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1916 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1917 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1918 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1919 | {} /* terminator */ |
| 1920 | }; |
| 1921 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1922 | static unsigned int ref922x_pin_configs[10] = { |
| 1923 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1924 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1925 | 0x40000100, 0x40000100, |
| 1926 | }; |
| 1927 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1928 | /* |
| 1929 | STAC 922X pin configs for |
| 1930 | 102801A7 |
| 1931 | 102801AB |
| 1932 | 102801A9 |
| 1933 | 102801D1 |
| 1934 | 102801D2 |
| 1935 | */ |
| 1936 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1937 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1938 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1939 | 0x01813122, 0x400001f2, |
| 1940 | }; |
| 1941 | |
| 1942 | /* |
| 1943 | STAC 922X pin configs for |
| 1944 | 102801AC |
| 1945 | 102801D0 |
| 1946 | */ |
| 1947 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1948 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1949 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1950 | 0x01813122, 0x400001f1, |
| 1951 | }; |
| 1952 | |
| 1953 | /* |
| 1954 | STAC 922X pin configs for |
| 1955 | 102801BF |
| 1956 | */ |
| 1957 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1958 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1959 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1960 | 0x40C003f1, 0x405003f0, |
| 1961 | }; |
| 1962 | |
| 1963 | /* |
| 1964 | STAC 9221 A1 pin configs for |
| 1965 | 102801D7 (Dell XPS M1210) |
| 1966 | */ |
| 1967 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1968 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1969 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1970 | 0x508003f3, 0x405003f4, |
| 1971 | }; |
| 1972 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1973 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1974 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1975 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1976 | 0x02a19120, 0x40000100, |
| 1977 | }; |
| 1978 | |
| 1979 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1980 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1981 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1982 | 0x02a19320, 0x40000100, |
| 1983 | }; |
| 1984 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1985 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1986 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1987 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1988 | 0x400000fc, 0x400000fb, |
| 1989 | }; |
| 1990 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1991 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1992 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1993 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1994 | 0x400000fc, 0x400000fb, |
| 1995 | }; |
| 1996 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1997 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1998 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1999 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 2000 | 0x400000fc, 0x400000fb, |
| 2001 | }; |
| 2002 | |
| 2003 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 2004 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2005 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2006 | 0x400000fc, 0x400000fb, |
| 2007 | }; |
| 2008 | |
| 2009 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 2010 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2011 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2012 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2013 | }; |
| 2014 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2015 | static unsigned int ecs202_pin_configs[10] = { |
| 2016 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 2017 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 2018 | 0x9037012e, 0x40e000f2, |
| 2019 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2020 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2021 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2022 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2023 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 2024 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2025 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 2026 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 2027 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 2028 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 2029 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2030 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2031 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2032 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 2033 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2034 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2035 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2036 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2037 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2038 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2039 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2040 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2041 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2042 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2043 | }; |
| 2044 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2045 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2046 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2047 | [STAC_D945_REF] = "ref", |
| 2048 | [STAC_D945GTP5] = "5stack", |
| 2049 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2050 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2051 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2052 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2053 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2054 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2055 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2056 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2057 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2058 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2059 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2060 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2061 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2062 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2063 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2064 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2065 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2066 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2067 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2068 | }; |
| 2069 | |
| 2070 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2071 | /* SigmaTel reference board */ |
| 2072 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2073 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2074 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2075 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2076 | /* Intel 945G based systems */ |
| 2077 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2078 | "Intel D945G", STAC_D945GTP3), |
| 2079 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2080 | "Intel D945G", STAC_D945GTP3), |
| 2081 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2082 | "Intel D945G", STAC_D945GTP3), |
| 2083 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2084 | "Intel D945G", STAC_D945GTP3), |
| 2085 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2086 | "Intel D945G", STAC_D945GTP3), |
| 2087 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2088 | "Intel D945G", STAC_D945GTP3), |
| 2089 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2090 | "Intel D945G", STAC_D945GTP3), |
| 2091 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2092 | "Intel D945G", STAC_D945GTP3), |
| 2093 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2094 | "Intel D945G", STAC_D945GTP3), |
| 2095 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2096 | "Intel D945G", STAC_D945GTP3), |
| 2097 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2098 | "Intel D945G", STAC_D945GTP3), |
| 2099 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2100 | "Intel D945G", STAC_D945GTP3), |
| 2101 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2102 | "Intel D945G", STAC_D945GTP3), |
| 2103 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2104 | "Intel D945G", STAC_D945GTP3), |
| 2105 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2106 | "Intel D945G", STAC_D945GTP3), |
| 2107 | /* Intel D945G 5-stack systems */ |
| 2108 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2109 | "Intel D945G", STAC_D945GTP5), |
| 2110 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2111 | "Intel D945G", STAC_D945GTP5), |
| 2112 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2113 | "Intel D945G", STAC_D945GTP5), |
| 2114 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2115 | "Intel D945G", STAC_D945GTP5), |
| 2116 | /* Intel 945P based systems */ |
| 2117 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2118 | "Intel D945P", STAC_D945GTP3), |
| 2119 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2120 | "Intel D945P", STAC_D945GTP3), |
| 2121 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2122 | "Intel D945P", STAC_D945GTP3), |
| 2123 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2124 | "Intel D945P", STAC_D945GTP3), |
| 2125 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2126 | "Intel D945P", STAC_D945GTP3), |
| 2127 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2128 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2129 | /* other intel */ |
| 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2131 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2132 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2133 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2134 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2135 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2136 | /* Dell systems */ |
| 2137 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2138 | "unknown Dell", STAC_922X_DELL_D81), |
| 2139 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2140 | "unknown Dell", STAC_922X_DELL_D81), |
| 2141 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2142 | "unknown Dell", STAC_922X_DELL_D81), |
| 2143 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2144 | "unknown Dell", STAC_922X_DELL_D82), |
| 2145 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2146 | "unknown Dell", STAC_922X_DELL_M81), |
| 2147 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2148 | "unknown Dell", STAC_922X_DELL_D82), |
| 2149 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2150 | "unknown Dell", STAC_922X_DELL_D81), |
| 2151 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2152 | "unknown Dell", STAC_922X_DELL_D81), |
| 2153 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2154 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2155 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2156 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2157 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2158 | {} /* terminator */ |
| 2159 | }; |
| 2160 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2161 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2162 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2163 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2164 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2165 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2166 | }; |
| 2167 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2168 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2169 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2170 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2171 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2172 | 0x40000100, 0x40000100 |
| 2173 | }; |
| 2174 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2175 | static unsigned int d965_5st_pin_configs[14] = { |
| 2176 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2177 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2178 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2179 | 0x40000100, 0x40000100 |
| 2180 | }; |
| 2181 | |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2182 | static unsigned int d965_5st_no_fp_pin_configs[14] = { |
| 2183 | 0x40000100, 0x40000100, 0x0181304e, 0x01014010, |
| 2184 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2185 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2186 | 0x40000100, 0x40000100 |
| 2187 | }; |
| 2188 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2189 | static unsigned int dell_3st_pin_configs[14] = { |
| 2190 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2191 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2192 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2193 | 0x40c003fc, 0x40000100 |
| 2194 | }; |
| 2195 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2196 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2197 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2198 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2199 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2200 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2201 | [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2202 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2203 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2204 | }; |
| 2205 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2206 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2207 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2208 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2209 | [STAC_D965_REF] = "ref", |
| 2210 | [STAC_D965_3ST] = "3stack", |
| 2211 | [STAC_D965_5ST] = "5stack", |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2212 | [STAC_D965_5ST_NO_FP] = "5stack-no-fp", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2213 | [STAC_DELL_3ST] = "dell-3stack", |
| 2214 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2215 | }; |
| 2216 | |
| 2217 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2218 | /* SigmaTel reference board */ |
| 2219 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2220 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2221 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2222 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2223 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2224 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2225 | 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] | 2226 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2227 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2228 | "Intel D965", STAC_D965_3ST), |
| 2229 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2230 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2231 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2232 | 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] | 2233 | 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] | 2234 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2235 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2236 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2237 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2238 | 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] | 2239 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 2240 | 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] | 2241 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2242 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2243 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2244 | 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] | 2245 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2246 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2247 | "Intel D965", STAC_D965_5ST), |
| 2248 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2249 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2250 | {} /* terminator */ |
| 2251 | }; |
| 2252 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2253 | static unsigned int ref9205_pin_configs[12] = { |
| 2254 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2255 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2256 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2257 | }; |
| 2258 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2259 | /* |
| 2260 | STAC 9205 pin configs for |
| 2261 | 102801F1 |
| 2262 | 102801F2 |
| 2263 | 102801FC |
| 2264 | 102801FD |
| 2265 | 10280204 |
| 2266 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2267 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2268 | */ |
| 2269 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2270 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2271 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2272 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2273 | }; |
| 2274 | |
| 2275 | /* |
| 2276 | STAC 9205 pin configs for |
| 2277 | 102801F9 |
| 2278 | 102801FA |
| 2279 | 102801FE |
| 2280 | 102801FF (Dell Precision M4300) |
| 2281 | 10280206 |
| 2282 | 10280200 |
| 2283 | 10280201 |
| 2284 | */ |
| 2285 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2286 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2287 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2288 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2289 | }; |
| 2290 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2291 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2292 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2293 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2294 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2295 | }; |
| 2296 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2297 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2298 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2299 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2300 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2301 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2302 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2303 | }; |
| 2304 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2305 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2306 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2307 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2308 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2309 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2310 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2311 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2312 | }; |
| 2313 | |
| 2314 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2315 | /* SigmaTel reference board */ |
| 2316 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2317 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 2318 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 2319 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2320 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2321 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2322 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2323 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2324 | "unknown Dell", STAC_9205_DELL_M42), |
| 2325 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2326 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2327 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2328 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2329 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2330 | "Dell Precision", STAC_9205_DELL_M43), |
| 2331 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2332 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2333 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2334 | "unknown Dell", STAC_9205_DELL_M42), |
| 2335 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2336 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2337 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2338 | "Dell Precision", STAC_9205_DELL_M43), |
| 2339 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2340 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2341 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2342 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2343 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2344 | "Dell Precision", STAC_9205_DELL_M43), |
| 2345 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2346 | "Dell Precision", STAC_9205_DELL_M43), |
| 2347 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2348 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2349 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2350 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2351 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2352 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2353 | /* Gateway */ |
Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 2354 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2355 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2356 | {} /* terminator */ |
| 2357 | }; |
| 2358 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2359 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2360 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2361 | { |
| 2362 | int i; |
| 2363 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2364 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2365 | if (!pincfgs) |
| 2366 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2367 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2368 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2369 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2370 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2371 | pincfgs[i]); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2372 | } |
| 2373 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2374 | /* |
| 2375 | * Analog playback callbacks |
| 2376 | */ |
| 2377 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2378 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2379 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2380 | { |
| 2381 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2382 | if (spec->stream_delay) |
| 2383 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2384 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2385 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2386 | } |
| 2387 | |
| 2388 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2389 | struct hda_codec *codec, |
| 2390 | unsigned int stream_tag, |
| 2391 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2392 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2393 | { |
| 2394 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2395 | 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] | 2396 | } |
| 2397 | |
| 2398 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2399 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2400 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2401 | { |
| 2402 | struct sigmatel_spec *spec = codec->spec; |
| 2403 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2404 | } |
| 2405 | |
| 2406 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2407 | * Digital playback callbacks |
| 2408 | */ |
| 2409 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2410 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2411 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2412 | { |
| 2413 | struct sigmatel_spec *spec = codec->spec; |
| 2414 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2415 | } |
| 2416 | |
| 2417 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2418 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2419 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2420 | { |
| 2421 | struct sigmatel_spec *spec = codec->spec; |
| 2422 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2423 | } |
| 2424 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2425 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2426 | struct hda_codec *codec, |
| 2427 | unsigned int stream_tag, |
| 2428 | unsigned int format, |
| 2429 | struct snd_pcm_substream *substream) |
| 2430 | { |
| 2431 | struct sigmatel_spec *spec = codec->spec; |
| 2432 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2433 | stream_tag, format, substream); |
| 2434 | } |
| 2435 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2436 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2437 | struct hda_codec *codec, |
| 2438 | struct snd_pcm_substream *substream) |
| 2439 | { |
| 2440 | struct sigmatel_spec *spec = codec->spec; |
| 2441 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2442 | } |
| 2443 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2444 | |
| 2445 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2446 | * Analog capture callbacks |
| 2447 | */ |
| 2448 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2449 | struct hda_codec *codec, |
| 2450 | unsigned int stream_tag, |
| 2451 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2452 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2453 | { |
| 2454 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2455 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2456 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2457 | if (spec->powerdown_adcs) { |
| 2458 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2459 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2460 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2461 | } |
| 2462 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2463 | return 0; |
| 2464 | } |
| 2465 | |
| 2466 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2467 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 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 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2474 | if (spec->powerdown_adcs) |
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_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2477 | return 0; |
| 2478 | } |
| 2479 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2480 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2481 | .substreams = 1, |
| 2482 | .channels_min = 2, |
| 2483 | .channels_max = 2, |
| 2484 | /* NID is set in stac92xx_build_pcms */ |
| 2485 | .ops = { |
| 2486 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2487 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2488 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2489 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2490 | }, |
| 2491 | }; |
| 2492 | |
| 2493 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2494 | .substreams = 1, |
| 2495 | .channels_min = 2, |
| 2496 | .channels_max = 2, |
| 2497 | /* NID is set in stac92xx_build_pcms */ |
| 2498 | }; |
| 2499 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2500 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2501 | .substreams = 1, |
| 2502 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2503 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2504 | .nid = 0x02, /* NID to query formats and rates */ |
| 2505 | .ops = { |
| 2506 | .open = stac92xx_playback_pcm_open, |
| 2507 | .prepare = stac92xx_playback_pcm_prepare, |
| 2508 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2509 | }, |
| 2510 | }; |
| 2511 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2512 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2513 | .substreams = 1, |
| 2514 | .channels_min = 2, |
| 2515 | .channels_max = 2, |
| 2516 | .nid = 0x06, /* NID to query formats and rates */ |
| 2517 | .ops = { |
| 2518 | .open = stac92xx_playback_pcm_open, |
| 2519 | .prepare = stac92xx_playback_pcm_prepare, |
| 2520 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2521 | }, |
| 2522 | }; |
| 2523 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2524 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2525 | .channels_min = 2, |
| 2526 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2527 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2528 | .ops = { |
| 2529 | .prepare = stac92xx_capture_pcm_prepare, |
| 2530 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2531 | }, |
| 2532 | }; |
| 2533 | |
| 2534 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2535 | { |
| 2536 | struct sigmatel_spec *spec = codec->spec; |
| 2537 | struct hda_pcm *info = spec->pcm_rec; |
| 2538 | |
| 2539 | codec->num_pcms = 1; |
| 2540 | codec->pcm_info = info; |
| 2541 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2542 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2543 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2544 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2545 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2546 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2547 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2548 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2549 | |
| 2550 | if (spec->alt_switch) { |
| 2551 | codec->num_pcms++; |
| 2552 | info++; |
| 2553 | info->name = "STAC92xx Analog Alt"; |
| 2554 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2555 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2556 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2557 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2558 | codec->num_pcms++; |
| 2559 | info++; |
| 2560 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2561 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2562 | if (spec->multiout.dig_out_nid) { |
| 2563 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2564 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2565 | } |
| 2566 | if (spec->dig_in_nid) { |
| 2567 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2568 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2569 | } |
| 2570 | } |
| 2571 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2572 | return 0; |
| 2573 | } |
| 2574 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2575 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, |
| 2576 | hda_nid_t nid) |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2577 | { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2578 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2579 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2580 | if (pincap & AC_PINCAP_VREF_100) |
| 2581 | return AC_PINCTL_VREF_100; |
| 2582 | if (pincap & AC_PINCAP_VREF_80) |
| 2583 | return AC_PINCTL_VREF_80; |
| 2584 | if (pincap & AC_PINCAP_VREF_50) |
| 2585 | return AC_PINCTL_VREF_50; |
| 2586 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2587 | return AC_PINCTL_VREF_GRD; |
| 2588 | return 0; |
| 2589 | } |
| 2590 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2591 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2592 | |
| 2593 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2594 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2595 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2596 | } |
| 2597 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2598 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2599 | |
| 2600 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2601 | struct snd_ctl_elem_value *ucontrol) |
| 2602 | { |
| 2603 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2604 | struct sigmatel_spec *spec = codec->spec; |
| 2605 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2606 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2607 | return 0; |
| 2608 | } |
| 2609 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2610 | 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] | 2611 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2612 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2613 | struct snd_ctl_elem_value *ucontrol) |
| 2614 | { |
| 2615 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2616 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2617 | int nid = kcontrol->private_value; |
| 2618 | |
| 2619 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2620 | |
| 2621 | /* check to be sure that the ports are upto date with |
| 2622 | * switch changes |
| 2623 | */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2624 | stac_issue_unsol_event(codec, nid); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2625 | |
| 2626 | return 1; |
| 2627 | } |
| 2628 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2629 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 2630 | struct snd_ctl_elem_info *uinfo) |
| 2631 | { |
| 2632 | int i; |
| 2633 | static char *texts[] = { |
| 2634 | "Mic In", "Line In", "Line Out" |
| 2635 | }; |
| 2636 | |
| 2637 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2638 | struct sigmatel_spec *spec = codec->spec; |
| 2639 | hda_nid_t nid = kcontrol->private_value; |
| 2640 | |
| 2641 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 2642 | i = 3; |
| 2643 | else |
| 2644 | i = 2; |
| 2645 | |
| 2646 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2647 | uinfo->value.enumerated.items = i; |
| 2648 | uinfo->count = 1; |
| 2649 | if (uinfo->value.enumerated.item >= i) |
| 2650 | uinfo->value.enumerated.item = i-1; |
| 2651 | strcpy(uinfo->value.enumerated.name, |
| 2652 | texts[uinfo->value.enumerated.item]); |
| 2653 | |
| 2654 | return 0; |
| 2655 | } |
| 2656 | |
| 2657 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 2658 | struct snd_ctl_elem_value *ucontrol) |
| 2659 | { |
| 2660 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2661 | hda_nid_t nid = kcontrol->private_value; |
| 2662 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 2663 | |
| 2664 | if (vref == stac92xx_get_default_vref(codec, nid)) |
| 2665 | ucontrol->value.enumerated.item[0] = 0; |
| 2666 | else if (vref == AC_PINCTL_VREF_GRD) |
| 2667 | ucontrol->value.enumerated.item[0] = 1; |
| 2668 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 2669 | ucontrol->value.enumerated.item[0] = 2; |
| 2670 | |
| 2671 | return 0; |
| 2672 | } |
| 2673 | |
| 2674 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 2675 | struct snd_ctl_elem_value *ucontrol) |
| 2676 | { |
| 2677 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2678 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 2679 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2680 | hda_nid_t nid = kcontrol->private_value; |
| 2681 | |
| 2682 | if (ucontrol->value.enumerated.item[0] == 0) |
| 2683 | new_vref = stac92xx_get_default_vref(codec, nid); |
| 2684 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 2685 | new_vref = AC_PINCTL_VREF_GRD; |
| 2686 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 2687 | new_vref = AC_PINCTL_VREF_HIZ; |
| 2688 | else |
| 2689 | return 0; |
| 2690 | |
| 2691 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 2692 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 2693 | return error; |
| 2694 | } |
| 2695 | |
| 2696 | return 0; |
| 2697 | } |
| 2698 | |
| 2699 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 2700 | struct snd_ctl_elem_info *uinfo) |
| 2701 | { |
| 2702 | static char *texts[2]; |
| 2703 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2704 | struct sigmatel_spec *spec = codec->spec; |
| 2705 | |
| 2706 | if (kcontrol->private_value == spec->line_switch) |
| 2707 | texts[0] = "Line In"; |
| 2708 | else |
| 2709 | texts[0] = "Mic In"; |
| 2710 | texts[1] = "Line Out"; |
| 2711 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2712 | uinfo->value.enumerated.items = 2; |
| 2713 | uinfo->count = 1; |
| 2714 | |
| 2715 | if (uinfo->value.enumerated.item >= 2) |
| 2716 | uinfo->value.enumerated.item = 1; |
| 2717 | strcpy(uinfo->value.enumerated.name, |
| 2718 | texts[uinfo->value.enumerated.item]); |
| 2719 | |
| 2720 | return 0; |
| 2721 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2722 | |
| 2723 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2724 | { |
| 2725 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2726 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2727 | hda_nid_t nid = kcontrol->private_value; |
| 2728 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2729 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2730 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2731 | return 0; |
| 2732 | } |
| 2733 | |
| 2734 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2735 | { |
| 2736 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2737 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2738 | hda_nid_t nid = kcontrol->private_value; |
| 2739 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 2740 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2741 | |
| 2742 | spec->io_switch[io_idx] = val; |
| 2743 | |
| 2744 | if (val) |
| 2745 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2746 | else { |
| 2747 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2748 | if (io_idx) /* set VREF for mic */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2749 | pinctl |= stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2750 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2751 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2752 | |
| 2753 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2754 | * appropriately according to the pin direction |
| 2755 | */ |
| 2756 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2757 | stac_issue_unsol_event(codec, nid); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2758 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2759 | return 1; |
| 2760 | } |
| 2761 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2762 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2763 | |
| 2764 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2765 | struct snd_ctl_elem_value *ucontrol) |
| 2766 | { |
| 2767 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2768 | struct sigmatel_spec *spec = codec->spec; |
| 2769 | |
| 2770 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2771 | return 0; |
| 2772 | } |
| 2773 | |
| 2774 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2775 | struct snd_ctl_elem_value *ucontrol) |
| 2776 | { |
| 2777 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2778 | struct sigmatel_spec *spec = codec->spec; |
| 2779 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2780 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2781 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2782 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2783 | return 0; |
| 2784 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2785 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2786 | |
| 2787 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2788 | spec->clfe_swap ? 0x4 : 0x0); |
| 2789 | |
| 2790 | return 1; |
| 2791 | } |
| 2792 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2793 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2794 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2795 | .name = xname, \ |
| 2796 | .index = 0, \ |
| 2797 | .info = stac92xx_hp_switch_info, \ |
| 2798 | .get = stac92xx_hp_switch_get, \ |
| 2799 | .put = stac92xx_hp_switch_put, \ |
| 2800 | } |
| 2801 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2802 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2803 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2804 | .name = xname, \ |
| 2805 | .index = 0, \ |
| 2806 | .info = stac92xx_io_switch_info, \ |
| 2807 | .get = stac92xx_io_switch_get, \ |
| 2808 | .put = stac92xx_io_switch_put, \ |
| 2809 | .private_value = xpval, \ |
| 2810 | } |
| 2811 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2812 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2813 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2814 | .name = xname, \ |
| 2815 | .index = 0, \ |
| 2816 | .info = stac92xx_clfe_switch_info, \ |
| 2817 | .get = stac92xx_clfe_switch_get, \ |
| 2818 | .put = stac92xx_clfe_switch_put, \ |
| 2819 | .private_value = xpval, \ |
| 2820 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2821 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2822 | enum { |
| 2823 | STAC_CTL_WIDGET_VOL, |
| 2824 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2825 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2826 | STAC_CTL_WIDGET_AMP_MUX, |
| 2827 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2828 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2829 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2830 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2831 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2832 | }; |
| 2833 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2834 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2835 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2836 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2837 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2838 | STAC_AMP_MUX, |
| 2839 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2840 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2841 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2842 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2843 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2844 | }; |
| 2845 | |
| 2846 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2847 | static struct snd_kcontrol_new * |
| 2848 | stac_control_new(struct sigmatel_spec *spec, |
| 2849 | struct snd_kcontrol_new *ktemp, |
| 2850 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2851 | { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2852 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2853 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2854 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2855 | knew = snd_array_new(&spec->kctls); |
| 2856 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2857 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2858 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2859 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2860 | if (!knew->name) { |
| 2861 | /* roolback */ |
| 2862 | memset(knew, 0, sizeof(*knew)); |
| 2863 | spec->kctls.alloced--; |
| 2864 | return NULL; |
| 2865 | } |
| 2866 | return knew; |
| 2867 | } |
| 2868 | |
| 2869 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2870 | struct snd_kcontrol_new *ktemp, |
| 2871 | int idx, const char *name, |
| 2872 | unsigned long val) |
| 2873 | { |
| 2874 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2875 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2876 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2877 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2878 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2879 | return 0; |
| 2880 | } |
| 2881 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2882 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2883 | int type, int idx, const char *name, |
| 2884 | unsigned long val) |
| 2885 | { |
| 2886 | return stac92xx_add_control_temp(spec, |
| 2887 | &stac92xx_control_templates[type], |
| 2888 | idx, name, val); |
| 2889 | } |
| 2890 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2891 | |
| 2892 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2893 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2894 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2895 | { |
| 2896 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2897 | } |
| 2898 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2899 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2900 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2901 | .name = "Input Source", |
| 2902 | .info = stac92xx_mux_enum_info, |
| 2903 | .get = stac92xx_mux_enum_get, |
| 2904 | .put = stac92xx_mux_enum_put, |
| 2905 | }; |
| 2906 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2907 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 2908 | hda_nid_t nid, int idx) |
| 2909 | { |
| 2910 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 2911 | int control = 0; |
| 2912 | struct sigmatel_spec *spec = codec->spec; |
| 2913 | char name[22]; |
| 2914 | |
| 2915 | if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { |
| 2916 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
| 2917 | && nid == spec->line_switch) |
| 2918 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2919 | else if (snd_hda_query_pin_caps(codec, nid) |
| 2920 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 2921 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 2922 | else if (nid == spec->mic_switch) |
| 2923 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2924 | } |
| 2925 | |
| 2926 | if (control) { |
| 2927 | strcpy(name, auto_pin_cfg_labels[idx]); |
| 2928 | return stac92xx_add_control(codec->spec, control, |
| 2929 | strcat(name, " Jack Mode"), nid); |
| 2930 | } |
| 2931 | |
| 2932 | return 0; |
| 2933 | } |
| 2934 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2935 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2936 | { |
| 2937 | struct snd_kcontrol_new *knew; |
| 2938 | struct hda_input_mux *imux = &spec->private_imux; |
| 2939 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 2940 | if (spec->auto_mic) |
| 2941 | return 0; /* no need for input source */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2942 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2943 | return 0; /* no need for input source control */ |
| 2944 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2945 | stac_input_src_temp.name); |
| 2946 | if (!knew) |
| 2947 | return -ENOMEM; |
| 2948 | knew->count = spec->num_adcs; |
| 2949 | return 0; |
| 2950 | } |
| 2951 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2952 | /* check whether the line-input can be used as line-out */ |
| 2953 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2954 | { |
| 2955 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2956 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2957 | hda_nid_t nid; |
| 2958 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2959 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2960 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2961 | return 0; |
| 2962 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2963 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2964 | if (pincap & AC_PINCAP_OUT) |
| 2965 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2966 | return 0; |
| 2967 | } |
| 2968 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2969 | /* check whether the mic-input can be used as line-out */ |
| 2970 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2971 | { |
| 2972 | struct sigmatel_spec *spec = codec->spec; |
| 2973 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2974 | unsigned int def_conf, pincap; |
| 2975 | unsigned int mic_pin; |
| 2976 | |
| 2977 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2978 | return 0; |
| 2979 | mic_pin = AUTO_PIN_MIC; |
| 2980 | for (;;) { |
| 2981 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2982 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2983 | /* some laptops have an internal analog microphone |
| 2984 | * which can't be used as a output */ |
| 2985 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2986 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2987 | if (pincap & AC_PINCAP_OUT) |
| 2988 | return nid; |
| 2989 | } |
| 2990 | if (mic_pin == AUTO_PIN_MIC) |
| 2991 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 2992 | else |
| 2993 | break; |
| 2994 | } |
| 2995 | return 0; |
| 2996 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2997 | |
| 2998 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2999 | { |
| 3000 | int i; |
| 3001 | |
| 3002 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 3003 | if (spec->multiout.dac_nids[i] == nid) |
| 3004 | return 1; |
| 3005 | } |
| 3006 | |
| 3007 | return 0; |
| 3008 | } |
| 3009 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3010 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3011 | { |
| 3012 | int i; |
| 3013 | if (is_in_dac_nids(spec, nid)) |
| 3014 | return 1; |
| 3015 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 3016 | if (spec->hp_dacs[i] == nid) |
| 3017 | return 1; |
| 3018 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 3019 | if (spec->speaker_dacs[i] == nid) |
| 3020 | return 1; |
| 3021 | return 0; |
| 3022 | } |
| 3023 | |
| 3024 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 3025 | { |
| 3026 | struct sigmatel_spec *spec = codec->spec; |
| 3027 | int j, conn_len; |
| 3028 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 3029 | unsigned int wcaps, wtype; |
| 3030 | |
| 3031 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 3032 | HDA_MAX_CONNECTIONS); |
| 3033 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 3034 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3035 | wtype = get_wcaps_type(wcaps); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3036 | /* we check only analog outputs */ |
| 3037 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 3038 | continue; |
| 3039 | /* if this route has a free DAC, assign it */ |
| 3040 | if (!check_all_dac_nids(spec, conn[j])) { |
| 3041 | if (conn_len > 1) { |
| 3042 | /* select this DAC in the pin's input mux */ |
| 3043 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3044 | AC_VERB_SET_CONNECT_SEL, j); |
| 3045 | } |
| 3046 | return conn[j]; |
| 3047 | } |
| 3048 | } |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 3049 | /* if all DACs are already assigned, connect to the primary DAC */ |
| 3050 | if (conn_len > 1) { |
| 3051 | for (j = 0; j < conn_len; j++) { |
| 3052 | if (conn[j] == spec->multiout.dac_nids[0]) { |
| 3053 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3054 | AC_VERB_SET_CONNECT_SEL, j); |
| 3055 | break; |
| 3056 | } |
| 3057 | } |
| 3058 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3059 | return 0; |
| 3060 | } |
| 3061 | |
| 3062 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3063 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3064 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3065 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3066 | * Fill in the dac_nids table from the parsed pin configuration |
| 3067 | * This function only works when every pin in line_out_pins[] |
| 3068 | * contains atleast one DAC in its connection list. Some 92xx |
| 3069 | * codecs are not connected directly to a DAC, such as the 9200 |
| 3070 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3071 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3072 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3073 | { |
| 3074 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3075 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3076 | int i; |
| 3077 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3078 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3079 | for (i = 0; i < cfg->line_outs; i++) { |
| 3080 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3081 | dac = get_unassigned_dac(codec, nid); |
| 3082 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 3083 | if (spec->multiout.num_dacs > 0) { |
| 3084 | /* we have already working output pins, |
| 3085 | * so let's drop the broken ones again |
| 3086 | */ |
| 3087 | cfg->line_outs = spec->multiout.num_dacs; |
| 3088 | break; |
| 3089 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3090 | /* error out, no available DAC found */ |
| 3091 | snd_printk(KERN_ERR |
| 3092 | "%s: No available DAC for pin 0x%x\n", |
| 3093 | __func__, nid); |
| 3094 | return -ENODEV; |
| 3095 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3096 | add_spec_dacs(spec, dac); |
| 3097 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3098 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 3099 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3100 | nid = cfg->hp_pins[i]; |
| 3101 | dac = get_unassigned_dac(codec, nid); |
| 3102 | if (dac) { |
| 3103 | if (!spec->multiout.hp_nid) |
| 3104 | spec->multiout.hp_nid = dac; |
| 3105 | else |
| 3106 | add_spec_extra_dacs(spec, dac); |
| 3107 | } |
| 3108 | spec->hp_dacs[i] = dac; |
| 3109 | } |
| 3110 | |
| 3111 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 3112 | nid = cfg->speaker_pins[i]; |
| 3113 | dac = get_unassigned_dac(codec, nid); |
| 3114 | if (dac) |
| 3115 | add_spec_extra_dacs(spec, dac); |
| 3116 | spec->speaker_dacs[i] = dac; |
| 3117 | } |
| 3118 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3119 | /* add line-in as output */ |
| 3120 | nid = check_line_out_switch(codec); |
| 3121 | if (nid) { |
| 3122 | dac = get_unassigned_dac(codec, nid); |
| 3123 | if (dac) { |
| 3124 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 3125 | nid, cfg->line_outs); |
| 3126 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3127 | cfg->line_outs++; |
| 3128 | spec->line_switch = nid; |
| 3129 | add_spec_dacs(spec, dac); |
| 3130 | } |
| 3131 | } |
| 3132 | /* add mic as output */ |
| 3133 | nid = check_mic_out_switch(codec); |
| 3134 | if (nid) { |
| 3135 | dac = get_unassigned_dac(codec, nid); |
| 3136 | if (dac) { |
| 3137 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 3138 | nid, cfg->line_outs); |
| 3139 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3140 | cfg->line_outs++; |
| 3141 | spec->mic_switch = nid; |
| 3142 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3143 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3144 | } |
| 3145 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3146 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3147 | spec->multiout.num_dacs, |
| 3148 | spec->multiout.dac_nids[0], |
| 3149 | spec->multiout.dac_nids[1], |
| 3150 | spec->multiout.dac_nids[2], |
| 3151 | spec->multiout.dac_nids[3], |
| 3152 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3153 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3154 | return 0; |
| 3155 | } |
| 3156 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3157 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3158 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 3159 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3160 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3161 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3162 | char name[32]; |
| 3163 | int err; |
| 3164 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3165 | if (!spec->check_volume_offset) { |
| 3166 | unsigned int caps, step, nums, db_scale; |
| 3167 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3168 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 3169 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 3170 | step = (step + 1) * 25; /* in .01dB unit */ |
| 3171 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 3172 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3173 | db_scale = nums * step; |
| 3174 | /* if dB scale is over -64dB, and finer enough, |
| 3175 | * let's reduce it to half |
| 3176 | */ |
| 3177 | if (db_scale > 6400 && nums >= 0x1f) |
| 3178 | spec->volume_offset = nums / 2; |
| 3179 | spec->check_volume_offset = 1; |
| 3180 | } |
| 3181 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3182 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3183 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3184 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3185 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3186 | if (err < 0) |
| 3187 | return err; |
| 3188 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3189 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3190 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3191 | if (err < 0) |
| 3192 | return err; |
| 3193 | return 0; |
| 3194 | } |
| 3195 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3196 | #define create_controls(codec, pfx, nid, chs) \ |
| 3197 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 3198 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3199 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3200 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3201 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3202 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3203 | return 1; |
| 3204 | } else { |
| 3205 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3206 | spec->multiout.num_dacs++; |
| 3207 | } |
| 3208 | return 0; |
| 3209 | } |
| 3210 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3211 | 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] | 3212 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3213 | int i; |
| 3214 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3215 | if (!spec->multiout.extra_out_nid[i]) { |
| 3216 | spec->multiout.extra_out_nid[i] = nid; |
| 3217 | return 0; |
| 3218 | } |
| 3219 | } |
| 3220 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3221 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3222 | } |
| 3223 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3224 | /* Create output controls |
| 3225 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3226 | */ |
| 3227 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3228 | const hda_nid_t *pins, |
| 3229 | const hda_nid_t *dac_nids, |
| 3230 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3231 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3232 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3233 | static const char *chname[4] = { |
| 3234 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3235 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3236 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3237 | int i, err; |
| 3238 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3239 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3240 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 3241 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3242 | wid_caps = get_wcaps(codec, pins[i]); |
| 3243 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3244 | spec->hp_detect = 1; |
| 3245 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3246 | nid = dac_nids[i]; |
| 3247 | if (!nid) |
| 3248 | continue; |
| 3249 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3250 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3251 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3252 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3253 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3254 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3255 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3256 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3257 | |
| 3258 | wid_caps = get_wcaps(codec, nid); |
| 3259 | |
| 3260 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3261 | err = stac92xx_add_control(spec, |
| 3262 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3263 | "Swap Center/LFE Playback Switch", nid); |
| 3264 | |
| 3265 | if (err < 0) |
| 3266 | return err; |
| 3267 | } |
| 3268 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3269 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3270 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3271 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3272 | switch (type) { |
| 3273 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3274 | name = "Headphone"; |
| 3275 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3276 | break; |
| 3277 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3278 | name = "Speaker"; |
| 3279 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3280 | break; |
| 3281 | default: |
| 3282 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3283 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3284 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3285 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3286 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3287 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3288 | return err; |
| 3289 | } |
| 3290 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3291 | return 0; |
| 3292 | } |
| 3293 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3294 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, |
| 3295 | unsigned long sw, int idx) |
| 3296 | { |
| 3297 | int err; |
| 3298 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, |
Takashi Iwai | bf677bd | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 3299 | "Capture Volume", vol); |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3300 | if (err < 0) |
| 3301 | return err; |
| 3302 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, |
Takashi Iwai | bf677bd | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 3303 | "Capture Switch", sw); |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3304 | if (err < 0) |
| 3305 | return err; |
| 3306 | return 0; |
| 3307 | } |
| 3308 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3309 | /* add playback controls from the parsed DAC table */ |
| 3310 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3311 | const struct auto_pin_cfg *cfg) |
| 3312 | { |
| 3313 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3314 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3315 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3316 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3317 | |
| 3318 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3319 | spec->multiout.dac_nids, |
| 3320 | cfg->line_out_type); |
| 3321 | if (err < 0) |
| 3322 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3323 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3324 | 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] | 3325 | err = stac92xx_add_control(spec, |
| 3326 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3327 | "Headphone as Line Out Switch", |
| 3328 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3329 | if (err < 0) |
| 3330 | return err; |
| 3331 | } |
| 3332 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3333 | for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { |
| 3334 | nid = cfg->input_pins[idx]; |
| 3335 | if (nid) { |
| 3336 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 3337 | if (err < 0) |
| 3338 | return err; |
| 3339 | } |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3340 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3341 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3342 | return 0; |
| 3343 | } |
| 3344 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3345 | /* add playback controls for Speaker and HP outputs */ |
| 3346 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3347 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3348 | { |
| 3349 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3350 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3351 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3352 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3353 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3354 | if (err < 0) |
| 3355 | return err; |
| 3356 | |
| 3357 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3358 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3359 | if (err < 0) |
| 3360 | return err; |
| 3361 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3362 | return 0; |
| 3363 | } |
| 3364 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3365 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3366 | static const char *stac92xx_mono_labels[4] = { |
| 3367 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3368 | }; |
| 3369 | |
| 3370 | /* create mono mux for mono out on capable codecs */ |
| 3371 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3372 | { |
| 3373 | struct sigmatel_spec *spec = codec->spec; |
| 3374 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3375 | int i, num_cons; |
| 3376 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3377 | |
| 3378 | num_cons = snd_hda_get_connections(codec, |
| 3379 | spec->mono_nid, |
| 3380 | con_lst, |
| 3381 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3382 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3383 | return -EINVAL; |
| 3384 | |
| 3385 | for (i = 0; i < num_cons; i++) { |
| 3386 | mono_mux->items[mono_mux->num_items].label = |
| 3387 | stac92xx_mono_labels[i]; |
| 3388 | mono_mux->items[mono_mux->num_items].index = i; |
| 3389 | mono_mux->num_items++; |
| 3390 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3391 | |
| 3392 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3393 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3394 | } |
| 3395 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3396 | /* labels for amp mux outputs */ |
| 3397 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3398 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3399 | }; |
| 3400 | |
| 3401 | /* create amp out controls mux on capable codecs */ |
| 3402 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3403 | { |
| 3404 | struct sigmatel_spec *spec = codec->spec; |
| 3405 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3406 | int i, err; |
| 3407 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3408 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3409 | amp_mux->items[amp_mux->num_items].label = |
| 3410 | stac92xx_amp_labels[i]; |
| 3411 | amp_mux->items[amp_mux->num_items].index = i; |
| 3412 | amp_mux->num_items++; |
| 3413 | } |
| 3414 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3415 | if (spec->num_amps > 1) { |
| 3416 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3417 | "Amp Selector Capture Switch", 0); |
| 3418 | if (err < 0) |
| 3419 | return err; |
| 3420 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3421 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3422 | "Amp Capture Volume", |
| 3423 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3424 | } |
| 3425 | |
| 3426 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3427 | /* create PC beep volume controls */ |
| 3428 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3429 | hda_nid_t nid) |
| 3430 | { |
| 3431 | struct sigmatel_spec *spec = codec->spec; |
| 3432 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3433 | int err; |
| 3434 | |
| 3435 | /* check for mute support for the the amp */ |
| 3436 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3437 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3438 | "PC Beep Playback Switch", |
| 3439 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3440 | if (err < 0) |
| 3441 | return err; |
| 3442 | } |
| 3443 | |
| 3444 | /* check to see if there is volume support for the amp */ |
| 3445 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3446 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3447 | "PC Beep Playback Volume", |
| 3448 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3449 | if (err < 0) |
| 3450 | return err; |
| 3451 | } |
| 3452 | return 0; |
| 3453 | } |
| 3454 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3455 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3456 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3457 | |
| 3458 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3459 | struct snd_ctl_elem_value *ucontrol) |
| 3460 | { |
| 3461 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3462 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3463 | return 0; |
| 3464 | } |
| 3465 | |
| 3466 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3467 | struct snd_ctl_elem_value *ucontrol) |
| 3468 | { |
| 3469 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3470 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3471 | if (codec->beep->enabled != enabled) { |
| 3472 | codec->beep->enabled = enabled; |
| 3473 | return 1; |
| 3474 | } |
| 3475 | return 0; |
| 3476 | } |
| 3477 | |
| 3478 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3479 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3480 | .info = stac92xx_dig_beep_switch_info, |
| 3481 | .get = stac92xx_dig_beep_switch_get, |
| 3482 | .put = stac92xx_dig_beep_switch_put, |
| 3483 | }; |
| 3484 | |
| 3485 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3486 | { |
| 3487 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3488 | 0, "PC Beep Playback Switch", 0); |
| 3489 | } |
| 3490 | #endif |
| 3491 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3492 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3493 | { |
| 3494 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3495 | int i, j, err = 0; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3496 | |
| 3497 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3498 | hda_nid_t nid; |
| 3499 | unsigned int wcaps; |
| 3500 | unsigned long val; |
| 3501 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3502 | nid = spec->mux_nids[i]; |
| 3503 | wcaps = get_wcaps(codec, nid); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3504 | if (!(wcaps & AC_WCAP_OUT_AMP)) |
| 3505 | continue; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3506 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3507 | /* check whether already the same control was created as |
| 3508 | * normal Capture Volume. |
| 3509 | */ |
| 3510 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3511 | for (j = 0; j < spec->num_caps; j++) { |
| 3512 | if (spec->capvols[j] == val) |
| 3513 | break; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3514 | } |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3515 | if (j < spec->num_caps) |
| 3516 | continue; |
| 3517 | |
| 3518 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i, |
| 3519 | "Mux Capture Volume", val); |
| 3520 | if (err < 0) |
| 3521 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3522 | } |
| 3523 | return 0; |
| 3524 | }; |
| 3525 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3526 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3527 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3528 | }; |
| 3529 | |
| 3530 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3531 | { |
| 3532 | struct sigmatel_spec *spec = codec->spec; |
| 3533 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3534 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3535 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3536 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3537 | |
| 3538 | num_cons = snd_hda_get_connections(codec, |
| 3539 | spec->smux_nids[0], |
| 3540 | con_lst, |
| 3541 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3542 | if (num_cons <= 0) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3543 | return -EINVAL; |
| 3544 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3545 | if (!labels) |
| 3546 | labels = stac92xx_spdif_labels; |
| 3547 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3548 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3549 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3550 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3551 | spdif_mux->num_items++; |
| 3552 | } |
| 3553 | |
| 3554 | return 0; |
| 3555 | } |
| 3556 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3557 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3558 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3559 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3560 | "Digital Mic 3", "Digital Mic 4" |
| 3561 | }; |
| 3562 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3563 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, |
| 3564 | hda_nid_t nid) |
| 3565 | { |
| 3566 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
| 3567 | int i, nums; |
| 3568 | |
| 3569 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 3570 | for (i = 0; i < nums; i++) |
| 3571 | if (conn[i] == nid) |
| 3572 | return i; |
| 3573 | return -1; |
| 3574 | } |
| 3575 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3576 | /* create a volume assigned to the given pin (only if supported) */ |
| 3577 | static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, |
| 3578 | const char *label) |
| 3579 | { |
| 3580 | unsigned int caps, nums; |
| 3581 | char name[32]; |
| 3582 | |
| 3583 | if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) |
| 3584 | return 0; |
| 3585 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3586 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3587 | if (!nums) |
| 3588 | return 0; |
| 3589 | snprintf(name, sizeof(name), "%s Capture Volume", label); |
| 3590 | return stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, |
| 3591 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 3592 | } |
| 3593 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3594 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3595 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3596 | const struct auto_pin_cfg *cfg) |
| 3597 | { |
| 3598 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3599 | struct hda_input_mux *imux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3600 | struct hda_input_mux *dimux = &spec->private_dimux; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3601 | int err, i, active_mics; |
| 3602 | unsigned int def_conf; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3603 | |
| 3604 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3605 | dimux->items[dimux->num_items].index = 0; |
| 3606 | dimux->num_items++; |
| 3607 | |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3608 | active_mics = 0; |
| 3609 | for (i = 0; i < spec->num_dmics; i++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3610 | /* check the validity: sometimes it's a dead vendor-spec node */ |
| 3611 | if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i])) |
| 3612 | != AC_WID_PIN) |
| 3613 | continue; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3614 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
| 3615 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) |
| 3616 | active_mics++; |
| 3617 | } |
| 3618 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3619 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3620 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3621 | int index; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3622 | const char *label; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3623 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3624 | nid = spec->dmic_nids[i]; |
| 3625 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 3626 | continue; |
| 3627 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3628 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3629 | continue; |
| 3630 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3631 | index = get_connection_index(codec, spec->dmux_nids[0], nid); |
| 3632 | if (index < 0) |
| 3633 | continue; |
| 3634 | |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3635 | if (active_mics == 1) |
| 3636 | label = "Digital Mic"; |
| 3637 | else |
| 3638 | label = stac92xx_dmic_labels[dimux->num_items]; |
| 3639 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3640 | err = create_elem_capture_vol(codec, nid, label); |
| 3641 | if (err < 0) |
| 3642 | return err; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3643 | |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3644 | dimux->items[dimux->num_items].label = label; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3645 | dimux->items[dimux->num_items].index = index; |
| 3646 | dimux->num_items++; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3647 | if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { |
| 3648 | imux->items[imux->num_items].label = label; |
| 3649 | imux->items[imux->num_items].index = index; |
| 3650 | imux->num_items++; |
| 3651 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3652 | } |
| 3653 | |
| 3654 | return 0; |
| 3655 | } |
| 3656 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3657 | static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, |
| 3658 | hda_nid_t *fixed, hda_nid_t *ext) |
| 3659 | { |
| 3660 | unsigned int cfg; |
| 3661 | |
| 3662 | if (!nid) |
| 3663 | return 0; |
| 3664 | cfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3665 | switch (get_defcfg_connect(cfg)) { |
| 3666 | case AC_JACK_PORT_FIXED: |
| 3667 | if (*fixed) |
| 3668 | return 1; /* already occupied */ |
| 3669 | *fixed = nid; |
| 3670 | break; |
| 3671 | case AC_JACK_PORT_COMPLEX: |
| 3672 | if (*ext) |
| 3673 | return 1; /* already occupied */ |
| 3674 | *ext = nid; |
| 3675 | break; |
| 3676 | } |
| 3677 | return 0; |
| 3678 | } |
| 3679 | |
| 3680 | static int set_mic_route(struct hda_codec *codec, |
| 3681 | struct sigmatel_mic_route *mic, |
| 3682 | hda_nid_t pin) |
| 3683 | { |
| 3684 | struct sigmatel_spec *spec = codec->spec; |
| 3685 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3686 | int i; |
| 3687 | |
| 3688 | mic->pin = pin; |
| 3689 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) |
| 3690 | if (pin == cfg->input_pins[i]) |
| 3691 | break; |
| 3692 | if (i <= AUTO_PIN_FRONT_MIC) { |
| 3693 | /* analog pin */ |
| 3694 | mic->dmux_idx = 0; |
| 3695 | i = get_connection_index(codec, spec->mux_nids[0], pin); |
| 3696 | if (i < 0) |
| 3697 | return -1; |
| 3698 | mic->mux_idx = i; |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 3699 | } else if (spec->dmux_nids) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3700 | /* digital pin */ |
| 3701 | mic->mux_idx = 0; |
| 3702 | i = get_connection_index(codec, spec->dmux_nids[0], pin); |
| 3703 | if (i < 0) |
| 3704 | return -1; |
| 3705 | mic->dmux_idx = i; |
| 3706 | } |
| 3707 | return 0; |
| 3708 | } |
| 3709 | |
| 3710 | /* return non-zero if the device is for automatic mic switch */ |
| 3711 | static int stac_check_auto_mic(struct hda_codec *codec) |
| 3712 | { |
| 3713 | struct sigmatel_spec *spec = codec->spec; |
| 3714 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3715 | hda_nid_t fixed, ext; |
| 3716 | int i; |
| 3717 | |
| 3718 | for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { |
| 3719 | if (cfg->input_pins[i]) |
| 3720 | return 0; /* must be exclusively mics */ |
| 3721 | } |
| 3722 | fixed = ext = 0; |
| 3723 | for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) |
| 3724 | if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) |
| 3725 | return 0; |
| 3726 | for (i = 0; i < spec->num_dmics; i++) |
| 3727 | if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) |
| 3728 | return 0; |
| 3729 | if (!fixed || !ext) |
| 3730 | return 0; |
| 3731 | if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) |
| 3732 | return 0; /* no unsol support */ |
| 3733 | if (set_mic_route(codec, &spec->ext_mic, ext) || |
| 3734 | set_mic_route(codec, &spec->int_mic, fixed)) |
| 3735 | return 0; /* something is wrong */ |
| 3736 | return 1; |
| 3737 | } |
| 3738 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3739 | /* create playback/capture controls for input pins */ |
| 3740 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3741 | { |
| 3742 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3743 | struct hda_input_mux *imux = &spec->private_imux; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3744 | int i, j; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3745 | |
| 3746 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3747 | hda_nid_t nid = cfg->input_pins[i]; |
| 3748 | int index, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3749 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3750 | if (!nid) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3751 | continue; |
| 3752 | index = -1; |
| 3753 | for (j = 0; j < spec->num_muxes; j++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3754 | index = get_connection_index(codec, spec->mux_nids[j], |
| 3755 | nid); |
| 3756 | if (index >= 0) |
| 3757 | break; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3758 | } |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3759 | if (index < 0) |
| 3760 | continue; |
| 3761 | |
| 3762 | err = create_elem_capture_vol(codec, nid, |
| 3763 | auto_pin_cfg_labels[i]); |
| 3764 | if (err < 0) |
| 3765 | return err; |
| 3766 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3767 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3768 | imux->items[imux->num_items].index = index; |
| 3769 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3770 | } |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3771 | spec->num_analog_muxes = imux->num_items; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3772 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3773 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3774 | /* |
| 3775 | * Set the current input for the muxes. |
| 3776 | * The STAC9221 has two input muxes with identical source |
| 3777 | * NID lists. Hopefully this won't get confused. |
| 3778 | */ |
| 3779 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3780 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3781 | AC_VERB_SET_CONNECT_SEL, |
| 3782 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3783 | } |
| 3784 | } |
| 3785 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3786 | return 0; |
| 3787 | } |
| 3788 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3789 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3790 | { |
| 3791 | struct sigmatel_spec *spec = codec->spec; |
| 3792 | int i; |
| 3793 | |
| 3794 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3795 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3796 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3797 | } |
| 3798 | } |
| 3799 | |
| 3800 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3801 | { |
| 3802 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3803 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3804 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3805 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3806 | hda_nid_t pin; |
| 3807 | pin = spec->autocfg.hp_pins[i]; |
| 3808 | if (pin) /* connect to front */ |
| 3809 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3810 | } |
| 3811 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3812 | hda_nid_t pin; |
| 3813 | pin = spec->autocfg.speaker_pins[i]; |
| 3814 | if (pin) /* connect to front */ |
| 3815 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3816 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3817 | } |
| 3818 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3819 | 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] | 3820 | { |
| 3821 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3822 | int hp_swap = 0; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3823 | int i, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3824 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3825 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3826 | &spec->autocfg, |
| 3827 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3828 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3829 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3830 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3831 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3832 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3833 | * be set up as multi-channel outputs. |
| 3834 | */ |
| 3835 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3836 | spec->autocfg.hp_outs > 1) { |
| 3837 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3838 | * speaker_outs so that the following routines can handle |
| 3839 | * HP pins as primary outputs. |
| 3840 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3841 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3842 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3843 | sizeof(spec->autocfg.line_out_pins)); |
| 3844 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3845 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3846 | sizeof(spec->autocfg.hp_pins)); |
| 3847 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3848 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3849 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3850 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3851 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3852 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3853 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3854 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3855 | u32 caps = query_amp_caps(codec, |
| 3856 | spec->autocfg.mono_out_pin, dir); |
| 3857 | hda_nid_t conn_list[1]; |
| 3858 | |
| 3859 | /* get the mixer node and then the mono mux if it exists */ |
| 3860 | if (snd_hda_get_connections(codec, |
| 3861 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3862 | snd_hda_get_connections(codec, conn_list[0], |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3863 | conn_list, 1) > 0) { |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3864 | |
| 3865 | int wcaps = get_wcaps(codec, conn_list[0]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3866 | int wid_type = get_wcaps_type(wcaps); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3867 | /* LR swap check, some stac925x have a mux that |
| 3868 | * changes the DACs output path instead of the |
| 3869 | * mono-mux path. |
| 3870 | */ |
| 3871 | if (wid_type == AC_WID_AUD_SEL && |
| 3872 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3873 | spec->mono_nid = conn_list[0]; |
| 3874 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3875 | if (dir) { |
| 3876 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3877 | |
| 3878 | /* most mono outs have a least a mute/unmute switch */ |
| 3879 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3880 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3881 | "Mono Playback Switch", |
| 3882 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3883 | if (err < 0) |
| 3884 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3885 | /* check for volume support for the amp */ |
| 3886 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3887 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3888 | err = stac92xx_add_control(spec, |
| 3889 | STAC_CTL_WIDGET_VOL, |
| 3890 | "Mono Playback Volume", |
| 3891 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3892 | if (err < 0) |
| 3893 | return err; |
| 3894 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3895 | } |
| 3896 | |
| 3897 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3898 | AC_PINCTL_OUT_EN); |
| 3899 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3900 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3901 | if (!spec->multiout.num_dacs) { |
| 3902 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3903 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3904 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3905 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3906 | &spec->autocfg); |
| 3907 | if (err < 0) |
| 3908 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3909 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3910 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3911 | /* setup analog beep controls */ |
| 3912 | if (spec->anabeep_nid > 0) { |
| 3913 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3914 | spec->anabeep_nid); |
| 3915 | if (err < 0) |
| 3916 | return err; |
| 3917 | } |
| 3918 | |
| 3919 | /* setup digital beep controls and input device */ |
| 3920 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3921 | if (spec->digbeep_nid > 0) { |
| 3922 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3923 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3924 | |
| 3925 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3926 | if (err < 0) |
| 3927 | return err; |
| 3928 | err = snd_hda_attach_beep_device(codec, nid); |
| 3929 | if (err < 0) |
| 3930 | return err; |
Takashi Iwai | fa79796 | 2009-05-19 12:50:04 +0200 | [diff] [blame] | 3931 | /* IDT/STAC codecs have linear beep tone parameter */ |
| 3932 | codec->beep->linear_tone = 1; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3933 | /* if no beep switch is available, make its own one */ |
| 3934 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3935 | if (codec->beep && |
| 3936 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3937 | err = stac92xx_beep_switch_ctl(codec); |
| 3938 | if (err < 0) |
| 3939 | return err; |
| 3940 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3941 | } |
| 3942 | #endif |
| 3943 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3944 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3945 | if (err < 0) |
| 3946 | return err; |
| 3947 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3948 | /* All output parsing done, now restore the swapped hp pins */ |
| 3949 | if (hp_swap) { |
| 3950 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3951 | sizeof(spec->autocfg.hp_pins)); |
| 3952 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3953 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3954 | spec->autocfg.line_outs = 0; |
| 3955 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3956 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3957 | if (stac_check_auto_mic(codec)) { |
| 3958 | spec->auto_mic = 1; |
| 3959 | /* only one capture for auto-mic */ |
| 3960 | spec->num_adcs = 1; |
| 3961 | spec->num_caps = 1; |
| 3962 | spec->num_muxes = 1; |
| 3963 | } |
| 3964 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3965 | for (i = 0; i < spec->num_caps; i++) { |
| 3966 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], |
| 3967 | spec->capsws[i], i); |
| 3968 | if (err < 0) |
| 3969 | return err; |
| 3970 | } |
| 3971 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3972 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3973 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3974 | return err; |
| 3975 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3976 | if (spec->mono_nid > 0) { |
| 3977 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3978 | if (err < 0) |
| 3979 | return err; |
| 3980 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3981 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3982 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3983 | if (err < 0) |
| 3984 | return err; |
| 3985 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3986 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3987 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3988 | &spec->autocfg)) < 0) |
| 3989 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3990 | if (spec->num_muxes > 0) { |
| 3991 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3992 | if (err < 0) |
| 3993 | return err; |
| 3994 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3995 | if (spec->num_smuxes > 0) { |
| 3996 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3997 | if (err < 0) |
| 3998 | return err; |
| 3999 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4000 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4001 | err = stac92xx_add_input_source(spec); |
| 4002 | if (err < 0) |
| 4003 | return err; |
| 4004 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4005 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4006 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4007 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4008 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4009 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4010 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4011 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4012 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4013 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4014 | if (spec->kctls.list) |
| 4015 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4016 | |
| 4017 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 4018 | if (!spec->dinput_mux) |
| 4019 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4020 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4021 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4022 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4023 | return 1; |
| 4024 | } |
| 4025 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4026 | /* add playback controls for HP output */ |
| 4027 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 4028 | struct auto_pin_cfg *cfg) |
| 4029 | { |
| 4030 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4031 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4032 | unsigned int wid_caps; |
| 4033 | |
| 4034 | if (! pin) |
| 4035 | return 0; |
| 4036 | |
| 4037 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4038 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4039 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4040 | |
| 4041 | return 0; |
| 4042 | } |
| 4043 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4044 | /* add playback controls for LFE output */ |
| 4045 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 4046 | struct auto_pin_cfg *cfg) |
| 4047 | { |
| 4048 | struct sigmatel_spec *spec = codec->spec; |
| 4049 | int err; |
| 4050 | hda_nid_t lfe_pin = 0x0; |
| 4051 | int i; |
| 4052 | |
| 4053 | /* |
| 4054 | * search speaker outs and line outs for a mono speaker pin |
| 4055 | * with an amp. If one is found, add LFE controls |
| 4056 | * for it. |
| 4057 | */ |
| 4058 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 4059 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 4060 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4061 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 4062 | if (wcaps == AC_WCAP_OUT_AMP) |
| 4063 | /* found a mono speaker with an amp, must be lfe */ |
| 4064 | lfe_pin = pin; |
| 4065 | } |
| 4066 | |
| 4067 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 4068 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 4069 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 4070 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 4071 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4072 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 4073 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 4074 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4075 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 4076 | if (wcaps == AC_WCAP_OUT_AMP) |
| 4077 | /* found a mono speaker with an amp, |
| 4078 | must be lfe */ |
| 4079 | lfe_pin = pin; |
| 4080 | } |
| 4081 | } |
| 4082 | } |
| 4083 | |
| 4084 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4085 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4086 | if (err < 0) |
| 4087 | return err; |
| 4088 | } |
| 4089 | |
| 4090 | return 0; |
| 4091 | } |
| 4092 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4093 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 4094 | { |
| 4095 | struct sigmatel_spec *spec = codec->spec; |
| 4096 | int err; |
| 4097 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 4098 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4099 | return err; |
| 4100 | |
| 4101 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 4102 | return err; |
| 4103 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4104 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 4105 | return err; |
| 4106 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 4107 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 4108 | return err; |
| 4109 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 4110 | if (spec->num_muxes > 0) { |
| 4111 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 4112 | if (err < 0) |
| 4113 | return err; |
| 4114 | } |
| 4115 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4116 | err = stac92xx_add_input_source(spec); |
| 4117 | if (err < 0) |
| 4118 | return err; |
| 4119 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4120 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4121 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4122 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4123 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4124 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4125 | if (spec->kctls.list) |
| 4126 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4127 | |
| 4128 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4129 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4130 | |
| 4131 | return 1; |
| 4132 | } |
| 4133 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4134 | /* |
| 4135 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 4136 | * funky external mute control using GPIO pins. |
| 4137 | */ |
| 4138 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4139 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4140 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4141 | { |
| 4142 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4143 | |
| 4144 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4145 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4146 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4147 | |
| 4148 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4149 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4150 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4151 | |
| 4152 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4153 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4154 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4155 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4156 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4157 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 4158 | |
| 4159 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4160 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4161 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4162 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4163 | |
| 4164 | msleep(1); |
| 4165 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4166 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4167 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4168 | } |
| 4169 | |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4170 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4171 | static void stac92xx_free_jack_priv(struct snd_jack *jack) |
| 4172 | { |
| 4173 | struct sigmatel_jack *jacks = jack->private_data; |
| 4174 | jacks->nid = 0; |
| 4175 | jacks->jack = NULL; |
| 4176 | } |
| 4177 | #endif |
| 4178 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4179 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 4180 | hda_nid_t nid, int type) |
| 4181 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4182 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4183 | struct sigmatel_spec *spec = codec->spec; |
| 4184 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4185 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4186 | int connectivity = get_defcfg_connect(def_conf); |
| 4187 | char name[32]; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4188 | int err; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4189 | |
| 4190 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 4191 | return 0; |
| 4192 | |
| 4193 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 4194 | jack = snd_array_new(&spec->jacks); |
| 4195 | if (!jack) |
| 4196 | return -ENOMEM; |
| 4197 | jack->nid = nid; |
| 4198 | jack->type = type; |
| 4199 | |
Takashi Iwai | 86de741 | 2009-07-22 16:02:46 +0200 | [diff] [blame] | 4200 | snprintf(name, sizeof(name), "%s at %s %s Jack", |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4201 | snd_hda_get_jack_type(def_conf), |
| 4202 | snd_hda_get_jack_connectivity(def_conf), |
| 4203 | snd_hda_get_jack_location(def_conf)); |
| 4204 | |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4205 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
| 4206 | if (err < 0) { |
| 4207 | jack->nid = 0; |
| 4208 | return err; |
| 4209 | } |
| 4210 | jack->jack->private_data = jack; |
| 4211 | jack->jack->private_free = stac92xx_free_jack_priv; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4212 | #endif |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4213 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4214 | } |
| 4215 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4216 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 4217 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4218 | { |
| 4219 | struct sigmatel_event *event; |
| 4220 | |
| 4221 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 4222 | event = snd_array_new(&spec->events); |
| 4223 | if (!event) |
| 4224 | return -ENOMEM; |
| 4225 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4226 | event->type = type; |
| 4227 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4228 | event->data = data; |
| 4229 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4230 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4231 | } |
| 4232 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4233 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4234 | hda_nid_t nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4235 | { |
| 4236 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4237 | struct sigmatel_event *event = spec->events.list; |
| 4238 | int i; |
| 4239 | |
| 4240 | for (i = 0; i < spec->events.used; i++, event++) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4241 | if (event->nid == nid) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4242 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4243 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4244 | return NULL; |
| 4245 | } |
| 4246 | |
| 4247 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 4248 | unsigned char tag) |
| 4249 | { |
| 4250 | struct sigmatel_spec *spec = codec->spec; |
| 4251 | struct sigmatel_event *event = spec->events.list; |
| 4252 | int i; |
| 4253 | |
| 4254 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4255 | if (event->tag == tag) |
| 4256 | return event; |
| 4257 | } |
| 4258 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4259 | } |
| 4260 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4261 | /* check if given nid is a valid pin and no other events are assigned |
| 4262 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
| 4263 | * Otherwise, returns zero. |
| 4264 | */ |
| 4265 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 4266 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4267 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4268 | struct sigmatel_event *event; |
| 4269 | int tag; |
| 4270 | |
| 4271 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4272 | return 0; |
| 4273 | event = stac_get_event(codec, nid); |
| 4274 | if (event) { |
| 4275 | if (event->type != type) |
| 4276 | return 0; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4277 | tag = event->tag; |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4278 | } else { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4279 | tag = stac_add_event(codec->spec, nid, type, 0); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4280 | if (tag < 0) |
| 4281 | return 0; |
| 4282 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4283 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4284 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4285 | AC_USRSP_EN | tag); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4286 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4287 | } |
| 4288 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4289 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 4290 | { |
| 4291 | int i; |
| 4292 | for (i = 0; i < cfg->hp_outs; i++) |
| 4293 | if (cfg->hp_pins[i] == nid) |
| 4294 | return 1; /* nid is a HP-Out */ |
| 4295 | |
| 4296 | return 0; /* nid is not a HP-Out */ |
| 4297 | }; |
| 4298 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4299 | static void stac92xx_power_down(struct hda_codec *codec) |
| 4300 | { |
| 4301 | struct sigmatel_spec *spec = codec->spec; |
| 4302 | |
| 4303 | /* power down inactive DACs */ |
| 4304 | hda_nid_t *dac; |
| 4305 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4306 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4307 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4308 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4309 | } |
| 4310 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4311 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4312 | int enable); |
| 4313 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4314 | /* override some hints from the hwdep entry */ |
| 4315 | static void stac_store_hints(struct hda_codec *codec) |
| 4316 | { |
| 4317 | struct sigmatel_spec *spec = codec->spec; |
| 4318 | const char *p; |
| 4319 | int val; |
| 4320 | |
| 4321 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 4322 | if (val >= 0) |
| 4323 | spec->hp_detect = val; |
| 4324 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 4325 | if (p) { |
| 4326 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 4327 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 4328 | spec->gpio_mask; |
| 4329 | } |
| 4330 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 4331 | if (p) |
| 4332 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4333 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 4334 | if (p) |
| 4335 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4336 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 4337 | if (p) |
| 4338 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4339 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 4340 | if (val >= 0) |
| 4341 | spec->eapd_switch = val; |
| 4342 | } |
| 4343 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4344 | static int stac92xx_init(struct hda_codec *codec) |
| 4345 | { |
| 4346 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4347 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4348 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4349 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4350 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4351 | snd_hda_sequence_write(codec, spec->init); |
| 4352 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4353 | /* power down adcs initially */ |
| 4354 | if (spec->powerdown_adcs) |
| 4355 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4356 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4357 | spec->adc_nids[i], 0, |
| 4358 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4359 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4360 | /* override some hints */ |
| 4361 | stac_store_hints(codec); |
| 4362 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4363 | /* set up GPIO */ |
| 4364 | gpio = spec->gpio_data; |
| 4365 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4366 | * otherwise, unsol event will turn it on/off dynamically |
| 4367 | */ |
| 4368 | if (!spec->eapd_switch) |
| 4369 | gpio |= spec->eapd_mask; |
| 4370 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4371 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4372 | /* set up pins */ |
| 4373 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4374 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4375 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4376 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4377 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4378 | } |
Takashi Iwai | 1c4bdf9 | 2009-08-13 08:23:24 +0200 | [diff] [blame] | 4379 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && |
| 4380 | cfg->speaker_outs > 0) { |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4381 | /* enable pin-detect for line-outs as well */ |
Takashi Iwai | 15cfa2b | 2009-08-03 14:23:33 +0200 | [diff] [blame] | 4382 | for (i = 0; i < cfg->line_outs; i++) { |
| 4383 | hda_nid_t nid = cfg->line_out_pins[i]; |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4384 | enable_pin_detect(codec, nid, STAC_LO_EVENT); |
| 4385 | } |
| 4386 | } |
| 4387 | |
Takashi Iwai | 0a07aca | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4388 | /* force to enable the first line-out; the others are set up |
| 4389 | * in unsol_event |
| 4390 | */ |
| 4391 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4392 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4393 | /* fake event to set up pins */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4394 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4395 | } else { |
| 4396 | stac92xx_auto_init_multi_out(codec); |
| 4397 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4398 | for (i = 0; i < cfg->hp_outs; i++) |
| 4399 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4400 | } |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4401 | if (spec->auto_mic) { |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 4402 | /* initialize connection to analog input */ |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 4403 | if (spec->dmux_nids) |
| 4404 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 4405 | AC_VERB_SET_CONNECT_SEL, 0); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4406 | if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) |
| 4407 | stac_issue_unsol_event(codec, spec->ext_mic.pin); |
| 4408 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4409 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4410 | hda_nid_t nid = cfg->input_pins[i]; |
| 4411 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4412 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4413 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4414 | /* for mic pins, force to initialize */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4415 | pinctl = stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4416 | pinctl |= AC_PINCTL_IN_EN; |
| 4417 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4418 | } else { |
| 4419 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4420 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4421 | /* if PINCTL already set then skip */ |
Takashi Iwai | 5dd17cb9 | 2009-05-07 16:22:53 +0200 | [diff] [blame] | 4422 | /* Also, if both INPUT and OUTPUT are set, |
| 4423 | * it must be a BIOS bug; need to override, too |
| 4424 | */ |
| 4425 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 4426 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 4427 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4428 | pinctl |= AC_PINCTL_IN_EN; |
| 4429 | stac92xx_auto_set_pinctl(codec, nid, |
| 4430 | pinctl); |
| 4431 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4432 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4433 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4434 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4435 | if (enable_pin_detect(codec, nid, |
| 4436 | STAC_INSERT_EVENT)) |
| 4437 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4438 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4439 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4440 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4441 | for (i = 0; i < spec->num_dmics; i++) |
| 4442 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4443 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4444 | if (cfg->dig_out_pins[0]) |
| 4445 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4446 | AC_PINCTL_OUT_EN); |
| 4447 | if (cfg->dig_in_pin) |
| 4448 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4449 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4450 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4451 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4452 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4453 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4454 | /* power on when no jack detection is available */ |
| 4455 | if (!spec->hp_detect) { |
| 4456 | stac_toggle_power_map(codec, nid, 1); |
| 4457 | continue; |
| 4458 | } |
| 4459 | |
| 4460 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4461 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4462 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4463 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4464 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4465 | /* outputs are only ports capable of power management |
| 4466 | * any attempts on powering down a input port cause the |
| 4467 | * referenced VREF to act quirky. |
| 4468 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4469 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4470 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4471 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4472 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4473 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4474 | def_conf = get_defcfg_connect(def_conf); |
| 4475 | /* skip any ports that don't have jacks since presence |
| 4476 | * detection is useless */ |
| 4477 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4478 | if (def_conf != AC_JACK_PORT_NONE) |
| 4479 | stac_toggle_power_map(codec, nid, 1); |
| 4480 | continue; |
| 4481 | } |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4482 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) |
| 4483 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4484 | } |
| 4485 | if (spec->dac_list) |
| 4486 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4487 | return 0; |
| 4488 | } |
| 4489 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4490 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4491 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4492 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4493 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4494 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4495 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4496 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4497 | int i; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4498 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
| 4499 | if (jacks->jack) |
| 4500 | snd_device_free(codec->bus->card, jacks->jack); |
| 4501 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4502 | } |
| 4503 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4504 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4505 | } |
| 4506 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4507 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4508 | { |
| 4509 | struct sigmatel_spec *spec = codec->spec; |
| 4510 | |
| 4511 | if (spec->kctls.list) { |
| 4512 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4513 | int i; |
| 4514 | for (i = 0; i < spec->kctls.used; i++) |
| 4515 | kfree(kctl[i].name); |
| 4516 | } |
| 4517 | snd_array_free(&spec->kctls); |
| 4518 | } |
| 4519 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4520 | static void stac92xx_free(struct hda_codec *codec) |
| 4521 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4522 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4523 | |
| 4524 | if (! spec) |
| 4525 | return; |
| 4526 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4527 | stac92xx_free_jacks(codec); |
| 4528 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4529 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4530 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4531 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4532 | } |
| 4533 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4534 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4535 | unsigned int flag) |
| 4536 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4537 | unsigned int old_ctl, pin_ctl; |
| 4538 | |
| 4539 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4540 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4541 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4542 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4543 | /* |
| 4544 | * we need to check the current set-up direction of |
| 4545 | * shared input pins since they can be switched via |
| 4546 | * "xxx as Output" mixer switch |
| 4547 | */ |
| 4548 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4549 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4550 | return; |
| 4551 | } |
| 4552 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4553 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4554 | /* if setting pin direction bits, clear the current |
| 4555 | direction bits first */ |
| 4556 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4557 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4558 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4559 | pin_ctl |= flag; |
| 4560 | if (old_ctl != pin_ctl) |
| 4561 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4562 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4563 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4564 | } |
| 4565 | |
| 4566 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4567 | unsigned int flag) |
| 4568 | { |
| 4569 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4570 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4571 | if (pin_ctl & flag) |
| 4572 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4573 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4574 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4575 | } |
| 4576 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4577 | 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] | 4578 | { |
| 4579 | if (!nid) |
| 4580 | return 0; |
| 4581 | 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] | 4582 | & (1 << 31)) |
| 4583 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4584 | return 0; |
| 4585 | } |
| 4586 | |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4587 | static void stac92xx_line_out_detect(struct hda_codec *codec, |
| 4588 | int presence) |
| 4589 | { |
| 4590 | struct sigmatel_spec *spec = codec->spec; |
| 4591 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4592 | int i; |
| 4593 | |
| 4594 | for (i = 0; i < cfg->line_outs; i++) { |
| 4595 | if (presence) |
| 4596 | break; |
| 4597 | presence = get_pin_presence(codec, cfg->line_out_pins[i]); |
| 4598 | if (presence) { |
| 4599 | unsigned int pinctl; |
| 4600 | pinctl = snd_hda_codec_read(codec, |
| 4601 | cfg->line_out_pins[i], 0, |
| 4602 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4603 | if (pinctl & AC_PINCTL_IN_EN) |
| 4604 | presence = 0; /* mic- or line-input */ |
| 4605 | } |
| 4606 | } |
| 4607 | |
| 4608 | if (presence) { |
| 4609 | /* disable speakers */ |
| 4610 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4611 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4612 | AC_PINCTL_OUT_EN); |
| 4613 | if (spec->eapd_mask && spec->eapd_switch) |
| 4614 | stac_gpio_set(codec, spec->gpio_mask, |
| 4615 | spec->gpio_dir, spec->gpio_data & |
| 4616 | ~spec->eapd_mask); |
| 4617 | } else { |
| 4618 | /* enable speakers */ |
| 4619 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4620 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4621 | AC_PINCTL_OUT_EN); |
| 4622 | if (spec->eapd_mask && spec->eapd_switch) |
| 4623 | stac_gpio_set(codec, spec->gpio_mask, |
| 4624 | spec->gpio_dir, spec->gpio_data | |
| 4625 | spec->eapd_mask); |
| 4626 | } |
| 4627 | } |
| 4628 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4629 | /* return non-zero if the hp-pin of the given array index isn't |
| 4630 | * a jack-detection target |
| 4631 | */ |
| 4632 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4633 | { |
| 4634 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4635 | |
| 4636 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4637 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4638 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4639 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4640 | return 1; |
| 4641 | /* ignore if the pin is set as line-out */ |
| 4642 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4643 | return 1; |
| 4644 | return 0; |
| 4645 | } |
| 4646 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4647 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4648 | { |
| 4649 | struct sigmatel_spec *spec = codec->spec; |
| 4650 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4651 | int i, presence; |
| 4652 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4653 | presence = 0; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4654 | if (spec->gpio_mute) |
| 4655 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4656 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4657 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4658 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4659 | if (presence) |
| 4660 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4661 | if (no_hp_sensing(spec, i)) |
| 4662 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4663 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4664 | if (presence) { |
| 4665 | unsigned int pinctl; |
| 4666 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4667 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4668 | if (pinctl & AC_PINCTL_IN_EN) |
| 4669 | presence = 0; /* mic- or line-input */ |
| 4670 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4671 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4672 | |
| 4673 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4674 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4675 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4676 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4677 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4678 | for (i = 0; i < cfg->line_outs; i++) |
| 4679 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4680 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4681 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4682 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4683 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4684 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4685 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4686 | for (i = 0; i < cfg->line_outs; i++) |
| 4687 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4688 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4689 | } |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4690 | stac92xx_line_out_detect(codec, presence); |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4691 | /* toggle hp outs */ |
| 4692 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4693 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4694 | if (no_hp_sensing(spec, i)) |
| 4695 | continue; |
| 4696 | if (presence) |
| 4697 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4698 | #if 0 /* FIXME */ |
| 4699 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4700 | * on some devices since they use the HP pin actually for line/speaker |
| 4701 | * outs although the default pin config shows a different pin (that is |
| 4702 | * wrong and useless). |
| 4703 | * |
| 4704 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4705 | * But, disabling the code below just works around it, and I'm too tired of |
| 4706 | * bug reports with such devices... |
| 4707 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4708 | else |
| 4709 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4710 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4711 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4712 | } |
| 4713 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4714 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4715 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4716 | { |
| 4717 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4718 | unsigned int idx, val; |
| 4719 | |
| 4720 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4721 | if (spec->pwr_nids[idx] == nid) |
| 4722 | break; |
| 4723 | } |
| 4724 | if (idx >= spec->num_pwrs) |
| 4725 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4726 | |
| 4727 | /* several codecs have two power down bits */ |
| 4728 | if (spec->pwr_mapping) |
| 4729 | idx = spec->pwr_mapping[idx]; |
| 4730 | else |
| 4731 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4732 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4733 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4734 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4735 | val &= ~idx; |
| 4736 | else |
| 4737 | val |= idx; |
| 4738 | |
| 4739 | /* power down unused output ports */ |
| 4740 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4741 | } |
| 4742 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4743 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4744 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4745 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4746 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4747 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4748 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4749 | { |
| 4750 | struct sigmatel_spec *spec = codec->spec; |
| 4751 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4752 | |
| 4753 | if (jacks) { |
| 4754 | int i; |
| 4755 | for (i = 0; i < spec->jacks.used; i++) { |
| 4756 | if (jacks->nid == nid) { |
| 4757 | unsigned int pin_ctl = |
| 4758 | snd_hda_codec_read(codec, nid, |
| 4759 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4760 | 0x00); |
| 4761 | int type = jacks->type; |
| 4762 | if (type == (SND_JACK_LINEOUT |
| 4763 | | SND_JACK_HEADPHONE)) |
| 4764 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4765 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4766 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4767 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4768 | ? type : 0); |
| 4769 | } |
| 4770 | jacks++; |
| 4771 | } |
| 4772 | } |
| 4773 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4774 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4775 | static void stac92xx_mic_detect(struct hda_codec *codec) |
| 4776 | { |
| 4777 | struct sigmatel_spec *spec = codec->spec; |
| 4778 | struct sigmatel_mic_route *mic; |
| 4779 | |
| 4780 | if (get_pin_presence(codec, spec->ext_mic.pin)) |
| 4781 | mic = &spec->ext_mic; |
| 4782 | else |
| 4783 | mic = &spec->int_mic; |
| 4784 | if (mic->dmux_idx) |
| 4785 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
| 4786 | AC_VERB_SET_CONNECT_SEL, |
| 4787 | mic->dmux_idx); |
| 4788 | else |
| 4789 | snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, |
| 4790 | AC_VERB_SET_CONNECT_SEL, |
| 4791 | mic->mux_idx); |
| 4792 | } |
| 4793 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4794 | 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] | 4795 | { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4796 | struct sigmatel_event *event = stac_get_event(codec, nid); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4797 | if (!event) |
| 4798 | return; |
| 4799 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4800 | } |
| 4801 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4802 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4803 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4804 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4805 | struct sigmatel_event *event; |
| 4806 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4807 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4808 | tag = (res >> 26) & 0x7f; |
| 4809 | event = stac_get_event_from_tag(codec, tag); |
| 4810 | if (!event) |
| 4811 | return; |
| 4812 | |
| 4813 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4814 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4815 | case STAC_LO_EVENT: |
Takashi Iwai | 16ffe32 | 2009-08-04 13:40:54 +0200 | [diff] [blame] | 4816 | stac92xx_hp_detect(codec); |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4817 | break; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4818 | case STAC_MIC_EVENT: |
| 4819 | stac92xx_mic_detect(codec); |
| 4820 | break; |
| 4821 | } |
| 4822 | |
| 4823 | switch (event->type) { |
| 4824 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4825 | case STAC_LO_EVENT: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4826 | case STAC_MIC_EVENT: |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4827 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4828 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4829 | if (spec->num_pwrs > 0) |
| 4830 | stac92xx_pin_sense(codec, event->nid); |
| 4831 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 4832 | |
| 4833 | switch (codec->subsystem_id) { |
| 4834 | case 0x103c308f: |
| 4835 | if (event->nid == 0xb) { |
| 4836 | int pin = AC_PINCTL_IN_EN; |
| 4837 | |
| 4838 | if (get_pin_presence(codec, 0xa) |
| 4839 | && get_pin_presence(codec, 0xb)) |
| 4840 | pin |= AC_PINCTL_VREF_80; |
| 4841 | if (!get_pin_presence(codec, 0xb)) |
| 4842 | pin |= AC_PINCTL_VREF_80; |
| 4843 | |
| 4844 | /* toggle VREF state based on mic + hp pin |
| 4845 | * status |
| 4846 | */ |
| 4847 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 4848 | } |
| 4849 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4850 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4851 | case STAC_VREF_EVENT: |
| 4852 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4853 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4854 | /* toggle VREF state based on GPIOx status */ |
| 4855 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4856 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4857 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4858 | } |
| 4859 | } |
| 4860 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4861 | #ifdef CONFIG_PROC_FS |
| 4862 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4863 | struct hda_codec *codec, hda_nid_t nid) |
| 4864 | { |
| 4865 | if (nid == codec->afg) |
| 4866 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4867 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4868 | } |
| 4869 | |
| 4870 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4871 | struct hda_codec *codec, |
| 4872 | unsigned int verb) |
| 4873 | { |
| 4874 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4875 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4876 | } |
| 4877 | |
| 4878 | /* stac92hd71bxx, stac92hd73xx */ |
| 4879 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4880 | struct hda_codec *codec, hda_nid_t nid) |
| 4881 | { |
| 4882 | stac92hd_proc_hook(buffer, codec, nid); |
| 4883 | if (nid == codec->afg) |
| 4884 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4885 | } |
| 4886 | |
| 4887 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4888 | struct hda_codec *codec, hda_nid_t nid) |
| 4889 | { |
| 4890 | if (nid == codec->afg) |
| 4891 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4892 | } |
| 4893 | |
| 4894 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4895 | struct hda_codec *codec, hda_nid_t nid) |
| 4896 | { |
| 4897 | if (nid == codec->afg) |
| 4898 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4899 | } |
| 4900 | #else |
| 4901 | #define stac92hd_proc_hook NULL |
| 4902 | #define stac92hd7x_proc_hook NULL |
| 4903 | #define stac9205_proc_hook NULL |
| 4904 | #define stac927x_proc_hook NULL |
| 4905 | #endif |
| 4906 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4907 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4908 | static int stac92xx_resume(struct hda_codec *codec) |
| 4909 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4910 | struct sigmatel_spec *spec = codec->spec; |
| 4911 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4912 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4913 | snd_hda_codec_resume_amp(codec); |
| 4914 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4915 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4916 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4917 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4918 | return 0; |
| 4919 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4920 | |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4921 | /* |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4922 | * using power check for controlling mute led of HP notebooks |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4923 | * check for mute state only on Speakers (nid = 0x10) |
| 4924 | * |
| 4925 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
| 4926 | * the LED is NOT working properly ! |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4927 | * |
| 4928 | * Changed name to reflect that it now works for any designated |
| 4929 | * model, not just HP HDX. |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4930 | */ |
| 4931 | |
| 4932 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4933 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4934 | hda_nid_t nid) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4935 | { |
| 4936 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4937 | |
| 4938 | if (nid == 0x10) { |
| 4939 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4940 | HDA_AMP_MUTE) |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 4941 | spec->gpio_data &= ~spec->gpio_led; /* orange */ |
Takashi Iwai | ba84bfc | 2009-05-30 08:59:03 +0200 | [diff] [blame] | 4942 | else |
| 4943 | spec->gpio_data |= spec->gpio_led; /* white */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4944 | |
| 4945 | stac_gpio_set(codec, spec->gpio_mask, |
| 4946 | spec->gpio_dir, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4947 | spec->gpio_data); |
| 4948 | } |
| 4949 | |
| 4950 | return 0; |
| 4951 | } |
| 4952 | #endif |
| 4953 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4954 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4955 | { |
| 4956 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4957 | int i; |
| 4958 | hda_nid_t nid; |
| 4959 | |
| 4960 | /* reset each pin before powering down DAC/ADC to avoid click noise */ |
| 4961 | nid = codec->start_nid; |
| 4962 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 4963 | unsigned int wcaps = get_wcaps(codec, nid); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 4964 | unsigned int wid_type = get_wcaps_type(wcaps); |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4965 | if (wid_type == AC_WID_PIN) |
| 4966 | snd_hda_codec_read(codec, nid, 0, |
| 4967 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); |
| 4968 | } |
| 4969 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4970 | if (spec->eapd_mask) |
| 4971 | stac_gpio_set(codec, spec->gpio_mask, |
| 4972 | spec->gpio_dir, spec->gpio_data & |
| 4973 | ~spec->eapd_mask); |
| 4974 | return 0; |
| 4975 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4976 | #endif |
| 4977 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4978 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4979 | .build_controls = stac92xx_build_controls, |
| 4980 | .build_pcms = stac92xx_build_pcms, |
| 4981 | .init = stac92xx_init, |
| 4982 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4983 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4984 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4985 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4986 | .resume = stac92xx_resume, |
| 4987 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4988 | }; |
| 4989 | |
| 4990 | static int patch_stac9200(struct hda_codec *codec) |
| 4991 | { |
| 4992 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4993 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4994 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4995 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4996 | if (spec == NULL) |
| 4997 | return -ENOMEM; |
| 4998 | |
| 4999 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5000 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5001 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5002 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 5003 | stac9200_models, |
| 5004 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5005 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5006 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5007 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5008 | else |
| 5009 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5010 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5011 | |
| 5012 | spec->multiout.max_channels = 2; |
| 5013 | spec->multiout.num_dacs = 1; |
| 5014 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 5015 | spec->adc_nids = stac9200_adc_nids; |
| 5016 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 5017 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5018 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5019 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5020 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5021 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 5022 | if (spec->board_config == STAC_9200_M4 || |
| 5023 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 5024 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 5025 | spec->init = stac9200_eapd_init; |
| 5026 | else |
| 5027 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5028 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5029 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 5030 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 5031 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 5032 | spec->gpio_data = 0x00; |
| 5033 | } |
| 5034 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5035 | err = stac9200_parse_auto_config(codec); |
| 5036 | if (err < 0) { |
| 5037 | stac92xx_free(codec); |
| 5038 | return err; |
| 5039 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5040 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 5041 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 5042 | * do detection and HP/speaker toggle because the hardware does it. |
| 5043 | */ |
| 5044 | if (spec->board_config == STAC_9200_PANASONIC) |
| 5045 | spec->hp_detect = 0; |
| 5046 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5047 | codec->patch_ops = stac92xx_patch_ops; |
| 5048 | |
| 5049 | return 0; |
| 5050 | } |
| 5051 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5052 | static int patch_stac925x(struct hda_codec *codec) |
| 5053 | { |
| 5054 | struct sigmatel_spec *spec; |
| 5055 | int err; |
| 5056 | |
| 5057 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5058 | if (spec == NULL) |
| 5059 | return -ENOMEM; |
| 5060 | |
| 5061 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5062 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5063 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 5064 | |
| 5065 | /* Check first for codec ID */ |
| 5066 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 5067 | STAC_925x_MODELS, |
| 5068 | stac925x_models, |
| 5069 | stac925x_codec_id_cfg_tbl); |
| 5070 | |
| 5071 | /* Now checks for PCI ID, if codec ID is not found */ |
| 5072 | if (spec->board_config < 0) |
| 5073 | spec->board_config = snd_hda_check_board_config(codec, |
| 5074 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5075 | stac925x_models, |
| 5076 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5077 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5078 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5079 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5080 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5081 | else |
| 5082 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5083 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5084 | |
| 5085 | spec->multiout.max_channels = 2; |
| 5086 | spec->multiout.num_dacs = 1; |
| 5087 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 5088 | spec->adc_nids = stac925x_adc_nids; |
| 5089 | spec->mux_nids = stac925x_mux_nids; |
| 5090 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5091 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5092 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 5093 | switch (codec->vendor_id) { |
| 5094 | case 0x83847632: /* STAC9202 */ |
| 5095 | case 0x83847633: /* STAC9202D */ |
| 5096 | case 0x83847636: /* STAC9251 */ |
| 5097 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5098 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 5099 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5100 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 5101 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 5102 | break; |
| 5103 | default: |
| 5104 | spec->num_dmics = 0; |
| 5105 | break; |
| 5106 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5107 | |
| 5108 | spec->init = stac925x_core_init; |
| 5109 | spec->mixer = stac925x_mixer; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5110 | spec->num_caps = 1; |
| 5111 | spec->capvols = stac925x_capvols; |
| 5112 | spec->capsws = stac925x_capsws; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5113 | |
| 5114 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5115 | if (!err) { |
| 5116 | if (spec->board_config < 0) { |
| 5117 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5118 | "available, default to model=ref\n"); |
| 5119 | spec->board_config = STAC_925x_REF; |
| 5120 | goto again; |
| 5121 | } |
| 5122 | err = -EINVAL; |
| 5123 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5124 | if (err < 0) { |
| 5125 | stac92xx_free(codec); |
| 5126 | return err; |
| 5127 | } |
| 5128 | |
| 5129 | codec->patch_ops = stac92xx_patch_ops; |
| 5130 | |
| 5131 | return 0; |
| 5132 | } |
| 5133 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5134 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 5135 | { |
| 5136 | struct sigmatel_spec *spec; |
| 5137 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 5138 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5139 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5140 | |
| 5141 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5142 | if (spec == NULL) |
| 5143 | return -ENOMEM; |
| 5144 | |
| 5145 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 5146 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5147 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 5148 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 5149 | spec->board_config = snd_hda_check_board_config(codec, |
| 5150 | STAC_92HD73XX_MODELS, |
| 5151 | stac92hd73xx_models, |
| 5152 | stac92hd73xx_cfg_tbl); |
| 5153 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5154 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5155 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5156 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5157 | else |
| 5158 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5159 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5160 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5161 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5162 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 5163 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5164 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5165 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 5166 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5167 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5168 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5169 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5170 | case 0x3: /* 6 Channel */ |
| 5171 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 5172 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5173 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5174 | break; |
| 5175 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5176 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 5177 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5178 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5179 | break; |
| 5180 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5181 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 5182 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5183 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 5184 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5185 | } |
| 5186 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5187 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5188 | spec->aloopback_mask = 0x01; |
| 5189 | spec->aloopback_shift = 8; |
| 5190 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5191 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5192 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 5193 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 5194 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 5195 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5196 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 5197 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5198 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5199 | |
| 5200 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 5201 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5202 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5203 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5204 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
| 5205 | spec->capvols = stac92hd73xx_capvols; |
| 5206 | spec->capsws = stac92hd73xx_capsws; |
| 5207 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5208 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5209 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 5210 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5211 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5212 | case STAC_DELL_M6_AMIC: |
| 5213 | case STAC_DELL_M6_DMIC: |
| 5214 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5215 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5216 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 5217 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5218 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5219 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5220 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5221 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5222 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5223 | switch (spec->board_config) { |
| 5224 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5225 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5226 | spec->num_dmics = 0; |
| 5227 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5228 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5229 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5230 | spec->num_dmics = 1; |
| 5231 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5232 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5233 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 5234 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5235 | spec->num_dmics = 1; |
| 5236 | break; |
| 5237 | } |
| 5238 | break; |
| 5239 | default: |
| 5240 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5241 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5242 | spec->eapd_switch = 1; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5243 | break; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5244 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5245 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 5246 | /* GPIO0 High = Enable EAPD */ |
| 5247 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 5248 | spec->gpio_data = 0x01; |
| 5249 | } |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5250 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5251 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 5252 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 5253 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5254 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5255 | |
| 5256 | if (!err) { |
| 5257 | if (spec->board_config < 0) { |
| 5258 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5259 | "available, default to model=ref\n"); |
| 5260 | spec->board_config = STAC_92HD73XX_REF; |
| 5261 | goto again; |
| 5262 | } |
| 5263 | err = -EINVAL; |
| 5264 | } |
| 5265 | |
| 5266 | if (err < 0) { |
| 5267 | stac92xx_free(codec); |
| 5268 | return err; |
| 5269 | } |
| 5270 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 5271 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 5272 | spec->hp_detect = 0; |
| 5273 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5274 | codec->patch_ops = stac92xx_patch_ops; |
| 5275 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5276 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5277 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5278 | return 0; |
| 5279 | } |
| 5280 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5281 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 5282 | { |
| 5283 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5284 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5285 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5286 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5287 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5288 | |
| 5289 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5290 | if (spec == NULL) |
| 5291 | return -ENOMEM; |
| 5292 | |
| 5293 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5294 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5295 | spec->mono_nid = 0x19; |
| 5296 | spec->digbeep_nid = 0x21; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5297 | spec->mux_nids = stac92hd83xxx_mux_nids; |
| 5298 | spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5299 | spec->adc_nids = stac92hd83xxx_adc_nids; |
Takashi Iwai | 7570ef1 | 2009-08-15 11:57:53 +0200 | [diff] [blame^] | 5300 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5301 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
| 5302 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 5303 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5304 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5305 | |
| 5306 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5307 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5308 | spec->pin_nids = stac92hd83xxx_pin_nids; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5309 | spec->num_caps = STAC92HD83XXX_NUM_CAPS; |
| 5310 | spec->capvols = stac92hd83xxx_capvols; |
| 5311 | spec->capsws = stac92hd83xxx_capsws; |
| 5312 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5313 | spec->board_config = snd_hda_check_board_config(codec, |
| 5314 | STAC_92HD83XXX_MODELS, |
| 5315 | stac92hd83xxx_models, |
| 5316 | stac92hd83xxx_cfg_tbl); |
| 5317 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5318 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5319 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5320 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5321 | else |
| 5322 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5323 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5324 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5325 | switch (codec->vendor_id) { |
| 5326 | case 0x111d7604: |
| 5327 | case 0x111d7605: |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5328 | case 0x111d76d5: |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5329 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 5330 | break; |
| 5331 | spec->num_pwrs = 0; |
| 5332 | break; |
| 5333 | } |
| 5334 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5335 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 5336 | if (!err) { |
| 5337 | if (spec->board_config < 0) { |
| 5338 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5339 | "available, default to model=ref\n"); |
| 5340 | spec->board_config = STAC_92HD83XXX_REF; |
| 5341 | goto again; |
| 5342 | } |
| 5343 | err = -EINVAL; |
| 5344 | } |
| 5345 | |
| 5346 | if (err < 0) { |
| 5347 | stac92xx_free(codec); |
| 5348 | return err; |
| 5349 | } |
| 5350 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5351 | switch (spec->board_config) { |
| 5352 | case STAC_DELL_S14: |
| 5353 | nid = 0xf; |
| 5354 | break; |
| 5355 | default: |
| 5356 | nid = 0xe; |
| 5357 | break; |
| 5358 | } |
| 5359 | |
| 5360 | num_dacs = snd_hda_get_connections(codec, nid, |
| 5361 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 5362 | if (num_dacs < 0) |
| 5363 | num_dacs = STAC92HD83_DAC_COUNT; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5364 | |
| 5365 | /* set port X to select the last DAC |
| 5366 | */ |
| 5367 | snd_hda_codec_write_cache(codec, nid, 0, |
| 5368 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 5369 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5370 | codec->patch_ops = stac92xx_patch_ops; |
| 5371 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5372 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 5373 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5374 | return 0; |
| 5375 | } |
| 5376 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5377 | /* get the pin connection (fixed, none, etc) */ |
| 5378 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 5379 | { |
| 5380 | struct sigmatel_spec *spec = codec->spec; |
| 5381 | unsigned int cfg; |
| 5382 | |
| 5383 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 5384 | return get_defcfg_connect(cfg); |
| 5385 | } |
| 5386 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5387 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 5388 | hda_nid_t *nids, int num_nids) |
| 5389 | { |
| 5390 | struct sigmatel_spec *spec = codec->spec; |
| 5391 | int idx, num; |
| 5392 | unsigned int def_conf; |
| 5393 | |
| 5394 | for (num = 0; num < num_nids; num++) { |
| 5395 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5396 | if (spec->pin_nids[idx] == nids[num]) |
| 5397 | break; |
| 5398 | if (idx >= spec->num_pins) |
| 5399 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5400 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5401 | if (def_conf == AC_JACK_PORT_NONE) |
| 5402 | break; |
| 5403 | } |
| 5404 | return num; |
| 5405 | } |
| 5406 | |
| 5407 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 5408 | hda_nid_t dig0pin) |
| 5409 | { |
| 5410 | struct sigmatel_spec *spec = codec->spec; |
| 5411 | int idx; |
| 5412 | |
| 5413 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5414 | if (spec->pin_nids[idx] == dig0pin) |
| 5415 | break; |
| 5416 | if ((idx + 2) >= spec->num_pins) |
| 5417 | return 0; |
| 5418 | |
| 5419 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5420 | 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] | 5421 | return 2; |
| 5422 | |
| 5423 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5424 | 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] | 5425 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5426 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5427 | return 1; |
| 5428 | else |
| 5429 | return 0; |
| 5430 | } |
| 5431 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5432 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 5433 | { |
| 5434 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5435 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5436 | int err = 0; |
| 5437 | |
| 5438 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5439 | if (spec == NULL) |
| 5440 | return -ENOMEM; |
| 5441 | |
| 5442 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5443 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5444 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 5445 | switch (codec->vendor_id) { |
| 5446 | case 0x111d76b6: |
| 5447 | case 0x111d76b7: |
| 5448 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 5449 | break; |
| 5450 | case 0x111d7603: |
| 5451 | case 0x111d7608: |
| 5452 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 5453 | spec->num_pins--; |
| 5454 | /* fallthrough */ |
| 5455 | default: |
| 5456 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 5457 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5458 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5459 | spec->board_config = snd_hda_check_board_config(codec, |
| 5460 | STAC_92HD71BXX_MODELS, |
| 5461 | stac92hd71bxx_models, |
| 5462 | stac92hd71bxx_cfg_tbl); |
| 5463 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5464 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5465 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5466 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5467 | else |
| 5468 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5469 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5470 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5471 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5472 | /* GPIO0 = EAPD */ |
| 5473 | spec->gpio_mask = 0x01; |
| 5474 | spec->gpio_dir = 0x01; |
| 5475 | spec->gpio_data = 0x01; |
| 5476 | } |
| 5477 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5478 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5479 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5480 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5481 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; |
| 5482 | spec->capvols = stac92hd71bxx_capvols; |
| 5483 | spec->capsws = stac92hd71bxx_capsws; |
| 5484 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5485 | switch (codec->vendor_id) { |
| 5486 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5487 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5488 | unmute_init++; |
| 5489 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5490 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5491 | case 0x111d76b5: |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5492 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5493 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5494 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5495 | stac92hd71bxx_dmic_nids, |
| 5496 | STAC92HD71BXX_NUM_DMICS); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5497 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5498 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5499 | switch (spec->board_config) { |
| 5500 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5501 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5502 | err = stac_add_event(spec, codec->afg, |
| 5503 | STAC_VREF_EVENT, 0x02); |
| 5504 | if (err < 0) |
| 5505 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5506 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5507 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5508 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5509 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5510 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5511 | spec->gpio_mask |= 0x02; |
| 5512 | break; |
| 5513 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5514 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5515 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5516 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5517 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5518 | /* no output amps */ |
| 5519 | spec->num_pwrs = 0; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5520 | /* disable VSW */ |
Takashi Iwai | 26a2798 | 2009-07-29 16:28:09 +0200 | [diff] [blame] | 5521 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5522 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5523 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5524 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5525 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5526 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5527 | stac92hd71bxx_dmic_nids, |
| 5528 | STAC92HD71BXX_NUM_DMICS - 1); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5529 | break; |
| 5530 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5531 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5532 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5533 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5534 | /* no output amps */ |
| 5535 | spec->num_pwrs = 0; |
| 5536 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5537 | default: |
Takashi Iwai | 26a2798 | 2009-07-29 16:28:09 +0200 | [diff] [blame] | 5538 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5539 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5540 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5541 | stac92hd71bxx_dmic_nids, |
| 5542 | STAC92HD71BXX_NUM_DMICS); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5543 | break; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5544 | } |
| 5545 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5546 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5547 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5548 | |
Takashi Iwai | b20f3b8 | 2009-06-02 01:20:22 +0200 | [diff] [blame] | 5549 | /* Some HP machines seem to have unstable codec communications |
| 5550 | * especially with ATI fglrx driver. For recovering from the |
| 5551 | * CORB/RIRB stall, allow the BUS reset and keep always sync |
| 5552 | */ |
| 5553 | if (spec->board_config == STAC_HP_DV5) { |
| 5554 | codec->bus->sync_write = 1; |
| 5555 | codec->bus->allow_bus_reset = 1; |
| 5556 | } |
| 5557 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5558 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5559 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5560 | spec->aloopback_shift = 0; |
| 5561 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5562 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5563 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5564 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5565 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5566 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5567 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5568 | |
| 5569 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5570 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5571 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5572 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5573 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5574 | switch (spec->board_config) { |
| 5575 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5576 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5577 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5578 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5579 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5580 | /* fallthru */ |
| 5581 | case STAC_DELL_M4_2: |
| 5582 | spec->num_dmics = 0; |
| 5583 | spec->num_smuxes = 0; |
| 5584 | spec->num_dmuxes = 0; |
| 5585 | break; |
| 5586 | case STAC_DELL_M4_1: |
| 5587 | case STAC_DELL_M4_3: |
| 5588 | spec->num_dmics = 1; |
| 5589 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5590 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5591 | break; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5592 | case STAC_HP_DV4_1222NR: |
| 5593 | spec->num_dmics = 1; |
| 5594 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 5595 | * bug reports to fix if needed |
| 5596 | */ |
| 5597 | spec->num_smuxes = 1; |
| 5598 | spec->num_dmuxes = 1; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5599 | spec->gpio_led = 0x01; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5600 | /* fallthrough */ |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5601 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5602 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5603 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5604 | break; |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5605 | case STAC_HP_HDX: |
| 5606 | spec->num_dmics = 1; |
| 5607 | spec->num_dmuxes = 1; |
| 5608 | spec->num_smuxes = 1; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5609 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5610 | spec->gpio_led = 0x08; |
| 5611 | break; |
| 5612 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5613 | |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5614 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5615 | if (spec->gpio_led) { |
| 5616 | spec->gpio_mask |= spec->gpio_led; |
| 5617 | spec->gpio_dir |= spec->gpio_led; |
| 5618 | spec->gpio_data |= spec->gpio_led; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5619 | /* register check_power_status callback. */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5620 | codec->patch_ops.check_power_status = |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5621 | stac92xx_hp_check_power_status; |
| 5622 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5623 | #endif |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5624 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5625 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5626 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5627 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5628 | if (!err) { |
| 5629 | if (spec->board_config < 0) { |
| 5630 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5631 | "available, default to model=ref\n"); |
| 5632 | spec->board_config = STAC_92HD71BXX_REF; |
| 5633 | goto again; |
| 5634 | } |
| 5635 | err = -EINVAL; |
| 5636 | } |
| 5637 | |
| 5638 | if (err < 0) { |
| 5639 | stac92xx_free(codec); |
| 5640 | return err; |
| 5641 | } |
| 5642 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5643 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5644 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5645 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5646 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5647 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5648 | static int patch_stac922x(struct hda_codec *codec) |
| 5649 | { |
| 5650 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5651 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5652 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5653 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5654 | if (spec == NULL) |
| 5655 | return -ENOMEM; |
| 5656 | |
| 5657 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5658 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5659 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5660 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5661 | stac922x_models, |
| 5662 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5663 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5664 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5665 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5666 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5667 | * codec SSID to distinguish the exact models |
| 5668 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5669 | 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] | 5670 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5671 | |
| 5672 | case 0x106b0800: |
| 5673 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5674 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5675 | case 0x106b0600: |
| 5676 | case 0x106b0700: |
| 5677 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5678 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5679 | case 0x106b0e00: |
| 5680 | case 0x106b0f00: |
| 5681 | case 0x106b1600: |
| 5682 | case 0x106b1700: |
| 5683 | case 0x106b0200: |
| 5684 | case 0x106b1e00: |
| 5685 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5686 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5687 | case 0x106b1a00: |
| 5688 | case 0x00000100: |
| 5689 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5690 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5691 | case 0x106b0a00: |
| 5692 | case 0x106b2200: |
| 5693 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5694 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5695 | default: |
| 5696 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5697 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5698 | } |
| 5699 | } |
| 5700 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5701 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5702 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5703 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5704 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5705 | else |
| 5706 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5707 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5708 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5709 | spec->adc_nids = stac922x_adc_nids; |
| 5710 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5711 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5712 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5713 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5714 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5715 | |
| 5716 | spec->init = stac922x_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5717 | |
| 5718 | spec->num_caps = STAC922X_NUM_CAPS; |
| 5719 | spec->capvols = stac922x_capvols; |
| 5720 | spec->capsws = stac922x_capsws; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5721 | |
| 5722 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5723 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5724 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5725 | if (!err) { |
| 5726 | if (spec->board_config < 0) { |
| 5727 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5728 | "available, default to model=ref\n"); |
| 5729 | spec->board_config = STAC_D945_REF; |
| 5730 | goto again; |
| 5731 | } |
| 5732 | err = -EINVAL; |
| 5733 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5734 | if (err < 0) { |
| 5735 | stac92xx_free(codec); |
| 5736 | return err; |
| 5737 | } |
| 5738 | |
| 5739 | codec->patch_ops = stac92xx_patch_ops; |
| 5740 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5741 | /* Fix Mux capture level; max to 2 */ |
| 5742 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5743 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5744 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5745 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5746 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5747 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5748 | return 0; |
| 5749 | } |
| 5750 | |
| 5751 | static int patch_stac927x(struct hda_codec *codec) |
| 5752 | { |
| 5753 | struct sigmatel_spec *spec; |
| 5754 | int err; |
| 5755 | |
| 5756 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5757 | if (spec == NULL) |
| 5758 | return -ENOMEM; |
| 5759 | |
| 5760 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5761 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5762 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5763 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5764 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5765 | stac927x_models, |
| 5766 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5767 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5768 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5769 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5770 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5771 | else |
| 5772 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5773 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5774 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5775 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5776 | spec->adc_nids = stac927x_adc_nids; |
| 5777 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5778 | spec->mux_nids = stac927x_mux_nids; |
| 5779 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5780 | spec->smux_nids = stac927x_smux_nids; |
| 5781 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5782 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5783 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5784 | spec->multiout.dac_nids = spec->dac_nids; |
| 5785 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5786 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5787 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5788 | case STAC_D965_5ST: |
| 5789 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5790 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5791 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5792 | spec->num_dmics = 0; |
| 5793 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5794 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5795 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5796 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5797 | switch (codec->subsystem_id) { |
| 5798 | case 0x10280209: |
| 5799 | case 0x1028022e: |
| 5800 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5801 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5802 | break; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5803 | } |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5804 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5805 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5806 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5807 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5808 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5809 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5810 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5811 | case STAC_DELL_3ST: |
| 5812 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5813 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5814 | spec->gpio_data = 0x04; |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 5815 | switch (codec->subsystem_id) { |
| 5816 | case 0x1028022f: |
| 5817 | /* correct EAPD to be GPIO0 */ |
| 5818 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5819 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5820 | break; |
| 5821 | }; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5822 | spec->dmic_nids = stac927x_dmic_nids; |
| 5823 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5824 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5825 | spec->init = d965_core_init; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5826 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5827 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5828 | break; |
| 5829 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5830 | if (spec->board_config > STAC_D965_REF) { |
| 5831 | /* GPIO0 High = Enable EAPD */ |
| 5832 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5833 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5834 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5835 | spec->num_dmics = 0; |
| 5836 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5837 | spec->init = stac927x_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5838 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5839 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5840 | spec->num_caps = STAC927X_NUM_CAPS; |
| 5841 | spec->capvols = stac927x_capvols; |
| 5842 | spec->capsws = stac927x_capsws; |
| 5843 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5844 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5845 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5846 | spec->aloopback_mask = 0x40; |
| 5847 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5848 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5849 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5850 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5851 | if (!err) { |
| 5852 | if (spec->board_config < 0) { |
| 5853 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5854 | "available, default to model=ref\n"); |
| 5855 | spec->board_config = STAC_D965_REF; |
| 5856 | goto again; |
| 5857 | } |
| 5858 | err = -EINVAL; |
| 5859 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5860 | if (err < 0) { |
| 5861 | stac92xx_free(codec); |
| 5862 | return err; |
| 5863 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5864 | |
| 5865 | codec->patch_ops = stac92xx_patch_ops; |
| 5866 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5867 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5868 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5869 | /* |
| 5870 | * !!FIXME!! |
| 5871 | * The STAC927x seem to require fairly long delays for certain |
| 5872 | * command sequences. With too short delays (even if the answer |
| 5873 | * is set to RIRB properly), it results in the silence output |
| 5874 | * on some hardwares like Dell. |
| 5875 | * |
| 5876 | * The below flag enables the longer delay (see get_response |
| 5877 | * in hda_intel.c). |
| 5878 | */ |
| 5879 | codec->bus->needs_damn_long_delay = 1; |
| 5880 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5881 | /* no jack detecion for ref-no-jd model */ |
| 5882 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5883 | spec->hp_detect = 0; |
| 5884 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5885 | return 0; |
| 5886 | } |
| 5887 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5888 | static int patch_stac9205(struct hda_codec *codec) |
| 5889 | { |
| 5890 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5891 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5892 | |
| 5893 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5894 | if (spec == NULL) |
| 5895 | return -ENOMEM; |
| 5896 | |
| 5897 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5898 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5899 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5900 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5901 | stac9205_models, |
| 5902 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5903 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5904 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5905 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5906 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5907 | else |
| 5908 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5909 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5910 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5911 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5912 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5913 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5914 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5915 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5916 | spec->smux_nids = stac9205_smux_nids; |
| 5917 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5918 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5919 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5920 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5921 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5922 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5923 | |
| 5924 | spec->init = stac9205_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5925 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5926 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5927 | spec->num_caps = STAC9205_NUM_CAPS; |
| 5928 | spec->capvols = stac9205_capvols; |
| 5929 | spec->capsws = stac9205_capsws; |
| 5930 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5931 | spec->aloopback_mask = 0x40; |
| 5932 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5933 | /* Turn on/off EAPD per HP plugging */ |
| 5934 | if (spec->board_config != STAC_9205_EAPD) |
| 5935 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5936 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5937 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5938 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5939 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5940 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5941 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5942 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5943 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5944 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5945 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5946 | if (err < 0) |
| 5947 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5948 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5949 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5950 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5951 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5952 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5953 | |
| 5954 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5955 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5956 | spec->gpio_mask = 0x1b; |
| 5957 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5958 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5959 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5960 | */ |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5961 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5962 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5963 | case STAC_9205_REF: |
| 5964 | /* SPDIF-In enabled */ |
| 5965 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5966 | default: |
| 5967 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5968 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5969 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5970 | break; |
| 5971 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5972 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5973 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5974 | if (!err) { |
| 5975 | if (spec->board_config < 0) { |
| 5976 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5977 | "available, default to model=ref\n"); |
| 5978 | spec->board_config = STAC_9205_REF; |
| 5979 | goto again; |
| 5980 | } |
| 5981 | err = -EINVAL; |
| 5982 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5983 | if (err < 0) { |
| 5984 | stac92xx_free(codec); |
| 5985 | return err; |
| 5986 | } |
| 5987 | |
| 5988 | codec->patch_ops = stac92xx_patch_ops; |
| 5989 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5990 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5991 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5992 | return 0; |
| 5993 | } |
| 5994 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5995 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5996 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5997 | */ |
| 5998 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5999 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 6000 | {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] | 6001 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 6002 | {} |
| 6003 | }; |
| 6004 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6005 | static hda_nid_t stac9872_pin_nids[] = { |
| 6006 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 6007 | 0x11, 0x13, 0x14, |
| 6008 | }; |
| 6009 | |
| 6010 | static hda_nid_t stac9872_adc_nids[] = { |
| 6011 | 0x8 /*,0x6*/ |
| 6012 | }; |
| 6013 | |
| 6014 | static hda_nid_t stac9872_mux_nids[] = { |
| 6015 | 0x15 |
| 6016 | }; |
| 6017 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6018 | static unsigned long stac9872_capvols[] = { |
| 6019 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), |
| 6020 | }; |
| 6021 | #define stac9872_capsws stac9872_capvols |
| 6022 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6023 | static unsigned int stac9872_vaio_pin_configs[9] = { |
| 6024 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
| 6025 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
| 6026 | 0x90a7013e |
| 6027 | }; |
| 6028 | |
| 6029 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 6030 | [STAC_9872_AUTO] = "auto", |
| 6031 | [STAC_9872_VAIO] = "vaio", |
| 6032 | }; |
| 6033 | |
| 6034 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { |
| 6035 | [STAC_9872_VAIO] = stac9872_vaio_pin_configs, |
| 6036 | }; |
| 6037 | |
| 6038 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 6039 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, |
| 6040 | "Sony VAIO F/S", STAC_9872_VAIO), |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6041 | {} /* terminator */ |
| 6042 | }; |
| 6043 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 6044 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6045 | { |
| 6046 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6047 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6048 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6049 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6050 | if (spec == NULL) |
| 6051 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6052 | codec->spec = spec; |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 6053 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 6054 | spec->pin_nids = stac9872_pin_nids; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6055 | |
| 6056 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 6057 | stac9872_models, |
| 6058 | stac9872_cfg_tbl); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6059 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 6060 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 6061 | codec->chip_name); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 6062 | else |
| 6063 | stac92xx_set_config_regs(codec, |
| 6064 | stac9872_brd_tbl[spec->board_config]); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6065 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6066 | spec->multiout.dac_nids = spec->dac_nids; |
| 6067 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 6068 | spec->adc_nids = stac9872_adc_nids; |
| 6069 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 6070 | spec->mux_nids = stac9872_mux_nids; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6071 | spec->init = stac9872_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6072 | spec->num_caps = 1; |
| 6073 | spec->capvols = stac9872_capvols; |
| 6074 | spec->capsws = stac9872_capsws; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6075 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6076 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 6077 | if (err < 0) { |
| 6078 | stac92xx_free(codec); |
| 6079 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 6080 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 6081 | spec->input_mux = &spec->private_imux; |
| 6082 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 6083 | return 0; |
| 6084 | } |
| 6085 | |
| 6086 | |
| 6087 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6088 | * patch entries |
| 6089 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6090 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6091 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 6092 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 6093 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 6094 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 6095 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 6096 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 6097 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 6098 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 6099 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 6100 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 6101 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 6102 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 6103 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 6104 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 6105 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 6106 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 6107 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 6108 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 6109 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 6110 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 6111 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 6112 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 6113 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6114 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 6115 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 6116 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 6117 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 6118 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 6119 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 6120 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 6121 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 6122 | /* The following does not take into account .id=0x83847661 when subsys = |
| 6123 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 6124 | * currently not fully supported. |
| 6125 | */ |
| 6126 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 6127 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 6128 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 6129 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 6130 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 6131 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 6132 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 6133 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 6134 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 6135 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 6136 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 6137 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6138 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6139 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 6140 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 6141 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6142 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6143 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 6144 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6145 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6146 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 6147 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 6148 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 6149 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 6150 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 6151 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 6152 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 6153 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6154 | {} /* terminator */ |
| 6155 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6156 | |
| 6157 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 6158 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 6159 | |
| 6160 | MODULE_LICENSE("GPL"); |
| 6161 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 6162 | |
| 6163 | static struct hda_codec_preset_list sigmatel_list = { |
| 6164 | .preset = snd_hda_preset_sigmatel, |
| 6165 | .owner = THIS_MODULE, |
| 6166 | }; |
| 6167 | |
| 6168 | static int __init patch_sigmatel_init(void) |
| 6169 | { |
| 6170 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 6171 | } |
| 6172 | |
| 6173 | static void __exit patch_sigmatel_exit(void) |
| 6174 | { |
| 6175 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 6176 | } |
| 6177 | |
| 6178 | module_init(patch_sigmatel_init) |
| 6179 | module_exit(patch_sigmatel_exit) |