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, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 103 | STAC_HP_DV4_1222NR, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 104 | STAC_92HD71BXX_MODELS |
| 105 | }; |
| 106 | |
| 107 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 108 | STAC_925x_AUTO, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 109 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 110 | STAC_M1, |
| 111 | STAC_M1_2, |
| 112 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 113 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 114 | STAC_M3, |
| 115 | STAC_M5, |
| 116 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 117 | STAC_925x_MODELS |
| 118 | }; |
| 119 | |
| 120 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 121 | STAC_922X_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 122 | STAC_D945_REF, |
| 123 | STAC_D945GTP3, |
| 124 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 125 | STAC_INTEL_MAC_V1, |
| 126 | STAC_INTEL_MAC_V2, |
| 127 | STAC_INTEL_MAC_V3, |
| 128 | STAC_INTEL_MAC_V4, |
| 129 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 130 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 131 | * is given, one of the above models will be |
| 132 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 133 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 134 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 135 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 136 | STAC_MACBOOK_PRO_V1, |
| 137 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 138 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 139 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 140 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 141 | STAC_922X_DELL_D81, |
| 142 | STAC_922X_DELL_D82, |
| 143 | STAC_922X_DELL_M81, |
| 144 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 145 | STAC_922X_MODELS |
| 146 | }; |
| 147 | |
| 148 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 149 | STAC_927X_AUTO, |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 150 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 151 | STAC_D965_REF, |
| 152 | STAC_D965_3ST, |
| 153 | STAC_D965_5ST, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 154 | STAC_D965_5ST_NO_FP, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 155 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 156 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 157 | STAC_927X_MODELS |
| 158 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 159 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 160 | enum { |
| 161 | STAC_9872_AUTO, |
| 162 | STAC_9872_VAIO, |
| 163 | STAC_9872_MODELS |
| 164 | }; |
| 165 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 166 | struct sigmatel_event { |
| 167 | hda_nid_t nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 168 | unsigned char type; |
| 169 | unsigned char tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 170 | int data; |
| 171 | }; |
| 172 | |
| 173 | struct sigmatel_jack { |
| 174 | hda_nid_t nid; |
| 175 | int type; |
| 176 | struct snd_jack *jack; |
| 177 | }; |
| 178 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 179 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 180 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 181 | unsigned int num_mixers; |
| 182 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 183 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 184 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 185 | unsigned int surr_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 186 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 187 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 188 | unsigned int spdif_mute: 1; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 189 | unsigned int check_volume_offset:1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 190 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 191 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 192 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 193 | unsigned int gpio_mask; |
| 194 | unsigned int gpio_dir; |
| 195 | unsigned int gpio_data; |
| 196 | unsigned int gpio_mute; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 197 | unsigned int gpio_led; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 198 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 199 | /* stream */ |
| 200 | unsigned int stream_delay; |
| 201 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 202 | /* analog loopback */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 203 | struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 204 | unsigned char aloopback_mask; |
| 205 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 206 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 207 | /* power management */ |
| 208 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 209 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 210 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 211 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 212 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 213 | /* jack detection */ |
| 214 | struct snd_array jacks; |
| 215 | |
| 216 | /* events */ |
| 217 | struct snd_array events; |
| 218 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 219 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 220 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 221 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 222 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 223 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 224 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 225 | hda_nid_t hp_dacs[5]; |
| 226 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 227 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 228 | int volume_offset; |
| 229 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 230 | /* capture */ |
| 231 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 232 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 233 | hda_nid_t *mux_nids; |
| 234 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 235 | hda_nid_t *dmic_nids; |
| 236 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 237 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 238 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 239 | hda_nid_t *smux_nids; |
| 240 | unsigned int num_smuxes; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 241 | |
| 242 | unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ |
| 243 | unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ |
| 244 | unsigned int num_caps; /* number of capture volume/switch elements */ |
| 245 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 246 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 247 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 248 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 249 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 250 | hda_nid_t anabeep_nid; |
| 251 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 252 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 253 | /* pin widgets */ |
| 254 | hda_nid_t *pin_nids; |
| 255 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 256 | |
| 257 | /* codec specific stuff */ |
| 258 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 259 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 260 | |
| 261 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 262 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 263 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 264 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 265 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 266 | struct hda_input_mux *sinput_mux; |
| 267 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 268 | unsigned int cur_amux; |
| 269 | hda_nid_t *amp_nids; |
| 270 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 271 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 272 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 273 | /* i/o switches */ |
| 274 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 275 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 276 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 277 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 278 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 279 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 280 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 281 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 282 | |
| 283 | /* dynamic controls and input_mux */ |
| 284 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 285 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 286 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 287 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 288 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 289 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 290 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | static hda_nid_t stac9200_adc_nids[1] = { |
| 294 | 0x03, |
| 295 | }; |
| 296 | |
| 297 | static hda_nid_t stac9200_mux_nids[1] = { |
| 298 | 0x0c, |
| 299 | }; |
| 300 | |
| 301 | static hda_nid_t stac9200_dac_nids[1] = { |
| 302 | 0x02, |
| 303 | }; |
| 304 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 305 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 306 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 307 | 0x0f, 0x10, 0x11 |
| 308 | }; |
| 309 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 310 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 311 | 0x26, 0, |
| 312 | }; |
| 313 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 314 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 315 | 0x1a, 0x1b |
| 316 | }; |
| 317 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 318 | #define DELL_M6_AMP 2 |
| 319 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 320 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 321 | }; |
| 322 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 323 | #define STAC92HD73XX_NUM_DMICS 2 |
| 324 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 325 | 0x13, 0x14, 0 |
| 326 | }; |
| 327 | |
| 328 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 329 | |
| 330 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 331 | 0x28, 0x29, 0x2a, 0x2b, |
| 332 | }; |
| 333 | |
| 334 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 335 | 0x20, 0x21, |
| 336 | }; |
| 337 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 338 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 339 | 0x22, 0x23, |
| 340 | }; |
| 341 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 342 | #define STAC92HD73XX_NUM_CAPS 2 |
| 343 | static unsigned long stac92hd73xx_capvols[] = { |
| 344 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
| 345 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 346 | }; |
| 347 | #define stac92hd73xx_capsws stac92hd73xx_capvols |
| 348 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 349 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 350 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 351 | 0x11, 0x12, 0 |
| 352 | }; |
| 353 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 354 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 355 | |
| 356 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 357 | 0x17, 0x18, |
| 358 | }; |
| 359 | |
| 360 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 361 | 0x15, 0x16, |
| 362 | }; |
| 363 | |
| 364 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 365 | 0xa, 0xb, 0xd, 0xe, |
| 366 | }; |
| 367 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 368 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 369 | 0x1e, 0, |
| 370 | }; |
| 371 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 372 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 373 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 374 | }; |
| 375 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 376 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 377 | 0xc, |
| 378 | }; |
| 379 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 380 | #define STAC92HD83XXX_NUM_CAPS 2 |
| 381 | static unsigned long stac92hd83xxx_capvols[] = { |
| 382 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), |
| 383 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), |
| 384 | }; |
| 385 | #define stac92hd83xxx_capsws stac92hd83xxx_capvols |
| 386 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 387 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 388 | 0x0a, 0x0d, 0x0f |
| 389 | }; |
| 390 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 391 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 392 | 0x12, 0x13, |
| 393 | }; |
| 394 | |
| 395 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 396 | 0x1a, 0x1b |
| 397 | }; |
| 398 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 399 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 400 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 401 | }; |
| 402 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 403 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 404 | 0x24, 0x25, |
| 405 | }; |
| 406 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 407 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 408 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 409 | 0x18, 0x19, 0 |
| 410 | }; |
| 411 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 412 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 413 | 0x22, 0 |
| 414 | }; |
| 415 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 416 | #define STAC92HD71BXX_NUM_CAPS 2 |
| 417 | static unsigned long stac92hd71bxx_capvols[] = { |
| 418 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 419 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 420 | }; |
| 421 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols |
| 422 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 423 | static hda_nid_t stac925x_adc_nids[1] = { |
| 424 | 0x03, |
| 425 | }; |
| 426 | |
| 427 | static hda_nid_t stac925x_mux_nids[1] = { |
| 428 | 0x0f, |
| 429 | }; |
| 430 | |
| 431 | static hda_nid_t stac925x_dac_nids[1] = { |
| 432 | 0x02, |
| 433 | }; |
| 434 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 435 | #define STAC925X_NUM_DMICS 1 |
| 436 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 437 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 438 | }; |
| 439 | |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 440 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 441 | 0x14, |
| 442 | }; |
| 443 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 444 | static unsigned long stac925x_capvols[] = { |
| 445 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), |
| 446 | }; |
| 447 | static unsigned long stac925x_capsws[] = { |
| 448 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 449 | }; |
| 450 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 451 | static hda_nid_t stac922x_adc_nids[2] = { |
| 452 | 0x06, 0x07, |
| 453 | }; |
| 454 | |
| 455 | static hda_nid_t stac922x_mux_nids[2] = { |
| 456 | 0x12, 0x13, |
| 457 | }; |
| 458 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 459 | #define STAC922X_NUM_CAPS 2 |
| 460 | static unsigned long stac922x_capvols[] = { |
| 461 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), |
| 462 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 463 | }; |
| 464 | #define stac922x_capsws stac922x_capvols |
| 465 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 466 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 467 | 0x1f, 0, |
| 468 | }; |
| 469 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 470 | static hda_nid_t stac927x_adc_nids[3] = { |
| 471 | 0x07, 0x08, 0x09 |
| 472 | }; |
| 473 | |
| 474 | static hda_nid_t stac927x_mux_nids[3] = { |
| 475 | 0x15, 0x16, 0x17 |
| 476 | }; |
| 477 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 478 | static hda_nid_t stac927x_smux_nids[1] = { |
| 479 | 0x21, |
| 480 | }; |
| 481 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 482 | static hda_nid_t stac927x_dac_nids[6] = { |
| 483 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 484 | }; |
| 485 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 486 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 487 | 0x1b, |
| 488 | }; |
| 489 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 490 | #define STAC927X_NUM_DMICS 2 |
| 491 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 492 | 0x13, 0x14, 0 |
| 493 | }; |
| 494 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 495 | #define STAC927X_NUM_CAPS 3 |
| 496 | static unsigned long stac927x_capvols[] = { |
| 497 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 498 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), |
| 499 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), |
| 500 | }; |
| 501 | static unsigned long stac927x_capsws[] = { |
| 502 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 503 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 504 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 505 | }; |
| 506 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 507 | static const char *stac927x_spdif_labels[5] = { |
| 508 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 509 | "Analog Mux 2", "Analog Mux 3" |
| 510 | }; |
| 511 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 512 | static hda_nid_t stac9205_adc_nids[2] = { |
| 513 | 0x12, 0x13 |
| 514 | }; |
| 515 | |
| 516 | static hda_nid_t stac9205_mux_nids[2] = { |
| 517 | 0x19, 0x1a |
| 518 | }; |
| 519 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 520 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 521 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 522 | }; |
| 523 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 524 | static hda_nid_t stac9205_smux_nids[1] = { |
| 525 | 0x21, |
| 526 | }; |
| 527 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 528 | #define STAC9205_NUM_DMICS 2 |
| 529 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 530 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 531 | }; |
| 532 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 533 | #define STAC9205_NUM_CAPS 2 |
| 534 | static unsigned long stac9205_capvols[] = { |
| 535 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), |
| 536 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), |
| 537 | }; |
| 538 | static unsigned long stac9205_capsws[] = { |
| 539 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 540 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), |
| 541 | }; |
| 542 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 543 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 544 | 0x08, 0x09, 0x0d, 0x0e, |
| 545 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 546 | }; |
| 547 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 548 | static hda_nid_t stac925x_pin_nids[8] = { |
| 549 | 0x07, 0x08, 0x0a, 0x0b, |
| 550 | 0x0c, 0x0d, 0x10, 0x11, |
| 551 | }; |
| 552 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 553 | static hda_nid_t stac922x_pin_nids[10] = { |
| 554 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 555 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 556 | }; |
| 557 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 558 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 559 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 560 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 561 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 562 | }; |
| 563 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 564 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 565 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 566 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 567 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 568 | |
| 569 | #define STAC92HD71BXX_NUM_PINS 13 |
| 570 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 571 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 572 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 573 | 0x1f, 0x20, 0x27 |
| 574 | }; |
| 575 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 576 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 577 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 578 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 579 | }; |
| 580 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 581 | static hda_nid_t stac927x_pin_nids[14] = { |
| 582 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 583 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 584 | 0x14, 0x21, 0x22, 0x23, |
| 585 | }; |
| 586 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 587 | static hda_nid_t stac9205_pin_nids[12] = { |
| 588 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 589 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 590 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 591 | }; |
| 592 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 593 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 594 | |
| 595 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 596 | struct snd_ctl_elem_value *ucontrol) |
| 597 | { |
| 598 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 599 | struct sigmatel_spec *spec = codec->spec; |
| 600 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 601 | |
| 602 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 603 | kcontrol->private_value |= nid; |
| 604 | |
| 605 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 606 | } |
| 607 | |
| 608 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 609 | struct snd_ctl_elem_value *ucontrol) |
| 610 | { |
| 611 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 612 | struct sigmatel_spec *spec = codec->spec; |
| 613 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 614 | |
| 615 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 616 | kcontrol->private_value |= nid; |
| 617 | |
| 618 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 619 | } |
| 620 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 621 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 622 | struct snd_ctl_elem_info *uinfo) |
| 623 | { |
| 624 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 625 | struct sigmatel_spec *spec = codec->spec; |
| 626 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 627 | } |
| 628 | |
| 629 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 630 | struct snd_ctl_elem_value *ucontrol) |
| 631 | { |
| 632 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 633 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 634 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 635 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 636 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 637 | return 0; |
| 638 | } |
| 639 | |
| 640 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 641 | struct snd_ctl_elem_value *ucontrol) |
| 642 | { |
| 643 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 644 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 645 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 646 | |
| 647 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 648 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 649 | } |
| 650 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 651 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 652 | struct snd_ctl_elem_info *uinfo) |
| 653 | { |
| 654 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 655 | struct sigmatel_spec *spec = codec->spec; |
| 656 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 657 | } |
| 658 | |
| 659 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 660 | struct snd_ctl_elem_value *ucontrol) |
| 661 | { |
| 662 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 663 | struct sigmatel_spec *spec = codec->spec; |
| 664 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 665 | |
| 666 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 671 | struct snd_ctl_elem_value *ucontrol) |
| 672 | { |
| 673 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 674 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 675 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 676 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 677 | int err, val; |
| 678 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 679 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 680 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 681 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 682 | if (err < 0) |
| 683 | return err; |
| 684 | |
| 685 | if (spec->spdif_mute) { |
| 686 | if (smux_idx == 0) |
| 687 | nid = spec->multiout.dig_out_nid; |
| 688 | else |
| 689 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 690 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 691 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 692 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 693 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 694 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 695 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 696 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 697 | } |
| 698 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 699 | } |
| 700 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 701 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 702 | hda_nid_t nid, unsigned int new_vref) |
| 703 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 704 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 705 | unsigned int pincfg; |
| 706 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 707 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 708 | |
| 709 | pincfg &= 0xff; |
| 710 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 711 | pincfg |= new_vref; |
| 712 | |
| 713 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 714 | pincfg |= AC_PINCTL_OUT_EN; |
| 715 | else |
| 716 | pincfg |= AC_PINCTL_IN_EN; |
| 717 | |
| 718 | error = snd_hda_codec_write_cache(codec, nid, 0, |
| 719 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); |
| 720 | if (error < 0) |
| 721 | return error; |
| 722 | else |
| 723 | return 1; |
| 724 | } |
| 725 | |
| 726 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 727 | { |
| 728 | unsigned int vref; |
| 729 | vref = snd_hda_codec_read(codec, nid, 0, |
| 730 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 731 | vref &= AC_PINCTL_VREFEN; |
| 732 | return vref; |
| 733 | } |
| 734 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 735 | 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] | 736 | { |
| 737 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 738 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 739 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 740 | } |
| 741 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 742 | 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] | 743 | { |
| 744 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 745 | struct sigmatel_spec *spec = codec->spec; |
| 746 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 747 | |
| 748 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 749 | return 0; |
| 750 | } |
| 751 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 752 | 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] | 753 | { |
| 754 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 755 | struct sigmatel_spec *spec = codec->spec; |
| 756 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 757 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 758 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 759 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 760 | } |
| 761 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 762 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 763 | struct snd_ctl_elem_info *uinfo) |
| 764 | { |
| 765 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 766 | struct sigmatel_spec *spec = codec->spec; |
| 767 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 768 | } |
| 769 | |
| 770 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 771 | struct snd_ctl_elem_value *ucontrol) |
| 772 | { |
| 773 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 774 | struct sigmatel_spec *spec = codec->spec; |
| 775 | |
| 776 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 777 | return 0; |
| 778 | } |
| 779 | |
| 780 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 781 | struct snd_ctl_elem_value *ucontrol) |
| 782 | { |
| 783 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 784 | struct sigmatel_spec *spec = codec->spec; |
| 785 | |
| 786 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 787 | spec->mono_nid, &spec->cur_mmux); |
| 788 | } |
| 789 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 790 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 791 | struct snd_ctl_elem_info *uinfo) |
| 792 | { |
| 793 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 794 | struct sigmatel_spec *spec = codec->spec; |
| 795 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 796 | } |
| 797 | |
| 798 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 799 | struct snd_ctl_elem_value *ucontrol) |
| 800 | { |
| 801 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 802 | struct sigmatel_spec *spec = codec->spec; |
| 803 | |
| 804 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 809 | struct snd_ctl_elem_value *ucontrol) |
| 810 | { |
| 811 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 812 | struct sigmatel_spec *spec = codec->spec; |
| 813 | struct snd_kcontrol *ctl = |
| 814 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 815 | if (!ctl) |
| 816 | return -EINVAL; |
| 817 | |
| 818 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 819 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 820 | |
| 821 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 822 | 0, &spec->cur_amux); |
| 823 | } |
| 824 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 825 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 826 | |
| 827 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 828 | struct snd_ctl_elem_value *ucontrol) |
| 829 | { |
| 830 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 831 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 832 | struct sigmatel_spec *spec = codec->spec; |
| 833 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 834 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 835 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 836 | return 0; |
| 837 | } |
| 838 | |
| 839 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 840 | struct snd_ctl_elem_value *ucontrol) |
| 841 | { |
| 842 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 843 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 844 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 845 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 846 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 847 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 848 | idx_val = spec->aloopback_mask << idx; |
| 849 | if (ucontrol->value.integer.value[0]) |
| 850 | val = spec->aloopback | idx_val; |
| 851 | else |
| 852 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 853 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 854 | return 0; |
| 855 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 856 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 857 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 858 | /* Only return the bits defined by the shift value of the |
| 859 | * first two bytes of the mask |
| 860 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 861 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 862 | kcontrol->private_value & 0xFFFF, 0x0); |
| 863 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 864 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 865 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 866 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 867 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 868 | } else { |
| 869 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 870 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 874 | kcontrol->private_value >> 16, dac_mode); |
| 875 | |
| 876 | return 1; |
| 877 | } |
| 878 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 879 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 880 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 881 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 882 | {} |
| 883 | }; |
| 884 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 885 | static struct hda_verb stac9200_eapd_init[] = { |
| 886 | /* set dac0mux for dac converter */ |
| 887 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 888 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 889 | {} |
| 890 | }; |
| 891 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 892 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 893 | /* set master volume and direct control */ |
| 894 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 895 | /* setup adcs to point to mixer */ |
| 896 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 897 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 898 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 899 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 900 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 901 | /* setup import muxs */ |
| 902 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 903 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 904 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 905 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 906 | {} |
| 907 | }; |
| 908 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 909 | static struct hda_verb dell_eq_core_init[] = { |
| 910 | /* set master volume to max value without distortion |
| 911 | * and direct control */ |
| 912 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 913 | /* setup adcs to point to mixer */ |
| 914 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 915 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 916 | /* setup import muxs */ |
| 917 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 918 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 919 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 920 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 921 | {} |
| 922 | }; |
| 923 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 924 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 925 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 926 | /* setup adcs to point to mixer */ |
| 927 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 928 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 929 | /* setup import muxs */ |
| 930 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 931 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 932 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 933 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 934 | {} |
| 935 | }; |
| 936 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 937 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 938 | /* set master volume and direct control */ |
| 939 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 940 | /* setup adcs to point to mixer */ |
| 941 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 942 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 943 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 944 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 945 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 946 | /* setup import muxs */ |
| 947 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 948 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 949 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 950 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 951 | {} |
| 952 | }; |
| 953 | |
| 954 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 955 | /* set master volume and direct control */ |
| 956 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 957 | /* dac3 is connected to import3 mux */ |
| 958 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 959 | /* setup adcs to point to mixer */ |
| 960 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 961 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 962 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 963 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 964 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 965 | /* setup import muxs */ |
| 966 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 967 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 968 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 969 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 970 | {} |
| 971 | }; |
| 972 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 973 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 974 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 975 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 976 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 977 | |
| 978 | /* power state controls amps */ |
| 979 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 980 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 981 | }; |
| 982 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 983 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 984 | /* set master volume and direct control */ |
| 985 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 986 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 987 | }; |
| 988 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 989 | #define HD_DISABLE_PORTF 1 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 990 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 991 | /* start of config #1 */ |
| 992 | |
| 993 | /* connect port 0f to audio mixer */ |
| 994 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 995 | /* start of config #2 */ |
| 996 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 997 | /* set master volume and direct control */ |
| 998 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 999 | {} |
| 1000 | }; |
| 1001 | |
| 1002 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 1003 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 1004 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1005 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 1006 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1007 | {} |
| 1008 | }; |
| 1009 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1010 | static struct hda_verb stac925x_core_init[] = { |
| 1011 | /* set dac0mux for dac converter */ |
| 1012 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1013 | /* mute the master volume */ |
| 1014 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1015 | {} |
| 1016 | }; |
| 1017 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1018 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1019 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1020 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1021 | {} |
| 1022 | }; |
| 1023 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1024 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1025 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1026 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1027 | /* unmute node 0x1b */ |
| 1028 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 1029 | /* select node 0x03 as DAC */ |
| 1030 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 1031 | {} |
| 1032 | }; |
| 1033 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1034 | static struct hda_verb stac927x_core_init[] = { |
| 1035 | /* set master volume and direct control */ |
| 1036 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1037 | /* enable analog pc beep path */ |
| 1038 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1039 | {} |
| 1040 | }; |
| 1041 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1042 | static struct hda_verb stac9205_core_init[] = { |
| 1043 | /* set master volume and direct control */ |
| 1044 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1045 | /* enable analog pc beep path */ |
| 1046 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1047 | {} |
| 1048 | }; |
| 1049 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 1050 | #define STAC_MONO_MUX \ |
| 1051 | { \ |
| 1052 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1053 | .name = "Mono Mux", \ |
| 1054 | .count = 1, \ |
| 1055 | .info = stac92xx_mono_mux_enum_info, \ |
| 1056 | .get = stac92xx_mono_mux_enum_get, \ |
| 1057 | .put = stac92xx_mono_mux_enum_put, \ |
| 1058 | } |
| 1059 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 1060 | #define STAC_AMP_MUX \ |
| 1061 | { \ |
| 1062 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1063 | .name = "Amp Selector Capture Switch", \ |
| 1064 | .count = 1, \ |
| 1065 | .info = stac92xx_amp_mux_enum_info, \ |
| 1066 | .get = stac92xx_amp_mux_enum_get, \ |
| 1067 | .put = stac92xx_amp_mux_enum_put, \ |
| 1068 | } |
| 1069 | |
| 1070 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 1071 | { \ |
| 1072 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1073 | .name = xname, \ |
| 1074 | .index = 0, \ |
| 1075 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1076 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1077 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 1078 | .info = stac92xx_amp_volume_info, \ |
| 1079 | .get = stac92xx_amp_volume_get, \ |
| 1080 | .put = stac92xx_amp_volume_put, \ |
| 1081 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 1082 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 1083 | } |
| 1084 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1085 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1086 | { \ |
| 1087 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1088 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1089 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1090 | .info = stac92xx_aloopback_info, \ |
| 1091 | .get = stac92xx_aloopback_get, \ |
| 1092 | .put = stac92xx_aloopback_put, \ |
| 1093 | .private_value = verb_read | (verb_write << 16), \ |
| 1094 | } |
| 1095 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1096 | #define DC_BIAS(xname, idx, nid) \ |
| 1097 | { \ |
| 1098 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1099 | .name = xname, \ |
| 1100 | .index = idx, \ |
| 1101 | .info = stac92xx_dc_bias_info, \ |
| 1102 | .get = stac92xx_dc_bias_get, \ |
| 1103 | .put = stac92xx_dc_bias_put, \ |
| 1104 | .private_value = nid, \ |
| 1105 | } |
| 1106 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1107 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1108 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1109 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1110 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1111 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1112 | { } /* end */ |
| 1113 | }; |
| 1114 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1115 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1116 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1117 | /* start of config #1 */ |
| 1118 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1119 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1120 | |
| 1121 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1122 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1123 | |
| 1124 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1125 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1126 | |
| 1127 | /* start of config #2 */ |
| 1128 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1129 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1130 | |
| 1131 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1132 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1133 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1134 | { } /* end */ |
| 1135 | }; |
| 1136 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1137 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1138 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1139 | {} |
| 1140 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1141 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1142 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1143 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1144 | {} |
| 1145 | }; |
| 1146 | |
| 1147 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1148 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1149 | {} |
| 1150 | }; |
| 1151 | |
| 1152 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1153 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1154 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1155 | |
| 1156 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1157 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1158 | |
| 1159 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1160 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1161 | |
| 1162 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1163 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1164 | |
| 1165 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1166 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1167 | { } /* end */ |
| 1168 | }; |
| 1169 | |
| 1170 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1171 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1172 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1173 | |
| 1174 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1175 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1176 | |
| 1177 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1178 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1179 | |
| 1180 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1181 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1182 | |
| 1183 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1184 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1185 | { } /* end */ |
| 1186 | }; |
| 1187 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1188 | |
| 1189 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1190 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1191 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1192 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1193 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1194 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1195 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1196 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1197 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1198 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1199 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1200 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1201 | |
| 1202 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1203 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1204 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1205 | */ |
| 1206 | { } /* end */ |
| 1207 | }; |
| 1208 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1209 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 687cb98e | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1210 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1211 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1212 | |
Matthew Ranostay | 687cb98e | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1213 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1214 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1215 | |
| 1216 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1217 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1218 | |
| 1219 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1220 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1221 | { } /* end */ |
| 1222 | }; |
| 1223 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1224 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1225 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1226 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1227 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1228 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1229 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1230 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1231 | { } /* end */ |
| 1232 | }; |
| 1233 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1234 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1235 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1236 | {} |
| 1237 | }; |
| 1238 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1239 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1240 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1241 | {} |
| 1242 | }; |
| 1243 | |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1244 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1245 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1246 | .name = "Digital Input Source", |
| 1247 | /* count set later */ |
| 1248 | .info = stac92xx_dmux_enum_info, |
| 1249 | .get = stac92xx_dmux_enum_get, |
| 1250 | .put = stac92xx_dmux_enum_put, |
| 1251 | }; |
| 1252 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1253 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1254 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1255 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1256 | /* count set later */ |
| 1257 | .info = stac92xx_smux_enum_info, |
| 1258 | .get = stac92xx_smux_enum_get, |
| 1259 | .put = stac92xx_smux_enum_put, |
| 1260 | }; |
| 1261 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1262 | static const char *slave_vols[] = { |
| 1263 | "Front Playback Volume", |
| 1264 | "Surround Playback Volume", |
| 1265 | "Center Playback Volume", |
| 1266 | "LFE Playback Volume", |
| 1267 | "Side Playback Volume", |
| 1268 | "Headphone Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1269 | "Speaker Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1270 | NULL |
| 1271 | }; |
| 1272 | |
| 1273 | static const char *slave_sws[] = { |
| 1274 | "Front Playback Switch", |
| 1275 | "Surround Playback Switch", |
| 1276 | "Center Playback Switch", |
| 1277 | "LFE Playback Switch", |
| 1278 | "Side Playback Switch", |
| 1279 | "Headphone Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1280 | "Speaker Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1281 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1282 | NULL |
| 1283 | }; |
| 1284 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1285 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1286 | 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] | 1287 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1288 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1289 | { |
| 1290 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1291 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1292 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1293 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1294 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1295 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 1296 | if (spec->mixer) { |
| 1297 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1298 | if (err < 0) |
| 1299 | return err; |
| 1300 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1301 | |
| 1302 | for (i = 0; i < spec->num_mixers; i++) { |
| 1303 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1304 | if (err < 0) |
| 1305 | return err; |
| 1306 | } |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1307 | if (spec->num_dmuxes > 0) { |
| 1308 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1309 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1310 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1311 | if (err < 0) |
| 1312 | return err; |
| 1313 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1314 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1315 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1316 | struct hda_input_mux *smux = &spec->private_smux; |
| 1317 | /* check for mute support on SPDIF out */ |
| 1318 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1319 | smux->items[smux->num_items].label = "Off"; |
| 1320 | smux->items[smux->num_items].index = 0; |
| 1321 | smux->num_items++; |
| 1322 | spec->spdif_mute = 1; |
| 1323 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1324 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1325 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1326 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1327 | if (err < 0) |
| 1328 | return err; |
| 1329 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1330 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1331 | if (spec->multiout.dig_out_nid) { |
| 1332 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1333 | if (err < 0) |
| 1334 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1335 | err = snd_hda_create_spdif_share_sw(codec, |
| 1336 | &spec->multiout); |
| 1337 | if (err < 0) |
| 1338 | return err; |
| 1339 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1340 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1341 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1342 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1343 | if (err < 0) |
| 1344 | return err; |
| 1345 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1346 | |
| 1347 | /* if we have no master control, let's create it */ |
| 1348 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1349 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1350 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1351 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1352 | /* correct volume offset */ |
| 1353 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1354 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1355 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1356 | if (err < 0) |
| 1357 | return err; |
| 1358 | } |
| 1359 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1360 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1361 | NULL, slave_sws); |
| 1362 | if (err < 0) |
| 1363 | return err; |
| 1364 | } |
| 1365 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1366 | if (spec->aloopback_ctl && |
| 1367 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1368 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1369 | if (err < 0) |
| 1370 | return err; |
| 1371 | } |
| 1372 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1373 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1374 | |
| 1375 | /* create jack input elements */ |
| 1376 | if (spec->hp_detect) { |
| 1377 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1378 | int type = SND_JACK_HEADPHONE; |
| 1379 | nid = cfg->hp_pins[i]; |
| 1380 | /* jack detection */ |
| 1381 | if (cfg->hp_outs == i) |
| 1382 | type |= SND_JACK_LINEOUT; |
| 1383 | err = stac92xx_add_jack(codec, nid, type); |
| 1384 | if (err < 0) |
| 1385 | return err; |
| 1386 | } |
| 1387 | } |
| 1388 | for (i = 0; i < cfg->line_outs; i++) { |
| 1389 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1390 | SND_JACK_LINEOUT); |
| 1391 | if (err < 0) |
| 1392 | return err; |
| 1393 | } |
| 1394 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1395 | nid = cfg->input_pins[i]; |
| 1396 | if (nid) { |
| 1397 | err = stac92xx_add_jack(codec, nid, |
| 1398 | SND_JACK_MICROPHONE); |
| 1399 | if (err < 0) |
| 1400 | return err; |
| 1401 | } |
| 1402 | } |
| 1403 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1404 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1405 | } |
| 1406 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1407 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1408 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1409 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1410 | }; |
| 1411 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1412 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1413 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1414 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1415 | }; |
| 1416 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1417 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1418 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1419 | }; |
| 1420 | |
| 1421 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1422 | STAC 9200 pin configs for |
| 1423 | 102801A8 |
| 1424 | 102801DE |
| 1425 | 102801E8 |
| 1426 | */ |
| 1427 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1428 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1429 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1430 | }; |
| 1431 | |
| 1432 | /* |
| 1433 | STAC 9200 pin configs for |
| 1434 | 102801C0 |
| 1435 | 102801C1 |
| 1436 | */ |
| 1437 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1438 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1439 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1440 | }; |
| 1441 | |
| 1442 | /* |
| 1443 | STAC 9200 pin configs for |
| 1444 | 102801C4 (Dell Dimension E310) |
| 1445 | 102801C5 |
| 1446 | 102801C7 |
| 1447 | 102801D9 |
| 1448 | 102801DA |
| 1449 | 102801E3 |
| 1450 | */ |
| 1451 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1452 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1453 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1454 | }; |
| 1455 | |
| 1456 | |
| 1457 | /* |
| 1458 | STAC 9200-32 pin configs for |
| 1459 | 102801B5 (Dell Inspiron 630m) |
| 1460 | 102801D8 (Dell Inspiron 640m) |
| 1461 | */ |
| 1462 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1463 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1464 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1465 | }; |
| 1466 | |
| 1467 | /* |
| 1468 | STAC 9200-32 pin configs for |
| 1469 | 102801C2 (Dell Latitude D620) |
| 1470 | 102801C8 |
| 1471 | 102801CC (Dell Latitude D820) |
| 1472 | 102801D4 |
| 1473 | 102801D6 |
| 1474 | */ |
| 1475 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1476 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1477 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1478 | }; |
| 1479 | |
| 1480 | /* |
| 1481 | STAC 9200-32 pin configs for |
| 1482 | 102801CE (Dell XPS M1710) |
| 1483 | 102801CF (Dell Precision M90) |
| 1484 | */ |
| 1485 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1486 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1487 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1488 | }; |
| 1489 | |
| 1490 | /* |
| 1491 | STAC 9200-32 pin configs for |
| 1492 | 102801C9 |
| 1493 | 102801CA |
| 1494 | 102801CB (Dell Latitude 120L) |
| 1495 | 102801D3 |
| 1496 | */ |
| 1497 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1498 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1499 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1500 | }; |
| 1501 | |
| 1502 | /* |
| 1503 | STAC 9200-32 pin configs for |
| 1504 | 102801BD (Dell Inspiron E1505n) |
| 1505 | 102801EE |
| 1506 | 102801EF |
| 1507 | */ |
| 1508 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1509 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1510 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1511 | }; |
| 1512 | |
| 1513 | /* |
| 1514 | STAC 9200-32 pin configs for |
| 1515 | 102801F5 (Dell Inspiron 1501) |
| 1516 | 102801F6 |
| 1517 | */ |
| 1518 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1519 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1520 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1521 | }; |
| 1522 | |
| 1523 | /* |
| 1524 | STAC 9200-32 |
| 1525 | 102801CD (Dell Inspiron E1705/9400) |
| 1526 | */ |
| 1527 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1528 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1529 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1530 | }; |
| 1531 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1532 | static unsigned int oqo9200_pin_configs[8] = { |
| 1533 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1534 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1535 | }; |
| 1536 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1537 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1538 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1539 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1540 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1541 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1542 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1543 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1544 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1545 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1546 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1547 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1548 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1549 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1550 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1551 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1552 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1553 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1554 | }; |
| 1555 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1556 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1557 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1558 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1559 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1560 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1561 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1562 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1563 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1564 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1565 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1566 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1567 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1568 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1569 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1570 | [STAC_9200_M4] = "gateway-m4", |
| 1571 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1572 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1573 | }; |
| 1574 | |
| 1575 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1576 | /* SigmaTel reference board */ |
| 1577 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1578 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1579 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1580 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1581 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1582 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1583 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1584 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1585 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1586 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1587 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1588 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1589 | "unknown Dell", STAC_9200_DELL_D22), |
| 1590 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1591 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1592 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1593 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1594 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1595 | "unknown Dell", STAC_9200_DELL_D23), |
| 1596 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1597 | "unknown Dell", STAC_9200_DELL_D23), |
| 1598 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1599 | "unknown Dell", STAC_9200_DELL_M22), |
| 1600 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1601 | "unknown Dell", STAC_9200_DELL_M24), |
| 1602 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1603 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1604 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1605 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1606 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1607 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1608 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1609 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1610 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1611 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1612 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1613 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1614 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1615 | "unknown Dell", STAC_9200_DELL_M22), |
| 1616 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1617 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1618 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1619 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1620 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1621 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1622 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1623 | "unknown Dell", STAC_9200_DELL_D23), |
| 1624 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1625 | "unknown Dell", STAC_9200_DELL_D23), |
| 1626 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1627 | "unknown Dell", STAC_9200_DELL_D21), |
| 1628 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1629 | "unknown Dell", STAC_9200_DELL_D23), |
| 1630 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1631 | "unknown Dell", STAC_9200_DELL_D21), |
| 1632 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1633 | "unknown Dell", STAC_9200_DELL_M25), |
| 1634 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1635 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1636 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1637 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1638 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1639 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1640 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1641 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1642 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1643 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1644 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1645 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1646 | /* OQO Mobile */ |
| 1647 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1648 | {} /* terminator */ |
| 1649 | }; |
| 1650 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1651 | static unsigned int ref925x_pin_configs[8] = { |
| 1652 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1653 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1654 | }; |
| 1655 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1656 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1657 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1658 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1659 | }; |
| 1660 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1661 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1662 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1663 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1664 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1665 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1666 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1667 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1668 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1669 | }; |
| 1670 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1671 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1672 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1673 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1674 | }; |
| 1675 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1676 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1677 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1678 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1679 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1681 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1682 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1683 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1684 | }; |
| 1685 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1686 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1687 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1688 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1689 | }; |
| 1690 | |
| 1691 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1692 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1693 | [STAC_M1] = stac925xM1_pin_configs, |
| 1694 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1695 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1696 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1697 | [STAC_M3] = stac925xM3_pin_configs, |
| 1698 | [STAC_M5] = stac925xM5_pin_configs, |
| 1699 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1700 | }; |
| 1701 | |
| 1702 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1703 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1704 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1705 | [STAC_M1] = "m1", |
| 1706 | [STAC_M1_2] = "m1-2", |
| 1707 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1708 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1709 | [STAC_M3] = "m3", |
| 1710 | [STAC_M5] = "m5", |
| 1711 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1712 | }; |
| 1713 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1714 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1715 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1716 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1717 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1718 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1719 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1720 | /* Not sure about the brand name for those */ |
| 1721 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1722 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1723 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1724 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1725 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1726 | }; |
| 1727 | |
| 1728 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1729 | /* SigmaTel reference board */ |
| 1730 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1731 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1732 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1733 | |
| 1734 | /* Default table for unknown ID */ |
| 1735 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1736 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1737 | {} /* terminator */ |
| 1738 | }; |
| 1739 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1740 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1741 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1742 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1743 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1744 | 0x01452050, |
| 1745 | }; |
| 1746 | |
| 1747 | static unsigned int dell_m6_pin_configs[13] = { |
| 1748 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1749 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1750 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1751 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1752 | }; |
| 1753 | |
| 1754 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1755 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1756 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1757 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1758 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1759 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1760 | }; |
| 1761 | |
| 1762 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1763 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1764 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1765 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1766 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1767 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1768 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1769 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1770 | }; |
| 1771 | |
| 1772 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1773 | /* SigmaTel reference board */ |
| 1774 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1775 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1776 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1777 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1778 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1779 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1780 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1781 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1782 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1783 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1784 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1785 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1786 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1787 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1788 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1789 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1790 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1791 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1792 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1793 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1795 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1796 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1797 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1798 | {} /* terminator */ |
| 1799 | }; |
| 1800 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1801 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1802 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1803 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1804 | 0x01451160, 0x98560170, |
| 1805 | }; |
| 1806 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1807 | static unsigned int dell_s14_pin_configs[10] = { |
| 1808 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1809 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1810 | 0x40f000f0, 0x40f000f0, |
| 1811 | }; |
| 1812 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1813 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1814 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1815 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1816 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1817 | }; |
| 1818 | |
| 1819 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1820 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1821 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1822 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1823 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1824 | }; |
| 1825 | |
| 1826 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1827 | /* SigmaTel reference board */ |
| 1828 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1829 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1830 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1831 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1832 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1833 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1834 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1835 | }; |
| 1836 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1837 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1838 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1839 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1840 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1841 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1842 | }; |
| 1843 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1844 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1845 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1846 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1847 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1848 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1849 | }; |
| 1850 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1851 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1852 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1853 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1854 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1855 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1856 | }; |
| 1857 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1858 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1859 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1860 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1861 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1862 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1863 | }; |
| 1864 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1865 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1866 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1867 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1868 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1869 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1870 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1871 | [STAC_HP_DV5] = NULL, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1872 | [STAC_HP_HDX] = NULL, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1873 | [STAC_HP_DV4_1222NR] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1874 | }; |
| 1875 | |
| 1876 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1877 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1878 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1879 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1880 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1881 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1882 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1883 | [STAC_HP_DV5] = "hp-dv5", |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1884 | [STAC_HP_HDX] = "hp-hdx", |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1885 | [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1886 | }; |
| 1887 | |
| 1888 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1889 | /* SigmaTel reference board */ |
| 1890 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1891 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1892 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1893 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1894 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 1895 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1896 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 1897 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1898 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1899 | "HP dv4-7", STAC_HP_DV5), |
| 1900 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1901 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1902 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 1903 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1904 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1905 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1906 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1907 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1908 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1909 | "unknown Dell", STAC_DELL_M4_1), |
| 1910 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1911 | "unknown Dell", STAC_DELL_M4_1), |
| 1912 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1913 | "unknown Dell", STAC_DELL_M4_1), |
| 1914 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1915 | "unknown Dell", STAC_DELL_M4_1), |
| 1916 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1917 | "unknown Dell", STAC_DELL_M4_1), |
| 1918 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1919 | "unknown Dell", STAC_DELL_M4_1), |
| 1920 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1921 | "unknown Dell", STAC_DELL_M4_1), |
| 1922 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1923 | "unknown Dell", STAC_DELL_M4_2), |
| 1924 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1925 | "unknown Dell", STAC_DELL_M4_2), |
| 1926 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1927 | "unknown Dell", STAC_DELL_M4_2), |
| 1928 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1929 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1930 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1931 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1932 | {} /* terminator */ |
| 1933 | }; |
| 1934 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1935 | static unsigned int ref922x_pin_configs[10] = { |
| 1936 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1937 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1938 | 0x40000100, 0x40000100, |
| 1939 | }; |
| 1940 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1941 | /* |
| 1942 | STAC 922X pin configs for |
| 1943 | 102801A7 |
| 1944 | 102801AB |
| 1945 | 102801A9 |
| 1946 | 102801D1 |
| 1947 | 102801D2 |
| 1948 | */ |
| 1949 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1950 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1951 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1952 | 0x01813122, 0x400001f2, |
| 1953 | }; |
| 1954 | |
| 1955 | /* |
| 1956 | STAC 922X pin configs for |
| 1957 | 102801AC |
| 1958 | 102801D0 |
| 1959 | */ |
| 1960 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1961 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1962 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1963 | 0x01813122, 0x400001f1, |
| 1964 | }; |
| 1965 | |
| 1966 | /* |
| 1967 | STAC 922X pin configs for |
| 1968 | 102801BF |
| 1969 | */ |
| 1970 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1971 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1972 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1973 | 0x40C003f1, 0x405003f0, |
| 1974 | }; |
| 1975 | |
| 1976 | /* |
| 1977 | STAC 9221 A1 pin configs for |
| 1978 | 102801D7 (Dell XPS M1210) |
| 1979 | */ |
| 1980 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1981 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1982 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1983 | 0x508003f3, 0x405003f4, |
| 1984 | }; |
| 1985 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1986 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1987 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1988 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1989 | 0x02a19120, 0x40000100, |
| 1990 | }; |
| 1991 | |
| 1992 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1993 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1994 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1995 | 0x02a19320, 0x40000100, |
| 1996 | }; |
| 1997 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1998 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1999 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 2000 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2001 | 0x400000fc, 0x400000fb, |
| 2002 | }; |
| 2003 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2004 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 2005 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2006 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2007 | 0x400000fc, 0x400000fb, |
| 2008 | }; |
| 2009 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2010 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 2011 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2012 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 2013 | 0x400000fc, 0x400000fb, |
| 2014 | }; |
| 2015 | |
| 2016 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 2017 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2018 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2019 | 0x400000fc, 0x400000fb, |
| 2020 | }; |
| 2021 | |
| 2022 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 2023 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2024 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2025 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2026 | }; |
| 2027 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2028 | static unsigned int ecs202_pin_configs[10] = { |
| 2029 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 2030 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 2031 | 0x9037012e, 0x40e000f2, |
| 2032 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2033 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2034 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2035 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2036 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 2037 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2038 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 2039 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 2040 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 2041 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 2042 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2043 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2044 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2045 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 2046 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2047 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2048 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2049 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2050 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2051 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2052 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2053 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2054 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2055 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2056 | }; |
| 2057 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2058 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2059 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2060 | [STAC_D945_REF] = "ref", |
| 2061 | [STAC_D945GTP5] = "5stack", |
| 2062 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2063 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2064 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2065 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2066 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2067 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2068 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2069 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2070 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2071 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2072 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2073 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2074 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2075 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2076 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2077 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2078 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2079 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2080 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2081 | }; |
| 2082 | |
| 2083 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2084 | /* SigmaTel reference board */ |
| 2085 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2086 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2087 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2088 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2089 | /* Intel 945G based systems */ |
| 2090 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2091 | "Intel D945G", STAC_D945GTP3), |
| 2092 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2093 | "Intel D945G", STAC_D945GTP3), |
| 2094 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2095 | "Intel D945G", STAC_D945GTP3), |
| 2096 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2097 | "Intel D945G", STAC_D945GTP3), |
| 2098 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2099 | "Intel D945G", STAC_D945GTP3), |
| 2100 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2101 | "Intel D945G", STAC_D945GTP3), |
| 2102 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2103 | "Intel D945G", STAC_D945GTP3), |
| 2104 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2105 | "Intel D945G", STAC_D945GTP3), |
| 2106 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2107 | "Intel D945G", STAC_D945GTP3), |
| 2108 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2109 | "Intel D945G", STAC_D945GTP3), |
| 2110 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2111 | "Intel D945G", STAC_D945GTP3), |
| 2112 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2113 | "Intel D945G", STAC_D945GTP3), |
| 2114 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2115 | "Intel D945G", STAC_D945GTP3), |
| 2116 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2117 | "Intel D945G", STAC_D945GTP3), |
| 2118 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2119 | "Intel D945G", STAC_D945GTP3), |
| 2120 | /* Intel D945G 5-stack systems */ |
| 2121 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2122 | "Intel D945G", STAC_D945GTP5), |
| 2123 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2124 | "Intel D945G", STAC_D945GTP5), |
| 2125 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2126 | "Intel D945G", STAC_D945GTP5), |
| 2127 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2128 | "Intel D945G", STAC_D945GTP5), |
| 2129 | /* Intel 945P based systems */ |
| 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2131 | "Intel D945P", STAC_D945GTP3), |
| 2132 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2133 | "Intel D945P", STAC_D945GTP3), |
| 2134 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2135 | "Intel D945P", STAC_D945GTP3), |
| 2136 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2137 | "Intel D945P", STAC_D945GTP3), |
| 2138 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2139 | "Intel D945P", STAC_D945GTP3), |
| 2140 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2141 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2142 | /* other intel */ |
| 2143 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2144 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2145 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2146 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2147 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2148 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2149 | /* Dell systems */ |
| 2150 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2151 | "unknown Dell", STAC_922X_DELL_D81), |
| 2152 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2153 | "unknown Dell", STAC_922X_DELL_D81), |
| 2154 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2155 | "unknown Dell", STAC_922X_DELL_D81), |
| 2156 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2157 | "unknown Dell", STAC_922X_DELL_D82), |
| 2158 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2159 | "unknown Dell", STAC_922X_DELL_M81), |
| 2160 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2161 | "unknown Dell", STAC_922X_DELL_D82), |
| 2162 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2163 | "unknown Dell", STAC_922X_DELL_D81), |
| 2164 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2165 | "unknown Dell", STAC_922X_DELL_D81), |
| 2166 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2167 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2168 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2169 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2170 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2171 | {} /* terminator */ |
| 2172 | }; |
| 2173 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2174 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2175 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2176 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2177 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2178 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2179 | }; |
| 2180 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2181 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2182 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2183 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2184 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2185 | 0x40000100, 0x40000100 |
| 2186 | }; |
| 2187 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2188 | static unsigned int d965_5st_pin_configs[14] = { |
| 2189 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2190 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2191 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2192 | 0x40000100, 0x40000100 |
| 2193 | }; |
| 2194 | |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2195 | static unsigned int d965_5st_no_fp_pin_configs[14] = { |
| 2196 | 0x40000100, 0x40000100, 0x0181304e, 0x01014010, |
| 2197 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2198 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2199 | 0x40000100, 0x40000100 |
| 2200 | }; |
| 2201 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2202 | static unsigned int dell_3st_pin_configs[14] = { |
| 2203 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2204 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2205 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2206 | 0x40c003fc, 0x40000100 |
| 2207 | }; |
| 2208 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2209 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2210 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2211 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2212 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2213 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2214 | [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2215 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2216 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2217 | }; |
| 2218 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2219 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2220 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2221 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2222 | [STAC_D965_REF] = "ref", |
| 2223 | [STAC_D965_3ST] = "3stack", |
| 2224 | [STAC_D965_5ST] = "5stack", |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2225 | [STAC_D965_5ST_NO_FP] = "5stack-no-fp", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2226 | [STAC_DELL_3ST] = "dell-3stack", |
| 2227 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2228 | }; |
| 2229 | |
| 2230 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2231 | /* SigmaTel reference board */ |
| 2232 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2233 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2234 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2235 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2236 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2237 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2238 | 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] | 2239 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2240 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2241 | "Intel D965", STAC_D965_3ST), |
| 2242 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2243 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2244 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2245 | 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] | 2246 | 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] | 2247 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2248 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2249 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2250 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2251 | 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] | 2252 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2253 | 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] | 2254 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2255 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2256 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2257 | 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] | 2258 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2259 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2260 | "Intel D965", STAC_D965_5ST), |
| 2261 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2262 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2263 | {} /* terminator */ |
| 2264 | }; |
| 2265 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2266 | static unsigned int ref9205_pin_configs[12] = { |
| 2267 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2268 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2269 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2270 | }; |
| 2271 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2272 | /* |
| 2273 | STAC 9205 pin configs for |
| 2274 | 102801F1 |
| 2275 | 102801F2 |
| 2276 | 102801FC |
| 2277 | 102801FD |
| 2278 | 10280204 |
| 2279 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2280 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2281 | */ |
| 2282 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2283 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2284 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2285 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2286 | }; |
| 2287 | |
| 2288 | /* |
| 2289 | STAC 9205 pin configs for |
| 2290 | 102801F9 |
| 2291 | 102801FA |
| 2292 | 102801FE |
| 2293 | 102801FF (Dell Precision M4300) |
| 2294 | 10280206 |
| 2295 | 10280200 |
| 2296 | 10280201 |
| 2297 | */ |
| 2298 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2299 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2300 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2301 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2302 | }; |
| 2303 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2304 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2305 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2306 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2307 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2308 | }; |
| 2309 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2310 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2311 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2312 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2313 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2314 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2315 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2316 | }; |
| 2317 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2318 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2319 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2320 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2321 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2322 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2323 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2324 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2325 | }; |
| 2326 | |
| 2327 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2328 | /* SigmaTel reference board */ |
| 2329 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2330 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 2331 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 2332 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2333 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2334 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2335 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2336 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2337 | "unknown Dell", STAC_9205_DELL_M42), |
| 2338 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2339 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2340 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2341 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2342 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2343 | "Dell Precision", STAC_9205_DELL_M43), |
| 2344 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2345 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2346 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2347 | "unknown Dell", STAC_9205_DELL_M42), |
| 2348 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2349 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2350 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2351 | "Dell Precision", STAC_9205_DELL_M43), |
| 2352 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2353 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2354 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2355 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2356 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2357 | "Dell Precision", STAC_9205_DELL_M43), |
| 2358 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2359 | "Dell Precision", STAC_9205_DELL_M43), |
| 2360 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2361 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2362 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2363 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2364 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2365 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2366 | /* Gateway */ |
Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 2367 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2368 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2369 | {} /* terminator */ |
| 2370 | }; |
| 2371 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2372 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2373 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2374 | { |
| 2375 | int i; |
| 2376 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2377 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2378 | if (!pincfgs) |
| 2379 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2380 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2381 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2382 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2383 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2384 | pincfgs[i]); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2385 | } |
| 2386 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2387 | /* |
| 2388 | * Analog playback callbacks |
| 2389 | */ |
| 2390 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2391 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2392 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2393 | { |
| 2394 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2395 | if (spec->stream_delay) |
| 2396 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2397 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2398 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2399 | } |
| 2400 | |
| 2401 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2402 | struct hda_codec *codec, |
| 2403 | unsigned int stream_tag, |
| 2404 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2405 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2406 | { |
| 2407 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2408 | 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] | 2409 | } |
| 2410 | |
| 2411 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2412 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2413 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2414 | { |
| 2415 | struct sigmatel_spec *spec = codec->spec; |
| 2416 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2417 | } |
| 2418 | |
| 2419 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2420 | * Digital playback callbacks |
| 2421 | */ |
| 2422 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2423 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2424 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2425 | { |
| 2426 | struct sigmatel_spec *spec = codec->spec; |
| 2427 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2428 | } |
| 2429 | |
| 2430 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2431 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2432 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2433 | { |
| 2434 | struct sigmatel_spec *spec = codec->spec; |
| 2435 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2436 | } |
| 2437 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2438 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2439 | struct hda_codec *codec, |
| 2440 | unsigned int stream_tag, |
| 2441 | unsigned int format, |
| 2442 | struct snd_pcm_substream *substream) |
| 2443 | { |
| 2444 | struct sigmatel_spec *spec = codec->spec; |
| 2445 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2446 | stream_tag, format, substream); |
| 2447 | } |
| 2448 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2449 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2450 | struct hda_codec *codec, |
| 2451 | struct snd_pcm_substream *substream) |
| 2452 | { |
| 2453 | struct sigmatel_spec *spec = codec->spec; |
| 2454 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2455 | } |
| 2456 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2457 | |
| 2458 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2459 | * Analog capture callbacks |
| 2460 | */ |
| 2461 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2462 | struct hda_codec *codec, |
| 2463 | unsigned int stream_tag, |
| 2464 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2465 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2466 | { |
| 2467 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2468 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2469 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2470 | if (spec->powerdown_adcs) { |
| 2471 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2472 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2473 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2474 | } |
| 2475 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2476 | return 0; |
| 2477 | } |
| 2478 | |
| 2479 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2480 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2481 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2482 | { |
| 2483 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2484 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2485 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2486 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2487 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2488 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2489 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2490 | return 0; |
| 2491 | } |
| 2492 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2493 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2494 | .substreams = 1, |
| 2495 | .channels_min = 2, |
| 2496 | .channels_max = 2, |
| 2497 | /* NID is set in stac92xx_build_pcms */ |
| 2498 | .ops = { |
| 2499 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2500 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2501 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2502 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2503 | }, |
| 2504 | }; |
| 2505 | |
| 2506 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2507 | .substreams = 1, |
| 2508 | .channels_min = 2, |
| 2509 | .channels_max = 2, |
| 2510 | /* NID is set in stac92xx_build_pcms */ |
| 2511 | }; |
| 2512 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2513 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2514 | .substreams = 1, |
| 2515 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2516 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2517 | .nid = 0x02, /* NID to query formats and rates */ |
| 2518 | .ops = { |
| 2519 | .open = stac92xx_playback_pcm_open, |
| 2520 | .prepare = stac92xx_playback_pcm_prepare, |
| 2521 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2522 | }, |
| 2523 | }; |
| 2524 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2525 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2526 | .substreams = 1, |
| 2527 | .channels_min = 2, |
| 2528 | .channels_max = 2, |
| 2529 | .nid = 0x06, /* NID to query formats and rates */ |
| 2530 | .ops = { |
| 2531 | .open = stac92xx_playback_pcm_open, |
| 2532 | .prepare = stac92xx_playback_pcm_prepare, |
| 2533 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2534 | }, |
| 2535 | }; |
| 2536 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2537 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2538 | .channels_min = 2, |
| 2539 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2540 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2541 | .ops = { |
| 2542 | .prepare = stac92xx_capture_pcm_prepare, |
| 2543 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2544 | }, |
| 2545 | }; |
| 2546 | |
| 2547 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2548 | { |
| 2549 | struct sigmatel_spec *spec = codec->spec; |
| 2550 | struct hda_pcm *info = spec->pcm_rec; |
| 2551 | |
| 2552 | codec->num_pcms = 1; |
| 2553 | codec->pcm_info = info; |
| 2554 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2555 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2556 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2557 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2558 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2559 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2560 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2561 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2562 | |
| 2563 | if (spec->alt_switch) { |
| 2564 | codec->num_pcms++; |
| 2565 | info++; |
| 2566 | info->name = "STAC92xx Analog Alt"; |
| 2567 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2568 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2569 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2570 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2571 | codec->num_pcms++; |
| 2572 | info++; |
| 2573 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2574 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2575 | if (spec->multiout.dig_out_nid) { |
| 2576 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2577 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2578 | } |
| 2579 | if (spec->dig_in_nid) { |
| 2580 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2581 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2582 | } |
| 2583 | } |
| 2584 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2585 | return 0; |
| 2586 | } |
| 2587 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2588 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, |
| 2589 | hda_nid_t nid) |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2590 | { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2591 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2592 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2593 | if (pincap & AC_PINCAP_VREF_100) |
| 2594 | return AC_PINCTL_VREF_100; |
| 2595 | if (pincap & AC_PINCAP_VREF_80) |
| 2596 | return AC_PINCTL_VREF_80; |
| 2597 | if (pincap & AC_PINCAP_VREF_50) |
| 2598 | return AC_PINCTL_VREF_50; |
| 2599 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2600 | return AC_PINCTL_VREF_GRD; |
| 2601 | return 0; |
| 2602 | } |
| 2603 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2604 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2605 | |
| 2606 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2607 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2608 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2609 | } |
| 2610 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2611 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2612 | |
| 2613 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2614 | struct snd_ctl_elem_value *ucontrol) |
| 2615 | { |
| 2616 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2617 | struct sigmatel_spec *spec = codec->spec; |
| 2618 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2619 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2620 | return 0; |
| 2621 | } |
| 2622 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 2623 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2624 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2625 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2626 | struct snd_ctl_elem_value *ucontrol) |
| 2627 | { |
| 2628 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2629 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2630 | int nid = kcontrol->private_value; |
| 2631 | |
| 2632 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2633 | |
| 2634 | /* check to be sure that the ports are upto date with |
| 2635 | * switch changes |
| 2636 | */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 2637 | stac_issue_unsol_event(codec, nid); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2638 | |
| 2639 | return 1; |
| 2640 | } |
| 2641 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2642 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 2643 | struct snd_ctl_elem_info *uinfo) |
| 2644 | { |
| 2645 | int i; |
| 2646 | static char *texts[] = { |
| 2647 | "Mic In", "Line In", "Line Out" |
| 2648 | }; |
| 2649 | |
| 2650 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2651 | struct sigmatel_spec *spec = codec->spec; |
| 2652 | hda_nid_t nid = kcontrol->private_value; |
| 2653 | |
| 2654 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 2655 | i = 3; |
| 2656 | else |
| 2657 | i = 2; |
| 2658 | |
| 2659 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2660 | uinfo->value.enumerated.items = i; |
| 2661 | uinfo->count = 1; |
| 2662 | if (uinfo->value.enumerated.item >= i) |
| 2663 | uinfo->value.enumerated.item = i-1; |
| 2664 | strcpy(uinfo->value.enumerated.name, |
| 2665 | texts[uinfo->value.enumerated.item]); |
| 2666 | |
| 2667 | return 0; |
| 2668 | } |
| 2669 | |
| 2670 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 2671 | struct snd_ctl_elem_value *ucontrol) |
| 2672 | { |
| 2673 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2674 | hda_nid_t nid = kcontrol->private_value; |
| 2675 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 2676 | |
| 2677 | if (vref == stac92xx_get_default_vref(codec, nid)) |
| 2678 | ucontrol->value.enumerated.item[0] = 0; |
| 2679 | else if (vref == AC_PINCTL_VREF_GRD) |
| 2680 | ucontrol->value.enumerated.item[0] = 1; |
| 2681 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 2682 | ucontrol->value.enumerated.item[0] = 2; |
| 2683 | |
| 2684 | return 0; |
| 2685 | } |
| 2686 | |
| 2687 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 2688 | struct snd_ctl_elem_value *ucontrol) |
| 2689 | { |
| 2690 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2691 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 2692 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2693 | hda_nid_t nid = kcontrol->private_value; |
| 2694 | |
| 2695 | if (ucontrol->value.enumerated.item[0] == 0) |
| 2696 | new_vref = stac92xx_get_default_vref(codec, nid); |
| 2697 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 2698 | new_vref = AC_PINCTL_VREF_GRD; |
| 2699 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 2700 | new_vref = AC_PINCTL_VREF_HIZ; |
| 2701 | else |
| 2702 | return 0; |
| 2703 | |
| 2704 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 2705 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 2706 | return error; |
| 2707 | } |
| 2708 | |
| 2709 | return 0; |
| 2710 | } |
| 2711 | |
| 2712 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 2713 | struct snd_ctl_elem_info *uinfo) |
| 2714 | { |
| 2715 | static char *texts[2]; |
| 2716 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2717 | struct sigmatel_spec *spec = codec->spec; |
| 2718 | |
| 2719 | if (kcontrol->private_value == spec->line_switch) |
| 2720 | texts[0] = "Line In"; |
| 2721 | else |
| 2722 | texts[0] = "Mic In"; |
| 2723 | texts[1] = "Line Out"; |
| 2724 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2725 | uinfo->value.enumerated.items = 2; |
| 2726 | uinfo->count = 1; |
| 2727 | |
| 2728 | if (uinfo->value.enumerated.item >= 2) |
| 2729 | uinfo->value.enumerated.item = 1; |
| 2730 | strcpy(uinfo->value.enumerated.name, |
| 2731 | texts[uinfo->value.enumerated.item]); |
| 2732 | |
| 2733 | return 0; |
| 2734 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2735 | |
| 2736 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2737 | { |
| 2738 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2739 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2740 | hda_nid_t nid = kcontrol->private_value; |
| 2741 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2742 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2743 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2744 | return 0; |
| 2745 | } |
| 2746 | |
| 2747 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2748 | { |
| 2749 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2750 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2751 | hda_nid_t nid = kcontrol->private_value; |
| 2752 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 2753 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2754 | |
| 2755 | spec->io_switch[io_idx] = val; |
| 2756 | |
| 2757 | if (val) |
| 2758 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2759 | else { |
| 2760 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2761 | if (io_idx) /* set VREF for mic */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2762 | pinctl |= stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2763 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2764 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2765 | |
| 2766 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2767 | * appropriately according to the pin direction |
| 2768 | */ |
| 2769 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 2770 | stac_issue_unsol_event(codec, nid); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2771 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2772 | return 1; |
| 2773 | } |
| 2774 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2775 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2776 | |
| 2777 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2778 | struct snd_ctl_elem_value *ucontrol) |
| 2779 | { |
| 2780 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2781 | struct sigmatel_spec *spec = codec->spec; |
| 2782 | |
| 2783 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2784 | return 0; |
| 2785 | } |
| 2786 | |
| 2787 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2788 | struct snd_ctl_elem_value *ucontrol) |
| 2789 | { |
| 2790 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2791 | struct sigmatel_spec *spec = codec->spec; |
| 2792 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2793 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2794 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2795 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2796 | return 0; |
| 2797 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2798 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2799 | |
| 2800 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2801 | spec->clfe_swap ? 0x4 : 0x0); |
| 2802 | |
| 2803 | return 1; |
| 2804 | } |
| 2805 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2806 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2807 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2808 | .name = xname, \ |
| 2809 | .index = 0, \ |
| 2810 | .info = stac92xx_hp_switch_info, \ |
| 2811 | .get = stac92xx_hp_switch_get, \ |
| 2812 | .put = stac92xx_hp_switch_put, \ |
| 2813 | } |
| 2814 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2815 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2816 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2817 | .name = xname, \ |
| 2818 | .index = 0, \ |
| 2819 | .info = stac92xx_io_switch_info, \ |
| 2820 | .get = stac92xx_io_switch_get, \ |
| 2821 | .put = stac92xx_io_switch_put, \ |
| 2822 | .private_value = xpval, \ |
| 2823 | } |
| 2824 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2825 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2826 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2827 | .name = xname, \ |
| 2828 | .index = 0, \ |
| 2829 | .info = stac92xx_clfe_switch_info, \ |
| 2830 | .get = stac92xx_clfe_switch_get, \ |
| 2831 | .put = stac92xx_clfe_switch_put, \ |
| 2832 | .private_value = xpval, \ |
| 2833 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2834 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2835 | enum { |
| 2836 | STAC_CTL_WIDGET_VOL, |
| 2837 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2838 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2839 | STAC_CTL_WIDGET_AMP_MUX, |
| 2840 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2841 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2842 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2843 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2844 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2845 | }; |
| 2846 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2847 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2848 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2849 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2850 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2851 | STAC_AMP_MUX, |
| 2852 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2853 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2854 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2855 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2856 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2857 | }; |
| 2858 | |
| 2859 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2860 | static struct snd_kcontrol_new * |
| 2861 | stac_control_new(struct sigmatel_spec *spec, |
| 2862 | struct snd_kcontrol_new *ktemp, |
| 2863 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2864 | { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2865 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2866 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2867 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2868 | knew = snd_array_new(&spec->kctls); |
| 2869 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2870 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2871 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2872 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2873 | if (!knew->name) { |
| 2874 | /* roolback */ |
| 2875 | memset(knew, 0, sizeof(*knew)); |
| 2876 | spec->kctls.alloced--; |
| 2877 | return NULL; |
| 2878 | } |
| 2879 | return knew; |
| 2880 | } |
| 2881 | |
| 2882 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2883 | struct snd_kcontrol_new *ktemp, |
| 2884 | int idx, const char *name, |
| 2885 | unsigned long val) |
| 2886 | { |
| 2887 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2888 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2889 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2890 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2891 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2892 | return 0; |
| 2893 | } |
| 2894 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2895 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2896 | int type, int idx, const char *name, |
| 2897 | unsigned long val) |
| 2898 | { |
| 2899 | return stac92xx_add_control_temp(spec, |
| 2900 | &stac92xx_control_templates[type], |
| 2901 | idx, name, val); |
| 2902 | } |
| 2903 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2904 | |
| 2905 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2906 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2907 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2908 | { |
| 2909 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2910 | } |
| 2911 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2912 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2913 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2914 | .name = "Input Source", |
| 2915 | .info = stac92xx_mux_enum_info, |
| 2916 | .get = stac92xx_mux_enum_get, |
| 2917 | .put = stac92xx_mux_enum_put, |
| 2918 | }; |
| 2919 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2920 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 2921 | hda_nid_t nid, int idx) |
| 2922 | { |
| 2923 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 2924 | int control = 0; |
| 2925 | struct sigmatel_spec *spec = codec->spec; |
| 2926 | char name[22]; |
| 2927 | |
| 2928 | if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { |
| 2929 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
| 2930 | && nid == spec->line_switch) |
| 2931 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2932 | else if (snd_hda_query_pin_caps(codec, nid) |
| 2933 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 2934 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 2935 | else if (nid == spec->mic_switch) |
| 2936 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2937 | } |
| 2938 | |
| 2939 | if (control) { |
| 2940 | strcpy(name, auto_pin_cfg_labels[idx]); |
| 2941 | return stac92xx_add_control(codec->spec, control, |
| 2942 | strcat(name, " Jack Mode"), nid); |
| 2943 | } |
| 2944 | |
| 2945 | return 0; |
| 2946 | } |
| 2947 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2948 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2949 | { |
| 2950 | struct snd_kcontrol_new *knew; |
| 2951 | struct hda_input_mux *imux = &spec->private_imux; |
| 2952 | |
| 2953 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2954 | return 0; /* no need for input source control */ |
| 2955 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2956 | stac_input_src_temp.name); |
| 2957 | if (!knew) |
| 2958 | return -ENOMEM; |
| 2959 | knew->count = spec->num_adcs; |
| 2960 | return 0; |
| 2961 | } |
| 2962 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2963 | /* check whether the line-input can be used as line-out */ |
| 2964 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2965 | { |
| 2966 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2967 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2968 | hda_nid_t nid; |
| 2969 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2970 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2971 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2972 | return 0; |
| 2973 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2974 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2975 | if (pincap & AC_PINCAP_OUT) |
| 2976 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2977 | return 0; |
| 2978 | } |
| 2979 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2980 | /* check whether the mic-input can be used as line-out */ |
| 2981 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2982 | { |
| 2983 | struct sigmatel_spec *spec = codec->spec; |
| 2984 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2985 | unsigned int def_conf, pincap; |
| 2986 | unsigned int mic_pin; |
| 2987 | |
| 2988 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2989 | return 0; |
| 2990 | mic_pin = AUTO_PIN_MIC; |
| 2991 | for (;;) { |
| 2992 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2993 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2994 | /* some laptops have an internal analog microphone |
| 2995 | * which can't be used as a output */ |
| 2996 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2997 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2998 | if (pincap & AC_PINCAP_OUT) |
| 2999 | return nid; |
| 3000 | } |
| 3001 | if (mic_pin == AUTO_PIN_MIC) |
| 3002 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 3003 | else |
| 3004 | break; |
| 3005 | } |
| 3006 | return 0; |
| 3007 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3008 | |
| 3009 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3010 | { |
| 3011 | int i; |
| 3012 | |
| 3013 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 3014 | if (spec->multiout.dac_nids[i] == nid) |
| 3015 | return 1; |
| 3016 | } |
| 3017 | |
| 3018 | return 0; |
| 3019 | } |
| 3020 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3021 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3022 | { |
| 3023 | int i; |
| 3024 | if (is_in_dac_nids(spec, nid)) |
| 3025 | return 1; |
| 3026 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 3027 | if (spec->hp_dacs[i] == nid) |
| 3028 | return 1; |
| 3029 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 3030 | if (spec->speaker_dacs[i] == nid) |
| 3031 | return 1; |
| 3032 | return 0; |
| 3033 | } |
| 3034 | |
| 3035 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 3036 | { |
| 3037 | struct sigmatel_spec *spec = codec->spec; |
| 3038 | int j, conn_len; |
| 3039 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 3040 | unsigned int wcaps, wtype; |
| 3041 | |
| 3042 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 3043 | HDA_MAX_CONNECTIONS); |
| 3044 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 3045 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3046 | wtype = get_wcaps_type(wcaps); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3047 | /* we check only analog outputs */ |
| 3048 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 3049 | continue; |
| 3050 | /* if this route has a free DAC, assign it */ |
| 3051 | if (!check_all_dac_nids(spec, conn[j])) { |
| 3052 | if (conn_len > 1) { |
| 3053 | /* select this DAC in the pin's input mux */ |
| 3054 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3055 | AC_VERB_SET_CONNECT_SEL, j); |
| 3056 | } |
| 3057 | return conn[j]; |
| 3058 | } |
| 3059 | } |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 3060 | /* if all DACs are already assigned, connect to the primary DAC */ |
| 3061 | if (conn_len > 1) { |
| 3062 | for (j = 0; j < conn_len; j++) { |
| 3063 | if (conn[j] == spec->multiout.dac_nids[0]) { |
| 3064 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3065 | AC_VERB_SET_CONNECT_SEL, j); |
| 3066 | break; |
| 3067 | } |
| 3068 | } |
| 3069 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3070 | return 0; |
| 3071 | } |
| 3072 | |
| 3073 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3074 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3075 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3076 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3077 | * Fill in the dac_nids table from the parsed pin configuration |
| 3078 | * This function only works when every pin in line_out_pins[] |
| 3079 | * contains atleast one DAC in its connection list. Some 92xx |
| 3080 | * codecs are not connected directly to a DAC, such as the 9200 |
| 3081 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3082 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3083 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3084 | { |
| 3085 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3086 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3087 | int i; |
| 3088 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3089 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3090 | for (i = 0; i < cfg->line_outs; i++) { |
| 3091 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3092 | dac = get_unassigned_dac(codec, nid); |
| 3093 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 3094 | if (spec->multiout.num_dacs > 0) { |
| 3095 | /* we have already working output pins, |
| 3096 | * so let's drop the broken ones again |
| 3097 | */ |
| 3098 | cfg->line_outs = spec->multiout.num_dacs; |
| 3099 | break; |
| 3100 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3101 | /* error out, no available DAC found */ |
| 3102 | snd_printk(KERN_ERR |
| 3103 | "%s: No available DAC for pin 0x%x\n", |
| 3104 | __func__, nid); |
| 3105 | return -ENODEV; |
| 3106 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3107 | add_spec_dacs(spec, dac); |
| 3108 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3109 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 3110 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3111 | nid = cfg->hp_pins[i]; |
| 3112 | dac = get_unassigned_dac(codec, nid); |
| 3113 | if (dac) { |
| 3114 | if (!spec->multiout.hp_nid) |
| 3115 | spec->multiout.hp_nid = dac; |
| 3116 | else |
| 3117 | add_spec_extra_dacs(spec, dac); |
| 3118 | } |
| 3119 | spec->hp_dacs[i] = dac; |
| 3120 | } |
| 3121 | |
| 3122 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 3123 | nid = cfg->speaker_pins[i]; |
| 3124 | dac = get_unassigned_dac(codec, nid); |
| 3125 | if (dac) |
| 3126 | add_spec_extra_dacs(spec, dac); |
| 3127 | spec->speaker_dacs[i] = dac; |
| 3128 | } |
| 3129 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3130 | /* add line-in as output */ |
| 3131 | nid = check_line_out_switch(codec); |
| 3132 | if (nid) { |
| 3133 | dac = get_unassigned_dac(codec, nid); |
| 3134 | if (dac) { |
| 3135 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 3136 | nid, cfg->line_outs); |
| 3137 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3138 | cfg->line_outs++; |
| 3139 | spec->line_switch = nid; |
| 3140 | add_spec_dacs(spec, dac); |
| 3141 | } |
| 3142 | } |
| 3143 | /* add mic as output */ |
| 3144 | nid = check_mic_out_switch(codec); |
| 3145 | if (nid) { |
| 3146 | dac = get_unassigned_dac(codec, nid); |
| 3147 | if (dac) { |
| 3148 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 3149 | nid, cfg->line_outs); |
| 3150 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3151 | cfg->line_outs++; |
| 3152 | spec->mic_switch = nid; |
| 3153 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3154 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3155 | } |
| 3156 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3157 | 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] | 3158 | spec->multiout.num_dacs, |
| 3159 | spec->multiout.dac_nids[0], |
| 3160 | spec->multiout.dac_nids[1], |
| 3161 | spec->multiout.dac_nids[2], |
| 3162 | spec->multiout.dac_nids[3], |
| 3163 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3164 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3165 | return 0; |
| 3166 | } |
| 3167 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3168 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3169 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 3170 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3171 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3172 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3173 | char name[32]; |
| 3174 | int err; |
| 3175 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3176 | if (!spec->check_volume_offset) { |
| 3177 | unsigned int caps, step, nums, db_scale; |
| 3178 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3179 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 3180 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 3181 | step = (step + 1) * 25; /* in .01dB unit */ |
| 3182 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 3183 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3184 | db_scale = nums * step; |
| 3185 | /* if dB scale is over -64dB, and finer enough, |
| 3186 | * let's reduce it to half |
| 3187 | */ |
| 3188 | if (db_scale > 6400 && nums >= 0x1f) |
| 3189 | spec->volume_offset = nums / 2; |
| 3190 | spec->check_volume_offset = 1; |
| 3191 | } |
| 3192 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3193 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3194 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3195 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3196 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3197 | if (err < 0) |
| 3198 | return err; |
| 3199 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3200 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3201 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3202 | if (err < 0) |
| 3203 | return err; |
| 3204 | return 0; |
| 3205 | } |
| 3206 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3207 | #define create_controls(codec, pfx, nid, chs) \ |
| 3208 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 3209 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3210 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3211 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3212 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3213 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3214 | return 1; |
| 3215 | } else { |
| 3216 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3217 | spec->multiout.num_dacs++; |
| 3218 | } |
| 3219 | return 0; |
| 3220 | } |
| 3221 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3222 | 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] | 3223 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3224 | int i; |
| 3225 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3226 | if (!spec->multiout.extra_out_nid[i]) { |
| 3227 | spec->multiout.extra_out_nid[i] = nid; |
| 3228 | return 0; |
| 3229 | } |
| 3230 | } |
| 3231 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3232 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3233 | } |
| 3234 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3235 | /* Create output controls |
| 3236 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3237 | */ |
| 3238 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3239 | const hda_nid_t *pins, |
| 3240 | const hda_nid_t *dac_nids, |
| 3241 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3242 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3243 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3244 | static const char *chname[4] = { |
| 3245 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3246 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3247 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3248 | int i, err; |
| 3249 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3250 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3251 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 3252 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3253 | wid_caps = get_wcaps(codec, pins[i]); |
| 3254 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3255 | spec->hp_detect = 1; |
| 3256 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3257 | nid = dac_nids[i]; |
| 3258 | if (!nid) |
| 3259 | continue; |
| 3260 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3261 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3262 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3263 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3264 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3265 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3266 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3267 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3268 | |
| 3269 | wid_caps = get_wcaps(codec, nid); |
| 3270 | |
| 3271 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3272 | err = stac92xx_add_control(spec, |
| 3273 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3274 | "Swap Center/LFE Playback Switch", nid); |
| 3275 | |
| 3276 | if (err < 0) |
| 3277 | return err; |
| 3278 | } |
| 3279 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3280 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3281 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3282 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3283 | switch (type) { |
| 3284 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3285 | name = "Headphone"; |
| 3286 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3287 | break; |
| 3288 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3289 | name = "Speaker"; |
| 3290 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3291 | break; |
| 3292 | default: |
| 3293 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3294 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3295 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3296 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3297 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3298 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3299 | return err; |
| 3300 | } |
| 3301 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3302 | return 0; |
| 3303 | } |
| 3304 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3305 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, |
| 3306 | unsigned long sw, int idx) |
| 3307 | { |
| 3308 | int err; |
| 3309 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, |
| 3310 | "Captuer Volume", vol); |
| 3311 | if (err < 0) |
| 3312 | return err; |
| 3313 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, |
| 3314 | "Captuer Switch", sw); |
| 3315 | if (err < 0) |
| 3316 | return err; |
| 3317 | return 0; |
| 3318 | } |
| 3319 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3320 | /* add playback controls from the parsed DAC table */ |
| 3321 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3322 | const struct auto_pin_cfg *cfg) |
| 3323 | { |
| 3324 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3325 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3326 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3327 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3328 | |
| 3329 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3330 | spec->multiout.dac_nids, |
| 3331 | cfg->line_out_type); |
| 3332 | if (err < 0) |
| 3333 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3334 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3335 | 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] | 3336 | err = stac92xx_add_control(spec, |
| 3337 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3338 | "Headphone as Line Out Switch", |
| 3339 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3340 | if (err < 0) |
| 3341 | return err; |
| 3342 | } |
| 3343 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3344 | for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { |
| 3345 | nid = cfg->input_pins[idx]; |
| 3346 | if (nid) { |
| 3347 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 3348 | if (err < 0) |
| 3349 | return err; |
| 3350 | } |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3351 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3352 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3353 | return 0; |
| 3354 | } |
| 3355 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3356 | /* add playback controls for Speaker and HP outputs */ |
| 3357 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3358 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3359 | { |
| 3360 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3361 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3362 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3363 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3364 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3365 | if (err < 0) |
| 3366 | return err; |
| 3367 | |
| 3368 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3369 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3370 | if (err < 0) |
| 3371 | return err; |
| 3372 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3373 | return 0; |
| 3374 | } |
| 3375 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3376 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3377 | static const char *stac92xx_mono_labels[4] = { |
| 3378 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3379 | }; |
| 3380 | |
| 3381 | /* create mono mux for mono out on capable codecs */ |
| 3382 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3383 | { |
| 3384 | struct sigmatel_spec *spec = codec->spec; |
| 3385 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3386 | int i, num_cons; |
| 3387 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3388 | |
| 3389 | num_cons = snd_hda_get_connections(codec, |
| 3390 | spec->mono_nid, |
| 3391 | con_lst, |
| 3392 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3393 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3394 | return -EINVAL; |
| 3395 | |
| 3396 | for (i = 0; i < num_cons; i++) { |
| 3397 | mono_mux->items[mono_mux->num_items].label = |
| 3398 | stac92xx_mono_labels[i]; |
| 3399 | mono_mux->items[mono_mux->num_items].index = i; |
| 3400 | mono_mux->num_items++; |
| 3401 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3402 | |
| 3403 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3404 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3405 | } |
| 3406 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3407 | /* labels for amp mux outputs */ |
| 3408 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3409 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3410 | }; |
| 3411 | |
| 3412 | /* create amp out controls mux on capable codecs */ |
| 3413 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3414 | { |
| 3415 | struct sigmatel_spec *spec = codec->spec; |
| 3416 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3417 | int i, err; |
| 3418 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3419 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3420 | amp_mux->items[amp_mux->num_items].label = |
| 3421 | stac92xx_amp_labels[i]; |
| 3422 | amp_mux->items[amp_mux->num_items].index = i; |
| 3423 | amp_mux->num_items++; |
| 3424 | } |
| 3425 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3426 | if (spec->num_amps > 1) { |
| 3427 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3428 | "Amp Selector Capture Switch", 0); |
| 3429 | if (err < 0) |
| 3430 | return err; |
| 3431 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3432 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3433 | "Amp Capture Volume", |
| 3434 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3435 | } |
| 3436 | |
| 3437 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3438 | /* create PC beep volume controls */ |
| 3439 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3440 | hda_nid_t nid) |
| 3441 | { |
| 3442 | struct sigmatel_spec *spec = codec->spec; |
| 3443 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3444 | int err; |
| 3445 | |
| 3446 | /* check for mute support for the the amp */ |
| 3447 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3448 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3449 | "PC Beep Playback Switch", |
| 3450 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3451 | if (err < 0) |
| 3452 | return err; |
| 3453 | } |
| 3454 | |
| 3455 | /* check to see if there is volume support for the amp */ |
| 3456 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3457 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3458 | "PC Beep Playback Volume", |
| 3459 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3460 | if (err < 0) |
| 3461 | return err; |
| 3462 | } |
| 3463 | return 0; |
| 3464 | } |
| 3465 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3466 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3467 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3468 | |
| 3469 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3470 | struct snd_ctl_elem_value *ucontrol) |
| 3471 | { |
| 3472 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3473 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3474 | return 0; |
| 3475 | } |
| 3476 | |
| 3477 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3478 | struct snd_ctl_elem_value *ucontrol) |
| 3479 | { |
| 3480 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3481 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3482 | if (codec->beep->enabled != enabled) { |
| 3483 | codec->beep->enabled = enabled; |
| 3484 | return 1; |
| 3485 | } |
| 3486 | return 0; |
| 3487 | } |
| 3488 | |
| 3489 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3490 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3491 | .info = stac92xx_dig_beep_switch_info, |
| 3492 | .get = stac92xx_dig_beep_switch_get, |
| 3493 | .put = stac92xx_dig_beep_switch_put, |
| 3494 | }; |
| 3495 | |
| 3496 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3497 | { |
| 3498 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3499 | 0, "PC Beep Playback Switch", 0); |
| 3500 | } |
| 3501 | #endif |
| 3502 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3503 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3504 | { |
| 3505 | struct sigmatel_spec *spec = codec->spec; |
| 3506 | int wcaps, nid, i, err = 0; |
| 3507 | |
| 3508 | for (i = 0; i < spec->num_muxes; i++) { |
| 3509 | nid = spec->mux_nids[i]; |
| 3510 | wcaps = get_wcaps(codec, nid); |
| 3511 | |
| 3512 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3513 | err = stac92xx_add_control_idx(spec, |
| 3514 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3515 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3516 | if (err < 0) |
| 3517 | return err; |
| 3518 | } |
| 3519 | } |
| 3520 | return 0; |
| 3521 | }; |
| 3522 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3523 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3524 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3525 | }; |
| 3526 | |
| 3527 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3528 | { |
| 3529 | struct sigmatel_spec *spec = codec->spec; |
| 3530 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3531 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3532 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3533 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3534 | |
| 3535 | num_cons = snd_hda_get_connections(codec, |
| 3536 | spec->smux_nids[0], |
| 3537 | con_lst, |
| 3538 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3539 | if (num_cons <= 0) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3540 | return -EINVAL; |
| 3541 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3542 | if (!labels) |
| 3543 | labels = stac92xx_spdif_labels; |
| 3544 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3545 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3546 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3547 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3548 | spdif_mux->num_items++; |
| 3549 | } |
| 3550 | |
| 3551 | return 0; |
| 3552 | } |
| 3553 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3554 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3555 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3556 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3557 | "Digital Mic 3", "Digital Mic 4" |
| 3558 | }; |
| 3559 | |
| 3560 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3561 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3562 | const struct auto_pin_cfg *cfg) |
| 3563 | { |
| 3564 | struct sigmatel_spec *spec = codec->spec; |
| 3565 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3566 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3567 | int err, i, j; |
| 3568 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3569 | |
| 3570 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3571 | dimux->items[dimux->num_items].index = 0; |
| 3572 | dimux->num_items++; |
| 3573 | |
| 3574 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3575 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3576 | int index; |
| 3577 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3578 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3579 | unsigned int def_conf; |
| 3580 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3581 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3582 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3583 | continue; |
| 3584 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3585 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3586 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3587 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3588 | con_lst, |
| 3589 | HDA_MAX_NUM_INPUTS); |
| 3590 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3591 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3592 | index = j; |
| 3593 | goto found; |
| 3594 | } |
| 3595 | continue; |
| 3596 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3597 | wcaps = get_wcaps(codec, nid) & |
| 3598 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3599 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3600 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3601 | sprintf(name, "%s Capture Volume", |
| 3602 | stac92xx_dmic_labels[dimux->num_items]); |
| 3603 | |
| 3604 | err = stac92xx_add_control(spec, |
| 3605 | STAC_CTL_WIDGET_VOL, |
| 3606 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3607 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3608 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3609 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3610 | if (err < 0) |
| 3611 | return err; |
| 3612 | } |
| 3613 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3614 | dimux->items[dimux->num_items].label = |
| 3615 | stac92xx_dmic_labels[dimux->num_items]; |
| 3616 | dimux->items[dimux->num_items].index = index; |
| 3617 | dimux->num_items++; |
| 3618 | } |
| 3619 | |
| 3620 | return 0; |
| 3621 | } |
| 3622 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3623 | /* create playback/capture controls for input pins */ |
| 3624 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3625 | { |
| 3626 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3627 | struct hda_input_mux *imux = &spec->private_imux; |
| 3628 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3629 | int i, j, k; |
| 3630 | |
| 3631 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3632 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3633 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3634 | if (!cfg->input_pins[i]) |
| 3635 | continue; |
| 3636 | index = -1; |
| 3637 | for (j = 0; j < spec->num_muxes; j++) { |
| 3638 | int num_cons; |
| 3639 | num_cons = snd_hda_get_connections(codec, |
| 3640 | spec->mux_nids[j], |
| 3641 | con_lst, |
| 3642 | HDA_MAX_NUM_INPUTS); |
| 3643 | for (k = 0; k < num_cons; k++) |
| 3644 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3645 | index = k; |
| 3646 | goto found; |
| 3647 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3648 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3649 | continue; |
| 3650 | found: |
| 3651 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3652 | imux->items[imux->num_items].index = index; |
| 3653 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3654 | } |
| 3655 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3656 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3657 | /* |
| 3658 | * Set the current input for the muxes. |
| 3659 | * The STAC9221 has two input muxes with identical source |
| 3660 | * NID lists. Hopefully this won't get confused. |
| 3661 | */ |
| 3662 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3663 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3664 | AC_VERB_SET_CONNECT_SEL, |
| 3665 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3666 | } |
| 3667 | } |
| 3668 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3669 | return 0; |
| 3670 | } |
| 3671 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3672 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3673 | { |
| 3674 | struct sigmatel_spec *spec = codec->spec; |
| 3675 | int i; |
| 3676 | |
| 3677 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3678 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3679 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3680 | } |
| 3681 | } |
| 3682 | |
| 3683 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3684 | { |
| 3685 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3686 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3687 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3688 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3689 | hda_nid_t pin; |
| 3690 | pin = spec->autocfg.hp_pins[i]; |
| 3691 | if (pin) /* connect to front */ |
| 3692 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3693 | } |
| 3694 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3695 | hda_nid_t pin; |
| 3696 | pin = spec->autocfg.speaker_pins[i]; |
| 3697 | if (pin) /* connect to front */ |
| 3698 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3699 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3700 | } |
| 3701 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3702 | 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] | 3703 | { |
| 3704 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3705 | int hp_swap = 0; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3706 | int i, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3707 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3708 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3709 | &spec->autocfg, |
| 3710 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3711 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3712 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3713 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3714 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3715 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3716 | * be set up as multi-channel outputs. |
| 3717 | */ |
| 3718 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3719 | spec->autocfg.hp_outs > 1) { |
| 3720 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3721 | * speaker_outs so that the following routines can handle |
| 3722 | * HP pins as primary outputs. |
| 3723 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3724 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3725 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3726 | sizeof(spec->autocfg.line_out_pins)); |
| 3727 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3728 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3729 | sizeof(spec->autocfg.hp_pins)); |
| 3730 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3731 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3732 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3733 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3734 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3735 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3736 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3737 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3738 | u32 caps = query_amp_caps(codec, |
| 3739 | spec->autocfg.mono_out_pin, dir); |
| 3740 | hda_nid_t conn_list[1]; |
| 3741 | |
| 3742 | /* get the mixer node and then the mono mux if it exists */ |
| 3743 | if (snd_hda_get_connections(codec, |
| 3744 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3745 | snd_hda_get_connections(codec, conn_list[0], |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3746 | conn_list, 1) > 0) { |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3747 | |
| 3748 | int wcaps = get_wcaps(codec, conn_list[0]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3749 | int wid_type = get_wcaps_type(wcaps); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3750 | /* LR swap check, some stac925x have a mux that |
| 3751 | * changes the DACs output path instead of the |
| 3752 | * mono-mux path. |
| 3753 | */ |
| 3754 | if (wid_type == AC_WID_AUD_SEL && |
| 3755 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3756 | spec->mono_nid = conn_list[0]; |
| 3757 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3758 | if (dir) { |
| 3759 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3760 | |
| 3761 | /* most mono outs have a least a mute/unmute switch */ |
| 3762 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3763 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3764 | "Mono Playback Switch", |
| 3765 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3766 | if (err < 0) |
| 3767 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3768 | /* check for volume support for the amp */ |
| 3769 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3770 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3771 | err = stac92xx_add_control(spec, |
| 3772 | STAC_CTL_WIDGET_VOL, |
| 3773 | "Mono Playback Volume", |
| 3774 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3775 | if (err < 0) |
| 3776 | return err; |
| 3777 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3778 | } |
| 3779 | |
| 3780 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3781 | AC_PINCTL_OUT_EN); |
| 3782 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3783 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3784 | if (!spec->multiout.num_dacs) { |
| 3785 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3786 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3787 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3788 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3789 | &spec->autocfg); |
| 3790 | if (err < 0) |
| 3791 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3792 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3793 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3794 | /* setup analog beep controls */ |
| 3795 | if (spec->anabeep_nid > 0) { |
| 3796 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3797 | spec->anabeep_nid); |
| 3798 | if (err < 0) |
| 3799 | return err; |
| 3800 | } |
| 3801 | |
| 3802 | /* setup digital beep controls and input device */ |
| 3803 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3804 | if (spec->digbeep_nid > 0) { |
| 3805 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3806 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3807 | |
| 3808 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3809 | if (err < 0) |
| 3810 | return err; |
| 3811 | err = snd_hda_attach_beep_device(codec, nid); |
| 3812 | if (err < 0) |
| 3813 | return err; |
Takashi Iwai | fa79796 | 2009-05-19 12:50:04 +0200 | [diff] [blame] | 3814 | /* IDT/STAC codecs have linear beep tone parameter */ |
| 3815 | codec->beep->linear_tone = 1; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3816 | /* if no beep switch is available, make its own one */ |
| 3817 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3818 | if (codec->beep && |
| 3819 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3820 | err = stac92xx_beep_switch_ctl(codec); |
| 3821 | if (err < 0) |
| 3822 | return err; |
| 3823 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3824 | } |
| 3825 | #endif |
| 3826 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3827 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3828 | if (err < 0) |
| 3829 | return err; |
| 3830 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3831 | /* All output parsing done, now restore the swapped hp pins */ |
| 3832 | if (hp_swap) { |
| 3833 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3834 | sizeof(spec->autocfg.hp_pins)); |
| 3835 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3836 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3837 | spec->autocfg.line_outs = 0; |
| 3838 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3839 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3840 | for (i = 0; i < spec->num_caps; i++) { |
| 3841 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], |
| 3842 | spec->capsws[i], i); |
| 3843 | if (err < 0) |
| 3844 | return err; |
| 3845 | } |
| 3846 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3847 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3848 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3849 | return err; |
| 3850 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3851 | if (spec->mono_nid > 0) { |
| 3852 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3853 | if (err < 0) |
| 3854 | return err; |
| 3855 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3856 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3857 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3858 | if (err < 0) |
| 3859 | return err; |
| 3860 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3861 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3862 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3863 | &spec->autocfg)) < 0) |
| 3864 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3865 | if (spec->num_muxes > 0) { |
| 3866 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3867 | if (err < 0) |
| 3868 | return err; |
| 3869 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3870 | if (spec->num_smuxes > 0) { |
| 3871 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3872 | if (err < 0) |
| 3873 | return err; |
| 3874 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3875 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3876 | err = stac92xx_add_input_source(spec); |
| 3877 | if (err < 0) |
| 3878 | return err; |
| 3879 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3880 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3881 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3882 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3883 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3884 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3885 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3886 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3887 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3888 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3889 | if (spec->kctls.list) |
| 3890 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3891 | |
| 3892 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3893 | if (!spec->dinput_mux) |
| 3894 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3895 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3896 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3897 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3898 | return 1; |
| 3899 | } |
| 3900 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3901 | /* add playback controls for HP output */ |
| 3902 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3903 | struct auto_pin_cfg *cfg) |
| 3904 | { |
| 3905 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3906 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3907 | unsigned int wid_caps; |
| 3908 | |
| 3909 | if (! pin) |
| 3910 | return 0; |
| 3911 | |
| 3912 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3913 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3914 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3915 | |
| 3916 | return 0; |
| 3917 | } |
| 3918 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3919 | /* add playback controls for LFE output */ |
| 3920 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3921 | struct auto_pin_cfg *cfg) |
| 3922 | { |
| 3923 | struct sigmatel_spec *spec = codec->spec; |
| 3924 | int err; |
| 3925 | hda_nid_t lfe_pin = 0x0; |
| 3926 | int i; |
| 3927 | |
| 3928 | /* |
| 3929 | * search speaker outs and line outs for a mono speaker pin |
| 3930 | * with an amp. If one is found, add LFE controls |
| 3931 | * for it. |
| 3932 | */ |
| 3933 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3934 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3935 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3936 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3937 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3938 | /* found a mono speaker with an amp, must be lfe */ |
| 3939 | lfe_pin = pin; |
| 3940 | } |
| 3941 | |
| 3942 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3943 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3944 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3945 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3946 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3947 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3948 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3949 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3950 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3951 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3952 | /* found a mono speaker with an amp, |
| 3953 | must be lfe */ |
| 3954 | lfe_pin = pin; |
| 3955 | } |
| 3956 | } |
| 3957 | } |
| 3958 | |
| 3959 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3960 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3961 | if (err < 0) |
| 3962 | return err; |
| 3963 | } |
| 3964 | |
| 3965 | return 0; |
| 3966 | } |
| 3967 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3968 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3969 | { |
| 3970 | struct sigmatel_spec *spec = codec->spec; |
| 3971 | int err; |
| 3972 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3973 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3974 | return err; |
| 3975 | |
| 3976 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3977 | return err; |
| 3978 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3979 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3980 | return err; |
| 3981 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3982 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3983 | return err; |
| 3984 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3985 | if (spec->num_muxes > 0) { |
| 3986 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3987 | if (err < 0) |
| 3988 | return err; |
| 3989 | } |
| 3990 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3991 | err = stac92xx_add_input_source(spec); |
| 3992 | if (err < 0) |
| 3993 | return err; |
| 3994 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3995 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3996 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3997 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3998 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3999 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4000 | if (spec->kctls.list) |
| 4001 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4002 | |
| 4003 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4004 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4005 | |
| 4006 | return 1; |
| 4007 | } |
| 4008 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4009 | /* |
| 4010 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 4011 | * funky external mute control using GPIO pins. |
| 4012 | */ |
| 4013 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4014 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4015 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4016 | { |
| 4017 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4018 | |
| 4019 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4020 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4021 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4022 | |
| 4023 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4024 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4025 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4026 | |
| 4027 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4028 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4029 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4030 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4031 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4032 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 4033 | |
| 4034 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4035 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4036 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4037 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4038 | |
| 4039 | msleep(1); |
| 4040 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4041 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4042 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4043 | } |
| 4044 | |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4045 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4046 | static void stac92xx_free_jack_priv(struct snd_jack *jack) |
| 4047 | { |
| 4048 | struct sigmatel_jack *jacks = jack->private_data; |
| 4049 | jacks->nid = 0; |
| 4050 | jacks->jack = NULL; |
| 4051 | } |
| 4052 | #endif |
| 4053 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4054 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 4055 | hda_nid_t nid, int type) |
| 4056 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4057 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4058 | struct sigmatel_spec *spec = codec->spec; |
| 4059 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4060 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4061 | int connectivity = get_defcfg_connect(def_conf); |
| 4062 | char name[32]; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4063 | int err; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4064 | |
| 4065 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 4066 | return 0; |
| 4067 | |
| 4068 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 4069 | jack = snd_array_new(&spec->jacks); |
| 4070 | if (!jack) |
| 4071 | return -ENOMEM; |
| 4072 | jack->nid = nid; |
| 4073 | jack->type = type; |
| 4074 | |
Takashi Iwai | 86de741 | 2009-07-22 16:02:46 +0200 | [diff] [blame] | 4075 | snprintf(name, sizeof(name), "%s at %s %s Jack", |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4076 | snd_hda_get_jack_type(def_conf), |
| 4077 | snd_hda_get_jack_connectivity(def_conf), |
| 4078 | snd_hda_get_jack_location(def_conf)); |
| 4079 | |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4080 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
| 4081 | if (err < 0) { |
| 4082 | jack->nid = 0; |
| 4083 | return err; |
| 4084 | } |
| 4085 | jack->jack->private_data = jack; |
| 4086 | jack->jack->private_free = stac92xx_free_jack_priv; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4087 | #endif |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4088 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4089 | } |
| 4090 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4091 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 4092 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4093 | { |
| 4094 | struct sigmatel_event *event; |
| 4095 | |
| 4096 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 4097 | event = snd_array_new(&spec->events); |
| 4098 | if (!event) |
| 4099 | return -ENOMEM; |
| 4100 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4101 | event->type = type; |
| 4102 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4103 | event->data = data; |
| 4104 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4105 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4106 | } |
| 4107 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4108 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4109 | hda_nid_t nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4110 | { |
| 4111 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4112 | struct sigmatel_event *event = spec->events.list; |
| 4113 | int i; |
| 4114 | |
| 4115 | for (i = 0; i < spec->events.used; i++, event++) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4116 | if (event->nid == nid) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4117 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4118 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4119 | return NULL; |
| 4120 | } |
| 4121 | |
| 4122 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 4123 | unsigned char tag) |
| 4124 | { |
| 4125 | struct sigmatel_spec *spec = codec->spec; |
| 4126 | struct sigmatel_event *event = spec->events.list; |
| 4127 | int i; |
| 4128 | |
| 4129 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4130 | if (event->tag == tag) |
| 4131 | return event; |
| 4132 | } |
| 4133 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4134 | } |
| 4135 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4136 | /* check if given nid is a valid pin and no other events are assigned |
| 4137 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
| 4138 | * Otherwise, returns zero. |
| 4139 | */ |
| 4140 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 4141 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4142 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4143 | struct sigmatel_event *event; |
| 4144 | int tag; |
| 4145 | |
| 4146 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4147 | return 0; |
| 4148 | event = stac_get_event(codec, nid); |
| 4149 | if (event) { |
| 4150 | if (event->type != type) |
| 4151 | return 0; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4152 | tag = event->tag; |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4153 | } else { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4154 | tag = stac_add_event(codec->spec, nid, type, 0); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4155 | if (tag < 0) |
| 4156 | return 0; |
| 4157 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4158 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4159 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4160 | AC_USRSP_EN | tag); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4161 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4162 | } |
| 4163 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4164 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 4165 | { |
| 4166 | int i; |
| 4167 | for (i = 0; i < cfg->hp_outs; i++) |
| 4168 | if (cfg->hp_pins[i] == nid) |
| 4169 | return 1; /* nid is a HP-Out */ |
| 4170 | |
| 4171 | return 0; /* nid is not a HP-Out */ |
| 4172 | }; |
| 4173 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4174 | static void stac92xx_power_down(struct hda_codec *codec) |
| 4175 | { |
| 4176 | struct sigmatel_spec *spec = codec->spec; |
| 4177 | |
| 4178 | /* power down inactive DACs */ |
| 4179 | hda_nid_t *dac; |
| 4180 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4181 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4182 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4183 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4184 | } |
| 4185 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4186 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4187 | int enable); |
| 4188 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4189 | /* override some hints from the hwdep entry */ |
| 4190 | static void stac_store_hints(struct hda_codec *codec) |
| 4191 | { |
| 4192 | struct sigmatel_spec *spec = codec->spec; |
| 4193 | const char *p; |
| 4194 | int val; |
| 4195 | |
| 4196 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 4197 | if (val >= 0) |
| 4198 | spec->hp_detect = val; |
| 4199 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 4200 | if (p) { |
| 4201 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 4202 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 4203 | spec->gpio_mask; |
| 4204 | } |
| 4205 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 4206 | if (p) |
| 4207 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4208 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 4209 | if (p) |
| 4210 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4211 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 4212 | if (p) |
| 4213 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4214 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 4215 | if (val >= 0) |
| 4216 | spec->eapd_switch = val; |
| 4217 | } |
| 4218 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4219 | static int stac92xx_init(struct hda_codec *codec) |
| 4220 | { |
| 4221 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4222 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4223 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4224 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4225 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4226 | snd_hda_sequence_write(codec, spec->init); |
| 4227 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4228 | /* power down adcs initially */ |
| 4229 | if (spec->powerdown_adcs) |
| 4230 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4231 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4232 | spec->adc_nids[i], 0, |
| 4233 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4234 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4235 | /* override some hints */ |
| 4236 | stac_store_hints(codec); |
| 4237 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4238 | /* set up GPIO */ |
| 4239 | gpio = spec->gpio_data; |
| 4240 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4241 | * otherwise, unsol event will turn it on/off dynamically |
| 4242 | */ |
| 4243 | if (!spec->eapd_switch) |
| 4244 | gpio |= spec->eapd_mask; |
| 4245 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4246 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4247 | /* set up pins */ |
| 4248 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4249 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4250 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4251 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4252 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4253 | } |
Takashi Iwai | 0a07aca | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4254 | /* force to enable the first line-out; the others are set up |
| 4255 | * in unsol_event |
| 4256 | */ |
| 4257 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4258 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4259 | /* fake event to set up pins */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4260 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4261 | } else { |
| 4262 | stac92xx_auto_init_multi_out(codec); |
| 4263 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4264 | for (i = 0; i < cfg->hp_outs; i++) |
| 4265 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4266 | } |
| 4267 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4268 | hda_nid_t nid = cfg->input_pins[i]; |
| 4269 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4270 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4271 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4272 | /* for mic pins, force to initialize */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4273 | pinctl = stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4274 | pinctl |= AC_PINCTL_IN_EN; |
| 4275 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4276 | } else { |
| 4277 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4278 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4279 | /* if PINCTL already set then skip */ |
Takashi Iwai | 5dd17cb9 | 2009-05-07 16:22:53 +0200 | [diff] [blame] | 4280 | /* Also, if both INPUT and OUTPUT are set, |
| 4281 | * it must be a BIOS bug; need to override, too |
| 4282 | */ |
| 4283 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 4284 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 4285 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4286 | pinctl |= AC_PINCTL_IN_EN; |
| 4287 | stac92xx_auto_set_pinctl(codec, nid, |
| 4288 | pinctl); |
| 4289 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4290 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4291 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4292 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4293 | if (enable_pin_detect(codec, nid, |
| 4294 | STAC_INSERT_EVENT)) |
| 4295 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4296 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4297 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4298 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4299 | for (i = 0; i < spec->num_dmics; i++) |
| 4300 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4301 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4302 | if (cfg->dig_out_pins[0]) |
| 4303 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4304 | AC_PINCTL_OUT_EN); |
| 4305 | if (cfg->dig_in_pin) |
| 4306 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4307 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4308 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4309 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4310 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4311 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4312 | /* power on when no jack detection is available */ |
| 4313 | if (!spec->hp_detect) { |
| 4314 | stac_toggle_power_map(codec, nid, 1); |
| 4315 | continue; |
| 4316 | } |
| 4317 | |
| 4318 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4319 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4320 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4321 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4322 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4323 | /* outputs are only ports capable of power management |
| 4324 | * any attempts on powering down a input port cause the |
| 4325 | * referenced VREF to act quirky. |
| 4326 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4327 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4328 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4329 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4330 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4331 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4332 | def_conf = get_defcfg_connect(def_conf); |
| 4333 | /* skip any ports that don't have jacks since presence |
| 4334 | * detection is useless */ |
| 4335 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4336 | if (def_conf != AC_JACK_PORT_NONE) |
| 4337 | stac_toggle_power_map(codec, nid, 1); |
| 4338 | continue; |
| 4339 | } |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4340 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) |
| 4341 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4342 | } |
| 4343 | if (spec->dac_list) |
| 4344 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4345 | return 0; |
| 4346 | } |
| 4347 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4348 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4349 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4350 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4351 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4352 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4353 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4354 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4355 | int i; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4356 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
| 4357 | if (jacks->jack) |
| 4358 | snd_device_free(codec->bus->card, jacks->jack); |
| 4359 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4360 | } |
| 4361 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4362 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4363 | } |
| 4364 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4365 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4366 | { |
| 4367 | struct sigmatel_spec *spec = codec->spec; |
| 4368 | |
| 4369 | if (spec->kctls.list) { |
| 4370 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4371 | int i; |
| 4372 | for (i = 0; i < spec->kctls.used; i++) |
| 4373 | kfree(kctl[i].name); |
| 4374 | } |
| 4375 | snd_array_free(&spec->kctls); |
| 4376 | } |
| 4377 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4378 | static void stac92xx_free(struct hda_codec *codec) |
| 4379 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4380 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4381 | |
| 4382 | if (! spec) |
| 4383 | return; |
| 4384 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4385 | stac92xx_free_jacks(codec); |
| 4386 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4387 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4388 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4389 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4390 | } |
| 4391 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4392 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4393 | unsigned int flag) |
| 4394 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4395 | unsigned int old_ctl, pin_ctl; |
| 4396 | |
| 4397 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4398 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4399 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4400 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4401 | /* |
| 4402 | * we need to check the current set-up direction of |
| 4403 | * shared input pins since they can be switched via |
| 4404 | * "xxx as Output" mixer switch |
| 4405 | */ |
| 4406 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4407 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4408 | return; |
| 4409 | } |
| 4410 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4411 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4412 | /* if setting pin direction bits, clear the current |
| 4413 | direction bits first */ |
| 4414 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4415 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4416 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4417 | pin_ctl |= flag; |
| 4418 | if (old_ctl != pin_ctl) |
| 4419 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4420 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4421 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4422 | } |
| 4423 | |
| 4424 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4425 | unsigned int flag) |
| 4426 | { |
| 4427 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4428 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4429 | if (pin_ctl & flag) |
| 4430 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4431 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4432 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4433 | } |
| 4434 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4435 | 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] | 4436 | { |
| 4437 | if (!nid) |
| 4438 | return 0; |
| 4439 | 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] | 4440 | & (1 << 31)) |
| 4441 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4442 | return 0; |
| 4443 | } |
| 4444 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4445 | /* return non-zero if the hp-pin of the given array index isn't |
| 4446 | * a jack-detection target |
| 4447 | */ |
| 4448 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4449 | { |
| 4450 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4451 | |
| 4452 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4453 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4454 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4455 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4456 | return 1; |
| 4457 | /* ignore if the pin is set as line-out */ |
| 4458 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4459 | return 1; |
| 4460 | return 0; |
| 4461 | } |
| 4462 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4463 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4464 | { |
| 4465 | struct sigmatel_spec *spec = codec->spec; |
| 4466 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4467 | int i, presence; |
| 4468 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4469 | presence = 0; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4470 | if (spec->gpio_mute) |
| 4471 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4472 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4473 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4474 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4475 | if (presence) |
| 4476 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4477 | if (no_hp_sensing(spec, i)) |
| 4478 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4479 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4480 | if (presence) { |
| 4481 | unsigned int pinctl; |
| 4482 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4483 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4484 | if (pinctl & AC_PINCTL_IN_EN) |
| 4485 | presence = 0; /* mic- or line-input */ |
| 4486 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4487 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4488 | |
| 4489 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4490 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4491 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4492 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4493 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4494 | for (i = 0; i < cfg->line_outs; i++) |
| 4495 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4496 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4497 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4498 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4499 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4500 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4501 | stac_gpio_set(codec, spec->gpio_mask, |
| 4502 | spec->gpio_dir, spec->gpio_data & |
| 4503 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4504 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4505 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4506 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4507 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4508 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4509 | for (i = 0; i < cfg->line_outs; i++) |
| 4510 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4511 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4512 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4513 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4514 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4515 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4516 | stac_gpio_set(codec, spec->gpio_mask, |
| 4517 | spec->gpio_dir, spec->gpio_data | |
| 4518 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4519 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4520 | /* toggle hp outs */ |
| 4521 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4522 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4523 | if (no_hp_sensing(spec, i)) |
| 4524 | continue; |
| 4525 | if (presence) |
| 4526 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4527 | #if 0 /* FIXME */ |
| 4528 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4529 | * on some devices since they use the HP pin actually for line/speaker |
| 4530 | * outs although the default pin config shows a different pin (that is |
| 4531 | * wrong and useless). |
| 4532 | * |
| 4533 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4534 | * But, disabling the code below just works around it, and I'm too tired of |
| 4535 | * bug reports with such devices... |
| 4536 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4537 | else |
| 4538 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4539 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4540 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4541 | } |
| 4542 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4543 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4544 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4545 | { |
| 4546 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4547 | unsigned int idx, val; |
| 4548 | |
| 4549 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4550 | if (spec->pwr_nids[idx] == nid) |
| 4551 | break; |
| 4552 | } |
| 4553 | if (idx >= spec->num_pwrs) |
| 4554 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4555 | |
| 4556 | /* several codecs have two power down bits */ |
| 4557 | if (spec->pwr_mapping) |
| 4558 | idx = spec->pwr_mapping[idx]; |
| 4559 | else |
| 4560 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4561 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4562 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4563 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4564 | val &= ~idx; |
| 4565 | else |
| 4566 | val |= idx; |
| 4567 | |
| 4568 | /* power down unused output ports */ |
| 4569 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4570 | } |
| 4571 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4572 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4573 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4574 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4575 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4576 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4577 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4578 | { |
| 4579 | struct sigmatel_spec *spec = codec->spec; |
| 4580 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4581 | |
| 4582 | if (jacks) { |
| 4583 | int i; |
| 4584 | for (i = 0; i < spec->jacks.used; i++) { |
| 4585 | if (jacks->nid == nid) { |
| 4586 | unsigned int pin_ctl = |
| 4587 | snd_hda_codec_read(codec, nid, |
| 4588 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4589 | 0x00); |
| 4590 | int type = jacks->type; |
| 4591 | if (type == (SND_JACK_LINEOUT |
| 4592 | | SND_JACK_HEADPHONE)) |
| 4593 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4594 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4595 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4596 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4597 | ? type : 0); |
| 4598 | } |
| 4599 | jacks++; |
| 4600 | } |
| 4601 | } |
| 4602 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4603 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4604 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4605 | { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4606 | struct sigmatel_event *event = stac_get_event(codec, nid); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4607 | if (!event) |
| 4608 | return; |
| 4609 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4610 | } |
| 4611 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4612 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4613 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4614 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4615 | struct sigmatel_event *event; |
| 4616 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4617 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4618 | tag = (res >> 26) & 0x7f; |
| 4619 | event = stac_get_event_from_tag(codec, tag); |
| 4620 | if (!event) |
| 4621 | return; |
| 4622 | |
| 4623 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4624 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4625 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4626 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4627 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4628 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4629 | if (spec->num_pwrs > 0) |
| 4630 | stac92xx_pin_sense(codec, event->nid); |
| 4631 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 4632 | |
| 4633 | switch (codec->subsystem_id) { |
| 4634 | case 0x103c308f: |
| 4635 | if (event->nid == 0xb) { |
| 4636 | int pin = AC_PINCTL_IN_EN; |
| 4637 | |
| 4638 | if (get_pin_presence(codec, 0xa) |
| 4639 | && get_pin_presence(codec, 0xb)) |
| 4640 | pin |= AC_PINCTL_VREF_80; |
| 4641 | if (!get_pin_presence(codec, 0xb)) |
| 4642 | pin |= AC_PINCTL_VREF_80; |
| 4643 | |
| 4644 | /* toggle VREF state based on mic + hp pin |
| 4645 | * status |
| 4646 | */ |
| 4647 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 4648 | } |
| 4649 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4650 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4651 | case STAC_VREF_EVENT: |
| 4652 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4653 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4654 | /* toggle VREF state based on GPIOx status */ |
| 4655 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4656 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4657 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4658 | } |
| 4659 | } |
| 4660 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4661 | #ifdef CONFIG_PROC_FS |
| 4662 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4663 | struct hda_codec *codec, hda_nid_t nid) |
| 4664 | { |
| 4665 | if (nid == codec->afg) |
| 4666 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4667 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4668 | } |
| 4669 | |
| 4670 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4671 | struct hda_codec *codec, |
| 4672 | unsigned int verb) |
| 4673 | { |
| 4674 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4675 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4676 | } |
| 4677 | |
| 4678 | /* stac92hd71bxx, stac92hd73xx */ |
| 4679 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4680 | struct hda_codec *codec, hda_nid_t nid) |
| 4681 | { |
| 4682 | stac92hd_proc_hook(buffer, codec, nid); |
| 4683 | if (nid == codec->afg) |
| 4684 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4685 | } |
| 4686 | |
| 4687 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4688 | struct hda_codec *codec, hda_nid_t nid) |
| 4689 | { |
| 4690 | if (nid == codec->afg) |
| 4691 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4692 | } |
| 4693 | |
| 4694 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4695 | struct hda_codec *codec, hda_nid_t nid) |
| 4696 | { |
| 4697 | if (nid == codec->afg) |
| 4698 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4699 | } |
| 4700 | #else |
| 4701 | #define stac92hd_proc_hook NULL |
| 4702 | #define stac92hd7x_proc_hook NULL |
| 4703 | #define stac9205_proc_hook NULL |
| 4704 | #define stac927x_proc_hook NULL |
| 4705 | #endif |
| 4706 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4707 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4708 | static int stac92xx_resume(struct hda_codec *codec) |
| 4709 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4710 | struct sigmatel_spec *spec = codec->spec; |
| 4711 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4712 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4713 | snd_hda_codec_resume_amp(codec); |
| 4714 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4715 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4716 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame^] | 4717 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4718 | return 0; |
| 4719 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4720 | |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4721 | /* |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4722 | * using power check for controlling mute led of HP notebooks |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4723 | * check for mute state only on Speakers (nid = 0x10) |
| 4724 | * |
| 4725 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
| 4726 | * the LED is NOT working properly ! |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4727 | * |
| 4728 | * Changed name to reflect that it now works for any designated |
| 4729 | * model, not just HP HDX. |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4730 | */ |
| 4731 | |
| 4732 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4733 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4734 | hda_nid_t nid) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4735 | { |
| 4736 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4737 | |
| 4738 | if (nid == 0x10) { |
| 4739 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4740 | HDA_AMP_MUTE) |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 4741 | spec->gpio_data &= ~spec->gpio_led; /* orange */ |
Takashi Iwai | ba84bfc | 2009-05-30 08:59:03 +0200 | [diff] [blame] | 4742 | else |
| 4743 | spec->gpio_data |= spec->gpio_led; /* white */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4744 | |
| 4745 | stac_gpio_set(codec, spec->gpio_mask, |
| 4746 | spec->gpio_dir, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4747 | spec->gpio_data); |
| 4748 | } |
| 4749 | |
| 4750 | return 0; |
| 4751 | } |
| 4752 | #endif |
| 4753 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4754 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4755 | { |
| 4756 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4757 | int i; |
| 4758 | hda_nid_t nid; |
| 4759 | |
| 4760 | /* reset each pin before powering down DAC/ADC to avoid click noise */ |
| 4761 | nid = codec->start_nid; |
| 4762 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 4763 | unsigned int wcaps = get_wcaps(codec, nid); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 4764 | unsigned int wid_type = get_wcaps_type(wcaps); |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4765 | if (wid_type == AC_WID_PIN) |
| 4766 | snd_hda_codec_read(codec, nid, 0, |
| 4767 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); |
| 4768 | } |
| 4769 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4770 | if (spec->eapd_mask) |
| 4771 | stac_gpio_set(codec, spec->gpio_mask, |
| 4772 | spec->gpio_dir, spec->gpio_data & |
| 4773 | ~spec->eapd_mask); |
| 4774 | return 0; |
| 4775 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4776 | #endif |
| 4777 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4778 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4779 | .build_controls = stac92xx_build_controls, |
| 4780 | .build_pcms = stac92xx_build_pcms, |
| 4781 | .init = stac92xx_init, |
| 4782 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4783 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4784 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4785 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4786 | .resume = stac92xx_resume, |
| 4787 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4788 | }; |
| 4789 | |
| 4790 | static int patch_stac9200(struct hda_codec *codec) |
| 4791 | { |
| 4792 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4793 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4794 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4795 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4796 | if (spec == NULL) |
| 4797 | return -ENOMEM; |
| 4798 | |
| 4799 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4800 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4801 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4802 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4803 | stac9200_models, |
| 4804 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4805 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4806 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4807 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4808 | else |
| 4809 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4810 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4811 | |
| 4812 | spec->multiout.max_channels = 2; |
| 4813 | spec->multiout.num_dacs = 1; |
| 4814 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4815 | spec->adc_nids = stac9200_adc_nids; |
| 4816 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4817 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4818 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4819 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4820 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4821 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4822 | if (spec->board_config == STAC_9200_M4 || |
| 4823 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4824 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4825 | spec->init = stac9200_eapd_init; |
| 4826 | else |
| 4827 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4828 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4829 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4830 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4831 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4832 | spec->gpio_data = 0x00; |
| 4833 | } |
| 4834 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4835 | err = stac9200_parse_auto_config(codec); |
| 4836 | if (err < 0) { |
| 4837 | stac92xx_free(codec); |
| 4838 | return err; |
| 4839 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4840 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4841 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 4842 | * do detection and HP/speaker toggle because the hardware does it. |
| 4843 | */ |
| 4844 | if (spec->board_config == STAC_9200_PANASONIC) |
| 4845 | spec->hp_detect = 0; |
| 4846 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4847 | codec->patch_ops = stac92xx_patch_ops; |
| 4848 | |
| 4849 | return 0; |
| 4850 | } |
| 4851 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4852 | static int patch_stac925x(struct hda_codec *codec) |
| 4853 | { |
| 4854 | struct sigmatel_spec *spec; |
| 4855 | int err; |
| 4856 | |
| 4857 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4858 | if (spec == NULL) |
| 4859 | return -ENOMEM; |
| 4860 | |
| 4861 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4862 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4863 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4864 | |
| 4865 | /* Check first for codec ID */ |
| 4866 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4867 | STAC_925x_MODELS, |
| 4868 | stac925x_models, |
| 4869 | stac925x_codec_id_cfg_tbl); |
| 4870 | |
| 4871 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4872 | if (spec->board_config < 0) |
| 4873 | spec->board_config = snd_hda_check_board_config(codec, |
| 4874 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4875 | stac925x_models, |
| 4876 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4877 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4878 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4879 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4880 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4881 | else |
| 4882 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4883 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4884 | |
| 4885 | spec->multiout.max_channels = 2; |
| 4886 | spec->multiout.num_dacs = 1; |
| 4887 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4888 | spec->adc_nids = stac925x_adc_nids; |
| 4889 | spec->mux_nids = stac925x_mux_nids; |
| 4890 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4891 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4892 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4893 | switch (codec->vendor_id) { |
| 4894 | case 0x83847632: /* STAC9202 */ |
| 4895 | case 0x83847633: /* STAC9202D */ |
| 4896 | case 0x83847636: /* STAC9251 */ |
| 4897 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4898 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4899 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4900 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4901 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4902 | break; |
| 4903 | default: |
| 4904 | spec->num_dmics = 0; |
| 4905 | break; |
| 4906 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4907 | |
| 4908 | spec->init = stac925x_core_init; |
| 4909 | spec->mixer = stac925x_mixer; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4910 | spec->num_caps = 1; |
| 4911 | spec->capvols = stac925x_capvols; |
| 4912 | spec->capsws = stac925x_capsws; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4913 | |
| 4914 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4915 | if (!err) { |
| 4916 | if (spec->board_config < 0) { |
| 4917 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4918 | "available, default to model=ref\n"); |
| 4919 | spec->board_config = STAC_925x_REF; |
| 4920 | goto again; |
| 4921 | } |
| 4922 | err = -EINVAL; |
| 4923 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4924 | if (err < 0) { |
| 4925 | stac92xx_free(codec); |
| 4926 | return err; |
| 4927 | } |
| 4928 | |
| 4929 | codec->patch_ops = stac92xx_patch_ops; |
| 4930 | |
| 4931 | return 0; |
| 4932 | } |
| 4933 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4934 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4935 | .num_items = 4, |
| 4936 | .items = { |
| 4937 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4938 | { "Digital Mic 1", 0x09 }, |
| 4939 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4940 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4941 | } |
| 4942 | }; |
| 4943 | |
| 4944 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4945 | { |
| 4946 | struct sigmatel_spec *spec; |
| 4947 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4948 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4949 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4950 | |
| 4951 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4952 | if (spec == NULL) |
| 4953 | return -ENOMEM; |
| 4954 | |
| 4955 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4956 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4957 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4958 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4959 | spec->board_config = snd_hda_check_board_config(codec, |
| 4960 | STAC_92HD73XX_MODELS, |
| 4961 | stac92hd73xx_models, |
| 4962 | stac92hd73xx_cfg_tbl); |
| 4963 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4964 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4965 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 4966 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4967 | else |
| 4968 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4969 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4970 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4971 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4972 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4973 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4974 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4975 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4976 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4977 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4978 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4979 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4980 | case 0x3: /* 6 Channel */ |
| 4981 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4982 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4983 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4984 | break; |
| 4985 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4986 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4987 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4988 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4989 | break; |
| 4990 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4991 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4992 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4993 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 4994 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4995 | } |
| 4996 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4997 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4998 | spec->aloopback_mask = 0x01; |
| 4999 | spec->aloopback_shift = 8; |
| 5000 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5001 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5002 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 5003 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 5004 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 5005 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5006 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 5007 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5008 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5009 | |
| 5010 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 5011 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5012 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5013 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 5014 | sizeof(stac92hd73xx_dmux)); |
| 5015 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5016 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
| 5017 | spec->capvols = stac92hd73xx_capvols; |
| 5018 | spec->capsws = stac92hd73xx_capsws; |
| 5019 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5020 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5021 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 5022 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5023 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5024 | case STAC_DELL_M6_AMIC: |
| 5025 | case STAC_DELL_M6_DMIC: |
| 5026 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5027 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5028 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 5029 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5030 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5031 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5032 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5033 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5034 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5035 | switch (spec->board_config) { |
| 5036 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5037 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5038 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5039 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5040 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5041 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5042 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5043 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5044 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5045 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5046 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5047 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 5048 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5049 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5050 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5051 | break; |
| 5052 | } |
| 5053 | break; |
| 5054 | default: |
| 5055 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5056 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5057 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5058 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5059 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 5060 | /* GPIO0 High = Enable EAPD */ |
| 5061 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 5062 | spec->gpio_data = 0x01; |
| 5063 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5064 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5065 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5066 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 5067 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 5068 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5069 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5070 | |
| 5071 | if (!err) { |
| 5072 | if (spec->board_config < 0) { |
| 5073 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5074 | "available, default to model=ref\n"); |
| 5075 | spec->board_config = STAC_92HD73XX_REF; |
| 5076 | goto again; |
| 5077 | } |
| 5078 | err = -EINVAL; |
| 5079 | } |
| 5080 | |
| 5081 | if (err < 0) { |
| 5082 | stac92xx_free(codec); |
| 5083 | return err; |
| 5084 | } |
| 5085 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 5086 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 5087 | spec->hp_detect = 0; |
| 5088 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5089 | codec->patch_ops = stac92xx_patch_ops; |
| 5090 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5091 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5092 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5093 | return 0; |
| 5094 | } |
| 5095 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5096 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 5097 | .num_items = 3, |
| 5098 | .items = { |
| 5099 | { "Analog Inputs", 0x03 }, |
| 5100 | { "Digital Mic 1", 0x04 }, |
| 5101 | { "Digital Mic 2", 0x05 }, |
| 5102 | } |
| 5103 | }; |
| 5104 | |
| 5105 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 5106 | { |
| 5107 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5108 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5109 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5110 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5111 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5112 | |
| 5113 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5114 | if (spec == NULL) |
| 5115 | return -ENOMEM; |
| 5116 | |
| 5117 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5118 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5119 | spec->mono_nid = 0x19; |
| 5120 | spec->digbeep_nid = 0x21; |
| 5121 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 5122 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 5123 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 5124 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5125 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5126 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 5127 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5128 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5129 | |
| 5130 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5131 | spec->mixer = stac92hd83xxx_mixer; |
| 5132 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 5133 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 5134 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5135 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5136 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 5137 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 5138 | spec->pin_nids = stac92hd83xxx_pin_nids; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5139 | spec->num_caps = STAC92HD83XXX_NUM_CAPS; |
| 5140 | spec->capvols = stac92hd83xxx_capvols; |
| 5141 | spec->capsws = stac92hd83xxx_capsws; |
| 5142 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5143 | spec->board_config = snd_hda_check_board_config(codec, |
| 5144 | STAC_92HD83XXX_MODELS, |
| 5145 | stac92hd83xxx_models, |
| 5146 | stac92hd83xxx_cfg_tbl); |
| 5147 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5148 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5149 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5150 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5151 | else |
| 5152 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5153 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5154 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5155 | switch (codec->vendor_id) { |
| 5156 | case 0x111d7604: |
| 5157 | case 0x111d7605: |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5158 | case 0x111d76d5: |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5159 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 5160 | break; |
| 5161 | spec->num_pwrs = 0; |
| 5162 | break; |
| 5163 | } |
| 5164 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5165 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 5166 | if (!err) { |
| 5167 | if (spec->board_config < 0) { |
| 5168 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5169 | "available, default to model=ref\n"); |
| 5170 | spec->board_config = STAC_92HD83XXX_REF; |
| 5171 | goto again; |
| 5172 | } |
| 5173 | err = -EINVAL; |
| 5174 | } |
| 5175 | |
| 5176 | if (err < 0) { |
| 5177 | stac92xx_free(codec); |
| 5178 | return err; |
| 5179 | } |
| 5180 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5181 | switch (spec->board_config) { |
| 5182 | case STAC_DELL_S14: |
| 5183 | nid = 0xf; |
| 5184 | break; |
| 5185 | default: |
| 5186 | nid = 0xe; |
| 5187 | break; |
| 5188 | } |
| 5189 | |
| 5190 | num_dacs = snd_hda_get_connections(codec, nid, |
| 5191 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 5192 | if (num_dacs < 0) |
| 5193 | num_dacs = STAC92HD83_DAC_COUNT; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5194 | |
| 5195 | /* set port X to select the last DAC |
| 5196 | */ |
| 5197 | snd_hda_codec_write_cache(codec, nid, 0, |
| 5198 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 5199 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5200 | codec->patch_ops = stac92xx_patch_ops; |
| 5201 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5202 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 5203 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5204 | return 0; |
| 5205 | } |
| 5206 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5207 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 5208 | .num_items = 3, |
| 5209 | .items = { |
| 5210 | { "Analog Inputs", 0x00 }, |
| 5211 | { "Digital Mic 1", 0x02 }, |
| 5212 | { "Digital Mic 2", 0x03 }, |
| 5213 | } |
| 5214 | }; |
| 5215 | |
| 5216 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5217 | .num_items = 4, |
| 5218 | .items = { |
| 5219 | { "Analog Inputs", 0x00 }, |
| 5220 | { "Mixer", 0x01 }, |
| 5221 | { "Digital Mic 1", 0x02 }, |
| 5222 | { "Digital Mic 2", 0x03 }, |
| 5223 | } |
| 5224 | }; |
| 5225 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5226 | /* get the pin connection (fixed, none, etc) */ |
| 5227 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 5228 | { |
| 5229 | struct sigmatel_spec *spec = codec->spec; |
| 5230 | unsigned int cfg; |
| 5231 | |
| 5232 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 5233 | return get_defcfg_connect(cfg); |
| 5234 | } |
| 5235 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5236 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 5237 | hda_nid_t *nids, int num_nids) |
| 5238 | { |
| 5239 | struct sigmatel_spec *spec = codec->spec; |
| 5240 | int idx, num; |
| 5241 | unsigned int def_conf; |
| 5242 | |
| 5243 | for (num = 0; num < num_nids; num++) { |
| 5244 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5245 | if (spec->pin_nids[idx] == nids[num]) |
| 5246 | break; |
| 5247 | if (idx >= spec->num_pins) |
| 5248 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5249 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5250 | if (def_conf == AC_JACK_PORT_NONE) |
| 5251 | break; |
| 5252 | } |
| 5253 | return num; |
| 5254 | } |
| 5255 | |
| 5256 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 5257 | hda_nid_t dig0pin) |
| 5258 | { |
| 5259 | struct sigmatel_spec *spec = codec->spec; |
| 5260 | int idx; |
| 5261 | |
| 5262 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5263 | if (spec->pin_nids[idx] == dig0pin) |
| 5264 | break; |
| 5265 | if ((idx + 2) >= spec->num_pins) |
| 5266 | return 0; |
| 5267 | |
| 5268 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5269 | 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] | 5270 | return 2; |
| 5271 | |
| 5272 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5273 | 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] | 5274 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5275 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5276 | return 1; |
| 5277 | else |
| 5278 | return 0; |
| 5279 | } |
| 5280 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5281 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 5282 | { |
| 5283 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5284 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5285 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5286 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5287 | |
| 5288 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5289 | if (spec == NULL) |
| 5290 | return -ENOMEM; |
| 5291 | |
| 5292 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5293 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5294 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 5295 | switch (codec->vendor_id) { |
| 5296 | case 0x111d76b6: |
| 5297 | case 0x111d76b7: |
| 5298 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 5299 | break; |
| 5300 | case 0x111d7603: |
| 5301 | case 0x111d7608: |
| 5302 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 5303 | spec->num_pins--; |
| 5304 | /* fallthrough */ |
| 5305 | default: |
| 5306 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 5307 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5308 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5309 | spec->board_config = snd_hda_check_board_config(codec, |
| 5310 | STAC_92HD71BXX_MODELS, |
| 5311 | stac92hd71bxx_models, |
| 5312 | stac92hd71bxx_cfg_tbl); |
| 5313 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5314 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5315 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5316 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5317 | else |
| 5318 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5319 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5320 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5321 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5322 | /* GPIO0 = EAPD */ |
| 5323 | spec->gpio_mask = 0x01; |
| 5324 | spec->gpio_dir = 0x01; |
| 5325 | spec->gpio_data = 0x01; |
| 5326 | } |
| 5327 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5328 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5329 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5330 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5331 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; |
| 5332 | spec->capvols = stac92hd71bxx_capvols; |
| 5333 | spec->capsws = stac92hd71bxx_capsws; |
| 5334 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5335 | switch (codec->vendor_id) { |
| 5336 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5337 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5338 | unmute_init++; |
| 5339 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5340 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5341 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5342 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 5343 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5344 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5345 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5346 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5347 | stac92hd71bxx_dmic_nids, |
| 5348 | STAC92HD71BXX_NUM_DMICS); |
| 5349 | if (spec->num_dmics) { |
| 5350 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5351 | spec->dinput_mux = &spec->private_dimux; |
| 5352 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5353 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5354 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5355 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5356 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5357 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5358 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5359 | switch (spec->board_config) { |
| 5360 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5361 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5362 | err = stac_add_event(spec, codec->afg, |
| 5363 | STAC_VREF_EVENT, 0x02); |
| 5364 | if (err < 0) |
| 5365 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5366 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5367 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5368 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5369 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5370 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5371 | spec->gpio_mask |= 0x02; |
| 5372 | break; |
| 5373 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5374 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5375 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5376 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5377 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5378 | /* no output amps */ |
| 5379 | spec->num_pwrs = 0; |
Takashi Iwai | 50c62f0 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 5380 | if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1) |
| 5381 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5382 | |
| 5383 | /* disable VSW */ |
| 5384 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5385 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5386 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5387 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5388 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5389 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5390 | stac92hd71bxx_dmic_nids, |
| 5391 | STAC92HD71BXX_NUM_DMICS - 1); |
Takashi Iwai | 4417932 | 2009-07-28 17:03:49 +0200 | [diff] [blame] | 5392 | if (spec->num_dmics) { |
| 5393 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5394 | spec->dinput_mux = &spec->private_dimux; |
| 5395 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
| 5396 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5397 | break; |
| 5398 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5399 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5400 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5401 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5402 | /* no output amps */ |
| 5403 | spec->num_pwrs = 0; |
| 5404 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5405 | default: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5406 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5407 | sizeof(stac92hd71bxx_dmux_amixer)); |
Takashi Iwai | 50c62f0 | 2009-07-28 18:25:29 +0200 | [diff] [blame] | 5408 | if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1) |
| 5409 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5410 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5411 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5412 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5413 | stac92hd71bxx_dmic_nids, |
| 5414 | STAC92HD71BXX_NUM_DMICS); |
Takashi Iwai | 4417932 | 2009-07-28 17:03:49 +0200 | [diff] [blame] | 5415 | if (spec->num_dmics) { |
| 5416 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5417 | spec->dinput_mux = &spec->private_dimux; |
| 5418 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5419 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5420 | } |
| 5421 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5422 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5423 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5424 | |
Takashi Iwai | b20f3b8 | 2009-06-02 01:20:22 +0200 | [diff] [blame] | 5425 | /* Some HP machines seem to have unstable codec communications |
| 5426 | * especially with ATI fglrx driver. For recovering from the |
| 5427 | * CORB/RIRB stall, allow the BUS reset and keep always sync |
| 5428 | */ |
| 5429 | if (spec->board_config == STAC_HP_DV5) { |
| 5430 | codec->bus->sync_write = 1; |
| 5431 | codec->bus->allow_bus_reset = 1; |
| 5432 | } |
| 5433 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5434 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5435 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5436 | spec->aloopback_shift = 0; |
| 5437 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5438 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5439 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5440 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5441 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5442 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5443 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5444 | |
| 5445 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5446 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5447 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5448 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5449 | switch (spec->board_config) { |
| 5450 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5451 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5452 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5453 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5454 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5455 | /* fallthru */ |
| 5456 | case STAC_DELL_M4_2: |
| 5457 | spec->num_dmics = 0; |
| 5458 | spec->num_smuxes = 0; |
| 5459 | spec->num_dmuxes = 0; |
| 5460 | break; |
| 5461 | case STAC_DELL_M4_1: |
| 5462 | case STAC_DELL_M4_3: |
| 5463 | spec->num_dmics = 1; |
| 5464 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5465 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5466 | break; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5467 | case STAC_HP_DV4_1222NR: |
| 5468 | spec->num_dmics = 1; |
| 5469 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 5470 | * bug reports to fix if needed |
| 5471 | */ |
| 5472 | spec->num_smuxes = 1; |
| 5473 | spec->num_dmuxes = 1; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5474 | spec->gpio_led = 0x01; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5475 | /* fallthrough */ |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5476 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5477 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5478 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5479 | break; |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5480 | case STAC_HP_HDX: |
| 5481 | spec->num_dmics = 1; |
| 5482 | spec->num_dmuxes = 1; |
| 5483 | spec->num_smuxes = 1; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5484 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5485 | spec->gpio_led = 0x08; |
| 5486 | break; |
| 5487 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5488 | |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5489 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5490 | if (spec->gpio_led) { |
| 5491 | spec->gpio_mask |= spec->gpio_led; |
| 5492 | spec->gpio_dir |= spec->gpio_led; |
| 5493 | spec->gpio_data |= spec->gpio_led; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5494 | /* register check_power_status callback. */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5495 | codec->patch_ops.check_power_status = |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5496 | stac92xx_hp_check_power_status; |
| 5497 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5498 | #endif |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5499 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5500 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5501 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5502 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5503 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5504 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5505 | if (!err) { |
| 5506 | if (spec->board_config < 0) { |
| 5507 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5508 | "available, default to model=ref\n"); |
| 5509 | spec->board_config = STAC_92HD71BXX_REF; |
| 5510 | goto again; |
| 5511 | } |
| 5512 | err = -EINVAL; |
| 5513 | } |
| 5514 | |
| 5515 | if (err < 0) { |
| 5516 | stac92xx_free(codec); |
| 5517 | return err; |
| 5518 | } |
| 5519 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5520 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5521 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5522 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5523 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5524 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5525 | static int patch_stac922x(struct hda_codec *codec) |
| 5526 | { |
| 5527 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5528 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5529 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5530 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5531 | if (spec == NULL) |
| 5532 | return -ENOMEM; |
| 5533 | |
| 5534 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5535 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5536 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5537 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5538 | stac922x_models, |
| 5539 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5540 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5541 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5542 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5543 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5544 | * codec SSID to distinguish the exact models |
| 5545 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5546 | 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] | 5547 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5548 | |
| 5549 | case 0x106b0800: |
| 5550 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5551 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5552 | case 0x106b0600: |
| 5553 | case 0x106b0700: |
| 5554 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5555 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5556 | case 0x106b0e00: |
| 5557 | case 0x106b0f00: |
| 5558 | case 0x106b1600: |
| 5559 | case 0x106b1700: |
| 5560 | case 0x106b0200: |
| 5561 | case 0x106b1e00: |
| 5562 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5563 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5564 | case 0x106b1a00: |
| 5565 | case 0x00000100: |
| 5566 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5567 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5568 | case 0x106b0a00: |
| 5569 | case 0x106b2200: |
| 5570 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5571 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5572 | default: |
| 5573 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5574 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5575 | } |
| 5576 | } |
| 5577 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5578 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5579 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5580 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5581 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5582 | else |
| 5583 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5584 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5585 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5586 | spec->adc_nids = stac922x_adc_nids; |
| 5587 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5588 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5589 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5590 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5591 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5592 | |
| 5593 | spec->init = stac922x_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5594 | |
| 5595 | spec->num_caps = STAC922X_NUM_CAPS; |
| 5596 | spec->capvols = stac922x_capvols; |
| 5597 | spec->capsws = stac922x_capsws; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5598 | |
| 5599 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5600 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5601 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5602 | if (!err) { |
| 5603 | if (spec->board_config < 0) { |
| 5604 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5605 | "available, default to model=ref\n"); |
| 5606 | spec->board_config = STAC_D945_REF; |
| 5607 | goto again; |
| 5608 | } |
| 5609 | err = -EINVAL; |
| 5610 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5611 | if (err < 0) { |
| 5612 | stac92xx_free(codec); |
| 5613 | return err; |
| 5614 | } |
| 5615 | |
| 5616 | codec->patch_ops = stac92xx_patch_ops; |
| 5617 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5618 | /* Fix Mux capture level; max to 2 */ |
| 5619 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5620 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5621 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5622 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5623 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5624 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5625 | return 0; |
| 5626 | } |
| 5627 | |
| 5628 | static int patch_stac927x(struct hda_codec *codec) |
| 5629 | { |
| 5630 | struct sigmatel_spec *spec; |
| 5631 | int err; |
| 5632 | |
| 5633 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5634 | if (spec == NULL) |
| 5635 | return -ENOMEM; |
| 5636 | |
| 5637 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5638 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5639 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5640 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5641 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5642 | stac927x_models, |
| 5643 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5644 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5645 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5646 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5647 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5648 | else |
| 5649 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5650 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5651 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5652 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5653 | spec->adc_nids = stac927x_adc_nids; |
| 5654 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5655 | spec->mux_nids = stac927x_mux_nids; |
| 5656 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5657 | spec->smux_nids = stac927x_smux_nids; |
| 5658 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5659 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5660 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5661 | spec->multiout.dac_nids = spec->dac_nids; |
| 5662 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5663 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5664 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5665 | case STAC_D965_5ST: |
| 5666 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5667 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5668 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5669 | spec->num_dmics = 0; |
| 5670 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5671 | spec->init = d965_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5672 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5673 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5674 | switch (codec->subsystem_id) { |
| 5675 | case 0x10280209: |
| 5676 | case 0x1028022e: |
| 5677 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5678 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5679 | break; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5680 | } |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5681 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5682 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5683 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5684 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5685 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5686 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5687 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5688 | case STAC_DELL_3ST: |
| 5689 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5690 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5691 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5692 | spec->dmic_nids = stac927x_dmic_nids; |
| 5693 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5694 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5695 | spec->init = d965_core_init; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5696 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5697 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5698 | break; |
| 5699 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5700 | if (spec->board_config > STAC_D965_REF) { |
| 5701 | /* GPIO0 High = Enable EAPD */ |
| 5702 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5703 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5704 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5705 | spec->num_dmics = 0; |
| 5706 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5707 | spec->init = stac927x_core_init; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5708 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5709 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5710 | spec->num_caps = STAC927X_NUM_CAPS; |
| 5711 | spec->capvols = stac927x_capvols; |
| 5712 | spec->capsws = stac927x_capsws; |
| 5713 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5714 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5715 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5716 | spec->aloopback_mask = 0x40; |
| 5717 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5718 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5719 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5720 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5721 | if (!err) { |
| 5722 | if (spec->board_config < 0) { |
| 5723 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5724 | "available, default to model=ref\n"); |
| 5725 | spec->board_config = STAC_D965_REF; |
| 5726 | goto again; |
| 5727 | } |
| 5728 | err = -EINVAL; |
| 5729 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5730 | if (err < 0) { |
| 5731 | stac92xx_free(codec); |
| 5732 | return err; |
| 5733 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5734 | |
| 5735 | codec->patch_ops = stac92xx_patch_ops; |
| 5736 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5737 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5738 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5739 | /* |
| 5740 | * !!FIXME!! |
| 5741 | * The STAC927x seem to require fairly long delays for certain |
| 5742 | * command sequences. With too short delays (even if the answer |
| 5743 | * is set to RIRB properly), it results in the silence output |
| 5744 | * on some hardwares like Dell. |
| 5745 | * |
| 5746 | * The below flag enables the longer delay (see get_response |
| 5747 | * in hda_intel.c). |
| 5748 | */ |
| 5749 | codec->bus->needs_damn_long_delay = 1; |
| 5750 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5751 | /* no jack detecion for ref-no-jd model */ |
| 5752 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5753 | spec->hp_detect = 0; |
| 5754 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5755 | return 0; |
| 5756 | } |
| 5757 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5758 | static int patch_stac9205(struct hda_codec *codec) |
| 5759 | { |
| 5760 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5761 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5762 | |
| 5763 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5764 | if (spec == NULL) |
| 5765 | return -ENOMEM; |
| 5766 | |
| 5767 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5768 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5769 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5770 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5771 | stac9205_models, |
| 5772 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5773 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5774 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5775 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5776 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5777 | else |
| 5778 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5779 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5780 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5781 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5782 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5783 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5784 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5785 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5786 | spec->smux_nids = stac9205_smux_nids; |
| 5787 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5788 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5789 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5790 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5791 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5792 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5793 | |
| 5794 | spec->init = stac9205_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5795 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5796 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5797 | spec->num_caps = STAC9205_NUM_CAPS; |
| 5798 | spec->capvols = stac9205_capvols; |
| 5799 | spec->capsws = stac9205_capsws; |
| 5800 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5801 | spec->aloopback_mask = 0x40; |
| 5802 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5803 | /* Turn on/off EAPD per HP plugging */ |
| 5804 | if (spec->board_config != STAC_9205_EAPD) |
| 5805 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5806 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5807 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5808 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5809 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5810 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5811 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5812 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5813 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5814 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5815 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5816 | if (err < 0) |
| 5817 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5818 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5819 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5820 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5821 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5822 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5823 | |
| 5824 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5825 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5826 | spec->gpio_mask = 0x1b; |
| 5827 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5828 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5829 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5830 | */ |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5831 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5832 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5833 | case STAC_9205_REF: |
| 5834 | /* SPDIF-In enabled */ |
| 5835 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5836 | default: |
| 5837 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5838 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5839 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5840 | break; |
| 5841 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5842 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5843 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5844 | if (!err) { |
| 5845 | if (spec->board_config < 0) { |
| 5846 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5847 | "available, default to model=ref\n"); |
| 5848 | spec->board_config = STAC_9205_REF; |
| 5849 | goto again; |
| 5850 | } |
| 5851 | err = -EINVAL; |
| 5852 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5853 | if (err < 0) { |
| 5854 | stac92xx_free(codec); |
| 5855 | return err; |
| 5856 | } |
| 5857 | |
| 5858 | codec->patch_ops = stac92xx_patch_ops; |
| 5859 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5860 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5861 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5862 | return 0; |
| 5863 | } |
| 5864 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5865 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5866 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5867 | */ |
| 5868 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5869 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5870 | {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] | 5871 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5872 | {} |
| 5873 | }; |
| 5874 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5875 | static hda_nid_t stac9872_pin_nids[] = { |
| 5876 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 5877 | 0x11, 0x13, 0x14, |
| 5878 | }; |
| 5879 | |
| 5880 | static hda_nid_t stac9872_adc_nids[] = { |
| 5881 | 0x8 /*,0x6*/ |
| 5882 | }; |
| 5883 | |
| 5884 | static hda_nid_t stac9872_mux_nids[] = { |
| 5885 | 0x15 |
| 5886 | }; |
| 5887 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5888 | static unsigned long stac9872_capvols[] = { |
| 5889 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), |
| 5890 | }; |
| 5891 | #define stac9872_capsws stac9872_capvols |
| 5892 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5893 | static unsigned int stac9872_vaio_pin_configs[9] = { |
| 5894 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
| 5895 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
| 5896 | 0x90a7013e |
| 5897 | }; |
| 5898 | |
| 5899 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 5900 | [STAC_9872_AUTO] = "auto", |
| 5901 | [STAC_9872_VAIO] = "vaio", |
| 5902 | }; |
| 5903 | |
| 5904 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { |
| 5905 | [STAC_9872_VAIO] = stac9872_vaio_pin_configs, |
| 5906 | }; |
| 5907 | |
| 5908 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 5909 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, |
| 5910 | "Sony VAIO F/S", STAC_9872_VAIO), |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5911 | {} /* terminator */ |
| 5912 | }; |
| 5913 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5914 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5915 | { |
| 5916 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5917 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5918 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5919 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5920 | if (spec == NULL) |
| 5921 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5922 | codec->spec = spec; |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 5923 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 5924 | spec->pin_nids = stac9872_pin_nids; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5925 | |
| 5926 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5927 | stac9872_models, |
| 5928 | stac9872_cfg_tbl); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5929 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5930 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 5931 | codec->chip_name); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5932 | else |
| 5933 | stac92xx_set_config_regs(codec, |
| 5934 | stac9872_brd_tbl[spec->board_config]); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5935 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5936 | spec->multiout.dac_nids = spec->dac_nids; |
| 5937 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 5938 | spec->adc_nids = stac9872_adc_nids; |
| 5939 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 5940 | spec->mux_nids = stac9872_mux_nids; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5941 | spec->init = stac9872_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5942 | spec->num_caps = 1; |
| 5943 | spec->capvols = stac9872_capvols; |
| 5944 | spec->capsws = stac9872_capsws; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5945 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5946 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 5947 | if (err < 0) { |
| 5948 | stac92xx_free(codec); |
| 5949 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5950 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5951 | spec->input_mux = &spec->private_imux; |
| 5952 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5953 | return 0; |
| 5954 | } |
| 5955 | |
| 5956 | |
| 5957 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5958 | * patch entries |
| 5959 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5960 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5961 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5962 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5963 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5964 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5965 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5966 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5967 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5968 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5969 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5970 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5971 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5972 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5973 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5974 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5975 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5976 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5977 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5978 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5979 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5980 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5981 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5982 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5983 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5984 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5985 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5986 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5987 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5988 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5989 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5990 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5991 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5992 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5993 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5994 | * currently not fully supported. |
| 5995 | */ |
| 5996 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5997 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5998 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 5999 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 6000 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 6001 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 6002 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 6003 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 6004 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 6005 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 6006 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 6007 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6008 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6009 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 6010 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 6011 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6012 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6013 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 6014 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6015 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6016 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 6017 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 6018 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 6019 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 6020 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 6021 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 6022 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 6023 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6024 | {} /* terminator */ |
| 6025 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6026 | |
| 6027 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 6028 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 6029 | |
| 6030 | MODULE_LICENSE("GPL"); |
| 6031 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 6032 | |
| 6033 | static struct hda_codec_preset_list sigmatel_list = { |
| 6034 | .preset = snd_hda_preset_sigmatel, |
| 6035 | .owner = THIS_MODULE, |
| 6036 | }; |
| 6037 | |
| 6038 | static int __init patch_sigmatel_init(void) |
| 6039 | { |
| 6040 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 6041 | } |
| 6042 | |
| 6043 | static void __exit patch_sigmatel_exit(void) |
| 6044 | { |
| 6045 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 6046 | } |
| 6047 | |
| 6048 | module_init(patch_sigmatel_init) |
| 6049 | module_exit(patch_sigmatel_exit) |