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, |
| 43 | }; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 44 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 45 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 46 | STAC_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 47 | STAC_REF, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 48 | STAC_9200_OQO, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 49 | STAC_9200_DELL_D21, |
| 50 | STAC_9200_DELL_D22, |
| 51 | STAC_9200_DELL_D23, |
| 52 | STAC_9200_DELL_M21, |
| 53 | STAC_9200_DELL_M22, |
| 54 | STAC_9200_DELL_M23, |
| 55 | STAC_9200_DELL_M24, |
| 56 | STAC_9200_DELL_M25, |
| 57 | STAC_9200_DELL_M26, |
| 58 | STAC_9200_DELL_M27, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 59 | STAC_9200_M4, |
| 60 | STAC_9200_M4_2, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 61 | STAC_9200_PANASONIC, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 62 | STAC_9200_MODELS |
| 63 | }; |
| 64 | |
| 65 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 66 | STAC_9205_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 67 | STAC_9205_REF, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 68 | STAC_9205_DELL_M42, |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 69 | STAC_9205_DELL_M43, |
| 70 | STAC_9205_DELL_M44, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 71 | STAC_9205_EAPD, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 72 | STAC_9205_MODELS |
| 73 | }; |
| 74 | |
| 75 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 76 | STAC_92HD73XX_AUTO, |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 77 | STAC_92HD73XX_NO_JD, /* no jack-detection */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 78 | STAC_92HD73XX_REF, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 79 | STAC_DELL_M6_AMIC, |
| 80 | STAC_DELL_M6_DMIC, |
| 81 | STAC_DELL_M6_BOTH, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 82 | STAC_DELL_EQ, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 83 | STAC_92HD73XX_MODELS |
| 84 | }; |
| 85 | |
| 86 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 87 | STAC_92HD83XXX_AUTO, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 88 | STAC_92HD83XXX_REF, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 89 | STAC_92HD83XXX_PWR_REF, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 90 | STAC_DELL_S14, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 91 | STAC_92HD83XXX_MODELS |
| 92 | }; |
| 93 | |
| 94 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 95 | STAC_92HD71BXX_AUTO, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 96 | STAC_92HD71BXX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 97 | STAC_DELL_M4_1, |
| 98 | STAC_DELL_M4_2, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 99 | STAC_DELL_M4_3, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 100 | STAC_HP_M4, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 101 | STAC_HP_DV5, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 102 | STAC_HP_HDX, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 103 | STAC_92HD71BXX_MODELS |
| 104 | }; |
| 105 | |
| 106 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 107 | STAC_925x_AUTO, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 108 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 109 | STAC_M1, |
| 110 | STAC_M1_2, |
| 111 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 112 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 113 | STAC_M3, |
| 114 | STAC_M5, |
| 115 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 116 | STAC_925x_MODELS |
| 117 | }; |
| 118 | |
| 119 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 120 | STAC_922X_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 121 | STAC_D945_REF, |
| 122 | STAC_D945GTP3, |
| 123 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 124 | STAC_INTEL_MAC_V1, |
| 125 | STAC_INTEL_MAC_V2, |
| 126 | STAC_INTEL_MAC_V3, |
| 127 | STAC_INTEL_MAC_V4, |
| 128 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 129 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 130 | * is given, one of the above models will be |
| 131 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 132 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 133 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 134 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 135 | STAC_MACBOOK_PRO_V1, |
| 136 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 137 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 138 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 139 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 140 | STAC_922X_DELL_D81, |
| 141 | STAC_922X_DELL_D82, |
| 142 | STAC_922X_DELL_M81, |
| 143 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 144 | STAC_922X_MODELS |
| 145 | }; |
| 146 | |
| 147 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 148 | STAC_927X_AUTO, |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 149 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 150 | STAC_D965_REF, |
| 151 | STAC_D965_3ST, |
| 152 | STAC_D965_5ST, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 153 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 154 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 155 | STAC_927X_MODELS |
| 156 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 157 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 158 | enum { |
| 159 | STAC_9872_AUTO, |
| 160 | STAC_9872_VAIO, |
| 161 | STAC_9872_MODELS |
| 162 | }; |
| 163 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 164 | struct sigmatel_event { |
| 165 | hda_nid_t nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 166 | unsigned char type; |
| 167 | unsigned char tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 168 | int data; |
| 169 | }; |
| 170 | |
| 171 | struct sigmatel_jack { |
| 172 | hda_nid_t nid; |
| 173 | int type; |
| 174 | struct snd_jack *jack; |
| 175 | }; |
| 176 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 177 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 178 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 179 | unsigned int num_mixers; |
| 180 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 181 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 182 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 183 | unsigned int surr_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 184 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 185 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 186 | unsigned int spdif_mute: 1; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 187 | unsigned int check_volume_offset:1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 188 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 189 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 190 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 191 | unsigned int gpio_mask; |
| 192 | unsigned int gpio_dir; |
| 193 | unsigned int gpio_data; |
| 194 | unsigned int gpio_mute; |
| 195 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 196 | /* stream */ |
| 197 | unsigned int stream_delay; |
| 198 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 199 | /* analog loopback */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 200 | struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 201 | unsigned char aloopback_mask; |
| 202 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 203 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 204 | /* power management */ |
| 205 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 206 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 207 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 208 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 209 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 210 | /* jack detection */ |
| 211 | struct snd_array jacks; |
| 212 | |
| 213 | /* events */ |
| 214 | struct snd_array events; |
| 215 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 216 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 217 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 218 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 219 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 220 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 221 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 222 | hda_nid_t hp_dacs[5]; |
| 223 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 224 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 225 | int volume_offset; |
| 226 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 227 | /* capture */ |
| 228 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 229 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 230 | hda_nid_t *mux_nids; |
| 231 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 232 | hda_nid_t *dmic_nids; |
| 233 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 234 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 235 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 236 | hda_nid_t *smux_nids; |
| 237 | unsigned int num_smuxes; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 238 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 239 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 240 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 241 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 242 | hda_nid_t anabeep_nid; |
| 243 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 244 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 245 | /* pin widgets */ |
| 246 | hda_nid_t *pin_nids; |
| 247 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 248 | |
| 249 | /* codec specific stuff */ |
| 250 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 251 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 252 | |
| 253 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 254 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 255 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 256 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 257 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 258 | struct hda_input_mux *sinput_mux; |
| 259 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 260 | unsigned int cur_amux; |
| 261 | hda_nid_t *amp_nids; |
| 262 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 263 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 264 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 265 | /* i/o switches */ |
| 266 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 267 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 268 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 269 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 270 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 271 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 272 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 273 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 274 | |
| 275 | /* dynamic controls and input_mux */ |
| 276 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 277 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 278 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 279 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 280 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 281 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 282 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | static hda_nid_t stac9200_adc_nids[1] = { |
| 286 | 0x03, |
| 287 | }; |
| 288 | |
| 289 | static hda_nid_t stac9200_mux_nids[1] = { |
| 290 | 0x0c, |
| 291 | }; |
| 292 | |
| 293 | static hda_nid_t stac9200_dac_nids[1] = { |
| 294 | 0x02, |
| 295 | }; |
| 296 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 297 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 298 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 299 | 0x0f, 0x10, 0x11 |
| 300 | }; |
| 301 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 302 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 303 | 0x26, 0, |
| 304 | }; |
| 305 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 306 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 307 | 0x1a, 0x1b |
| 308 | }; |
| 309 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 310 | #define DELL_M6_AMP 2 |
| 311 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 312 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 313 | }; |
| 314 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 315 | #define STAC92HD73XX_NUM_DMICS 2 |
| 316 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 317 | 0x13, 0x14, 0 |
| 318 | }; |
| 319 | |
| 320 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 321 | |
| 322 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 323 | 0x28, 0x29, 0x2a, 0x2b, |
| 324 | }; |
| 325 | |
| 326 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 327 | 0x20, 0x21, |
| 328 | }; |
| 329 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 330 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 331 | 0x22, 0x23, |
| 332 | }; |
| 333 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 334 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 335 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 336 | 0x11, 0x12, 0 |
| 337 | }; |
| 338 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 339 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 340 | |
| 341 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 342 | 0x17, 0x18, |
| 343 | }; |
| 344 | |
| 345 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 346 | 0x15, 0x16, |
| 347 | }; |
| 348 | |
| 349 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 350 | 0xa, 0xb, 0xd, 0xe, |
| 351 | }; |
| 352 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 353 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 354 | 0x1e, 0, |
| 355 | }; |
| 356 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 357 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 358 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 359 | }; |
| 360 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 361 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 362 | 0xc, |
| 363 | }; |
| 364 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 365 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 366 | 0x0a, 0x0d, 0x0f |
| 367 | }; |
| 368 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 369 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 370 | 0x12, 0x13, |
| 371 | }; |
| 372 | |
| 373 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 374 | 0x1a, 0x1b |
| 375 | }; |
| 376 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 377 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 378 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 379 | }; |
| 380 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 381 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 382 | 0x24, 0x25, |
| 383 | }; |
| 384 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 385 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 386 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 387 | 0x18, 0x19, 0 |
| 388 | }; |
| 389 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 390 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 391 | 0x22, 0 |
| 392 | }; |
| 393 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 394 | static hda_nid_t stac925x_adc_nids[1] = { |
| 395 | 0x03, |
| 396 | }; |
| 397 | |
| 398 | static hda_nid_t stac925x_mux_nids[1] = { |
| 399 | 0x0f, |
| 400 | }; |
| 401 | |
| 402 | static hda_nid_t stac925x_dac_nids[1] = { |
| 403 | 0x02, |
| 404 | }; |
| 405 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 406 | #define STAC925X_NUM_DMICS 1 |
| 407 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 408 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 409 | }; |
| 410 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 411 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 412 | 0x14, |
| 413 | }; |
| 414 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 415 | static hda_nid_t stac922x_adc_nids[2] = { |
| 416 | 0x06, 0x07, |
| 417 | }; |
| 418 | |
| 419 | static hda_nid_t stac922x_mux_nids[2] = { |
| 420 | 0x12, 0x13, |
| 421 | }; |
| 422 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 423 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 424 | 0x1f, 0, |
| 425 | }; |
| 426 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 427 | static hda_nid_t stac927x_adc_nids[3] = { |
| 428 | 0x07, 0x08, 0x09 |
| 429 | }; |
| 430 | |
| 431 | static hda_nid_t stac927x_mux_nids[3] = { |
| 432 | 0x15, 0x16, 0x17 |
| 433 | }; |
| 434 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 435 | static hda_nid_t stac927x_smux_nids[1] = { |
| 436 | 0x21, |
| 437 | }; |
| 438 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 439 | static hda_nid_t stac927x_dac_nids[6] = { |
| 440 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 441 | }; |
| 442 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 443 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 444 | 0x1b, |
| 445 | }; |
| 446 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 447 | #define STAC927X_NUM_DMICS 2 |
| 448 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 449 | 0x13, 0x14, 0 |
| 450 | }; |
| 451 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 452 | static const char *stac927x_spdif_labels[5] = { |
| 453 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 454 | "Analog Mux 2", "Analog Mux 3" |
| 455 | }; |
| 456 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 457 | static hda_nid_t stac9205_adc_nids[2] = { |
| 458 | 0x12, 0x13 |
| 459 | }; |
| 460 | |
| 461 | static hda_nid_t stac9205_mux_nids[2] = { |
| 462 | 0x19, 0x1a |
| 463 | }; |
| 464 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 465 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 466 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 467 | }; |
| 468 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 469 | static hda_nid_t stac9205_smux_nids[1] = { |
| 470 | 0x21, |
| 471 | }; |
| 472 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 473 | #define STAC9205_NUM_DMICS 2 |
| 474 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 475 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 476 | }; |
| 477 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 478 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 479 | 0x08, 0x09, 0x0d, 0x0e, |
| 480 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 481 | }; |
| 482 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 483 | static hda_nid_t stac925x_pin_nids[8] = { |
| 484 | 0x07, 0x08, 0x0a, 0x0b, |
| 485 | 0x0c, 0x0d, 0x10, 0x11, |
| 486 | }; |
| 487 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 488 | static hda_nid_t stac922x_pin_nids[10] = { |
| 489 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 490 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 491 | }; |
| 492 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 493 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 494 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 495 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 496 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 497 | }; |
| 498 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 499 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 500 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 501 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 502 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 503 | |
| 504 | #define STAC92HD71BXX_NUM_PINS 13 |
| 505 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 506 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 507 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 508 | 0x1f, 0x20, 0x27 |
| 509 | }; |
| 510 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 511 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 512 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 513 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 514 | }; |
| 515 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 516 | static hda_nid_t stac927x_pin_nids[14] = { |
| 517 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 518 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 519 | 0x14, 0x21, 0x22, 0x23, |
| 520 | }; |
| 521 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 522 | static hda_nid_t stac9205_pin_nids[12] = { |
| 523 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 524 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 525 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 526 | }; |
| 527 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 528 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 529 | |
| 530 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 531 | struct snd_ctl_elem_value *ucontrol) |
| 532 | { |
| 533 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 534 | struct sigmatel_spec *spec = codec->spec; |
| 535 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 536 | |
| 537 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 538 | kcontrol->private_value |= nid; |
| 539 | |
| 540 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 541 | } |
| 542 | |
| 543 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 544 | struct snd_ctl_elem_value *ucontrol) |
| 545 | { |
| 546 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 547 | struct sigmatel_spec *spec = codec->spec; |
| 548 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 549 | |
| 550 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 551 | kcontrol->private_value |= nid; |
| 552 | |
| 553 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 554 | } |
| 555 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 556 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 557 | struct snd_ctl_elem_info *uinfo) |
| 558 | { |
| 559 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 560 | struct sigmatel_spec *spec = codec->spec; |
| 561 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 562 | } |
| 563 | |
| 564 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 565 | struct snd_ctl_elem_value *ucontrol) |
| 566 | { |
| 567 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 568 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 569 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 570 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 571 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 572 | return 0; |
| 573 | } |
| 574 | |
| 575 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 576 | struct snd_ctl_elem_value *ucontrol) |
| 577 | { |
| 578 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 579 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 580 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 581 | |
| 582 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 583 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 584 | } |
| 585 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 586 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 587 | struct snd_ctl_elem_info *uinfo) |
| 588 | { |
| 589 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 590 | struct sigmatel_spec *spec = codec->spec; |
| 591 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 592 | } |
| 593 | |
| 594 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 595 | struct snd_ctl_elem_value *ucontrol) |
| 596 | { |
| 597 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 598 | struct sigmatel_spec *spec = codec->spec; |
| 599 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 600 | |
| 601 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 602 | return 0; |
| 603 | } |
| 604 | |
| 605 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 606 | struct snd_ctl_elem_value *ucontrol) |
| 607 | { |
| 608 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 609 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 610 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 611 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 612 | int err, val; |
| 613 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 614 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 615 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 616 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 617 | if (err < 0) |
| 618 | return err; |
| 619 | |
| 620 | if (spec->spdif_mute) { |
| 621 | if (smux_idx == 0) |
| 622 | nid = spec->multiout.dig_out_nid; |
| 623 | else |
| 624 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 625 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 626 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 627 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 628 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 629 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 630 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 631 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 632 | } |
| 633 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 634 | } |
| 635 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 636 | 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] | 637 | { |
| 638 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 639 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 640 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 641 | } |
| 642 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 643 | 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] | 644 | { |
| 645 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 646 | struct sigmatel_spec *spec = codec->spec; |
| 647 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 648 | |
| 649 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 650 | return 0; |
| 651 | } |
| 652 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 653 | 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] | 654 | { |
| 655 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 656 | struct sigmatel_spec *spec = codec->spec; |
| 657 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 658 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 659 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 660 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 661 | } |
| 662 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 663 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 664 | struct snd_ctl_elem_info *uinfo) |
| 665 | { |
| 666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 667 | struct sigmatel_spec *spec = codec->spec; |
| 668 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 669 | } |
| 670 | |
| 671 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 672 | struct snd_ctl_elem_value *ucontrol) |
| 673 | { |
| 674 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 675 | struct sigmatel_spec *spec = codec->spec; |
| 676 | |
| 677 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 682 | struct snd_ctl_elem_value *ucontrol) |
| 683 | { |
| 684 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 685 | struct sigmatel_spec *spec = codec->spec; |
| 686 | |
| 687 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 688 | spec->mono_nid, &spec->cur_mmux); |
| 689 | } |
| 690 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 691 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 692 | struct snd_ctl_elem_info *uinfo) |
| 693 | { |
| 694 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 695 | struct sigmatel_spec *spec = codec->spec; |
| 696 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 697 | } |
| 698 | |
| 699 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 700 | struct snd_ctl_elem_value *ucontrol) |
| 701 | { |
| 702 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 703 | struct sigmatel_spec *spec = codec->spec; |
| 704 | |
| 705 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 710 | struct snd_ctl_elem_value *ucontrol) |
| 711 | { |
| 712 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 713 | struct sigmatel_spec *spec = codec->spec; |
| 714 | struct snd_kcontrol *ctl = |
| 715 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 716 | if (!ctl) |
| 717 | return -EINVAL; |
| 718 | |
| 719 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 720 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 721 | |
| 722 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 723 | 0, &spec->cur_amux); |
| 724 | } |
| 725 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 726 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 727 | |
| 728 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 729 | struct snd_ctl_elem_value *ucontrol) |
| 730 | { |
| 731 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 732 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 733 | struct sigmatel_spec *spec = codec->spec; |
| 734 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 735 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 736 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 741 | struct snd_ctl_elem_value *ucontrol) |
| 742 | { |
| 743 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 744 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 745 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 746 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 747 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 748 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 749 | idx_val = spec->aloopback_mask << idx; |
| 750 | if (ucontrol->value.integer.value[0]) |
| 751 | val = spec->aloopback | idx_val; |
| 752 | else |
| 753 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 754 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 755 | return 0; |
| 756 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 757 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 758 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 759 | /* Only return the bits defined by the shift value of the |
| 760 | * first two bytes of the mask |
| 761 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 762 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 763 | kcontrol->private_value & 0xFFFF, 0x0); |
| 764 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 765 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 766 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 767 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 768 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 769 | } else { |
| 770 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 771 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 775 | kcontrol->private_value >> 16, dac_mode); |
| 776 | |
| 777 | return 1; |
| 778 | } |
| 779 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 780 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 781 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 782 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 783 | {} |
| 784 | }; |
| 785 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 786 | static struct hda_verb stac9200_eapd_init[] = { |
| 787 | /* set dac0mux for dac converter */ |
| 788 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 789 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 790 | {} |
| 791 | }; |
| 792 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 793 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 794 | /* set master volume and direct control */ |
| 795 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 796 | /* setup adcs to point to mixer */ |
| 797 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 798 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 799 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 800 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 801 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 802 | /* setup import muxs */ |
| 803 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 804 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 805 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 806 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 807 | {} |
| 808 | }; |
| 809 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 810 | static struct hda_verb dell_eq_core_init[] = { |
| 811 | /* set master volume to max value without distortion |
| 812 | * and direct control */ |
| 813 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 814 | /* setup adcs to point to mixer */ |
| 815 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 816 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 817 | /* setup import muxs */ |
| 818 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 819 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 820 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 821 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 822 | {} |
| 823 | }; |
| 824 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 825 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 826 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 827 | /* setup adcs to point to mixer */ |
| 828 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 829 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 830 | /* setup import muxs */ |
| 831 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 832 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 833 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 834 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 835 | {} |
| 836 | }; |
| 837 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 838 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 839 | /* set master volume and direct control */ |
| 840 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 841 | /* setup adcs to point to mixer */ |
| 842 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 843 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 844 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 845 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 846 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 847 | /* setup import muxs */ |
| 848 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 849 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 850 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 851 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 852 | {} |
| 853 | }; |
| 854 | |
| 855 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 856 | /* set master volume and direct control */ |
| 857 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 858 | /* dac3 is connected to import3 mux */ |
| 859 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 860 | /* setup adcs to point to mixer */ |
| 861 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 862 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 863 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 864 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 865 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 866 | /* setup import muxs */ |
| 867 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 868 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 869 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 870 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 871 | {} |
| 872 | }; |
| 873 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 874 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 875 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 876 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 877 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 878 | |
| 879 | /* power state controls amps */ |
| 880 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 881 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 882 | }; |
| 883 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 884 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 885 | /* set master volume and direct control */ |
| 886 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 887 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 888 | }; |
| 889 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 890 | #define HD_DISABLE_PORTF 1 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 891 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 892 | /* start of config #1 */ |
| 893 | |
| 894 | /* connect port 0f to audio mixer */ |
| 895 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 896 | /* start of config #2 */ |
| 897 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 898 | /* set master volume and direct control */ |
| 899 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 900 | {} |
| 901 | }; |
| 902 | |
| 903 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 904 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 905 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 906 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 907 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 908 | {} |
| 909 | }; |
| 910 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 911 | static struct hda_verb stac925x_core_init[] = { |
| 912 | /* set dac0mux for dac converter */ |
| 913 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 914 | /* mute the master volume */ |
| 915 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 916 | {} |
| 917 | }; |
| 918 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 919 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 920 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 921 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 922 | {} |
| 923 | }; |
| 924 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 925 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 926 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 927 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 928 | /* unmute node 0x1b */ |
| 929 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 930 | /* select node 0x03 as DAC */ |
| 931 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 932 | {} |
| 933 | }; |
| 934 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 935 | static struct hda_verb stac927x_core_init[] = { |
| 936 | /* set master volume and direct control */ |
| 937 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 938 | /* enable analog pc beep path */ |
| 939 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 940 | {} |
| 941 | }; |
| 942 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 943 | static struct hda_verb stac9205_core_init[] = { |
| 944 | /* set master volume and direct control */ |
| 945 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 946 | /* enable analog pc beep path */ |
| 947 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 948 | {} |
| 949 | }; |
| 950 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 951 | #define STAC_MONO_MUX \ |
| 952 | { \ |
| 953 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 954 | .name = "Mono Mux", \ |
| 955 | .count = 1, \ |
| 956 | .info = stac92xx_mono_mux_enum_info, \ |
| 957 | .get = stac92xx_mono_mux_enum_get, \ |
| 958 | .put = stac92xx_mono_mux_enum_put, \ |
| 959 | } |
| 960 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 961 | #define STAC_AMP_MUX \ |
| 962 | { \ |
| 963 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 964 | .name = "Amp Selector Capture Switch", \ |
| 965 | .count = 1, \ |
| 966 | .info = stac92xx_amp_mux_enum_info, \ |
| 967 | .get = stac92xx_amp_mux_enum_get, \ |
| 968 | .put = stac92xx_amp_mux_enum_put, \ |
| 969 | } |
| 970 | |
| 971 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 972 | { \ |
| 973 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 974 | .name = xname, \ |
| 975 | .index = 0, \ |
| 976 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 977 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 978 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 979 | .info = stac92xx_amp_volume_info, \ |
| 980 | .get = stac92xx_amp_volume_get, \ |
| 981 | .put = stac92xx_amp_volume_put, \ |
| 982 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 983 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 984 | } |
| 985 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 986 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 987 | { \ |
| 988 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 989 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 990 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 991 | .info = stac92xx_aloopback_info, \ |
| 992 | .get = stac92xx_aloopback_get, \ |
| 993 | .put = stac92xx_aloopback_put, \ |
| 994 | .private_value = verb_read | (verb_write << 16), \ |
| 995 | } |
| 996 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 997 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 998 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 999 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1000 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1001 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1002 | { } /* end */ |
| 1003 | }; |
| 1004 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1005 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1006 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1007 | /* start of config #1 */ |
| 1008 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1009 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1010 | |
| 1011 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1012 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1013 | |
| 1014 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1015 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1016 | |
| 1017 | /* start of config #2 */ |
| 1018 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1019 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1020 | |
| 1021 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1022 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1023 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1024 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1025 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1026 | |
| 1027 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1028 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1029 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1030 | { } /* end */ |
| 1031 | }; |
| 1032 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1033 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1034 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1035 | {} |
| 1036 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1037 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1038 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1039 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1040 | {} |
| 1041 | }; |
| 1042 | |
| 1043 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1044 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1045 | {} |
| 1046 | }; |
| 1047 | |
| 1048 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1049 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1050 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1051 | |
| 1052 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1053 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1054 | |
| 1055 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1056 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1057 | |
| 1058 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1059 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1060 | |
| 1061 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1062 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1063 | |
| 1064 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1065 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1066 | |
| 1067 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1068 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1069 | { } /* end */ |
| 1070 | }; |
| 1071 | |
| 1072 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1073 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1074 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1075 | |
| 1076 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1077 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1078 | |
| 1079 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1080 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1081 | |
| 1082 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1083 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1084 | |
| 1085 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1086 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1087 | |
| 1088 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1089 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1090 | |
| 1091 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1092 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1093 | { } /* end */ |
| 1094 | }; |
| 1095 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1096 | |
| 1097 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1098 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1099 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1100 | |
| 1101 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1102 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1103 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1104 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1105 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1106 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1107 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1108 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1109 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1110 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1111 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1112 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1113 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1114 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1115 | |
| 1116 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1117 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1118 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1119 | */ |
| 1120 | { } /* end */ |
| 1121 | }; |
| 1122 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1123 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1124 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1125 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1126 | |
| 1127 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1128 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1129 | /* analog pc-beep replaced with digital beep support */ |
| 1130 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1131 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1132 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1133 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1134 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1135 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1136 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1137 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1138 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1139 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1140 | |
| 1141 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1142 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1143 | |
| 1144 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1145 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1146 | { } /* end */ |
| 1147 | }; |
| 1148 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1149 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1150 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1151 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1152 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1153 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1154 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1155 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1156 | |
| 1157 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1158 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1159 | { } /* end */ |
| 1160 | }; |
| 1161 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1162 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1163 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1164 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1165 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1166 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1167 | { } /* end */ |
| 1168 | }; |
| 1169 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1170 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1171 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1172 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1173 | |
| 1174 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1175 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1176 | { } /* end */ |
| 1177 | }; |
| 1178 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1179 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1180 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1181 | {} |
| 1182 | }; |
| 1183 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1184 | /* This needs to be generated dynamically based on sequence */ |
| 1185 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1186 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1187 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1188 | |
| 1189 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1190 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1191 | { } /* end */ |
| 1192 | }; |
| 1193 | |
| 1194 | |
| 1195 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1196 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1197 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1198 | |
| 1199 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1200 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1201 | |
| 1202 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1203 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1204 | { } /* end */ |
| 1205 | }; |
| 1206 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1207 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1208 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1209 | {} |
| 1210 | }; |
| 1211 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1212 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1213 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1214 | .name = "Digital Input Source", |
| 1215 | /* count set later */ |
| 1216 | .info = stac92xx_dmux_enum_info, |
| 1217 | .get = stac92xx_dmux_enum_get, |
| 1218 | .put = stac92xx_dmux_enum_put, |
| 1219 | }; |
| 1220 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1221 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1223 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1224 | /* count set later */ |
| 1225 | .info = stac92xx_smux_enum_info, |
| 1226 | .get = stac92xx_smux_enum_get, |
| 1227 | .put = stac92xx_smux_enum_put, |
| 1228 | }; |
| 1229 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1230 | static const char *slave_vols[] = { |
| 1231 | "Front Playback Volume", |
| 1232 | "Surround Playback Volume", |
| 1233 | "Center Playback Volume", |
| 1234 | "LFE Playback Volume", |
| 1235 | "Side Playback Volume", |
| 1236 | "Headphone Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1237 | "Speaker Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1238 | NULL |
| 1239 | }; |
| 1240 | |
| 1241 | static const char *slave_sws[] = { |
| 1242 | "Front Playback Switch", |
| 1243 | "Surround Playback Switch", |
| 1244 | "Center Playback Switch", |
| 1245 | "LFE Playback Switch", |
| 1246 | "Side Playback Switch", |
| 1247 | "Headphone Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1248 | "Speaker Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1249 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1250 | NULL |
| 1251 | }; |
| 1252 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1253 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1254 | 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] | 1255 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1256 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1257 | { |
| 1258 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1259 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1260 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1261 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1262 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1263 | |
| 1264 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1265 | if (err < 0) |
| 1266 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1267 | |
| 1268 | for (i = 0; i < spec->num_mixers; i++) { |
| 1269 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1270 | if (err < 0) |
| 1271 | return err; |
| 1272 | } |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1273 | if (spec->num_dmuxes > 0) { |
| 1274 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1275 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1276 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1277 | if (err < 0) |
| 1278 | return err; |
| 1279 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1280 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1281 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1282 | struct hda_input_mux *smux = &spec->private_smux; |
| 1283 | /* check for mute support on SPDIF out */ |
| 1284 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1285 | smux->items[smux->num_items].label = "Off"; |
| 1286 | smux->items[smux->num_items].index = 0; |
| 1287 | smux->num_items++; |
| 1288 | spec->spdif_mute = 1; |
| 1289 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1290 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1291 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1292 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1293 | if (err < 0) |
| 1294 | return err; |
| 1295 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1296 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1297 | if (spec->multiout.dig_out_nid) { |
| 1298 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1299 | if (err < 0) |
| 1300 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1301 | err = snd_hda_create_spdif_share_sw(codec, |
| 1302 | &spec->multiout); |
| 1303 | if (err < 0) |
| 1304 | return err; |
| 1305 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1306 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1307 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1308 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1309 | if (err < 0) |
| 1310 | return err; |
| 1311 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1312 | |
| 1313 | /* if we have no master control, let's create it */ |
| 1314 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1315 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1316 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1317 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1318 | /* correct volume offset */ |
| 1319 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1320 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1321 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1322 | if (err < 0) |
| 1323 | return err; |
| 1324 | } |
| 1325 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1326 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1327 | NULL, slave_sws); |
| 1328 | if (err < 0) |
| 1329 | return err; |
| 1330 | } |
| 1331 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1332 | if (spec->aloopback_ctl && |
| 1333 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1334 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1335 | if (err < 0) |
| 1336 | return err; |
| 1337 | } |
| 1338 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1339 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1340 | |
| 1341 | /* create jack input elements */ |
| 1342 | if (spec->hp_detect) { |
| 1343 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1344 | int type = SND_JACK_HEADPHONE; |
| 1345 | nid = cfg->hp_pins[i]; |
| 1346 | /* jack detection */ |
| 1347 | if (cfg->hp_outs == i) |
| 1348 | type |= SND_JACK_LINEOUT; |
| 1349 | err = stac92xx_add_jack(codec, nid, type); |
| 1350 | if (err < 0) |
| 1351 | return err; |
| 1352 | } |
| 1353 | } |
| 1354 | for (i = 0; i < cfg->line_outs; i++) { |
| 1355 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1356 | SND_JACK_LINEOUT); |
| 1357 | if (err < 0) |
| 1358 | return err; |
| 1359 | } |
| 1360 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1361 | nid = cfg->input_pins[i]; |
| 1362 | if (nid) { |
| 1363 | err = stac92xx_add_jack(codec, nid, |
| 1364 | SND_JACK_MICROPHONE); |
| 1365 | if (err < 0) |
| 1366 | return err; |
| 1367 | } |
| 1368 | } |
| 1369 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1370 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1371 | } |
| 1372 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1373 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1374 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1375 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1376 | }; |
| 1377 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1378 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1379 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1380 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1381 | }; |
| 1382 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1383 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1384 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1385 | }; |
| 1386 | |
| 1387 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1388 | STAC 9200 pin configs for |
| 1389 | 102801A8 |
| 1390 | 102801DE |
| 1391 | 102801E8 |
| 1392 | */ |
| 1393 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1394 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1395 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1396 | }; |
| 1397 | |
| 1398 | /* |
| 1399 | STAC 9200 pin configs for |
| 1400 | 102801C0 |
| 1401 | 102801C1 |
| 1402 | */ |
| 1403 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1404 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1405 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1406 | }; |
| 1407 | |
| 1408 | /* |
| 1409 | STAC 9200 pin configs for |
| 1410 | 102801C4 (Dell Dimension E310) |
| 1411 | 102801C5 |
| 1412 | 102801C7 |
| 1413 | 102801D9 |
| 1414 | 102801DA |
| 1415 | 102801E3 |
| 1416 | */ |
| 1417 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1418 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1419 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1420 | }; |
| 1421 | |
| 1422 | |
| 1423 | /* |
| 1424 | STAC 9200-32 pin configs for |
| 1425 | 102801B5 (Dell Inspiron 630m) |
| 1426 | 102801D8 (Dell Inspiron 640m) |
| 1427 | */ |
| 1428 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1429 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1430 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1431 | }; |
| 1432 | |
| 1433 | /* |
| 1434 | STAC 9200-32 pin configs for |
| 1435 | 102801C2 (Dell Latitude D620) |
| 1436 | 102801C8 |
| 1437 | 102801CC (Dell Latitude D820) |
| 1438 | 102801D4 |
| 1439 | 102801D6 |
| 1440 | */ |
| 1441 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1442 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1443 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1444 | }; |
| 1445 | |
| 1446 | /* |
| 1447 | STAC 9200-32 pin configs for |
| 1448 | 102801CE (Dell XPS M1710) |
| 1449 | 102801CF (Dell Precision M90) |
| 1450 | */ |
| 1451 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1452 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1453 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1454 | }; |
| 1455 | |
| 1456 | /* |
| 1457 | STAC 9200-32 pin configs for |
| 1458 | 102801C9 |
| 1459 | 102801CA |
| 1460 | 102801CB (Dell Latitude 120L) |
| 1461 | 102801D3 |
| 1462 | */ |
| 1463 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1464 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1465 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1466 | }; |
| 1467 | |
| 1468 | /* |
| 1469 | STAC 9200-32 pin configs for |
| 1470 | 102801BD (Dell Inspiron E1505n) |
| 1471 | 102801EE |
| 1472 | 102801EF |
| 1473 | */ |
| 1474 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1475 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1476 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1477 | }; |
| 1478 | |
| 1479 | /* |
| 1480 | STAC 9200-32 pin configs for |
| 1481 | 102801F5 (Dell Inspiron 1501) |
| 1482 | 102801F6 |
| 1483 | */ |
| 1484 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1485 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1486 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1487 | }; |
| 1488 | |
| 1489 | /* |
| 1490 | STAC 9200-32 |
| 1491 | 102801CD (Dell Inspiron E1705/9400) |
| 1492 | */ |
| 1493 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1494 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1495 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1496 | }; |
| 1497 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1498 | static unsigned int oqo9200_pin_configs[8] = { |
| 1499 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1500 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1501 | }; |
| 1502 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1503 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1504 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1505 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1506 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1507 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1508 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1509 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1510 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1511 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1512 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1513 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1514 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1515 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1516 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1517 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1518 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1519 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1520 | }; |
| 1521 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1522 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1523 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1524 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1525 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1526 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1527 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1528 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1529 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1530 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1531 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1532 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1533 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1534 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1535 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1536 | [STAC_9200_M4] = "gateway-m4", |
| 1537 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1538 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1539 | }; |
| 1540 | |
| 1541 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1542 | /* SigmaTel reference board */ |
| 1543 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1544 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1545 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1546 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1547 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1548 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1549 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1550 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1551 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1552 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1553 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1554 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1555 | "unknown Dell", STAC_9200_DELL_D22), |
| 1556 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1557 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1558 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1559 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1560 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1561 | "unknown Dell", STAC_9200_DELL_D23), |
| 1562 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1563 | "unknown Dell", STAC_9200_DELL_D23), |
| 1564 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1565 | "unknown Dell", STAC_9200_DELL_M22), |
| 1566 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1567 | "unknown Dell", STAC_9200_DELL_M24), |
| 1568 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1569 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1570 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1571 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1572 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1573 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1574 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1575 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1576 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1577 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1578 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1579 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1580 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1581 | "unknown Dell", STAC_9200_DELL_M22), |
| 1582 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1583 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1584 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1585 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1586 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1587 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1588 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1589 | "unknown Dell", STAC_9200_DELL_D23), |
| 1590 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1591 | "unknown Dell", STAC_9200_DELL_D23), |
| 1592 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1593 | "unknown Dell", STAC_9200_DELL_D21), |
| 1594 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1595 | "unknown Dell", STAC_9200_DELL_D23), |
| 1596 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1597 | "unknown Dell", STAC_9200_DELL_D21), |
| 1598 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1599 | "unknown Dell", STAC_9200_DELL_M25), |
| 1600 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1601 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1602 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1603 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1604 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1605 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1606 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1607 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1608 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1609 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1610 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1611 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1612 | /* OQO Mobile */ |
| 1613 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1614 | {} /* terminator */ |
| 1615 | }; |
| 1616 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1617 | static unsigned int ref925x_pin_configs[8] = { |
| 1618 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1619 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1620 | }; |
| 1621 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1622 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1623 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1624 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1625 | }; |
| 1626 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1627 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1628 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1629 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1630 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1631 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1632 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1633 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1634 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1635 | }; |
| 1636 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1637 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1638 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1639 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1640 | }; |
| 1641 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1642 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1643 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1644 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1645 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1646 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1647 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1648 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1649 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1650 | }; |
| 1651 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1652 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1653 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1654 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1655 | }; |
| 1656 | |
| 1657 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1658 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1659 | [STAC_M1] = stac925xM1_pin_configs, |
| 1660 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1661 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1662 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1663 | [STAC_M3] = stac925xM3_pin_configs, |
| 1664 | [STAC_M5] = stac925xM5_pin_configs, |
| 1665 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1666 | }; |
| 1667 | |
| 1668 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1669 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1670 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1671 | [STAC_M1] = "m1", |
| 1672 | [STAC_M1_2] = "m1-2", |
| 1673 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1674 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1675 | [STAC_M3] = "m3", |
| 1676 | [STAC_M5] = "m5", |
| 1677 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1678 | }; |
| 1679 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1681 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1682 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1683 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1684 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1685 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1686 | /* Not sure about the brand name for those */ |
| 1687 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1688 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1689 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1690 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1691 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1692 | }; |
| 1693 | |
| 1694 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1695 | /* SigmaTel reference board */ |
| 1696 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1698 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1699 | |
| 1700 | /* Default table for unknown ID */ |
| 1701 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1702 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1703 | {} /* terminator */ |
| 1704 | }; |
| 1705 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1706 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1707 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1708 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1709 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1710 | 0x01452050, |
| 1711 | }; |
| 1712 | |
| 1713 | static unsigned int dell_m6_pin_configs[13] = { |
| 1714 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1715 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1716 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1717 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1718 | }; |
| 1719 | |
| 1720 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1721 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1722 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1723 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1724 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1725 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1726 | }; |
| 1727 | |
| 1728 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1729 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1730 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1731 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1732 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1733 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1734 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1735 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1736 | }; |
| 1737 | |
| 1738 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1739 | /* SigmaTel reference board */ |
| 1740 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1741 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1742 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1743 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1744 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1745 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1746 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1747 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1748 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1749 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1750 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1751 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1752 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1753 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1754 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1755 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1756 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1757 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1758 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1759 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1760 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1761 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1762 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1763 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1764 | {} /* terminator */ |
| 1765 | }; |
| 1766 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1767 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1768 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1769 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1770 | 0x01451160, 0x98560170, |
| 1771 | }; |
| 1772 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1773 | static unsigned int dell_s14_pin_configs[10] = { |
| 1774 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1775 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1776 | 0x40f000f0, 0x40f000f0, |
| 1777 | }; |
| 1778 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1779 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1780 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1781 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1782 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1783 | }; |
| 1784 | |
| 1785 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1786 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1787 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1788 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1789 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1790 | }; |
| 1791 | |
| 1792 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1793 | /* SigmaTel reference board */ |
| 1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1795 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1796 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1797 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1798 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1799 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1800 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1801 | }; |
| 1802 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1803 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1804 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1805 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1806 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1807 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1808 | }; |
| 1809 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1810 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1811 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1812 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1813 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1814 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1815 | }; |
| 1816 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1817 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1818 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1819 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1820 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1821 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1822 | }; |
| 1823 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1824 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1825 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1826 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1827 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1828 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1829 | }; |
| 1830 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1831 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1832 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1833 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1834 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1835 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1836 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1837 | [STAC_HP_DV5] = NULL, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1838 | [STAC_HP_HDX] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1839 | }; |
| 1840 | |
| 1841 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1842 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1843 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1844 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1845 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1846 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1847 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1848 | [STAC_HP_DV5] = "hp-dv5", |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1849 | [STAC_HP_HDX] = "hp-hdx", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1850 | }; |
| 1851 | |
| 1852 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1853 | /* SigmaTel reference board */ |
| 1854 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1855 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1856 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1857 | "DFI LanParty", STAC_92HD71BXX_REF), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1858 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 1859 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1860 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1861 | "HP dv4-7", STAC_HP_DV5), |
| 1862 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1863 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1864 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 1865 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1866 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1867 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1868 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1869 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1870 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1871 | "unknown Dell", STAC_DELL_M4_1), |
| 1872 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1873 | "unknown Dell", STAC_DELL_M4_1), |
| 1874 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1875 | "unknown Dell", STAC_DELL_M4_1), |
| 1876 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1877 | "unknown Dell", STAC_DELL_M4_1), |
| 1878 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1879 | "unknown Dell", STAC_DELL_M4_1), |
| 1880 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1881 | "unknown Dell", STAC_DELL_M4_1), |
| 1882 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1883 | "unknown Dell", STAC_DELL_M4_1), |
| 1884 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1885 | "unknown Dell", STAC_DELL_M4_2), |
| 1886 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1887 | "unknown Dell", STAC_DELL_M4_2), |
| 1888 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1889 | "unknown Dell", STAC_DELL_M4_2), |
| 1890 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1891 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1892 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1893 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1894 | {} /* terminator */ |
| 1895 | }; |
| 1896 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1897 | static unsigned int ref922x_pin_configs[10] = { |
| 1898 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1899 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1900 | 0x40000100, 0x40000100, |
| 1901 | }; |
| 1902 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1903 | /* |
| 1904 | STAC 922X pin configs for |
| 1905 | 102801A7 |
| 1906 | 102801AB |
| 1907 | 102801A9 |
| 1908 | 102801D1 |
| 1909 | 102801D2 |
| 1910 | */ |
| 1911 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1912 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1913 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1914 | 0x01813122, 0x400001f2, |
| 1915 | }; |
| 1916 | |
| 1917 | /* |
| 1918 | STAC 922X pin configs for |
| 1919 | 102801AC |
| 1920 | 102801D0 |
| 1921 | */ |
| 1922 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1923 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1924 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1925 | 0x01813122, 0x400001f1, |
| 1926 | }; |
| 1927 | |
| 1928 | /* |
| 1929 | STAC 922X pin configs for |
| 1930 | 102801BF |
| 1931 | */ |
| 1932 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1933 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1934 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1935 | 0x40C003f1, 0x405003f0, |
| 1936 | }; |
| 1937 | |
| 1938 | /* |
| 1939 | STAC 9221 A1 pin configs for |
| 1940 | 102801D7 (Dell XPS M1210) |
| 1941 | */ |
| 1942 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1943 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1944 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1945 | 0x508003f3, 0x405003f4, |
| 1946 | }; |
| 1947 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1948 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1949 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1950 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1951 | 0x02a19120, 0x40000100, |
| 1952 | }; |
| 1953 | |
| 1954 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1955 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1956 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1957 | 0x02a19320, 0x40000100, |
| 1958 | }; |
| 1959 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1960 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1961 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1962 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1963 | 0x400000fc, 0x400000fb, |
| 1964 | }; |
| 1965 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1966 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1967 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1968 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1969 | 0x400000fc, 0x400000fb, |
| 1970 | }; |
| 1971 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1972 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1973 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1974 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 1975 | 0x400000fc, 0x400000fb, |
| 1976 | }; |
| 1977 | |
| 1978 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 1979 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1980 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1981 | 0x400000fc, 0x400000fb, |
| 1982 | }; |
| 1983 | |
| 1984 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 1985 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1986 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1987 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1988 | }; |
| 1989 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1990 | static unsigned int ecs202_pin_configs[10] = { |
| 1991 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 1992 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 1993 | 0x9037012e, 0x40e000f2, |
| 1994 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1995 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1996 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1997 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1998 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 1999 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2000 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 2001 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 2002 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 2003 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 2004 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2005 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2006 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2007 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 2008 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2009 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2010 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2011 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2012 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2013 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2014 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2015 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2016 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2017 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2018 | }; |
| 2019 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2020 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2021 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2022 | [STAC_D945_REF] = "ref", |
| 2023 | [STAC_D945GTP5] = "5stack", |
| 2024 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2025 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2026 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2027 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2028 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2029 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2030 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2031 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2032 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2033 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2034 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2035 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2036 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2037 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2038 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2039 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2040 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2041 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2042 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2043 | }; |
| 2044 | |
| 2045 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2046 | /* SigmaTel reference board */ |
| 2047 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2048 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2049 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2050 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2051 | /* Intel 945G based systems */ |
| 2052 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2053 | "Intel D945G", STAC_D945GTP3), |
| 2054 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2055 | "Intel D945G", STAC_D945GTP3), |
| 2056 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2057 | "Intel D945G", STAC_D945GTP3), |
| 2058 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2059 | "Intel D945G", STAC_D945GTP3), |
| 2060 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2061 | "Intel D945G", STAC_D945GTP3), |
| 2062 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2063 | "Intel D945G", STAC_D945GTP3), |
| 2064 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2065 | "Intel D945G", STAC_D945GTP3), |
| 2066 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2067 | "Intel D945G", STAC_D945GTP3), |
| 2068 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2069 | "Intel D945G", STAC_D945GTP3), |
| 2070 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2071 | "Intel D945G", STAC_D945GTP3), |
| 2072 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2073 | "Intel D945G", STAC_D945GTP3), |
| 2074 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2075 | "Intel D945G", STAC_D945GTP3), |
| 2076 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2077 | "Intel D945G", STAC_D945GTP3), |
| 2078 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2079 | "Intel D945G", STAC_D945GTP3), |
| 2080 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2081 | "Intel D945G", STAC_D945GTP3), |
| 2082 | /* Intel D945G 5-stack systems */ |
| 2083 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2084 | "Intel D945G", STAC_D945GTP5), |
| 2085 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2086 | "Intel D945G", STAC_D945GTP5), |
| 2087 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2088 | "Intel D945G", STAC_D945GTP5), |
| 2089 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2090 | "Intel D945G", STAC_D945GTP5), |
| 2091 | /* Intel 945P based systems */ |
| 2092 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2093 | "Intel D945P", STAC_D945GTP3), |
| 2094 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2095 | "Intel D945P", STAC_D945GTP3), |
| 2096 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2097 | "Intel D945P", STAC_D945GTP3), |
| 2098 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2099 | "Intel D945P", STAC_D945GTP3), |
| 2100 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2101 | "Intel D945P", STAC_D945GTP3), |
| 2102 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2103 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2104 | /* other intel */ |
| 2105 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2106 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2107 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2108 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2109 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2110 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2111 | /* Dell systems */ |
| 2112 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2113 | "unknown Dell", STAC_922X_DELL_D81), |
| 2114 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2115 | "unknown Dell", STAC_922X_DELL_D81), |
| 2116 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2117 | "unknown Dell", STAC_922X_DELL_D81), |
| 2118 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2119 | "unknown Dell", STAC_922X_DELL_D82), |
| 2120 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2121 | "unknown Dell", STAC_922X_DELL_M81), |
| 2122 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2123 | "unknown Dell", STAC_922X_DELL_D82), |
| 2124 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2125 | "unknown Dell", STAC_922X_DELL_D81), |
| 2126 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2127 | "unknown Dell", STAC_922X_DELL_D81), |
| 2128 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2129 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2130 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2131 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2132 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2133 | {} /* terminator */ |
| 2134 | }; |
| 2135 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2136 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2137 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2138 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2139 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2140 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2141 | }; |
| 2142 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2143 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2144 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2145 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2146 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2147 | 0x40000100, 0x40000100 |
| 2148 | }; |
| 2149 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2150 | static unsigned int d965_5st_pin_configs[14] = { |
| 2151 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2152 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2153 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2154 | 0x40000100, 0x40000100 |
| 2155 | }; |
| 2156 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2157 | static unsigned int dell_3st_pin_configs[14] = { |
| 2158 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2159 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2160 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2161 | 0x40c003fc, 0x40000100 |
| 2162 | }; |
| 2163 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2164 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2165 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2166 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2167 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2168 | [STAC_D965_5ST] = d965_5st_pin_configs, |
| 2169 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2170 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2171 | }; |
| 2172 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2173 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2174 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2175 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2176 | [STAC_D965_REF] = "ref", |
| 2177 | [STAC_D965_3ST] = "3stack", |
| 2178 | [STAC_D965_5ST] = "5stack", |
| 2179 | [STAC_DELL_3ST] = "dell-3stack", |
| 2180 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2181 | }; |
| 2182 | |
| 2183 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2184 | /* SigmaTel reference board */ |
| 2185 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2186 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2187 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2188 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2189 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2190 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2191 | 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] | 2192 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2193 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2194 | "Intel D965", STAC_D965_3ST), |
| 2195 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2196 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2197 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2198 | 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] | 2199 | 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] | 2200 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2201 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2202 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2203 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2204 | 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] | 2205 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2206 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2207 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2208 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2209 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2210 | 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] | 2211 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2212 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2213 | "Intel D965", STAC_D965_5ST), |
| 2214 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2215 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2216 | {} /* terminator */ |
| 2217 | }; |
| 2218 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2219 | static unsigned int ref9205_pin_configs[12] = { |
| 2220 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2221 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2222 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2223 | }; |
| 2224 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2225 | /* |
| 2226 | STAC 9205 pin configs for |
| 2227 | 102801F1 |
| 2228 | 102801F2 |
| 2229 | 102801FC |
| 2230 | 102801FD |
| 2231 | 10280204 |
| 2232 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2233 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2234 | */ |
| 2235 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2236 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2237 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2238 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2239 | }; |
| 2240 | |
| 2241 | /* |
| 2242 | STAC 9205 pin configs for |
| 2243 | 102801F9 |
| 2244 | 102801FA |
| 2245 | 102801FE |
| 2246 | 102801FF (Dell Precision M4300) |
| 2247 | 10280206 |
| 2248 | 10280200 |
| 2249 | 10280201 |
| 2250 | */ |
| 2251 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2252 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2253 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2254 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2255 | }; |
| 2256 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2257 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2258 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2259 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2260 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2261 | }; |
| 2262 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2263 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2264 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2265 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2266 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2267 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2268 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2269 | }; |
| 2270 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2271 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2272 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2273 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2274 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2275 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2276 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2277 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2278 | }; |
| 2279 | |
| 2280 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2281 | /* SigmaTel reference board */ |
| 2282 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2283 | "DFI LanParty", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2284 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2285 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2286 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2287 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2288 | "unknown Dell", STAC_9205_DELL_M42), |
| 2289 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2290 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2291 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2292 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2293 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2294 | "Dell Precision", STAC_9205_DELL_M43), |
| 2295 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2296 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2297 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2298 | "unknown Dell", STAC_9205_DELL_M42), |
| 2299 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2300 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2301 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2302 | "Dell Precision", STAC_9205_DELL_M43), |
| 2303 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2304 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2305 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2306 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2307 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2308 | "Dell Precision", STAC_9205_DELL_M43), |
| 2309 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2310 | "Dell Precision", STAC_9205_DELL_M43), |
| 2311 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2312 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2313 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2314 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2315 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2316 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2317 | /* Gateway */ |
| 2318 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2319 | {} /* terminator */ |
| 2320 | }; |
| 2321 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2322 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2323 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2324 | { |
| 2325 | int i; |
| 2326 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2327 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2328 | if (!pincfgs) |
| 2329 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2330 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2331 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2332 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2333 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2334 | pincfgs[i]); |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2335 | } |
| 2336 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2337 | /* |
| 2338 | * Analog playback callbacks |
| 2339 | */ |
| 2340 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2341 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2342 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2343 | { |
| 2344 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2345 | if (spec->stream_delay) |
| 2346 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2347 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2348 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2349 | } |
| 2350 | |
| 2351 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2352 | struct hda_codec *codec, |
| 2353 | unsigned int stream_tag, |
| 2354 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2355 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2356 | { |
| 2357 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2358 | 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] | 2359 | } |
| 2360 | |
| 2361 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2362 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2363 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2364 | { |
| 2365 | struct sigmatel_spec *spec = codec->spec; |
| 2366 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2367 | } |
| 2368 | |
| 2369 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2370 | * Digital playback callbacks |
| 2371 | */ |
| 2372 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2373 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2374 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2375 | { |
| 2376 | struct sigmatel_spec *spec = codec->spec; |
| 2377 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2378 | } |
| 2379 | |
| 2380 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2381 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2382 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2383 | { |
| 2384 | struct sigmatel_spec *spec = codec->spec; |
| 2385 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2386 | } |
| 2387 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2388 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2389 | struct hda_codec *codec, |
| 2390 | unsigned int stream_tag, |
| 2391 | unsigned int format, |
| 2392 | struct snd_pcm_substream *substream) |
| 2393 | { |
| 2394 | struct sigmatel_spec *spec = codec->spec; |
| 2395 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2396 | stream_tag, format, substream); |
| 2397 | } |
| 2398 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2399 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2400 | struct hda_codec *codec, |
| 2401 | struct snd_pcm_substream *substream) |
| 2402 | { |
| 2403 | struct sigmatel_spec *spec = codec->spec; |
| 2404 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2405 | } |
| 2406 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2407 | |
| 2408 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2409 | * Analog capture callbacks |
| 2410 | */ |
| 2411 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2412 | struct hda_codec *codec, |
| 2413 | unsigned int stream_tag, |
| 2414 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2415 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2416 | { |
| 2417 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2418 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2419 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2420 | if (spec->powerdown_adcs) { |
| 2421 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2422 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2423 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2424 | } |
| 2425 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2426 | return 0; |
| 2427 | } |
| 2428 | |
| 2429 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2430 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2431 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2432 | { |
| 2433 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2434 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2435 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2436 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2437 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2438 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2439 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2440 | return 0; |
| 2441 | } |
| 2442 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2443 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2444 | .substreams = 1, |
| 2445 | .channels_min = 2, |
| 2446 | .channels_max = 2, |
| 2447 | /* NID is set in stac92xx_build_pcms */ |
| 2448 | .ops = { |
| 2449 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2450 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2451 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2452 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2453 | }, |
| 2454 | }; |
| 2455 | |
| 2456 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2457 | .substreams = 1, |
| 2458 | .channels_min = 2, |
| 2459 | .channels_max = 2, |
| 2460 | /* NID is set in stac92xx_build_pcms */ |
| 2461 | }; |
| 2462 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2463 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2464 | .substreams = 1, |
| 2465 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2466 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2467 | .nid = 0x02, /* NID to query formats and rates */ |
| 2468 | .ops = { |
| 2469 | .open = stac92xx_playback_pcm_open, |
| 2470 | .prepare = stac92xx_playback_pcm_prepare, |
| 2471 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2472 | }, |
| 2473 | }; |
| 2474 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2475 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2476 | .substreams = 1, |
| 2477 | .channels_min = 2, |
| 2478 | .channels_max = 2, |
| 2479 | .nid = 0x06, /* NID to query formats and rates */ |
| 2480 | .ops = { |
| 2481 | .open = stac92xx_playback_pcm_open, |
| 2482 | .prepare = stac92xx_playback_pcm_prepare, |
| 2483 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2484 | }, |
| 2485 | }; |
| 2486 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2487 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2488 | .channels_min = 2, |
| 2489 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2490 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2491 | .ops = { |
| 2492 | .prepare = stac92xx_capture_pcm_prepare, |
| 2493 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2494 | }, |
| 2495 | }; |
| 2496 | |
| 2497 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2498 | { |
| 2499 | struct sigmatel_spec *spec = codec->spec; |
| 2500 | struct hda_pcm *info = spec->pcm_rec; |
| 2501 | |
| 2502 | codec->num_pcms = 1; |
| 2503 | codec->pcm_info = info; |
| 2504 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2505 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2506 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2507 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2508 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2509 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2510 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2511 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2512 | |
| 2513 | if (spec->alt_switch) { |
| 2514 | codec->num_pcms++; |
| 2515 | info++; |
| 2516 | info->name = "STAC92xx Analog Alt"; |
| 2517 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2518 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2519 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2520 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2521 | codec->num_pcms++; |
| 2522 | info++; |
| 2523 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2524 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2525 | if (spec->multiout.dig_out_nid) { |
| 2526 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2527 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2528 | } |
| 2529 | if (spec->dig_in_nid) { |
| 2530 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2531 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2532 | } |
| 2533 | } |
| 2534 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2535 | return 0; |
| 2536 | } |
| 2537 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2538 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 2539 | { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2540 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2541 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2542 | if (pincap & AC_PINCAP_VREF_100) |
| 2543 | return AC_PINCTL_VREF_100; |
| 2544 | if (pincap & AC_PINCAP_VREF_80) |
| 2545 | return AC_PINCTL_VREF_80; |
| 2546 | if (pincap & AC_PINCAP_VREF_50) |
| 2547 | return AC_PINCTL_VREF_50; |
| 2548 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2549 | return AC_PINCTL_VREF_GRD; |
| 2550 | return 0; |
| 2551 | } |
| 2552 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2553 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2554 | |
| 2555 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2556 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2557 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2558 | } |
| 2559 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2560 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2561 | |
| 2562 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2563 | struct snd_ctl_elem_value *ucontrol) |
| 2564 | { |
| 2565 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2566 | struct sigmatel_spec *spec = codec->spec; |
| 2567 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2568 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2569 | return 0; |
| 2570 | } |
| 2571 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2572 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 2573 | unsigned char type); |
| 2574 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2575 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2576 | struct snd_ctl_elem_value *ucontrol) |
| 2577 | { |
| 2578 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2579 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2580 | int nid = kcontrol->private_value; |
| 2581 | |
| 2582 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2583 | |
| 2584 | /* check to be sure that the ports are upto date with |
| 2585 | * switch changes |
| 2586 | */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2587 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2588 | |
| 2589 | return 1; |
| 2590 | } |
| 2591 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 2592 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2593 | |
| 2594 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2595 | { |
| 2596 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2597 | struct sigmatel_spec *spec = codec->spec; |
| 2598 | int io_idx = kcontrol-> private_value & 0xff; |
| 2599 | |
| 2600 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 2601 | return 0; |
| 2602 | } |
| 2603 | |
| 2604 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2605 | { |
| 2606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2607 | struct sigmatel_spec *spec = codec->spec; |
| 2608 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 2609 | int io_idx = kcontrol-> private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2610 | unsigned short val = !!ucontrol->value.integer.value[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2611 | |
| 2612 | spec->io_switch[io_idx] = val; |
| 2613 | |
| 2614 | if (val) |
| 2615 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2616 | else { |
| 2617 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2618 | if (io_idx) /* set VREF for mic */ |
| 2619 | pinctl |= stac92xx_get_vref(codec, nid); |
| 2620 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2621 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2622 | |
| 2623 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2624 | * appropriately according to the pin direction |
| 2625 | */ |
| 2626 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2627 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2628 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2629 | return 1; |
| 2630 | } |
| 2631 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2632 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2633 | |
| 2634 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2635 | struct snd_ctl_elem_value *ucontrol) |
| 2636 | { |
| 2637 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2638 | struct sigmatel_spec *spec = codec->spec; |
| 2639 | |
| 2640 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2641 | return 0; |
| 2642 | } |
| 2643 | |
| 2644 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2645 | struct snd_ctl_elem_value *ucontrol) |
| 2646 | { |
| 2647 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2648 | struct sigmatel_spec *spec = codec->spec; |
| 2649 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2650 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2651 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2652 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2653 | return 0; |
| 2654 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2655 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2656 | |
| 2657 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2658 | spec->clfe_swap ? 0x4 : 0x0); |
| 2659 | |
| 2660 | return 1; |
| 2661 | } |
| 2662 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2663 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2664 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2665 | .name = xname, \ |
| 2666 | .index = 0, \ |
| 2667 | .info = stac92xx_hp_switch_info, \ |
| 2668 | .get = stac92xx_hp_switch_get, \ |
| 2669 | .put = stac92xx_hp_switch_put, \ |
| 2670 | } |
| 2671 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2672 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2673 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2674 | .name = xname, \ |
| 2675 | .index = 0, \ |
| 2676 | .info = stac92xx_io_switch_info, \ |
| 2677 | .get = stac92xx_io_switch_get, \ |
| 2678 | .put = stac92xx_io_switch_put, \ |
| 2679 | .private_value = xpval, \ |
| 2680 | } |
| 2681 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2682 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2683 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2684 | .name = xname, \ |
| 2685 | .index = 0, \ |
| 2686 | .info = stac92xx_clfe_switch_info, \ |
| 2687 | .get = stac92xx_clfe_switch_get, \ |
| 2688 | .put = stac92xx_clfe_switch_put, \ |
| 2689 | .private_value = xpval, \ |
| 2690 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2691 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2692 | enum { |
| 2693 | STAC_CTL_WIDGET_VOL, |
| 2694 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2695 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2696 | STAC_CTL_WIDGET_AMP_MUX, |
| 2697 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2698 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2699 | STAC_CTL_WIDGET_IO_SWITCH, |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2700 | STAC_CTL_WIDGET_CLFE_SWITCH |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2701 | }; |
| 2702 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2703 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2704 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2705 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2706 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2707 | STAC_AMP_MUX, |
| 2708 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2709 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2710 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2711 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2712 | }; |
| 2713 | |
| 2714 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2715 | static struct snd_kcontrol_new * |
| 2716 | stac_control_new(struct sigmatel_spec *spec, |
| 2717 | struct snd_kcontrol_new *ktemp, |
| 2718 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2719 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2720 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2721 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2722 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2723 | knew = snd_array_new(&spec->kctls); |
| 2724 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2725 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2726 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2727 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2728 | if (!knew->name) { |
| 2729 | /* roolback */ |
| 2730 | memset(knew, 0, sizeof(*knew)); |
| 2731 | spec->kctls.alloced--; |
| 2732 | return NULL; |
| 2733 | } |
| 2734 | return knew; |
| 2735 | } |
| 2736 | |
| 2737 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2738 | struct snd_kcontrol_new *ktemp, |
| 2739 | int idx, const char *name, |
| 2740 | unsigned long val) |
| 2741 | { |
| 2742 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2743 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2744 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2745 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2746 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2747 | return 0; |
| 2748 | } |
| 2749 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2750 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2751 | int type, int idx, const char *name, |
| 2752 | unsigned long val) |
| 2753 | { |
| 2754 | return stac92xx_add_control_temp(spec, |
| 2755 | &stac92xx_control_templates[type], |
| 2756 | idx, name, val); |
| 2757 | } |
| 2758 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2759 | |
| 2760 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2761 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2762 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2763 | { |
| 2764 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2765 | } |
| 2766 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2767 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2768 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2769 | .name = "Input Source", |
| 2770 | .info = stac92xx_mux_enum_info, |
| 2771 | .get = stac92xx_mux_enum_get, |
| 2772 | .put = stac92xx_mux_enum_put, |
| 2773 | }; |
| 2774 | |
| 2775 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2776 | { |
| 2777 | struct snd_kcontrol_new *knew; |
| 2778 | struct hda_input_mux *imux = &spec->private_imux; |
| 2779 | |
| 2780 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2781 | return 0; /* no need for input source control */ |
| 2782 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2783 | stac_input_src_temp.name); |
| 2784 | if (!knew) |
| 2785 | return -ENOMEM; |
| 2786 | knew->count = spec->num_adcs; |
| 2787 | return 0; |
| 2788 | } |
| 2789 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2790 | /* check whether the line-input can be used as line-out */ |
| 2791 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2792 | { |
| 2793 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2794 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2795 | hda_nid_t nid; |
| 2796 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2797 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2798 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2799 | return 0; |
| 2800 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2801 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2802 | if (pincap & AC_PINCAP_OUT) |
| 2803 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2804 | return 0; |
| 2805 | } |
| 2806 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2807 | /* check whether the mic-input can be used as line-out */ |
| 2808 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2809 | { |
| 2810 | struct sigmatel_spec *spec = codec->spec; |
| 2811 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2812 | unsigned int def_conf, pincap; |
| 2813 | unsigned int mic_pin; |
| 2814 | |
| 2815 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2816 | return 0; |
| 2817 | mic_pin = AUTO_PIN_MIC; |
| 2818 | for (;;) { |
| 2819 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2820 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2821 | /* some laptops have an internal analog microphone |
| 2822 | * which can't be used as a output */ |
| 2823 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2824 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2825 | if (pincap & AC_PINCAP_OUT) |
| 2826 | return nid; |
| 2827 | } |
| 2828 | if (mic_pin == AUTO_PIN_MIC) |
| 2829 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 2830 | else |
| 2831 | break; |
| 2832 | } |
| 2833 | return 0; |
| 2834 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2835 | |
| 2836 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2837 | { |
| 2838 | int i; |
| 2839 | |
| 2840 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 2841 | if (spec->multiout.dac_nids[i] == nid) |
| 2842 | return 1; |
| 2843 | } |
| 2844 | |
| 2845 | return 0; |
| 2846 | } |
| 2847 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2848 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2849 | { |
| 2850 | int i; |
| 2851 | if (is_in_dac_nids(spec, nid)) |
| 2852 | return 1; |
| 2853 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 2854 | if (spec->hp_dacs[i] == nid) |
| 2855 | return 1; |
| 2856 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 2857 | if (spec->speaker_dacs[i] == nid) |
| 2858 | return 1; |
| 2859 | return 0; |
| 2860 | } |
| 2861 | |
| 2862 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 2863 | { |
| 2864 | struct sigmatel_spec *spec = codec->spec; |
| 2865 | int j, conn_len; |
| 2866 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 2867 | unsigned int wcaps, wtype; |
| 2868 | |
| 2869 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 2870 | HDA_MAX_CONNECTIONS); |
| 2871 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 2872 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2873 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 2874 | /* we check only analog outputs */ |
| 2875 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 2876 | continue; |
| 2877 | /* if this route has a free DAC, assign it */ |
| 2878 | if (!check_all_dac_nids(spec, conn[j])) { |
| 2879 | if (conn_len > 1) { |
| 2880 | /* select this DAC in the pin's input mux */ |
| 2881 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2882 | AC_VERB_SET_CONNECT_SEL, j); |
| 2883 | } |
| 2884 | return conn[j]; |
| 2885 | } |
| 2886 | } |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 2887 | /* if all DACs are already assigned, connect to the primary DAC */ |
| 2888 | if (conn_len > 1) { |
| 2889 | for (j = 0; j < conn_len; j++) { |
| 2890 | if (conn[j] == spec->multiout.dac_nids[0]) { |
| 2891 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2892 | AC_VERB_SET_CONNECT_SEL, j); |
| 2893 | break; |
| 2894 | } |
| 2895 | } |
| 2896 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2897 | return 0; |
| 2898 | } |
| 2899 | |
| 2900 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 2901 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 2902 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2903 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2904 | * Fill in the dac_nids table from the parsed pin configuration |
| 2905 | * This function only works when every pin in line_out_pins[] |
| 2906 | * contains atleast one DAC in its connection list. Some 92xx |
| 2907 | * codecs are not connected directly to a DAC, such as the 9200 |
| 2908 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2909 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2910 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2911 | { |
| 2912 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2913 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2914 | int i; |
| 2915 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2916 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2917 | for (i = 0; i < cfg->line_outs; i++) { |
| 2918 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2919 | dac = get_unassigned_dac(codec, nid); |
| 2920 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2921 | if (spec->multiout.num_dacs > 0) { |
| 2922 | /* we have already working output pins, |
| 2923 | * so let's drop the broken ones again |
| 2924 | */ |
| 2925 | cfg->line_outs = spec->multiout.num_dacs; |
| 2926 | break; |
| 2927 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2928 | /* error out, no available DAC found */ |
| 2929 | snd_printk(KERN_ERR |
| 2930 | "%s: No available DAC for pin 0x%x\n", |
| 2931 | __func__, nid); |
| 2932 | return -ENODEV; |
| 2933 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2934 | add_spec_dacs(spec, dac); |
| 2935 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2936 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 2937 | for (i = 0; i < cfg->hp_outs; i++) { |
| 2938 | nid = cfg->hp_pins[i]; |
| 2939 | dac = get_unassigned_dac(codec, nid); |
| 2940 | if (dac) { |
| 2941 | if (!spec->multiout.hp_nid) |
| 2942 | spec->multiout.hp_nid = dac; |
| 2943 | else |
| 2944 | add_spec_extra_dacs(spec, dac); |
| 2945 | } |
| 2946 | spec->hp_dacs[i] = dac; |
| 2947 | } |
| 2948 | |
| 2949 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 2950 | nid = cfg->speaker_pins[i]; |
| 2951 | dac = get_unassigned_dac(codec, nid); |
| 2952 | if (dac) |
| 2953 | add_spec_extra_dacs(spec, dac); |
| 2954 | spec->speaker_dacs[i] = dac; |
| 2955 | } |
| 2956 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2957 | /* add line-in as output */ |
| 2958 | nid = check_line_out_switch(codec); |
| 2959 | if (nid) { |
| 2960 | dac = get_unassigned_dac(codec, nid); |
| 2961 | if (dac) { |
| 2962 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 2963 | nid, cfg->line_outs); |
| 2964 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 2965 | cfg->line_outs++; |
| 2966 | spec->line_switch = nid; |
| 2967 | add_spec_dacs(spec, dac); |
| 2968 | } |
| 2969 | } |
| 2970 | /* add mic as output */ |
| 2971 | nid = check_mic_out_switch(codec); |
| 2972 | if (nid) { |
| 2973 | dac = get_unassigned_dac(codec, nid); |
| 2974 | if (dac) { |
| 2975 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 2976 | nid, cfg->line_outs); |
| 2977 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 2978 | cfg->line_outs++; |
| 2979 | spec->mic_switch = nid; |
| 2980 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2981 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2982 | } |
| 2983 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2984 | 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] | 2985 | spec->multiout.num_dacs, |
| 2986 | spec->multiout.dac_nids[0], |
| 2987 | spec->multiout.dac_nids[1], |
| 2988 | spec->multiout.dac_nids[2], |
| 2989 | spec->multiout.dac_nids[3], |
| 2990 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2991 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2992 | return 0; |
| 2993 | } |
| 2994 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2995 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 2996 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 2997 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2998 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2999 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3000 | char name[32]; |
| 3001 | int err; |
| 3002 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3003 | if (!spec->check_volume_offset) { |
| 3004 | unsigned int caps, step, nums, db_scale; |
| 3005 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3006 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 3007 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 3008 | step = (step + 1) * 25; /* in .01dB unit */ |
| 3009 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 3010 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3011 | db_scale = nums * step; |
| 3012 | /* if dB scale is over -64dB, and finer enough, |
| 3013 | * let's reduce it to half |
| 3014 | */ |
| 3015 | if (db_scale > 6400 && nums >= 0x1f) |
| 3016 | spec->volume_offset = nums / 2; |
| 3017 | spec->check_volume_offset = 1; |
| 3018 | } |
| 3019 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3020 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3021 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3022 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3023 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3024 | if (err < 0) |
| 3025 | return err; |
| 3026 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3027 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3028 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3029 | if (err < 0) |
| 3030 | return err; |
| 3031 | return 0; |
| 3032 | } |
| 3033 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3034 | #define create_controls(codec, pfx, nid, chs) \ |
| 3035 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 3036 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3037 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3038 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3039 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3040 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3041 | return 1; |
| 3042 | } else { |
| 3043 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3044 | spec->multiout.num_dacs++; |
| 3045 | } |
| 3046 | return 0; |
| 3047 | } |
| 3048 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3049 | 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] | 3050 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3051 | int i; |
| 3052 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3053 | if (!spec->multiout.extra_out_nid[i]) { |
| 3054 | spec->multiout.extra_out_nid[i] = nid; |
| 3055 | return 0; |
| 3056 | } |
| 3057 | } |
| 3058 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3059 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3060 | } |
| 3061 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3062 | /* Create output controls |
| 3063 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3064 | */ |
| 3065 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3066 | const hda_nid_t *pins, |
| 3067 | const hda_nid_t *dac_nids, |
| 3068 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3069 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3070 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3071 | static const char *chname[4] = { |
| 3072 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3073 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3074 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3075 | int i, err; |
| 3076 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3077 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3078 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
| 3079 | nid = dac_nids[i]; |
| 3080 | if (!nid) |
| 3081 | continue; |
| 3082 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3083 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3084 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3085 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3086 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3087 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3088 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3089 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3090 | |
| 3091 | wid_caps = get_wcaps(codec, nid); |
| 3092 | |
| 3093 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3094 | err = stac92xx_add_control(spec, |
| 3095 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3096 | "Swap Center/LFE Playback Switch", nid); |
| 3097 | |
| 3098 | if (err < 0) |
| 3099 | return err; |
| 3100 | } |
| 3101 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3102 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3103 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3104 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3105 | switch (type) { |
| 3106 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3107 | name = "Headphone"; |
| 3108 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3109 | break; |
| 3110 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3111 | name = "Speaker"; |
| 3112 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3113 | break; |
| 3114 | default: |
| 3115 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3116 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3117 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3118 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3119 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3120 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3121 | return err; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3122 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3123 | wid_caps = get_wcaps(codec, pins[i]); |
| 3124 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3125 | spec->hp_detect = 1; |
| 3126 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3127 | } |
| 3128 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3129 | return 0; |
| 3130 | } |
| 3131 | |
| 3132 | /* add playback controls from the parsed DAC table */ |
| 3133 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3134 | const struct auto_pin_cfg *cfg) |
| 3135 | { |
| 3136 | struct sigmatel_spec *spec = codec->spec; |
| 3137 | int err; |
| 3138 | |
| 3139 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3140 | spec->multiout.dac_nids, |
| 3141 | cfg->line_out_type); |
| 3142 | if (err < 0) |
| 3143 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3144 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3145 | 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] | 3146 | err = stac92xx_add_control(spec, |
| 3147 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3148 | "Headphone as Line Out Switch", |
| 3149 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3150 | if (err < 0) |
| 3151 | return err; |
| 3152 | } |
| 3153 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3154 | if (spec->line_switch) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3155 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
| 3156 | "Line In as Output Switch", |
| 3157 | spec->line_switch << 8); |
| 3158 | if (err < 0) |
| 3159 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3160 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3161 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3162 | if (spec->mic_switch) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3163 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
| 3164 | "Mic as Output Switch", |
| 3165 | (spec->mic_switch << 8) | 1); |
| 3166 | if (err < 0) |
| 3167 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3168 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3169 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3170 | return 0; |
| 3171 | } |
| 3172 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3173 | /* add playback controls for Speaker and HP outputs */ |
| 3174 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3175 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3176 | { |
| 3177 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3178 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3179 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3180 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3181 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3182 | if (err < 0) |
| 3183 | return err; |
| 3184 | |
| 3185 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3186 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3187 | if (err < 0) |
| 3188 | return err; |
| 3189 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3190 | return 0; |
| 3191 | } |
| 3192 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3193 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3194 | static const char *stac92xx_mono_labels[4] = { |
| 3195 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3196 | }; |
| 3197 | |
| 3198 | /* create mono mux for mono out on capable codecs */ |
| 3199 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3200 | { |
| 3201 | struct sigmatel_spec *spec = codec->spec; |
| 3202 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3203 | int i, num_cons; |
| 3204 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3205 | |
| 3206 | num_cons = snd_hda_get_connections(codec, |
| 3207 | spec->mono_nid, |
| 3208 | con_lst, |
| 3209 | HDA_MAX_NUM_INPUTS); |
| 3210 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 3211 | return -EINVAL; |
| 3212 | |
| 3213 | for (i = 0; i < num_cons; i++) { |
| 3214 | mono_mux->items[mono_mux->num_items].label = |
| 3215 | stac92xx_mono_labels[i]; |
| 3216 | mono_mux->items[mono_mux->num_items].index = i; |
| 3217 | mono_mux->num_items++; |
| 3218 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3219 | |
| 3220 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3221 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3222 | } |
| 3223 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3224 | /* labels for amp mux outputs */ |
| 3225 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3226 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3227 | }; |
| 3228 | |
| 3229 | /* create amp out controls mux on capable codecs */ |
| 3230 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3231 | { |
| 3232 | struct sigmatel_spec *spec = codec->spec; |
| 3233 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3234 | int i, err; |
| 3235 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3236 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3237 | amp_mux->items[amp_mux->num_items].label = |
| 3238 | stac92xx_amp_labels[i]; |
| 3239 | amp_mux->items[amp_mux->num_items].index = i; |
| 3240 | amp_mux->num_items++; |
| 3241 | } |
| 3242 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3243 | if (spec->num_amps > 1) { |
| 3244 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3245 | "Amp Selector Capture Switch", 0); |
| 3246 | if (err < 0) |
| 3247 | return err; |
| 3248 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3249 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3250 | "Amp Capture Volume", |
| 3251 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3252 | } |
| 3253 | |
| 3254 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3255 | /* create PC beep volume controls */ |
| 3256 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3257 | hda_nid_t nid) |
| 3258 | { |
| 3259 | struct sigmatel_spec *spec = codec->spec; |
| 3260 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3261 | int err; |
| 3262 | |
| 3263 | /* check for mute support for the the amp */ |
| 3264 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3265 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3266 | "PC Beep Playback Switch", |
| 3267 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3268 | if (err < 0) |
| 3269 | return err; |
| 3270 | } |
| 3271 | |
| 3272 | /* check to see if there is volume support for the amp */ |
| 3273 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3274 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3275 | "PC Beep Playback Volume", |
| 3276 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3277 | if (err < 0) |
| 3278 | return err; |
| 3279 | } |
| 3280 | return 0; |
| 3281 | } |
| 3282 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3283 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3284 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3285 | |
| 3286 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3287 | struct snd_ctl_elem_value *ucontrol) |
| 3288 | { |
| 3289 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3290 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3291 | return 0; |
| 3292 | } |
| 3293 | |
| 3294 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3295 | struct snd_ctl_elem_value *ucontrol) |
| 3296 | { |
| 3297 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3298 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3299 | if (codec->beep->enabled != enabled) { |
| 3300 | codec->beep->enabled = enabled; |
| 3301 | return 1; |
| 3302 | } |
| 3303 | return 0; |
| 3304 | } |
| 3305 | |
| 3306 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3307 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3308 | .info = stac92xx_dig_beep_switch_info, |
| 3309 | .get = stac92xx_dig_beep_switch_get, |
| 3310 | .put = stac92xx_dig_beep_switch_put, |
| 3311 | }; |
| 3312 | |
| 3313 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3314 | { |
| 3315 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3316 | 0, "PC Beep Playback Switch", 0); |
| 3317 | } |
| 3318 | #endif |
| 3319 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3320 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3321 | { |
| 3322 | struct sigmatel_spec *spec = codec->spec; |
| 3323 | int wcaps, nid, i, err = 0; |
| 3324 | |
| 3325 | for (i = 0; i < spec->num_muxes; i++) { |
| 3326 | nid = spec->mux_nids[i]; |
| 3327 | wcaps = get_wcaps(codec, nid); |
| 3328 | |
| 3329 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3330 | err = stac92xx_add_control_idx(spec, |
| 3331 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3332 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3333 | if (err < 0) |
| 3334 | return err; |
| 3335 | } |
| 3336 | } |
| 3337 | return 0; |
| 3338 | }; |
| 3339 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3340 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3341 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3342 | }; |
| 3343 | |
| 3344 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3345 | { |
| 3346 | struct sigmatel_spec *spec = codec->spec; |
| 3347 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3348 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3349 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3350 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3351 | |
| 3352 | num_cons = snd_hda_get_connections(codec, |
| 3353 | spec->smux_nids[0], |
| 3354 | con_lst, |
| 3355 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3356 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3357 | return -EINVAL; |
| 3358 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3359 | if (!labels) |
| 3360 | labels = stac92xx_spdif_labels; |
| 3361 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3362 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3363 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3364 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3365 | spdif_mux->num_items++; |
| 3366 | } |
| 3367 | |
| 3368 | return 0; |
| 3369 | } |
| 3370 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3371 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3372 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3373 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3374 | "Digital Mic 3", "Digital Mic 4" |
| 3375 | }; |
| 3376 | |
| 3377 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3378 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3379 | const struct auto_pin_cfg *cfg) |
| 3380 | { |
| 3381 | struct sigmatel_spec *spec = codec->spec; |
| 3382 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3383 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3384 | int err, i, j; |
| 3385 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3386 | |
| 3387 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3388 | dimux->items[dimux->num_items].index = 0; |
| 3389 | dimux->num_items++; |
| 3390 | |
| 3391 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3392 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3393 | int index; |
| 3394 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3395 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3396 | unsigned int def_conf; |
| 3397 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3398 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3399 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3400 | continue; |
| 3401 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3402 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3403 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3404 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3405 | con_lst, |
| 3406 | HDA_MAX_NUM_INPUTS); |
| 3407 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3408 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3409 | index = j; |
| 3410 | goto found; |
| 3411 | } |
| 3412 | continue; |
| 3413 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3414 | wcaps = get_wcaps(codec, nid) & |
| 3415 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3416 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3417 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3418 | sprintf(name, "%s Capture Volume", |
| 3419 | stac92xx_dmic_labels[dimux->num_items]); |
| 3420 | |
| 3421 | err = stac92xx_add_control(spec, |
| 3422 | STAC_CTL_WIDGET_VOL, |
| 3423 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3424 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3425 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3426 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3427 | if (err < 0) |
| 3428 | return err; |
| 3429 | } |
| 3430 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3431 | dimux->items[dimux->num_items].label = |
| 3432 | stac92xx_dmic_labels[dimux->num_items]; |
| 3433 | dimux->items[dimux->num_items].index = index; |
| 3434 | dimux->num_items++; |
| 3435 | } |
| 3436 | |
| 3437 | return 0; |
| 3438 | } |
| 3439 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3440 | /* create playback/capture controls for input pins */ |
| 3441 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3442 | { |
| 3443 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3444 | struct hda_input_mux *imux = &spec->private_imux; |
| 3445 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3446 | int i, j, k; |
| 3447 | |
| 3448 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3449 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3450 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3451 | if (!cfg->input_pins[i]) |
| 3452 | continue; |
| 3453 | index = -1; |
| 3454 | for (j = 0; j < spec->num_muxes; j++) { |
| 3455 | int num_cons; |
| 3456 | num_cons = snd_hda_get_connections(codec, |
| 3457 | spec->mux_nids[j], |
| 3458 | con_lst, |
| 3459 | HDA_MAX_NUM_INPUTS); |
| 3460 | for (k = 0; k < num_cons; k++) |
| 3461 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3462 | index = k; |
| 3463 | goto found; |
| 3464 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3465 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3466 | continue; |
| 3467 | found: |
| 3468 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3469 | imux->items[imux->num_items].index = index; |
| 3470 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3471 | } |
| 3472 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3473 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3474 | /* |
| 3475 | * Set the current input for the muxes. |
| 3476 | * The STAC9221 has two input muxes with identical source |
| 3477 | * NID lists. Hopefully this won't get confused. |
| 3478 | */ |
| 3479 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3480 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3481 | AC_VERB_SET_CONNECT_SEL, |
| 3482 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3483 | } |
| 3484 | } |
| 3485 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3486 | return 0; |
| 3487 | } |
| 3488 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3489 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3490 | { |
| 3491 | struct sigmatel_spec *spec = codec->spec; |
| 3492 | int i; |
| 3493 | |
| 3494 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3495 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3496 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3497 | } |
| 3498 | } |
| 3499 | |
| 3500 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3501 | { |
| 3502 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3503 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3504 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3505 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3506 | hda_nid_t pin; |
| 3507 | pin = spec->autocfg.hp_pins[i]; |
| 3508 | if (pin) /* connect to front */ |
| 3509 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3510 | } |
| 3511 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3512 | hda_nid_t pin; |
| 3513 | pin = spec->autocfg.speaker_pins[i]; |
| 3514 | if (pin) /* connect to front */ |
| 3515 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3516 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3517 | } |
| 3518 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3519 | 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] | 3520 | { |
| 3521 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3522 | int hp_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3523 | int err; |
| 3524 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3525 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3526 | &spec->autocfg, |
| 3527 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3528 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3529 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3530 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3531 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3532 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3533 | * be set up as multi-channel outputs. |
| 3534 | */ |
| 3535 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3536 | spec->autocfg.hp_outs > 1) { |
| 3537 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3538 | * speaker_outs so that the following routines can handle |
| 3539 | * HP pins as primary outputs. |
| 3540 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3541 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3542 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3543 | sizeof(spec->autocfg.line_out_pins)); |
| 3544 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3545 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3546 | sizeof(spec->autocfg.hp_pins)); |
| 3547 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3548 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3549 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3550 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3551 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3552 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3553 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3554 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3555 | u32 caps = query_amp_caps(codec, |
| 3556 | spec->autocfg.mono_out_pin, dir); |
| 3557 | hda_nid_t conn_list[1]; |
| 3558 | |
| 3559 | /* get the mixer node and then the mono mux if it exists */ |
| 3560 | if (snd_hda_get_connections(codec, |
| 3561 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3562 | snd_hda_get_connections(codec, conn_list[0], |
| 3563 | conn_list, 1)) { |
| 3564 | |
| 3565 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3566 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3567 | >> AC_WCAP_TYPE_SHIFT; |
| 3568 | /* LR swap check, some stac925x have a mux that |
| 3569 | * changes the DACs output path instead of the |
| 3570 | * mono-mux path. |
| 3571 | */ |
| 3572 | if (wid_type == AC_WID_AUD_SEL && |
| 3573 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3574 | spec->mono_nid = conn_list[0]; |
| 3575 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3576 | if (dir) { |
| 3577 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3578 | |
| 3579 | /* most mono outs have a least a mute/unmute switch */ |
| 3580 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3581 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3582 | "Mono Playback Switch", |
| 3583 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3584 | if (err < 0) |
| 3585 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3586 | /* check for volume support for the amp */ |
| 3587 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3588 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3589 | err = stac92xx_add_control(spec, |
| 3590 | STAC_CTL_WIDGET_VOL, |
| 3591 | "Mono Playback Volume", |
| 3592 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3593 | if (err < 0) |
| 3594 | return err; |
| 3595 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3596 | } |
| 3597 | |
| 3598 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3599 | AC_PINCTL_OUT_EN); |
| 3600 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3601 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3602 | if (!spec->multiout.num_dacs) { |
| 3603 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3604 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3605 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3606 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3607 | &spec->autocfg); |
| 3608 | if (err < 0) |
| 3609 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3610 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3611 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3612 | /* setup analog beep controls */ |
| 3613 | if (spec->anabeep_nid > 0) { |
| 3614 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3615 | spec->anabeep_nid); |
| 3616 | if (err < 0) |
| 3617 | return err; |
| 3618 | } |
| 3619 | |
| 3620 | /* setup digital beep controls and input device */ |
| 3621 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3622 | if (spec->digbeep_nid > 0) { |
| 3623 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3624 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3625 | |
| 3626 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3627 | if (err < 0) |
| 3628 | return err; |
| 3629 | err = snd_hda_attach_beep_device(codec, nid); |
| 3630 | if (err < 0) |
| 3631 | return err; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3632 | /* if no beep switch is available, make its own one */ |
| 3633 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3634 | if (codec->beep && |
| 3635 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3636 | err = stac92xx_beep_switch_ctl(codec); |
| 3637 | if (err < 0) |
| 3638 | return err; |
| 3639 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3640 | } |
| 3641 | #endif |
| 3642 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3643 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3644 | if (err < 0) |
| 3645 | return err; |
| 3646 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3647 | /* All output parsing done, now restore the swapped hp pins */ |
| 3648 | if (hp_swap) { |
| 3649 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3650 | sizeof(spec->autocfg.hp_pins)); |
| 3651 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3652 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3653 | spec->autocfg.line_outs = 0; |
| 3654 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3655 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3656 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3657 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3658 | return err; |
| 3659 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3660 | if (spec->mono_nid > 0) { |
| 3661 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3662 | if (err < 0) |
| 3663 | return err; |
| 3664 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3665 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3666 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3667 | if (err < 0) |
| 3668 | return err; |
| 3669 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3670 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3671 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3672 | &spec->autocfg)) < 0) |
| 3673 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3674 | if (spec->num_muxes > 0) { |
| 3675 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3676 | if (err < 0) |
| 3677 | return err; |
| 3678 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3679 | if (spec->num_smuxes > 0) { |
| 3680 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3681 | if (err < 0) |
| 3682 | return err; |
| 3683 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3684 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3685 | err = stac92xx_add_input_source(spec); |
| 3686 | if (err < 0) |
| 3687 | return err; |
| 3688 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3689 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3690 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3691 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3692 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3693 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3694 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3695 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3696 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3697 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3698 | if (spec->kctls.list) |
| 3699 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3700 | |
| 3701 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3702 | if (!spec->dinput_mux) |
| 3703 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3704 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3705 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3706 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3707 | return 1; |
| 3708 | } |
| 3709 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3710 | /* add playback controls for HP output */ |
| 3711 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3712 | struct auto_pin_cfg *cfg) |
| 3713 | { |
| 3714 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3715 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3716 | unsigned int wid_caps; |
| 3717 | |
| 3718 | if (! pin) |
| 3719 | return 0; |
| 3720 | |
| 3721 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3722 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3723 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3724 | |
| 3725 | return 0; |
| 3726 | } |
| 3727 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3728 | /* add playback controls for LFE output */ |
| 3729 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3730 | struct auto_pin_cfg *cfg) |
| 3731 | { |
| 3732 | struct sigmatel_spec *spec = codec->spec; |
| 3733 | int err; |
| 3734 | hda_nid_t lfe_pin = 0x0; |
| 3735 | int i; |
| 3736 | |
| 3737 | /* |
| 3738 | * search speaker outs and line outs for a mono speaker pin |
| 3739 | * with an amp. If one is found, add LFE controls |
| 3740 | * for it. |
| 3741 | */ |
| 3742 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3743 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3744 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3745 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3746 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3747 | /* found a mono speaker with an amp, must be lfe */ |
| 3748 | lfe_pin = pin; |
| 3749 | } |
| 3750 | |
| 3751 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3752 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3753 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3754 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3755 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3756 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3757 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3758 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3759 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3760 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3761 | /* found a mono speaker with an amp, |
| 3762 | must be lfe */ |
| 3763 | lfe_pin = pin; |
| 3764 | } |
| 3765 | } |
| 3766 | } |
| 3767 | |
| 3768 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3769 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3770 | if (err < 0) |
| 3771 | return err; |
| 3772 | } |
| 3773 | |
| 3774 | return 0; |
| 3775 | } |
| 3776 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3777 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3778 | { |
| 3779 | struct sigmatel_spec *spec = codec->spec; |
| 3780 | int err; |
| 3781 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3782 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3783 | return err; |
| 3784 | |
| 3785 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3786 | return err; |
| 3787 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3788 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3789 | return err; |
| 3790 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3791 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3792 | return err; |
| 3793 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3794 | if (spec->num_muxes > 0) { |
| 3795 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3796 | if (err < 0) |
| 3797 | return err; |
| 3798 | } |
| 3799 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3800 | err = stac92xx_add_input_source(spec); |
| 3801 | if (err < 0) |
| 3802 | return err; |
| 3803 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3804 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3805 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3806 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3807 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3808 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3809 | if (spec->kctls.list) |
| 3810 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3811 | |
| 3812 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3813 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3814 | |
| 3815 | return 1; |
| 3816 | } |
| 3817 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3818 | /* |
| 3819 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 3820 | * funky external mute control using GPIO pins. |
| 3821 | */ |
| 3822 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3823 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3824 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3825 | { |
| 3826 | unsigned int gpiostate, gpiomask, gpiodir; |
| 3827 | |
| 3828 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 3829 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3830 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3831 | |
| 3832 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 3833 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3834 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3835 | |
| 3836 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 3837 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3838 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3839 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3840 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3841 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 3842 | |
| 3843 | snd_hda_codec_write(codec, codec->afg, 0, |
| 3844 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3845 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3846 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3847 | |
| 3848 | msleep(1); |
| 3849 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3850 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3851 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3852 | } |
| 3853 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3854 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 3855 | hda_nid_t nid, int type) |
| 3856 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3857 | #ifdef CONFIG_SND_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3858 | struct sigmatel_spec *spec = codec->spec; |
| 3859 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3860 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3861 | int connectivity = get_defcfg_connect(def_conf); |
| 3862 | char name[32]; |
| 3863 | |
| 3864 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 3865 | return 0; |
| 3866 | |
| 3867 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 3868 | jack = snd_array_new(&spec->jacks); |
| 3869 | if (!jack) |
| 3870 | return -ENOMEM; |
| 3871 | jack->nid = nid; |
| 3872 | jack->type = type; |
| 3873 | |
| 3874 | sprintf(name, "%s at %s %s Jack", |
| 3875 | snd_hda_get_jack_type(def_conf), |
| 3876 | snd_hda_get_jack_connectivity(def_conf), |
| 3877 | snd_hda_get_jack_location(def_conf)); |
| 3878 | |
| 3879 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3880 | #else |
| 3881 | return 0; |
| 3882 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3883 | } |
| 3884 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3885 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 3886 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3887 | { |
| 3888 | struct sigmatel_event *event; |
| 3889 | |
| 3890 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 3891 | event = snd_array_new(&spec->events); |
| 3892 | if (!event) |
| 3893 | return -ENOMEM; |
| 3894 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3895 | event->type = type; |
| 3896 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3897 | event->data = data; |
| 3898 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3899 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3900 | } |
| 3901 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3902 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
| 3903 | hda_nid_t nid, unsigned char type) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3904 | { |
| 3905 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3906 | struct sigmatel_event *event = spec->events.list; |
| 3907 | int i; |
| 3908 | |
| 3909 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3910 | if (event->nid == nid && event->type == type) |
| 3911 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3912 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3913 | return NULL; |
| 3914 | } |
| 3915 | |
| 3916 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 3917 | unsigned char tag) |
| 3918 | { |
| 3919 | struct sigmatel_spec *spec = codec->spec; |
| 3920 | struct sigmatel_event *event = spec->events.list; |
| 3921 | int i; |
| 3922 | |
| 3923 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3924 | if (event->tag == tag) |
| 3925 | return event; |
| 3926 | } |
| 3927 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3928 | } |
| 3929 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3930 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3931 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3932 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3933 | struct sigmatel_event *event; |
| 3934 | int tag; |
| 3935 | |
| 3936 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
| 3937 | return; |
| 3938 | event = stac_get_event(codec, nid, type); |
| 3939 | if (event) |
| 3940 | tag = event->tag; |
| 3941 | else |
| 3942 | tag = stac_add_event(codec->spec, nid, type, 0); |
| 3943 | if (tag < 0) |
| 3944 | return; |
| 3945 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3946 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3947 | AC_USRSP_EN | tag); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3948 | } |
| 3949 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3950 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3951 | { |
| 3952 | int i; |
| 3953 | for (i = 0; i < cfg->hp_outs; i++) |
| 3954 | if (cfg->hp_pins[i] == nid) |
| 3955 | return 1; /* nid is a HP-Out */ |
| 3956 | |
| 3957 | return 0; /* nid is not a HP-Out */ |
| 3958 | }; |
| 3959 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3960 | static void stac92xx_power_down(struct hda_codec *codec) |
| 3961 | { |
| 3962 | struct sigmatel_spec *spec = codec->spec; |
| 3963 | |
| 3964 | /* power down inactive DACs */ |
| 3965 | hda_nid_t *dac; |
| 3966 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3967 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3968 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3969 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3970 | } |
| 3971 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3972 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 3973 | int enable); |
| 3974 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 3975 | /* override some hints from the hwdep entry */ |
| 3976 | static void stac_store_hints(struct hda_codec *codec) |
| 3977 | { |
| 3978 | struct sigmatel_spec *spec = codec->spec; |
| 3979 | const char *p; |
| 3980 | int val; |
| 3981 | |
| 3982 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 3983 | if (val >= 0) |
| 3984 | spec->hp_detect = val; |
| 3985 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 3986 | if (p) { |
| 3987 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 3988 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 3989 | spec->gpio_mask; |
| 3990 | } |
| 3991 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 3992 | if (p) |
| 3993 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 3994 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 3995 | if (p) |
| 3996 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 3997 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 3998 | if (p) |
| 3999 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4000 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 4001 | if (val >= 0) |
| 4002 | spec->eapd_switch = val; |
| 4003 | } |
| 4004 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4005 | static int stac92xx_init(struct hda_codec *codec) |
| 4006 | { |
| 4007 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4008 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4009 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4010 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4011 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4012 | snd_hda_sequence_write(codec, spec->init); |
| 4013 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4014 | /* power down adcs initially */ |
| 4015 | if (spec->powerdown_adcs) |
| 4016 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4017 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4018 | spec->adc_nids[i], 0, |
| 4019 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4020 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4021 | /* override some hints */ |
| 4022 | stac_store_hints(codec); |
| 4023 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4024 | /* set up GPIO */ |
| 4025 | gpio = spec->gpio_data; |
| 4026 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4027 | * otherwise, unsol event will turn it on/off dynamically |
| 4028 | */ |
| 4029 | if (!spec->eapd_switch) |
| 4030 | gpio |= spec->eapd_mask; |
| 4031 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4032 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4033 | /* set up pins */ |
| 4034 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4035 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4036 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4037 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4038 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4039 | } |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4040 | /* force to enable the first line-out; the others are set up |
| 4041 | * in unsol_event |
| 4042 | */ |
| 4043 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4044 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4045 | /* fake event to set up pins */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4046 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4047 | STAC_HP_EVENT); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4048 | } else { |
| 4049 | stac92xx_auto_init_multi_out(codec); |
| 4050 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4051 | for (i = 0; i < cfg->hp_outs; i++) |
| 4052 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4053 | } |
| 4054 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4055 | hda_nid_t nid = cfg->input_pins[i]; |
| 4056 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4057 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4058 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4059 | /* for mic pins, force to initialize */ |
| 4060 | pinctl = stac92xx_get_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4061 | pinctl |= AC_PINCTL_IN_EN; |
| 4062 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4063 | } else { |
| 4064 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4065 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4066 | /* if PINCTL already set then skip */ |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4067 | if (!(pinctl & AC_PINCTL_IN_EN)) { |
| 4068 | pinctl |= AC_PINCTL_IN_EN; |
| 4069 | stac92xx_auto_set_pinctl(codec, nid, |
| 4070 | pinctl); |
| 4071 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4072 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4073 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4074 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 4075 | enable_pin_detect(codec, nid, |
| 4076 | STAC_INSERT_EVENT); |
| 4077 | stac_issue_unsol_event(codec, nid, |
| 4078 | STAC_INSERT_EVENT); |
| 4079 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4080 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4081 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4082 | for (i = 0; i < spec->num_dmics; i++) |
| 4083 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4084 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4085 | if (cfg->dig_out_pins[0]) |
| 4086 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4087 | AC_PINCTL_OUT_EN); |
| 4088 | if (cfg->dig_in_pin) |
| 4089 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4090 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4091 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4092 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4093 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4094 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4095 | /* power on when no jack detection is available */ |
| 4096 | if (!spec->hp_detect) { |
| 4097 | stac_toggle_power_map(codec, nid, 1); |
| 4098 | continue; |
| 4099 | } |
| 4100 | |
| 4101 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4102 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4103 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4104 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4105 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4106 | /* outputs are only ports capable of power management |
| 4107 | * any attempts on powering down a input port cause the |
| 4108 | * referenced VREF to act quirky. |
| 4109 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4110 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4111 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4112 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4113 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4114 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4115 | def_conf = get_defcfg_connect(def_conf); |
| 4116 | /* skip any ports that don't have jacks since presence |
| 4117 | * detection is useless */ |
| 4118 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4119 | if (def_conf != AC_JACK_PORT_NONE) |
| 4120 | stac_toggle_power_map(codec, nid, 1); |
| 4121 | continue; |
| 4122 | } |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4123 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
| 4124 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
| 4125 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); |
| 4126 | } |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4127 | } |
| 4128 | if (spec->dac_list) |
| 4129 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4130 | return 0; |
| 4131 | } |
| 4132 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4133 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4134 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4135 | #ifdef CONFIG_SND_JACK |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4136 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4137 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4138 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4139 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4140 | int i; |
| 4141 | for (i = 0; i < spec->jacks.used; i++) |
| 4142 | snd_device_free(codec->bus->card, &jacks[i].jack); |
| 4143 | } |
| 4144 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4145 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4146 | } |
| 4147 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4148 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4149 | { |
| 4150 | struct sigmatel_spec *spec = codec->spec; |
| 4151 | |
| 4152 | if (spec->kctls.list) { |
| 4153 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4154 | int i; |
| 4155 | for (i = 0; i < spec->kctls.used; i++) |
| 4156 | kfree(kctl[i].name); |
| 4157 | } |
| 4158 | snd_array_free(&spec->kctls); |
| 4159 | } |
| 4160 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4161 | static void stac92xx_free(struct hda_codec *codec) |
| 4162 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4163 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4164 | |
| 4165 | if (! spec) |
| 4166 | return; |
| 4167 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4168 | stac92xx_free_jacks(codec); |
| 4169 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4170 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4171 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4172 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4173 | } |
| 4174 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4175 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4176 | unsigned int flag) |
| 4177 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4178 | unsigned int old_ctl, pin_ctl; |
| 4179 | |
| 4180 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4181 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4182 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4183 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4184 | /* |
| 4185 | * we need to check the current set-up direction of |
| 4186 | * shared input pins since they can be switched via |
| 4187 | * "xxx as Output" mixer switch |
| 4188 | */ |
| 4189 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4190 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4191 | return; |
| 4192 | } |
| 4193 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4194 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4195 | /* if setting pin direction bits, clear the current |
| 4196 | direction bits first */ |
| 4197 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4198 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4199 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4200 | pin_ctl |= flag; |
| 4201 | if (old_ctl != pin_ctl) |
| 4202 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4203 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4204 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4205 | } |
| 4206 | |
| 4207 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4208 | unsigned int flag) |
| 4209 | { |
| 4210 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4211 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4212 | if (pin_ctl & flag) |
| 4213 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4214 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4215 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4216 | } |
| 4217 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4218 | 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] | 4219 | { |
| 4220 | if (!nid) |
| 4221 | return 0; |
| 4222 | 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] | 4223 | & (1 << 31)) |
| 4224 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4225 | return 0; |
| 4226 | } |
| 4227 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4228 | /* return non-zero if the hp-pin of the given array index isn't |
| 4229 | * a jack-detection target |
| 4230 | */ |
| 4231 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4232 | { |
| 4233 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4234 | |
| 4235 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4236 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4237 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4238 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4239 | return 1; |
| 4240 | /* ignore if the pin is set as line-out */ |
| 4241 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4242 | return 1; |
| 4243 | return 0; |
| 4244 | } |
| 4245 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4246 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4247 | { |
| 4248 | struct sigmatel_spec *spec = codec->spec; |
| 4249 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4250 | int i, presence; |
| 4251 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4252 | presence = 0; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4253 | if (spec->gpio_mute) |
| 4254 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4255 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4256 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4257 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4258 | if (presence) |
| 4259 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4260 | if (no_hp_sensing(spec, i)) |
| 4261 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4262 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4263 | if (presence) { |
| 4264 | unsigned int pinctl; |
| 4265 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4266 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4267 | if (pinctl & AC_PINCTL_IN_EN) |
| 4268 | presence = 0; /* mic- or line-input */ |
| 4269 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4270 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4271 | |
| 4272 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4273 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4274 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4275 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4276 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4277 | for (i = 0; i < cfg->line_outs; i++) |
| 4278 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4279 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4280 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4281 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4282 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4283 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4284 | stac_gpio_set(codec, spec->gpio_mask, |
| 4285 | spec->gpio_dir, spec->gpio_data & |
| 4286 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4287 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4288 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4289 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4290 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4291 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4292 | for (i = 0; i < cfg->line_outs; i++) |
| 4293 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4294 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4295 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4296 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4297 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4298 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4299 | stac_gpio_set(codec, spec->gpio_mask, |
| 4300 | spec->gpio_dir, spec->gpio_data | |
| 4301 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4302 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4303 | /* toggle hp outs */ |
| 4304 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4305 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4306 | if (no_hp_sensing(spec, i)) |
| 4307 | continue; |
| 4308 | if (presence) |
| 4309 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4310 | #if 0 /* FIXME */ |
| 4311 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4312 | * on some devices since they use the HP pin actually for line/speaker |
| 4313 | * outs although the default pin config shows a different pin (that is |
| 4314 | * wrong and useless). |
| 4315 | * |
| 4316 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4317 | * But, disabling the code below just works around it, and I'm too tired of |
| 4318 | * bug reports with such devices... |
| 4319 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4320 | else |
| 4321 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4322 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4323 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4324 | } |
| 4325 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4326 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4327 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4328 | { |
| 4329 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4330 | unsigned int idx, val; |
| 4331 | |
| 4332 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4333 | if (spec->pwr_nids[idx] == nid) |
| 4334 | break; |
| 4335 | } |
| 4336 | if (idx >= spec->num_pwrs) |
| 4337 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4338 | |
| 4339 | /* several codecs have two power down bits */ |
| 4340 | if (spec->pwr_mapping) |
| 4341 | idx = spec->pwr_mapping[idx]; |
| 4342 | else |
| 4343 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4344 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4345 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4346 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4347 | val &= ~idx; |
| 4348 | else |
| 4349 | val |= idx; |
| 4350 | |
| 4351 | /* power down unused output ports */ |
| 4352 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4353 | } |
| 4354 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4355 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4356 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4357 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4358 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4359 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4360 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4361 | { |
| 4362 | struct sigmatel_spec *spec = codec->spec; |
| 4363 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4364 | |
| 4365 | if (jacks) { |
| 4366 | int i; |
| 4367 | for (i = 0; i < spec->jacks.used; i++) { |
| 4368 | if (jacks->nid == nid) { |
| 4369 | unsigned int pin_ctl = |
| 4370 | snd_hda_codec_read(codec, nid, |
| 4371 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4372 | 0x00); |
| 4373 | int type = jacks->type; |
| 4374 | if (type == (SND_JACK_LINEOUT |
| 4375 | | SND_JACK_HEADPHONE)) |
| 4376 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4377 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4378 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4379 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4380 | ? type : 0); |
| 4381 | } |
| 4382 | jacks++; |
| 4383 | } |
| 4384 | } |
| 4385 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4386 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4387 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 4388 | unsigned char type) |
| 4389 | { |
| 4390 | struct sigmatel_event *event = stac_get_event(codec, nid, type); |
| 4391 | if (!event) |
| 4392 | return; |
| 4393 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4394 | } |
| 4395 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4396 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4397 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4398 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4399 | struct sigmatel_event *event; |
| 4400 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4401 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4402 | tag = (res >> 26) & 0x7f; |
| 4403 | event = stac_get_event_from_tag(codec, tag); |
| 4404 | if (!event) |
| 4405 | return; |
| 4406 | |
| 4407 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4408 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4409 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4410 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4411 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4412 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4413 | if (spec->num_pwrs > 0) |
| 4414 | stac92xx_pin_sense(codec, event->nid); |
| 4415 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4416 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4417 | case STAC_VREF_EVENT: |
| 4418 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4419 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4420 | /* toggle VREF state based on GPIOx status */ |
| 4421 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4422 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4423 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4424 | } |
| 4425 | } |
| 4426 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4427 | #ifdef CONFIG_PROC_FS |
| 4428 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4429 | struct hda_codec *codec, hda_nid_t nid) |
| 4430 | { |
| 4431 | if (nid == codec->afg) |
| 4432 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4433 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4434 | } |
| 4435 | |
| 4436 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4437 | struct hda_codec *codec, |
| 4438 | unsigned int verb) |
| 4439 | { |
| 4440 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4441 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4442 | } |
| 4443 | |
| 4444 | /* stac92hd71bxx, stac92hd73xx */ |
| 4445 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4446 | struct hda_codec *codec, hda_nid_t nid) |
| 4447 | { |
| 4448 | stac92hd_proc_hook(buffer, codec, nid); |
| 4449 | if (nid == codec->afg) |
| 4450 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4451 | } |
| 4452 | |
| 4453 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4454 | struct hda_codec *codec, hda_nid_t nid) |
| 4455 | { |
| 4456 | if (nid == codec->afg) |
| 4457 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4458 | } |
| 4459 | |
| 4460 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4461 | struct hda_codec *codec, hda_nid_t nid) |
| 4462 | { |
| 4463 | if (nid == codec->afg) |
| 4464 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4465 | } |
| 4466 | #else |
| 4467 | #define stac92hd_proc_hook NULL |
| 4468 | #define stac92hd7x_proc_hook NULL |
| 4469 | #define stac9205_proc_hook NULL |
| 4470 | #define stac927x_proc_hook NULL |
| 4471 | #endif |
| 4472 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4473 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4474 | static int stac92xx_resume(struct hda_codec *codec) |
| 4475 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4476 | struct sigmatel_spec *spec = codec->spec; |
| 4477 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4478 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4479 | snd_hda_codec_resume_amp(codec); |
| 4480 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4481 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4482 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4483 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4484 | STAC_HP_EVENT); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4485 | return 0; |
| 4486 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4487 | |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4488 | |
| 4489 | /* |
| 4490 | * using power check for controlling mute led of HP HDX notebooks |
| 4491 | * check for mute state only on Speakers (nid = 0x10) |
| 4492 | * |
| 4493 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
| 4494 | * the LED is NOT working properly ! |
| 4495 | */ |
| 4496 | |
| 4497 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4498 | static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec, |
| 4499 | hda_nid_t nid) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4500 | { |
| 4501 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4502 | |
| 4503 | if (nid == 0x10) { |
| 4504 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4505 | HDA_AMP_MUTE) |
| 4506 | spec->gpio_data &= ~0x08; /* orange */ |
| 4507 | else |
| 4508 | spec->gpio_data |= 0x08; /* white */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4509 | |
| 4510 | stac_gpio_set(codec, spec->gpio_mask, |
| 4511 | spec->gpio_dir, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4512 | spec->gpio_data); |
| 4513 | } |
| 4514 | |
| 4515 | return 0; |
| 4516 | } |
| 4517 | #endif |
| 4518 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4519 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4520 | { |
| 4521 | struct sigmatel_spec *spec = codec->spec; |
| 4522 | if (spec->eapd_mask) |
| 4523 | stac_gpio_set(codec, spec->gpio_mask, |
| 4524 | spec->gpio_dir, spec->gpio_data & |
| 4525 | ~spec->eapd_mask); |
| 4526 | return 0; |
| 4527 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4528 | #endif |
| 4529 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4530 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4531 | .build_controls = stac92xx_build_controls, |
| 4532 | .build_pcms = stac92xx_build_pcms, |
| 4533 | .init = stac92xx_init, |
| 4534 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4535 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4536 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4537 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4538 | .resume = stac92xx_resume, |
| 4539 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4540 | }; |
| 4541 | |
| 4542 | static int patch_stac9200(struct hda_codec *codec) |
| 4543 | { |
| 4544 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4545 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4546 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4547 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4548 | if (spec == NULL) |
| 4549 | return -ENOMEM; |
| 4550 | |
| 4551 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4552 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4553 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4554 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4555 | stac9200_models, |
| 4556 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4557 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4558 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4559 | else |
| 4560 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4561 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4562 | |
| 4563 | spec->multiout.max_channels = 2; |
| 4564 | spec->multiout.num_dacs = 1; |
| 4565 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4566 | spec->adc_nids = stac9200_adc_nids; |
| 4567 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4568 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4569 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4570 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4571 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4572 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4573 | if (spec->board_config == STAC_9200_M4 || |
| 4574 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4575 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4576 | spec->init = stac9200_eapd_init; |
| 4577 | else |
| 4578 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4579 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4580 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4581 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4582 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4583 | spec->gpio_data = 0x00; |
| 4584 | } |
| 4585 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4586 | err = stac9200_parse_auto_config(codec); |
| 4587 | if (err < 0) { |
| 4588 | stac92xx_free(codec); |
| 4589 | return err; |
| 4590 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4591 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4592 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 4593 | * do detection and HP/speaker toggle because the hardware does it. |
| 4594 | */ |
| 4595 | if (spec->board_config == STAC_9200_PANASONIC) |
| 4596 | spec->hp_detect = 0; |
| 4597 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4598 | codec->patch_ops = stac92xx_patch_ops; |
| 4599 | |
| 4600 | return 0; |
| 4601 | } |
| 4602 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4603 | static int patch_stac925x(struct hda_codec *codec) |
| 4604 | { |
| 4605 | struct sigmatel_spec *spec; |
| 4606 | int err; |
| 4607 | |
| 4608 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4609 | if (spec == NULL) |
| 4610 | return -ENOMEM; |
| 4611 | |
| 4612 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4613 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4614 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4615 | |
| 4616 | /* Check first for codec ID */ |
| 4617 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4618 | STAC_925x_MODELS, |
| 4619 | stac925x_models, |
| 4620 | stac925x_codec_id_cfg_tbl); |
| 4621 | |
| 4622 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4623 | if (spec->board_config < 0) |
| 4624 | spec->board_config = snd_hda_check_board_config(codec, |
| 4625 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4626 | stac925x_models, |
| 4627 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4628 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4629 | if (spec->board_config < 0) |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4630 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4631 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4632 | else |
| 4633 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4634 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4635 | |
| 4636 | spec->multiout.max_channels = 2; |
| 4637 | spec->multiout.num_dacs = 1; |
| 4638 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4639 | spec->adc_nids = stac925x_adc_nids; |
| 4640 | spec->mux_nids = stac925x_mux_nids; |
| 4641 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4642 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4643 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4644 | switch (codec->vendor_id) { |
| 4645 | case 0x83847632: /* STAC9202 */ |
| 4646 | case 0x83847633: /* STAC9202D */ |
| 4647 | case 0x83847636: /* STAC9251 */ |
| 4648 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4649 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4650 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4651 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4652 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4653 | break; |
| 4654 | default: |
| 4655 | spec->num_dmics = 0; |
| 4656 | break; |
| 4657 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4658 | |
| 4659 | spec->init = stac925x_core_init; |
| 4660 | spec->mixer = stac925x_mixer; |
| 4661 | |
| 4662 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4663 | if (!err) { |
| 4664 | if (spec->board_config < 0) { |
| 4665 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4666 | "available, default to model=ref\n"); |
| 4667 | spec->board_config = STAC_925x_REF; |
| 4668 | goto again; |
| 4669 | } |
| 4670 | err = -EINVAL; |
| 4671 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4672 | if (err < 0) { |
| 4673 | stac92xx_free(codec); |
| 4674 | return err; |
| 4675 | } |
| 4676 | |
| 4677 | codec->patch_ops = stac92xx_patch_ops; |
| 4678 | |
| 4679 | return 0; |
| 4680 | } |
| 4681 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4682 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4683 | .num_items = 4, |
| 4684 | .items = { |
| 4685 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4686 | { "Digital Mic 1", 0x09 }, |
| 4687 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4688 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4689 | } |
| 4690 | }; |
| 4691 | |
| 4692 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4693 | { |
| 4694 | struct sigmatel_spec *spec; |
| 4695 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4696 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4697 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4698 | |
| 4699 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4700 | if (spec == NULL) |
| 4701 | return -ENOMEM; |
| 4702 | |
| 4703 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4704 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4705 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4706 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4707 | spec->board_config = snd_hda_check_board_config(codec, |
| 4708 | STAC_92HD73XX_MODELS, |
| 4709 | stac92hd73xx_models, |
| 4710 | stac92hd73xx_cfg_tbl); |
| 4711 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4712 | if (spec->board_config < 0) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4713 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4714 | " STAC92HD73XX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4715 | else |
| 4716 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4717 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4718 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4719 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4720 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4721 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4722 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4723 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4724 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4725 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4726 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4727 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4728 | case 0x3: /* 6 Channel */ |
| 4729 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4730 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4731 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4732 | break; |
| 4733 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4734 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4735 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4736 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4737 | break; |
| 4738 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4739 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4740 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4741 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 4742 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4743 | } |
| 4744 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4745 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4746 | spec->aloopback_mask = 0x01; |
| 4747 | spec->aloopback_shift = 8; |
| 4748 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4749 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4750 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4751 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4752 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4753 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4754 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4755 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4756 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4757 | |
| 4758 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4759 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4760 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4761 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 4762 | sizeof(stac92hd73xx_dmux)); |
| 4763 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4764 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4765 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4766 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4767 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4768 | case STAC_DELL_M6_AMIC: |
| 4769 | case STAC_DELL_M6_DMIC: |
| 4770 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4771 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4772 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 4773 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4774 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4775 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4776 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4777 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4778 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4779 | switch (spec->board_config) { |
| 4780 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4781 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4782 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4783 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4784 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4785 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4786 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4787 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4788 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4789 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4790 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4791 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 4792 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4793 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4794 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4795 | break; |
| 4796 | } |
| 4797 | break; |
| 4798 | default: |
| 4799 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4800 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4801 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4802 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4803 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 4804 | /* GPIO0 High = Enable EAPD */ |
| 4805 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 4806 | spec->gpio_data = 0x01; |
| 4807 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4808 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4809 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4810 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 4811 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 4812 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4813 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4814 | |
| 4815 | if (!err) { |
| 4816 | if (spec->board_config < 0) { |
| 4817 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4818 | "available, default to model=ref\n"); |
| 4819 | spec->board_config = STAC_92HD73XX_REF; |
| 4820 | goto again; |
| 4821 | } |
| 4822 | err = -EINVAL; |
| 4823 | } |
| 4824 | |
| 4825 | if (err < 0) { |
| 4826 | stac92xx_free(codec); |
| 4827 | return err; |
| 4828 | } |
| 4829 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 4830 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 4831 | spec->hp_detect = 0; |
| 4832 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4833 | codec->patch_ops = stac92xx_patch_ops; |
| 4834 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4835 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 4836 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4837 | return 0; |
| 4838 | } |
| 4839 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4840 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 4841 | .num_items = 3, |
| 4842 | .items = { |
| 4843 | { "Analog Inputs", 0x03 }, |
| 4844 | { "Digital Mic 1", 0x04 }, |
| 4845 | { "Digital Mic 2", 0x05 }, |
| 4846 | } |
| 4847 | }; |
| 4848 | |
| 4849 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 4850 | { |
| 4851 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 4852 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4853 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 4854 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 4855 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4856 | |
| 4857 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4858 | if (spec == NULL) |
| 4859 | return -ENOMEM; |
| 4860 | |
| 4861 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4862 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4863 | spec->mono_nid = 0x19; |
| 4864 | spec->digbeep_nid = 0x21; |
| 4865 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 4866 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 4867 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 4868 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 4869 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4870 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 4871 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4872 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4873 | |
| 4874 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4875 | spec->mixer = stac92hd83xxx_mixer; |
| 4876 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 4877 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 4878 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 4879 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4880 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 4881 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 4882 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 4883 | spec->board_config = snd_hda_check_board_config(codec, |
| 4884 | STAC_92HD83XXX_MODELS, |
| 4885 | stac92hd83xxx_models, |
| 4886 | stac92hd83xxx_cfg_tbl); |
| 4887 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4888 | if (spec->board_config < 0) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4889 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4890 | " STAC92HD83XXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4891 | else |
| 4892 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4893 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4894 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 4895 | switch (codec->vendor_id) { |
| 4896 | case 0x111d7604: |
| 4897 | case 0x111d7605: |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame^] | 4898 | case 0x111d76d5: |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 4899 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 4900 | break; |
| 4901 | spec->num_pwrs = 0; |
| 4902 | break; |
| 4903 | } |
| 4904 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4905 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 4906 | if (!err) { |
| 4907 | if (spec->board_config < 0) { |
| 4908 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4909 | "available, default to model=ref\n"); |
| 4910 | spec->board_config = STAC_92HD83XXX_REF; |
| 4911 | goto again; |
| 4912 | } |
| 4913 | err = -EINVAL; |
| 4914 | } |
| 4915 | |
| 4916 | if (err < 0) { |
| 4917 | stac92xx_free(codec); |
| 4918 | return err; |
| 4919 | } |
| 4920 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 4921 | switch (spec->board_config) { |
| 4922 | case STAC_DELL_S14: |
| 4923 | nid = 0xf; |
| 4924 | break; |
| 4925 | default: |
| 4926 | nid = 0xe; |
| 4927 | break; |
| 4928 | } |
| 4929 | |
| 4930 | num_dacs = snd_hda_get_connections(codec, nid, |
| 4931 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
| 4932 | |
| 4933 | /* set port X to select the last DAC |
| 4934 | */ |
| 4935 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4936 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 4937 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4938 | codec->patch_ops = stac92xx_patch_ops; |
| 4939 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4940 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 4941 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4942 | return 0; |
| 4943 | } |
| 4944 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4945 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 4946 | .num_items = 3, |
| 4947 | .items = { |
| 4948 | { "Analog Inputs", 0x00 }, |
| 4949 | { "Digital Mic 1", 0x02 }, |
| 4950 | { "Digital Mic 2", 0x03 }, |
| 4951 | } |
| 4952 | }; |
| 4953 | |
| 4954 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4955 | .num_items = 4, |
| 4956 | .items = { |
| 4957 | { "Analog Inputs", 0x00 }, |
| 4958 | { "Mixer", 0x01 }, |
| 4959 | { "Digital Mic 1", 0x02 }, |
| 4960 | { "Digital Mic 2", 0x03 }, |
| 4961 | } |
| 4962 | }; |
| 4963 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4964 | /* get the pin connection (fixed, none, etc) */ |
| 4965 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 4966 | { |
| 4967 | struct sigmatel_spec *spec = codec->spec; |
| 4968 | unsigned int cfg; |
| 4969 | |
| 4970 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 4971 | return get_defcfg_connect(cfg); |
| 4972 | } |
| 4973 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4974 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 4975 | hda_nid_t *nids, int num_nids) |
| 4976 | { |
| 4977 | struct sigmatel_spec *spec = codec->spec; |
| 4978 | int idx, num; |
| 4979 | unsigned int def_conf; |
| 4980 | |
| 4981 | for (num = 0; num < num_nids; num++) { |
| 4982 | for (idx = 0; idx < spec->num_pins; idx++) |
| 4983 | if (spec->pin_nids[idx] == nids[num]) |
| 4984 | break; |
| 4985 | if (idx >= spec->num_pins) |
| 4986 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4987 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4988 | if (def_conf == AC_JACK_PORT_NONE) |
| 4989 | break; |
| 4990 | } |
| 4991 | return num; |
| 4992 | } |
| 4993 | |
| 4994 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 4995 | hda_nid_t dig0pin) |
| 4996 | { |
| 4997 | struct sigmatel_spec *spec = codec->spec; |
| 4998 | int idx; |
| 4999 | |
| 5000 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5001 | if (spec->pin_nids[idx] == dig0pin) |
| 5002 | break; |
| 5003 | if ((idx + 2) >= spec->num_pins) |
| 5004 | return 0; |
| 5005 | |
| 5006 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5007 | 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] | 5008 | return 2; |
| 5009 | |
| 5010 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5011 | 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] | 5012 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5013 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5014 | return 1; |
| 5015 | else |
| 5016 | return 0; |
| 5017 | } |
| 5018 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5019 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 5020 | { |
| 5021 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5022 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5023 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5024 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5025 | |
| 5026 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5027 | if (spec == NULL) |
| 5028 | return -ENOMEM; |
| 5029 | |
| 5030 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5031 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5032 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 5033 | switch (codec->vendor_id) { |
| 5034 | case 0x111d76b6: |
| 5035 | case 0x111d76b7: |
| 5036 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 5037 | break; |
| 5038 | case 0x111d7603: |
| 5039 | case 0x111d7608: |
| 5040 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 5041 | spec->num_pins--; |
| 5042 | /* fallthrough */ |
| 5043 | default: |
| 5044 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 5045 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5046 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5047 | spec->board_config = snd_hda_check_board_config(codec, |
| 5048 | STAC_92HD71BXX_MODELS, |
| 5049 | stac92hd71bxx_models, |
| 5050 | stac92hd71bxx_cfg_tbl); |
| 5051 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5052 | if (spec->board_config < 0) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5053 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5054 | " STAC92HD71BXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5055 | else |
| 5056 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5057 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5058 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5059 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5060 | /* GPIO0 = EAPD */ |
| 5061 | spec->gpio_mask = 0x01; |
| 5062 | spec->gpio_dir = 0x01; |
| 5063 | spec->gpio_data = 0x01; |
| 5064 | } |
| 5065 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5066 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5067 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5068 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5069 | switch (codec->vendor_id) { |
| 5070 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5071 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5072 | unmute_init++; |
| 5073 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5074 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5075 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5076 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 5077 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5078 | spec->mixer = stac92hd71bxx_mixer; |
| 5079 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5080 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5081 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5082 | stac92hd71bxx_dmic_nids, |
| 5083 | STAC92HD71BXX_NUM_DMICS); |
| 5084 | if (spec->num_dmics) { |
| 5085 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5086 | spec->dinput_mux = &spec->private_dimux; |
| 5087 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5088 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5089 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5090 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5091 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5092 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5093 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5094 | switch (spec->board_config) { |
| 5095 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5096 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5097 | err = stac_add_event(spec, codec->afg, |
| 5098 | STAC_VREF_EVENT, 0x02); |
| 5099 | if (err < 0) |
| 5100 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5101 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5102 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5103 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5104 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5105 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5106 | spec->gpio_mask |= 0x02; |
| 5107 | break; |
| 5108 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5109 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5110 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5111 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5112 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5113 | /* no output amps */ |
| 5114 | spec->num_pwrs = 0; |
| 5115 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5116 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5117 | |
| 5118 | /* disable VSW */ |
| 5119 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5120 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5121 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5122 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5123 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5124 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5125 | stac92hd71bxx_dmic_nids, |
| 5126 | STAC92HD71BXX_NUM_DMICS - 1); |
| 5127 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5128 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5129 | break; |
| 5130 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5131 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5132 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5133 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5134 | /* no output amps */ |
| 5135 | spec->num_pwrs = 0; |
| 5136 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5137 | default: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5138 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5139 | sizeof(stac92hd71bxx_dmux_amixer)); |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5140 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5141 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 5142 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5143 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5144 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5145 | stac92hd71bxx_dmic_nids, |
| 5146 | STAC92HD71BXX_NUM_DMICS); |
| 5147 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5148 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5149 | } |
| 5150 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5151 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5152 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5153 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5154 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5155 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5156 | spec->aloopback_shift = 0; |
| 5157 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5158 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5159 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5160 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5161 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5162 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5163 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5164 | |
| 5165 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5166 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5167 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5168 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5169 | switch (spec->board_config) { |
| 5170 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5171 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5172 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5173 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5174 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5175 | /* fallthru */ |
| 5176 | case STAC_DELL_M4_2: |
| 5177 | spec->num_dmics = 0; |
| 5178 | spec->num_smuxes = 0; |
| 5179 | spec->num_dmuxes = 0; |
| 5180 | break; |
| 5181 | case STAC_DELL_M4_1: |
| 5182 | case STAC_DELL_M4_3: |
| 5183 | spec->num_dmics = 1; |
| 5184 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5185 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5186 | break; |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5187 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5188 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5189 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5190 | break; |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5191 | case STAC_HP_HDX: |
| 5192 | spec->num_dmics = 1; |
| 5193 | spec->num_dmuxes = 1; |
| 5194 | spec->num_smuxes = 1; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5195 | /* |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5196 | * For controlling MUTE LED on HP HDX16/HDX18 notebooks, |
| 5197 | * the CONFIG_SND_HDA_POWER_SAVE is needed to be set. |
| 5198 | */ |
| 5199 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5200 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
| 5201 | spec->gpio_mask |= 0x08; |
| 5202 | spec->gpio_dir |= 0x08; |
| 5203 | spec->gpio_data |= 0x08; /* set to white */ |
| 5204 | |
| 5205 | /* register check_power_status callback. */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5206 | codec->patch_ops.check_power_status = |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5207 | stac92xx_hp_hdx_check_power_status; |
| 5208 | #endif |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5209 | break; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5210 | }; |
| 5211 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5212 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5213 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5214 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5215 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5216 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5217 | if (!err) { |
| 5218 | if (spec->board_config < 0) { |
| 5219 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5220 | "available, default to model=ref\n"); |
| 5221 | spec->board_config = STAC_92HD71BXX_REF; |
| 5222 | goto again; |
| 5223 | } |
| 5224 | err = -EINVAL; |
| 5225 | } |
| 5226 | |
| 5227 | if (err < 0) { |
| 5228 | stac92xx_free(codec); |
| 5229 | return err; |
| 5230 | } |
| 5231 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5232 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5233 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5234 | return 0; |
| 5235 | }; |
| 5236 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5237 | static int patch_stac922x(struct hda_codec *codec) |
| 5238 | { |
| 5239 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5240 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5241 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5242 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5243 | if (spec == NULL) |
| 5244 | return -ENOMEM; |
| 5245 | |
| 5246 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5247 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5248 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5249 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5250 | stac922x_models, |
| 5251 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5252 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5253 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5254 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5255 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5256 | * codec SSID to distinguish the exact models |
| 5257 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5258 | 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] | 5259 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5260 | |
| 5261 | case 0x106b0800: |
| 5262 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5263 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5264 | case 0x106b0600: |
| 5265 | case 0x106b0700: |
| 5266 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5267 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5268 | case 0x106b0e00: |
| 5269 | case 0x106b0f00: |
| 5270 | case 0x106b1600: |
| 5271 | case 0x106b1700: |
| 5272 | case 0x106b0200: |
| 5273 | case 0x106b1e00: |
| 5274 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5275 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5276 | case 0x106b1a00: |
| 5277 | case 0x00000100: |
| 5278 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5279 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5280 | case 0x106b0a00: |
| 5281 | case 0x106b2200: |
| 5282 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5283 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5284 | default: |
| 5285 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5286 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5287 | } |
| 5288 | } |
| 5289 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5290 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5291 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5292 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 5293 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5294 | else |
| 5295 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5296 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5297 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5298 | spec->adc_nids = stac922x_adc_nids; |
| 5299 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5300 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5301 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5302 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5303 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5304 | |
| 5305 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5306 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5307 | |
| 5308 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5309 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5310 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5311 | if (!err) { |
| 5312 | if (spec->board_config < 0) { |
| 5313 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5314 | "available, default to model=ref\n"); |
| 5315 | spec->board_config = STAC_D945_REF; |
| 5316 | goto again; |
| 5317 | } |
| 5318 | err = -EINVAL; |
| 5319 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5320 | if (err < 0) { |
| 5321 | stac92xx_free(codec); |
| 5322 | return err; |
| 5323 | } |
| 5324 | |
| 5325 | codec->patch_ops = stac92xx_patch_ops; |
| 5326 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5327 | /* Fix Mux capture level; max to 2 */ |
| 5328 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5329 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5330 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5331 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5332 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5333 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5334 | return 0; |
| 5335 | } |
| 5336 | |
| 5337 | static int patch_stac927x(struct hda_codec *codec) |
| 5338 | { |
| 5339 | struct sigmatel_spec *spec; |
| 5340 | int err; |
| 5341 | |
| 5342 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5343 | if (spec == NULL) |
| 5344 | return -ENOMEM; |
| 5345 | |
| 5346 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5347 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5348 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5349 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5350 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5351 | stac927x_models, |
| 5352 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5353 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5354 | if (spec->board_config < 0) |
Herton Ronaldo Krzesinski | c98041f | 2009-02-11 20:33:15 -0200 | [diff] [blame] | 5355 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5356 | "STAC927x, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5357 | else |
| 5358 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5359 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5360 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5361 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5362 | spec->adc_nids = stac927x_adc_nids; |
| 5363 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5364 | spec->mux_nids = stac927x_mux_nids; |
| 5365 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5366 | spec->smux_nids = stac927x_smux_nids; |
| 5367 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5368 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5369 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5370 | spec->multiout.dac_nids = spec->dac_nids; |
| 5371 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5372 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5373 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5374 | case STAC_D965_5ST: |
| 5375 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5376 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5377 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5378 | spec->num_dmics = 0; |
| 5379 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5380 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5381 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5382 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5383 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5384 | switch (codec->subsystem_id) { |
| 5385 | case 0x10280209: |
| 5386 | case 0x1028022e: |
| 5387 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5388 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5389 | break; |
| 5390 | }; |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5391 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5392 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5393 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5394 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5395 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5396 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5397 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5398 | case STAC_DELL_3ST: |
| 5399 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5400 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5401 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5402 | spec->dmic_nids = stac927x_dmic_nids; |
| 5403 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5404 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5405 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5406 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5407 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5408 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5409 | break; |
| 5410 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5411 | if (spec->board_config > STAC_D965_REF) { |
| 5412 | /* GPIO0 High = Enable EAPD */ |
| 5413 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5414 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5415 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5416 | spec->num_dmics = 0; |
| 5417 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5418 | spec->init = stac927x_core_init; |
| 5419 | spec->mixer = stac927x_mixer; |
| 5420 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5421 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5422 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5423 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5424 | spec->aloopback_mask = 0x40; |
| 5425 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5426 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5427 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5428 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5429 | if (!err) { |
| 5430 | if (spec->board_config < 0) { |
| 5431 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5432 | "available, default to model=ref\n"); |
| 5433 | spec->board_config = STAC_D965_REF; |
| 5434 | goto again; |
| 5435 | } |
| 5436 | err = -EINVAL; |
| 5437 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5438 | if (err < 0) { |
| 5439 | stac92xx_free(codec); |
| 5440 | return err; |
| 5441 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5442 | |
| 5443 | codec->patch_ops = stac92xx_patch_ops; |
| 5444 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5445 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5446 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5447 | /* |
| 5448 | * !!FIXME!! |
| 5449 | * The STAC927x seem to require fairly long delays for certain |
| 5450 | * command sequences. With too short delays (even if the answer |
| 5451 | * is set to RIRB properly), it results in the silence output |
| 5452 | * on some hardwares like Dell. |
| 5453 | * |
| 5454 | * The below flag enables the longer delay (see get_response |
| 5455 | * in hda_intel.c). |
| 5456 | */ |
| 5457 | codec->bus->needs_damn_long_delay = 1; |
| 5458 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5459 | /* no jack detecion for ref-no-jd model */ |
| 5460 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5461 | spec->hp_detect = 0; |
| 5462 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5463 | return 0; |
| 5464 | } |
| 5465 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5466 | static int patch_stac9205(struct hda_codec *codec) |
| 5467 | { |
| 5468 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5469 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5470 | |
| 5471 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5472 | if (spec == NULL) |
| 5473 | return -ENOMEM; |
| 5474 | |
| 5475 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5476 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5477 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5478 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5479 | stac9205_models, |
| 5480 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5481 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5482 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5483 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5484 | else |
| 5485 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5486 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5487 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5488 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5489 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5490 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5491 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5492 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5493 | spec->smux_nids = stac9205_smux_nids; |
| 5494 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5495 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5496 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5497 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5498 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5499 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5500 | |
| 5501 | spec->init = stac9205_core_init; |
| 5502 | spec->mixer = stac9205_mixer; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5503 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5504 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5505 | spec->aloopback_mask = 0x40; |
| 5506 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5507 | /* Turn on/off EAPD per HP plugging */ |
| 5508 | if (spec->board_config != STAC_9205_EAPD) |
| 5509 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5510 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5511 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5512 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5513 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5514 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5515 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5516 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5517 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5518 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5519 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5520 | if (err < 0) |
| 5521 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5522 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5523 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5524 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5525 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5526 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5527 | |
| 5528 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5529 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5530 | spec->gpio_mask = 0x1b; |
| 5531 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5532 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5533 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5534 | */ |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5535 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5536 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5537 | case STAC_9205_REF: |
| 5538 | /* SPDIF-In enabled */ |
| 5539 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5540 | default: |
| 5541 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5542 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5543 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5544 | break; |
| 5545 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5546 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5547 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5548 | if (!err) { |
| 5549 | if (spec->board_config < 0) { |
| 5550 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5551 | "available, default to model=ref\n"); |
| 5552 | spec->board_config = STAC_9205_REF; |
| 5553 | goto again; |
| 5554 | } |
| 5555 | err = -EINVAL; |
| 5556 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5557 | if (err < 0) { |
| 5558 | stac92xx_free(codec); |
| 5559 | return err; |
| 5560 | } |
| 5561 | |
| 5562 | codec->patch_ops = stac92xx_patch_ops; |
| 5563 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5564 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5565 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5566 | return 0; |
| 5567 | } |
| 5568 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5569 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5570 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5571 | */ |
| 5572 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5573 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5574 | {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] | 5575 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5576 | {} |
| 5577 | }; |
| 5578 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5579 | static struct snd_kcontrol_new stac9872_mixer[] = { |
| 5580 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5581 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5582 | { } /* end */ |
| 5583 | }; |
| 5584 | |
| 5585 | static hda_nid_t stac9872_pin_nids[] = { |
| 5586 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 5587 | 0x11, 0x13, 0x14, |
| 5588 | }; |
| 5589 | |
| 5590 | static hda_nid_t stac9872_adc_nids[] = { |
| 5591 | 0x8 /*,0x6*/ |
| 5592 | }; |
| 5593 | |
| 5594 | static hda_nid_t stac9872_mux_nids[] = { |
| 5595 | 0x15 |
| 5596 | }; |
| 5597 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5598 | static unsigned int stac9872_vaio_pin_configs[9] = { |
| 5599 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
| 5600 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
| 5601 | 0x90a7013e |
| 5602 | }; |
| 5603 | |
| 5604 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 5605 | [STAC_9872_AUTO] = "auto", |
| 5606 | [STAC_9872_VAIO] = "vaio", |
| 5607 | }; |
| 5608 | |
| 5609 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { |
| 5610 | [STAC_9872_VAIO] = stac9872_vaio_pin_configs, |
| 5611 | }; |
| 5612 | |
| 5613 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 5614 | {} /* terminator */ |
| 5615 | }; |
| 5616 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5617 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5618 | { |
| 5619 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5620 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5621 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5622 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5623 | if (spec == NULL) |
| 5624 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5625 | codec->spec = spec; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5626 | |
| 5627 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5628 | stac9872_models, |
| 5629 | stac9872_cfg_tbl); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5630 | if (spec->board_config < 0) |
| 5631 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " |
| 5632 | "using BIOS defaults\n"); |
| 5633 | else |
| 5634 | stac92xx_set_config_regs(codec, |
| 5635 | stac9872_brd_tbl[spec->board_config]); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5636 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5637 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 5638 | spec->pin_nids = stac9872_pin_nids; |
| 5639 | spec->multiout.dac_nids = spec->dac_nids; |
| 5640 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 5641 | spec->adc_nids = stac9872_adc_nids; |
| 5642 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 5643 | spec->mux_nids = stac9872_mux_nids; |
| 5644 | spec->mixer = stac9872_mixer; |
| 5645 | spec->init = stac9872_core_init; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5646 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5647 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 5648 | if (err < 0) { |
| 5649 | stac92xx_free(codec); |
| 5650 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5651 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5652 | spec->input_mux = &spec->private_imux; |
| 5653 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5654 | return 0; |
| 5655 | } |
| 5656 | |
| 5657 | |
| 5658 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5659 | * patch entries |
| 5660 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5661 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5662 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5663 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5664 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5665 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5666 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5667 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5668 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5669 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5670 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5671 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5672 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5673 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5674 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5675 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5676 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5677 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5678 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5679 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5680 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5681 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5682 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5683 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5684 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5685 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5686 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5687 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5688 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5689 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5690 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5691 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5692 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5693 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5694 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5695 | * currently not fully supported. |
| 5696 | */ |
| 5697 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5698 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5699 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5700 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5701 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5702 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5703 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5704 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5705 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5706 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5707 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5708 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5709 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5710 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame^] | 5711 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5712 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5713 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5714 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5715 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5716 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5717 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5718 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5719 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5720 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5721 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5722 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5723 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5724 | {} /* terminator */ |
| 5725 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5726 | |
| 5727 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 5728 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 5729 | |
| 5730 | MODULE_LICENSE("GPL"); |
| 5731 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 5732 | |
| 5733 | static struct hda_codec_preset_list sigmatel_list = { |
| 5734 | .preset = snd_hda_preset_sigmatel, |
| 5735 | .owner = THIS_MODULE, |
| 5736 | }; |
| 5737 | |
| 5738 | static int __init patch_sigmatel_init(void) |
| 5739 | { |
| 5740 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 5741 | } |
| 5742 | |
| 5743 | static void __exit patch_sigmatel_exit(void) |
| 5744 | { |
| 5745 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 5746 | } |
| 5747 | |
| 5748 | module_init(patch_sigmatel_init) |
| 5749 | module_exit(patch_sigmatel_exit) |