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; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 241 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 242 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 243 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 244 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 245 | hda_nid_t anabeep_nid; |
| 246 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 247 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 248 | /* pin widgets */ |
| 249 | hda_nid_t *pin_nids; |
| 250 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 251 | |
| 252 | /* codec specific stuff */ |
| 253 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 254 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 255 | |
| 256 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 257 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 258 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 259 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 260 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 261 | struct hda_input_mux *sinput_mux; |
| 262 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 263 | unsigned int cur_amux; |
| 264 | hda_nid_t *amp_nids; |
| 265 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 266 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 267 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 268 | /* i/o switches */ |
| 269 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 270 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 271 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 272 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 273 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 274 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 275 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 276 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 277 | |
| 278 | /* dynamic controls and input_mux */ |
| 279 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 280 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 281 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 282 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 283 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 284 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 285 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | static hda_nid_t stac9200_adc_nids[1] = { |
| 289 | 0x03, |
| 290 | }; |
| 291 | |
| 292 | static hda_nid_t stac9200_mux_nids[1] = { |
| 293 | 0x0c, |
| 294 | }; |
| 295 | |
| 296 | static hda_nid_t stac9200_dac_nids[1] = { |
| 297 | 0x02, |
| 298 | }; |
| 299 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 300 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 301 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 302 | 0x0f, 0x10, 0x11 |
| 303 | }; |
| 304 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 305 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 306 | 0x26, 0, |
| 307 | }; |
| 308 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 309 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 310 | 0x1a, 0x1b |
| 311 | }; |
| 312 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 313 | #define DELL_M6_AMP 2 |
| 314 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 315 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 316 | }; |
| 317 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 318 | #define STAC92HD73XX_NUM_DMICS 2 |
| 319 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 320 | 0x13, 0x14, 0 |
| 321 | }; |
| 322 | |
| 323 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 324 | |
| 325 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 326 | 0x28, 0x29, 0x2a, 0x2b, |
| 327 | }; |
| 328 | |
| 329 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 330 | 0x20, 0x21, |
| 331 | }; |
| 332 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 333 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 334 | 0x22, 0x23, |
| 335 | }; |
| 336 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 337 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 338 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 339 | 0x11, 0x12, 0 |
| 340 | }; |
| 341 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 342 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 343 | |
| 344 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 345 | 0x17, 0x18, |
| 346 | }; |
| 347 | |
| 348 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 349 | 0x15, 0x16, |
| 350 | }; |
| 351 | |
| 352 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 353 | 0xa, 0xb, 0xd, 0xe, |
| 354 | }; |
| 355 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 356 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 357 | 0x1e, 0, |
| 358 | }; |
| 359 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 360 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 361 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 362 | }; |
| 363 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 364 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 365 | 0xc, |
| 366 | }; |
| 367 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 368 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 369 | 0x0a, 0x0d, 0x0f |
| 370 | }; |
| 371 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 372 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 373 | 0x12, 0x13, |
| 374 | }; |
| 375 | |
| 376 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 377 | 0x1a, 0x1b |
| 378 | }; |
| 379 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 380 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 381 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 382 | }; |
| 383 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 384 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 385 | 0x24, 0x25, |
| 386 | }; |
| 387 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 388 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 389 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 390 | 0x18, 0x19, 0 |
| 391 | }; |
| 392 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 393 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 394 | 0x22, 0 |
| 395 | }; |
| 396 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 397 | static hda_nid_t stac925x_adc_nids[1] = { |
| 398 | 0x03, |
| 399 | }; |
| 400 | |
| 401 | static hda_nid_t stac925x_mux_nids[1] = { |
| 402 | 0x0f, |
| 403 | }; |
| 404 | |
| 405 | static hda_nid_t stac925x_dac_nids[1] = { |
| 406 | 0x02, |
| 407 | }; |
| 408 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 409 | #define STAC925X_NUM_DMICS 1 |
| 410 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 411 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 412 | }; |
| 413 | |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 414 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 415 | 0x14, |
| 416 | }; |
| 417 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 418 | static hda_nid_t stac922x_adc_nids[2] = { |
| 419 | 0x06, 0x07, |
| 420 | }; |
| 421 | |
| 422 | static hda_nid_t stac922x_mux_nids[2] = { |
| 423 | 0x12, 0x13, |
| 424 | }; |
| 425 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 426 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 427 | 0x1f, 0, |
| 428 | }; |
| 429 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 430 | static hda_nid_t stac927x_adc_nids[3] = { |
| 431 | 0x07, 0x08, 0x09 |
| 432 | }; |
| 433 | |
| 434 | static hda_nid_t stac927x_mux_nids[3] = { |
| 435 | 0x15, 0x16, 0x17 |
| 436 | }; |
| 437 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 438 | static hda_nid_t stac927x_smux_nids[1] = { |
| 439 | 0x21, |
| 440 | }; |
| 441 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 442 | static hda_nid_t stac927x_dac_nids[6] = { |
| 443 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 444 | }; |
| 445 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 446 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 447 | 0x1b, |
| 448 | }; |
| 449 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 450 | #define STAC927X_NUM_DMICS 2 |
| 451 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 452 | 0x13, 0x14, 0 |
| 453 | }; |
| 454 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 455 | static const char *stac927x_spdif_labels[5] = { |
| 456 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 457 | "Analog Mux 2", "Analog Mux 3" |
| 458 | }; |
| 459 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 460 | static hda_nid_t stac9205_adc_nids[2] = { |
| 461 | 0x12, 0x13 |
| 462 | }; |
| 463 | |
| 464 | static hda_nid_t stac9205_mux_nids[2] = { |
| 465 | 0x19, 0x1a |
| 466 | }; |
| 467 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 468 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 469 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 470 | }; |
| 471 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 472 | static hda_nid_t stac9205_smux_nids[1] = { |
| 473 | 0x21, |
| 474 | }; |
| 475 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 476 | #define STAC9205_NUM_DMICS 2 |
| 477 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 478 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 479 | }; |
| 480 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 481 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 482 | 0x08, 0x09, 0x0d, 0x0e, |
| 483 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 484 | }; |
| 485 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 486 | static hda_nid_t stac925x_pin_nids[8] = { |
| 487 | 0x07, 0x08, 0x0a, 0x0b, |
| 488 | 0x0c, 0x0d, 0x10, 0x11, |
| 489 | }; |
| 490 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 491 | static hda_nid_t stac922x_pin_nids[10] = { |
| 492 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 493 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 494 | }; |
| 495 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 496 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 497 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 498 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 499 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 500 | }; |
| 501 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 502 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 503 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 504 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 505 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 506 | |
| 507 | #define STAC92HD71BXX_NUM_PINS 13 |
| 508 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 509 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 510 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 511 | 0x1f, 0x20, 0x27 |
| 512 | }; |
| 513 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 514 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 515 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 516 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 517 | }; |
| 518 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 519 | static hda_nid_t stac927x_pin_nids[14] = { |
| 520 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 521 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 522 | 0x14, 0x21, 0x22, 0x23, |
| 523 | }; |
| 524 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 525 | static hda_nid_t stac9205_pin_nids[12] = { |
| 526 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 527 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 528 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 529 | }; |
| 530 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 531 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 532 | |
| 533 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 534 | struct snd_ctl_elem_value *ucontrol) |
| 535 | { |
| 536 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 537 | struct sigmatel_spec *spec = codec->spec; |
| 538 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 539 | |
| 540 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 541 | kcontrol->private_value |= nid; |
| 542 | |
| 543 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 544 | } |
| 545 | |
| 546 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 547 | struct snd_ctl_elem_value *ucontrol) |
| 548 | { |
| 549 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 550 | struct sigmatel_spec *spec = codec->spec; |
| 551 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 552 | |
| 553 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 554 | kcontrol->private_value |= nid; |
| 555 | |
| 556 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 557 | } |
| 558 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 559 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 560 | struct snd_ctl_elem_info *uinfo) |
| 561 | { |
| 562 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 563 | struct sigmatel_spec *spec = codec->spec; |
| 564 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 565 | } |
| 566 | |
| 567 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 568 | struct snd_ctl_elem_value *ucontrol) |
| 569 | { |
| 570 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 571 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 572 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 573 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 574 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 579 | struct snd_ctl_elem_value *ucontrol) |
| 580 | { |
| 581 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 582 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 583 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 584 | |
| 585 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 586 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 587 | } |
| 588 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 589 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 590 | struct snd_ctl_elem_info *uinfo) |
| 591 | { |
| 592 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 593 | struct sigmatel_spec *spec = codec->spec; |
| 594 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 595 | } |
| 596 | |
| 597 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 598 | struct snd_ctl_elem_value *ucontrol) |
| 599 | { |
| 600 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 601 | struct sigmatel_spec *spec = codec->spec; |
| 602 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 603 | |
| 604 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 605 | return 0; |
| 606 | } |
| 607 | |
| 608 | static int stac92xx_smux_enum_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; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 613 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 614 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 615 | int err, val; |
| 616 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 617 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 618 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 619 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 620 | if (err < 0) |
| 621 | return err; |
| 622 | |
| 623 | if (spec->spdif_mute) { |
| 624 | if (smux_idx == 0) |
| 625 | nid = spec->multiout.dig_out_nid; |
| 626 | else |
| 627 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 628 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 629 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 630 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 631 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 632 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 633 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 634 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 635 | } |
| 636 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 637 | } |
| 638 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 639 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 640 | hda_nid_t nid, unsigned int new_vref) |
| 641 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 642 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 643 | unsigned int pincfg; |
| 644 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 645 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 646 | |
| 647 | pincfg &= 0xff; |
| 648 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 649 | pincfg |= new_vref; |
| 650 | |
| 651 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 652 | pincfg |= AC_PINCTL_OUT_EN; |
| 653 | else |
| 654 | pincfg |= AC_PINCTL_IN_EN; |
| 655 | |
| 656 | error = snd_hda_codec_write_cache(codec, nid, 0, |
| 657 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); |
| 658 | if (error < 0) |
| 659 | return error; |
| 660 | else |
| 661 | return 1; |
| 662 | } |
| 663 | |
| 664 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 665 | { |
| 666 | unsigned int vref; |
| 667 | vref = snd_hda_codec_read(codec, nid, 0, |
| 668 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 669 | vref &= AC_PINCTL_VREFEN; |
| 670 | return vref; |
| 671 | } |
| 672 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 673 | 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] | 674 | { |
| 675 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 676 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 677 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 678 | } |
| 679 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 680 | 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] | 681 | { |
| 682 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 683 | struct sigmatel_spec *spec = codec->spec; |
| 684 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 685 | |
| 686 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 687 | return 0; |
| 688 | } |
| 689 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 690 | 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] | 691 | { |
| 692 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 693 | struct sigmatel_spec *spec = codec->spec; |
| 694 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 695 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 696 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 697 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 698 | } |
| 699 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 700 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 701 | struct snd_ctl_elem_info *uinfo) |
| 702 | { |
| 703 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 704 | struct sigmatel_spec *spec = codec->spec; |
| 705 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 706 | } |
| 707 | |
| 708 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 709 | struct snd_ctl_elem_value *ucontrol) |
| 710 | { |
| 711 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 712 | struct sigmatel_spec *spec = codec->spec; |
| 713 | |
| 714 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 715 | return 0; |
| 716 | } |
| 717 | |
| 718 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 719 | struct snd_ctl_elem_value *ucontrol) |
| 720 | { |
| 721 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 722 | struct sigmatel_spec *spec = codec->spec; |
| 723 | |
| 724 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 725 | spec->mono_nid, &spec->cur_mmux); |
| 726 | } |
| 727 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 728 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 729 | struct snd_ctl_elem_info *uinfo) |
| 730 | { |
| 731 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 732 | struct sigmatel_spec *spec = codec->spec; |
| 733 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 734 | } |
| 735 | |
| 736 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 737 | struct snd_ctl_elem_value *ucontrol) |
| 738 | { |
| 739 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 740 | struct sigmatel_spec *spec = codec->spec; |
| 741 | |
| 742 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 743 | return 0; |
| 744 | } |
| 745 | |
| 746 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 747 | struct snd_ctl_elem_value *ucontrol) |
| 748 | { |
| 749 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 750 | struct sigmatel_spec *spec = codec->spec; |
| 751 | struct snd_kcontrol *ctl = |
| 752 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 753 | if (!ctl) |
| 754 | return -EINVAL; |
| 755 | |
| 756 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 757 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 758 | |
| 759 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 760 | 0, &spec->cur_amux); |
| 761 | } |
| 762 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 763 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 764 | |
| 765 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 766 | struct snd_ctl_elem_value *ucontrol) |
| 767 | { |
| 768 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 769 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 770 | struct sigmatel_spec *spec = codec->spec; |
| 771 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 772 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 773 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 778 | struct snd_ctl_elem_value *ucontrol) |
| 779 | { |
| 780 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 781 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 782 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 783 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 784 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 785 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 786 | idx_val = spec->aloopback_mask << idx; |
| 787 | if (ucontrol->value.integer.value[0]) |
| 788 | val = spec->aloopback | idx_val; |
| 789 | else |
| 790 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 791 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 792 | return 0; |
| 793 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 794 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 795 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 796 | /* Only return the bits defined by the shift value of the |
| 797 | * first two bytes of the mask |
| 798 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 799 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 800 | kcontrol->private_value & 0xFFFF, 0x0); |
| 801 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 802 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 803 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 804 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 805 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 806 | } else { |
| 807 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 808 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 812 | kcontrol->private_value >> 16, dac_mode); |
| 813 | |
| 814 | return 1; |
| 815 | } |
| 816 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 817 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 818 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 819 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 820 | {} |
| 821 | }; |
| 822 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 823 | static struct hda_verb stac9200_eapd_init[] = { |
| 824 | /* set dac0mux for dac converter */ |
| 825 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 826 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 827 | {} |
| 828 | }; |
| 829 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 830 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 831 | /* set master volume and direct control */ |
| 832 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 833 | /* setup adcs to point to mixer */ |
| 834 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 835 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 836 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 837 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 838 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 839 | /* setup import muxs */ |
| 840 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 841 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 842 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 843 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 844 | {} |
| 845 | }; |
| 846 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 847 | static struct hda_verb dell_eq_core_init[] = { |
| 848 | /* set master volume to max value without distortion |
| 849 | * and direct control */ |
| 850 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 851 | /* setup adcs to point to mixer */ |
| 852 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 853 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 854 | /* setup import muxs */ |
| 855 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 856 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 857 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 858 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 859 | {} |
| 860 | }; |
| 861 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 862 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 863 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 864 | /* setup adcs to point to mixer */ |
| 865 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 866 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 867 | /* setup import muxs */ |
| 868 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 869 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 870 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 871 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 872 | {} |
| 873 | }; |
| 874 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 875 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 876 | /* set master volume and direct control */ |
| 877 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 878 | /* setup adcs to point to mixer */ |
| 879 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 880 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 881 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 882 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 883 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 884 | /* setup import muxs */ |
| 885 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 886 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 887 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 888 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 889 | {} |
| 890 | }; |
| 891 | |
| 892 | static struct hda_verb stac92hd73xx_10ch_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 | /* dac3 is connected to import3 mux */ |
| 896 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 897 | /* setup adcs to point to mixer */ |
| 898 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 899 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 900 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 901 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 902 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 903 | /* setup import muxs */ |
| 904 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 905 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 906 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 907 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 908 | {} |
| 909 | }; |
| 910 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 911 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 912 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 913 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 914 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 915 | |
| 916 | /* power state controls amps */ |
| 917 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 918 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 919 | }; |
| 920 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 921 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 922 | /* set master volume and direct control */ |
| 923 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 924 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 925 | }; |
| 926 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 927 | #define HD_DISABLE_PORTF 1 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 928 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 929 | /* start of config #1 */ |
| 930 | |
| 931 | /* connect port 0f to audio mixer */ |
| 932 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 933 | /* start of config #2 */ |
| 934 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 935 | /* set master volume and direct control */ |
| 936 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 937 | {} |
| 938 | }; |
| 939 | |
| 940 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 941 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 942 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 943 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 944 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 945 | {} |
| 946 | }; |
| 947 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 948 | static struct hda_verb stac925x_core_init[] = { |
| 949 | /* set dac0mux for dac converter */ |
| 950 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 951 | /* mute the master volume */ |
| 952 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 953 | {} |
| 954 | }; |
| 955 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 956 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 957 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 958 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 959 | {} |
| 960 | }; |
| 961 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 962 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 963 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 964 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 965 | /* unmute node 0x1b */ |
| 966 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 967 | /* select node 0x03 as DAC */ |
| 968 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 969 | {} |
| 970 | }; |
| 971 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 972 | static struct hda_verb stac927x_core_init[] = { |
| 973 | /* set master volume and direct control */ |
| 974 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 975 | /* enable analog pc beep path */ |
| 976 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 977 | {} |
| 978 | }; |
| 979 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 980 | static struct hda_verb stac9205_core_init[] = { |
| 981 | /* set master volume and direct control */ |
| 982 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 983 | /* enable analog pc beep path */ |
| 984 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 985 | {} |
| 986 | }; |
| 987 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 988 | #define STAC_MONO_MUX \ |
| 989 | { \ |
| 990 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 991 | .name = "Mono Mux", \ |
| 992 | .count = 1, \ |
| 993 | .info = stac92xx_mono_mux_enum_info, \ |
| 994 | .get = stac92xx_mono_mux_enum_get, \ |
| 995 | .put = stac92xx_mono_mux_enum_put, \ |
| 996 | } |
| 997 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 998 | #define STAC_AMP_MUX \ |
| 999 | { \ |
| 1000 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1001 | .name = "Amp Selector Capture Switch", \ |
| 1002 | .count = 1, \ |
| 1003 | .info = stac92xx_amp_mux_enum_info, \ |
| 1004 | .get = stac92xx_amp_mux_enum_get, \ |
| 1005 | .put = stac92xx_amp_mux_enum_put, \ |
| 1006 | } |
| 1007 | |
| 1008 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 1009 | { \ |
| 1010 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1011 | .name = xname, \ |
| 1012 | .index = 0, \ |
| 1013 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1014 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1015 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 1016 | .info = stac92xx_amp_volume_info, \ |
| 1017 | .get = stac92xx_amp_volume_get, \ |
| 1018 | .put = stac92xx_amp_volume_put, \ |
| 1019 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 1020 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 1021 | } |
| 1022 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1023 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1024 | { \ |
| 1025 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1026 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1027 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1028 | .info = stac92xx_aloopback_info, \ |
| 1029 | .get = stac92xx_aloopback_get, \ |
| 1030 | .put = stac92xx_aloopback_put, \ |
| 1031 | .private_value = verb_read | (verb_write << 16), \ |
| 1032 | } |
| 1033 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1034 | #define DC_BIAS(xname, idx, nid) \ |
| 1035 | { \ |
| 1036 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1037 | .name = xname, \ |
| 1038 | .index = idx, \ |
| 1039 | .info = stac92xx_dc_bias_info, \ |
| 1040 | .get = stac92xx_dc_bias_get, \ |
| 1041 | .put = stac92xx_dc_bias_put, \ |
| 1042 | .private_value = nid, \ |
| 1043 | } |
| 1044 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1045 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1046 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1047 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1048 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1049 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1050 | { } /* end */ |
| 1051 | }; |
| 1052 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1053 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1054 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1055 | /* start of config #1 */ |
| 1056 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1057 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1058 | |
| 1059 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1060 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1061 | |
| 1062 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1063 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1064 | |
| 1065 | /* start of config #2 */ |
| 1066 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1067 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1068 | |
| 1069 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1070 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1071 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1072 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1073 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1074 | |
| 1075 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1076 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1077 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1078 | { } /* end */ |
| 1079 | }; |
| 1080 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1081 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1082 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1083 | {} |
| 1084 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1085 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1086 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1087 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1088 | {} |
| 1089 | }; |
| 1090 | |
| 1091 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1092 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1093 | {} |
| 1094 | }; |
| 1095 | |
| 1096 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1097 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1098 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1099 | |
| 1100 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1101 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1102 | |
| 1103 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1104 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1105 | |
| 1106 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1107 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1108 | |
| 1109 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1110 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1111 | |
| 1112 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1113 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1114 | |
| 1115 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1116 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1117 | { } /* end */ |
| 1118 | }; |
| 1119 | |
| 1120 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1121 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1122 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1123 | |
| 1124 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1125 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1126 | |
| 1127 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1128 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1129 | |
| 1130 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1131 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1132 | |
| 1133 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1134 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1135 | |
| 1136 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1137 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1138 | |
| 1139 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1140 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1141 | { } /* end */ |
| 1142 | }; |
| 1143 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1144 | |
| 1145 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1146 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1147 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1148 | |
| 1149 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1150 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1151 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1152 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1153 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1154 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1155 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1156 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1157 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1158 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1159 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1160 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1161 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1162 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1163 | |
| 1164 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1165 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1166 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1167 | */ |
| 1168 | { } /* end */ |
| 1169 | }; |
| 1170 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1171 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1172 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1173 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1174 | |
| 1175 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1176 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1177 | /* analog pc-beep replaced with digital beep support */ |
| 1178 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1179 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1180 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1181 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1182 | |
Matthew Ranostay | 687cb98e | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1183 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1184 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1185 | |
Matthew Ranostay | 687cb98e | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1186 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1187 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1188 | |
| 1189 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1190 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1191 | |
| 1192 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1193 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1194 | { } /* end */ |
| 1195 | }; |
| 1196 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1197 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1198 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1199 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1200 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1201 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1202 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1203 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1204 | |
| 1205 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1206 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1207 | { } /* end */ |
| 1208 | }; |
| 1209 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1210 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1211 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1212 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1213 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1214 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1215 | { } /* end */ |
| 1216 | }; |
| 1217 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1218 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1219 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1220 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1221 | |
| 1222 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1223 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1224 | { } /* end */ |
| 1225 | }; |
| 1226 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1227 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1228 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1229 | {} |
| 1230 | }; |
| 1231 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1232 | /* This needs to be generated dynamically based on sequence */ |
| 1233 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1234 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1235 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1236 | |
| 1237 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1238 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1239 | { } /* end */ |
| 1240 | }; |
| 1241 | |
| 1242 | |
| 1243 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1244 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1245 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1246 | |
| 1247 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1248 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1249 | |
| 1250 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1251 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1252 | { } /* end */ |
| 1253 | }; |
| 1254 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1255 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1256 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1257 | {} |
| 1258 | }; |
| 1259 | |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1260 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1261 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1262 | .name = "Digital Input Source", |
| 1263 | /* count set later */ |
| 1264 | .info = stac92xx_dmux_enum_info, |
| 1265 | .get = stac92xx_dmux_enum_get, |
| 1266 | .put = stac92xx_dmux_enum_put, |
| 1267 | }; |
| 1268 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1269 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1270 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1271 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1272 | /* count set later */ |
| 1273 | .info = stac92xx_smux_enum_info, |
| 1274 | .get = stac92xx_smux_enum_get, |
| 1275 | .put = stac92xx_smux_enum_put, |
| 1276 | }; |
| 1277 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1278 | static const char *slave_vols[] = { |
| 1279 | "Front Playback Volume", |
| 1280 | "Surround Playback Volume", |
| 1281 | "Center Playback Volume", |
| 1282 | "LFE Playback Volume", |
| 1283 | "Side Playback Volume", |
| 1284 | "Headphone Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1285 | "Speaker Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1286 | NULL |
| 1287 | }; |
| 1288 | |
| 1289 | static const char *slave_sws[] = { |
| 1290 | "Front Playback Switch", |
| 1291 | "Surround Playback Switch", |
| 1292 | "Center Playback Switch", |
| 1293 | "LFE Playback Switch", |
| 1294 | "Side Playback Switch", |
| 1295 | "Headphone Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1296 | "Speaker Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1297 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1298 | NULL |
| 1299 | }; |
| 1300 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1301 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1302 | 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] | 1303 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1304 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1305 | { |
| 1306 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1307 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1308 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1309 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1310 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1311 | |
| 1312 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1313 | if (err < 0) |
| 1314 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1315 | |
| 1316 | for (i = 0; i < spec->num_mixers; i++) { |
| 1317 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1318 | if (err < 0) |
| 1319 | return err; |
| 1320 | } |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1321 | if (spec->num_dmuxes > 0) { |
| 1322 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1323 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1324 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1325 | if (err < 0) |
| 1326 | return err; |
| 1327 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1328 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1329 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1330 | struct hda_input_mux *smux = &spec->private_smux; |
| 1331 | /* check for mute support on SPDIF out */ |
| 1332 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1333 | smux->items[smux->num_items].label = "Off"; |
| 1334 | smux->items[smux->num_items].index = 0; |
| 1335 | smux->num_items++; |
| 1336 | spec->spdif_mute = 1; |
| 1337 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1338 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1339 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1340 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1341 | if (err < 0) |
| 1342 | return err; |
| 1343 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1344 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1345 | if (spec->multiout.dig_out_nid) { |
| 1346 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1347 | if (err < 0) |
| 1348 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1349 | err = snd_hda_create_spdif_share_sw(codec, |
| 1350 | &spec->multiout); |
| 1351 | if (err < 0) |
| 1352 | return err; |
| 1353 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1354 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1355 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1356 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1357 | if (err < 0) |
| 1358 | return err; |
| 1359 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1360 | |
| 1361 | /* if we have no master control, let's create it */ |
| 1362 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1363 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1364 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1365 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1366 | /* correct volume offset */ |
| 1367 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1368 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1369 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1370 | if (err < 0) |
| 1371 | return err; |
| 1372 | } |
| 1373 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1374 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1375 | NULL, slave_sws); |
| 1376 | if (err < 0) |
| 1377 | return err; |
| 1378 | } |
| 1379 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1380 | if (spec->aloopback_ctl && |
| 1381 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1382 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1383 | if (err < 0) |
| 1384 | return err; |
| 1385 | } |
| 1386 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1387 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1388 | |
| 1389 | /* create jack input elements */ |
| 1390 | if (spec->hp_detect) { |
| 1391 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1392 | int type = SND_JACK_HEADPHONE; |
| 1393 | nid = cfg->hp_pins[i]; |
| 1394 | /* jack detection */ |
| 1395 | if (cfg->hp_outs == i) |
| 1396 | type |= SND_JACK_LINEOUT; |
| 1397 | err = stac92xx_add_jack(codec, nid, type); |
| 1398 | if (err < 0) |
| 1399 | return err; |
| 1400 | } |
| 1401 | } |
| 1402 | for (i = 0; i < cfg->line_outs; i++) { |
| 1403 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1404 | SND_JACK_LINEOUT); |
| 1405 | if (err < 0) |
| 1406 | return err; |
| 1407 | } |
| 1408 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1409 | nid = cfg->input_pins[i]; |
| 1410 | if (nid) { |
| 1411 | err = stac92xx_add_jack(codec, nid, |
| 1412 | SND_JACK_MICROPHONE); |
| 1413 | if (err < 0) |
| 1414 | return err; |
| 1415 | } |
| 1416 | } |
| 1417 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1418 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1419 | } |
| 1420 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1421 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1422 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1423 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1424 | }; |
| 1425 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1426 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1427 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1428 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1429 | }; |
| 1430 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1431 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1432 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1433 | }; |
| 1434 | |
| 1435 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1436 | STAC 9200 pin configs for |
| 1437 | 102801A8 |
| 1438 | 102801DE |
| 1439 | 102801E8 |
| 1440 | */ |
| 1441 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1442 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1443 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1444 | }; |
| 1445 | |
| 1446 | /* |
| 1447 | STAC 9200 pin configs for |
| 1448 | 102801C0 |
| 1449 | 102801C1 |
| 1450 | */ |
| 1451 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1452 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1453 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1454 | }; |
| 1455 | |
| 1456 | /* |
| 1457 | STAC 9200 pin configs for |
| 1458 | 102801C4 (Dell Dimension E310) |
| 1459 | 102801C5 |
| 1460 | 102801C7 |
| 1461 | 102801D9 |
| 1462 | 102801DA |
| 1463 | 102801E3 |
| 1464 | */ |
| 1465 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1466 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1467 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1468 | }; |
| 1469 | |
| 1470 | |
| 1471 | /* |
| 1472 | STAC 9200-32 pin configs for |
| 1473 | 102801B5 (Dell Inspiron 630m) |
| 1474 | 102801D8 (Dell Inspiron 640m) |
| 1475 | */ |
| 1476 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1477 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1478 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1479 | }; |
| 1480 | |
| 1481 | /* |
| 1482 | STAC 9200-32 pin configs for |
| 1483 | 102801C2 (Dell Latitude D620) |
| 1484 | 102801C8 |
| 1485 | 102801CC (Dell Latitude D820) |
| 1486 | 102801D4 |
| 1487 | 102801D6 |
| 1488 | */ |
| 1489 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1490 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1491 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1492 | }; |
| 1493 | |
| 1494 | /* |
| 1495 | STAC 9200-32 pin configs for |
| 1496 | 102801CE (Dell XPS M1710) |
| 1497 | 102801CF (Dell Precision M90) |
| 1498 | */ |
| 1499 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1500 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1501 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1502 | }; |
| 1503 | |
| 1504 | /* |
| 1505 | STAC 9200-32 pin configs for |
| 1506 | 102801C9 |
| 1507 | 102801CA |
| 1508 | 102801CB (Dell Latitude 120L) |
| 1509 | 102801D3 |
| 1510 | */ |
| 1511 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1512 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1513 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1514 | }; |
| 1515 | |
| 1516 | /* |
| 1517 | STAC 9200-32 pin configs for |
| 1518 | 102801BD (Dell Inspiron E1505n) |
| 1519 | 102801EE |
| 1520 | 102801EF |
| 1521 | */ |
| 1522 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1523 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1524 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1525 | }; |
| 1526 | |
| 1527 | /* |
| 1528 | STAC 9200-32 pin configs for |
| 1529 | 102801F5 (Dell Inspiron 1501) |
| 1530 | 102801F6 |
| 1531 | */ |
| 1532 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1533 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1534 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1535 | }; |
| 1536 | |
| 1537 | /* |
| 1538 | STAC 9200-32 |
| 1539 | 102801CD (Dell Inspiron E1705/9400) |
| 1540 | */ |
| 1541 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1542 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1543 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1544 | }; |
| 1545 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1546 | static unsigned int oqo9200_pin_configs[8] = { |
| 1547 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1548 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1549 | }; |
| 1550 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1551 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1552 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1553 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1554 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1555 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1556 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1557 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1558 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1559 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1560 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1561 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1562 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1563 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1564 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1565 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1566 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1567 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1568 | }; |
| 1569 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1570 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1571 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1572 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1573 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1574 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1575 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1576 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1577 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1578 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1579 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1580 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1581 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1582 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1583 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1584 | [STAC_9200_M4] = "gateway-m4", |
| 1585 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1586 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1587 | }; |
| 1588 | |
| 1589 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1590 | /* SigmaTel reference board */ |
| 1591 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1592 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1593 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1594 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1595 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1596 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1597 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1598 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1599 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1600 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1601 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1602 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1603 | "unknown Dell", STAC_9200_DELL_D22), |
| 1604 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1605 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1606 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1607 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1608 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1609 | "unknown Dell", STAC_9200_DELL_D23), |
| 1610 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1611 | "unknown Dell", STAC_9200_DELL_D23), |
| 1612 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1613 | "unknown Dell", STAC_9200_DELL_M22), |
| 1614 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1615 | "unknown Dell", STAC_9200_DELL_M24), |
| 1616 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1617 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1618 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1619 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1620 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1621 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1622 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1623 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1624 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1625 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1626 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1627 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1628 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1629 | "unknown Dell", STAC_9200_DELL_M22), |
| 1630 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1631 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1632 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1633 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1634 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1635 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1636 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1637 | "unknown Dell", STAC_9200_DELL_D23), |
| 1638 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1639 | "unknown Dell", STAC_9200_DELL_D23), |
| 1640 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1641 | "unknown Dell", STAC_9200_DELL_D21), |
| 1642 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1643 | "unknown Dell", STAC_9200_DELL_D23), |
| 1644 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1645 | "unknown Dell", STAC_9200_DELL_D21), |
| 1646 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1647 | "unknown Dell", STAC_9200_DELL_M25), |
| 1648 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1649 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1650 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1651 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1652 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1653 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1654 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1655 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1656 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1657 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1658 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1659 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1660 | /* OQO Mobile */ |
| 1661 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1662 | {} /* terminator */ |
| 1663 | }; |
| 1664 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1665 | static unsigned int ref925x_pin_configs[8] = { |
| 1666 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1667 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1668 | }; |
| 1669 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1670 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1671 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1672 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1673 | }; |
| 1674 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1675 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1676 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1677 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1678 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1679 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1681 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1682 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1683 | }; |
| 1684 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1685 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1686 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1687 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1688 | }; |
| 1689 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1690 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1691 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1692 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1693 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1694 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1695 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1696 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1697 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1698 | }; |
| 1699 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1700 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1701 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1702 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1703 | }; |
| 1704 | |
| 1705 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1706 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1707 | [STAC_M1] = stac925xM1_pin_configs, |
| 1708 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1709 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1710 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1711 | [STAC_M3] = stac925xM3_pin_configs, |
| 1712 | [STAC_M5] = stac925xM5_pin_configs, |
| 1713 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1714 | }; |
| 1715 | |
| 1716 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1717 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1718 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1719 | [STAC_M1] = "m1", |
| 1720 | [STAC_M1_2] = "m1-2", |
| 1721 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1722 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1723 | [STAC_M3] = "m3", |
| 1724 | [STAC_M5] = "m5", |
| 1725 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1726 | }; |
| 1727 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1728 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1729 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1730 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1731 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1732 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1733 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1734 | /* Not sure about the brand name for those */ |
| 1735 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1736 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1737 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1738 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1739 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1740 | }; |
| 1741 | |
| 1742 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1743 | /* SigmaTel reference board */ |
| 1744 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1745 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1746 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1747 | |
| 1748 | /* Default table for unknown ID */ |
| 1749 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1750 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1751 | {} /* terminator */ |
| 1752 | }; |
| 1753 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1754 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1755 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1756 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1757 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1758 | 0x01452050, |
| 1759 | }; |
| 1760 | |
| 1761 | static unsigned int dell_m6_pin_configs[13] = { |
| 1762 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1763 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1764 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1765 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1766 | }; |
| 1767 | |
| 1768 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1769 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1770 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1771 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1772 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1773 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1774 | }; |
| 1775 | |
| 1776 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1777 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1778 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1779 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1780 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1781 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1782 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1783 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1784 | }; |
| 1785 | |
| 1786 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1787 | /* SigmaTel reference board */ |
| 1788 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1789 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1790 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1791 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1792 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1793 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1795 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1796 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1797 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1798 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1799 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1800 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1801 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1802 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1803 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1804 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1805 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1806 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1807 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1808 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1809 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1810 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1811 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1812 | {} /* terminator */ |
| 1813 | }; |
| 1814 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1815 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1816 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1817 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1818 | 0x01451160, 0x98560170, |
| 1819 | }; |
| 1820 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1821 | static unsigned int dell_s14_pin_configs[10] = { |
| 1822 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1823 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1824 | 0x40f000f0, 0x40f000f0, |
| 1825 | }; |
| 1826 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1827 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1828 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1829 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1830 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1831 | }; |
| 1832 | |
| 1833 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1834 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1835 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1836 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1837 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1838 | }; |
| 1839 | |
| 1840 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1841 | /* SigmaTel reference board */ |
| 1842 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1843 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1844 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1845 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1846 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1847 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1848 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1849 | }; |
| 1850 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1851 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1852 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1853 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1854 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1855 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1856 | }; |
| 1857 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1858 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1859 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1860 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1861 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1862 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1863 | }; |
| 1864 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1865 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1866 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1867 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1868 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1869 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1870 | }; |
| 1871 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1872 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1873 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1874 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1875 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1876 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1877 | }; |
| 1878 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1879 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1880 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1881 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1882 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1883 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1884 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1885 | [STAC_HP_DV5] = NULL, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1886 | [STAC_HP_HDX] = NULL, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1887 | [STAC_HP_DV4_1222NR] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1888 | }; |
| 1889 | |
| 1890 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1891 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1892 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1893 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1894 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1895 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1896 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1897 | [STAC_HP_DV5] = "hp-dv5", |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1898 | [STAC_HP_HDX] = "hp-hdx", |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1899 | [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1900 | }; |
| 1901 | |
| 1902 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1903 | /* SigmaTel reference board */ |
| 1904 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1905 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1906 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1907 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1908 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 1909 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1910 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 1911 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1912 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1913 | "HP dv4-7", STAC_HP_DV5), |
| 1914 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1915 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1916 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 1917 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1918 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1919 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1920 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1921 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1922 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1923 | "unknown Dell", STAC_DELL_M4_1), |
| 1924 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1925 | "unknown Dell", STAC_DELL_M4_1), |
| 1926 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1927 | "unknown Dell", STAC_DELL_M4_1), |
| 1928 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1929 | "unknown Dell", STAC_DELL_M4_1), |
| 1930 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1931 | "unknown Dell", STAC_DELL_M4_1), |
| 1932 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1933 | "unknown Dell", STAC_DELL_M4_1), |
| 1934 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1935 | "unknown Dell", STAC_DELL_M4_1), |
| 1936 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1937 | "unknown Dell", STAC_DELL_M4_2), |
| 1938 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1939 | "unknown Dell", STAC_DELL_M4_2), |
| 1940 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1941 | "unknown Dell", STAC_DELL_M4_2), |
| 1942 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1943 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1944 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1945 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1946 | {} /* terminator */ |
| 1947 | }; |
| 1948 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1949 | static unsigned int ref922x_pin_configs[10] = { |
| 1950 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1951 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1952 | 0x40000100, 0x40000100, |
| 1953 | }; |
| 1954 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1955 | /* |
| 1956 | STAC 922X pin configs for |
| 1957 | 102801A7 |
| 1958 | 102801AB |
| 1959 | 102801A9 |
| 1960 | 102801D1 |
| 1961 | 102801D2 |
| 1962 | */ |
| 1963 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1964 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1965 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1966 | 0x01813122, 0x400001f2, |
| 1967 | }; |
| 1968 | |
| 1969 | /* |
| 1970 | STAC 922X pin configs for |
| 1971 | 102801AC |
| 1972 | 102801D0 |
| 1973 | */ |
| 1974 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1975 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1976 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1977 | 0x01813122, 0x400001f1, |
| 1978 | }; |
| 1979 | |
| 1980 | /* |
| 1981 | STAC 922X pin configs for |
| 1982 | 102801BF |
| 1983 | */ |
| 1984 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1985 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1986 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1987 | 0x40C003f1, 0x405003f0, |
| 1988 | }; |
| 1989 | |
| 1990 | /* |
| 1991 | STAC 9221 A1 pin configs for |
| 1992 | 102801D7 (Dell XPS M1210) |
| 1993 | */ |
| 1994 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1995 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1996 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1997 | 0x508003f3, 0x405003f4, |
| 1998 | }; |
| 1999 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2000 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 2001 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2002 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2003 | 0x02a19120, 0x40000100, |
| 2004 | }; |
| 2005 | |
| 2006 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 2007 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 2008 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2009 | 0x02a19320, 0x40000100, |
| 2010 | }; |
| 2011 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2012 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 2013 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 2014 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2015 | 0x400000fc, 0x400000fb, |
| 2016 | }; |
| 2017 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2018 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 2019 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2020 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2021 | 0x400000fc, 0x400000fb, |
| 2022 | }; |
| 2023 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2024 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 2025 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2026 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 2027 | 0x400000fc, 0x400000fb, |
| 2028 | }; |
| 2029 | |
| 2030 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 2031 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2032 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2033 | 0x400000fc, 0x400000fb, |
| 2034 | }; |
| 2035 | |
| 2036 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 2037 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2038 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2039 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2040 | }; |
| 2041 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2042 | static unsigned int ecs202_pin_configs[10] = { |
| 2043 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 2044 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 2045 | 0x9037012e, 0x40e000f2, |
| 2046 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2047 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2048 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2049 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2050 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 2051 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2052 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 2053 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 2054 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 2055 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 2056 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2057 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2058 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2059 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 2060 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2061 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2062 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2063 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2064 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2065 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2066 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2067 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2068 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2069 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2070 | }; |
| 2071 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2072 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2073 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2074 | [STAC_D945_REF] = "ref", |
| 2075 | [STAC_D945GTP5] = "5stack", |
| 2076 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2077 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2078 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2079 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2080 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2081 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2082 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2083 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2084 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2085 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2086 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2087 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2088 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2089 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2090 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2091 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2092 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2093 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2094 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2095 | }; |
| 2096 | |
| 2097 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2098 | /* SigmaTel reference board */ |
| 2099 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2100 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2101 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2102 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2103 | /* Intel 945G based systems */ |
| 2104 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2105 | "Intel D945G", STAC_D945GTP3), |
| 2106 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2107 | "Intel D945G", STAC_D945GTP3), |
| 2108 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2109 | "Intel D945G", STAC_D945GTP3), |
| 2110 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2111 | "Intel D945G", STAC_D945GTP3), |
| 2112 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2113 | "Intel D945G", STAC_D945GTP3), |
| 2114 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2115 | "Intel D945G", STAC_D945GTP3), |
| 2116 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2117 | "Intel D945G", STAC_D945GTP3), |
| 2118 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2119 | "Intel D945G", STAC_D945GTP3), |
| 2120 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2121 | "Intel D945G", STAC_D945GTP3), |
| 2122 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2123 | "Intel D945G", STAC_D945GTP3), |
| 2124 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2125 | "Intel D945G", STAC_D945GTP3), |
| 2126 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2127 | "Intel D945G", STAC_D945GTP3), |
| 2128 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2129 | "Intel D945G", STAC_D945GTP3), |
| 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2131 | "Intel D945G", STAC_D945GTP3), |
| 2132 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2133 | "Intel D945G", STAC_D945GTP3), |
| 2134 | /* Intel D945G 5-stack systems */ |
| 2135 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2136 | "Intel D945G", STAC_D945GTP5), |
| 2137 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2138 | "Intel D945G", STAC_D945GTP5), |
| 2139 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2140 | "Intel D945G", STAC_D945GTP5), |
| 2141 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2142 | "Intel D945G", STAC_D945GTP5), |
| 2143 | /* Intel 945P based systems */ |
| 2144 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2145 | "Intel D945P", STAC_D945GTP3), |
| 2146 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2147 | "Intel D945P", STAC_D945GTP3), |
| 2148 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2149 | "Intel D945P", STAC_D945GTP3), |
| 2150 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2151 | "Intel D945P", STAC_D945GTP3), |
| 2152 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2153 | "Intel D945P", STAC_D945GTP3), |
| 2154 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2155 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2156 | /* other intel */ |
| 2157 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2158 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2159 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2160 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2161 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2162 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2163 | /* Dell systems */ |
| 2164 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2165 | "unknown Dell", STAC_922X_DELL_D81), |
| 2166 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2167 | "unknown Dell", STAC_922X_DELL_D81), |
| 2168 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2169 | "unknown Dell", STAC_922X_DELL_D81), |
| 2170 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2171 | "unknown Dell", STAC_922X_DELL_D82), |
| 2172 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2173 | "unknown Dell", STAC_922X_DELL_M81), |
| 2174 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2175 | "unknown Dell", STAC_922X_DELL_D82), |
| 2176 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2177 | "unknown Dell", STAC_922X_DELL_D81), |
| 2178 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2179 | "unknown Dell", STAC_922X_DELL_D81), |
| 2180 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2181 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2182 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2183 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2184 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2185 | {} /* terminator */ |
| 2186 | }; |
| 2187 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2188 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2189 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2190 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2191 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2192 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2193 | }; |
| 2194 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2195 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2196 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2197 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2198 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2199 | 0x40000100, 0x40000100 |
| 2200 | }; |
| 2201 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2202 | static unsigned int d965_5st_pin_configs[14] = { |
| 2203 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2204 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2205 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2206 | 0x40000100, 0x40000100 |
| 2207 | }; |
| 2208 | |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2209 | static unsigned int d965_5st_no_fp_pin_configs[14] = { |
| 2210 | 0x40000100, 0x40000100, 0x0181304e, 0x01014010, |
| 2211 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2212 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2213 | 0x40000100, 0x40000100 |
| 2214 | }; |
| 2215 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2216 | static unsigned int dell_3st_pin_configs[14] = { |
| 2217 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2218 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2219 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2220 | 0x40c003fc, 0x40000100 |
| 2221 | }; |
| 2222 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2223 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2224 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2225 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2226 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2227 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2228 | [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2229 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2230 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2231 | }; |
| 2232 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2233 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2234 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2235 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2236 | [STAC_D965_REF] = "ref", |
| 2237 | [STAC_D965_3ST] = "3stack", |
| 2238 | [STAC_D965_5ST] = "5stack", |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2239 | [STAC_D965_5ST_NO_FP] = "5stack-no-fp", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2240 | [STAC_DELL_3ST] = "dell-3stack", |
| 2241 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2242 | }; |
| 2243 | |
| 2244 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2245 | /* SigmaTel reference board */ |
| 2246 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2247 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2248 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2249 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2250 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2251 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2252 | 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] | 2253 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2254 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2255 | "Intel D965", STAC_D965_3ST), |
| 2256 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2257 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2258 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2259 | 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] | 2260 | 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] | 2261 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2262 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2263 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2264 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2265 | 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] | 2266 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2267 | 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] | 2268 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2269 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2270 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2271 | 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] | 2272 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2273 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2274 | "Intel D965", STAC_D965_5ST), |
| 2275 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2276 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2277 | {} /* terminator */ |
| 2278 | }; |
| 2279 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2280 | static unsigned int ref9205_pin_configs[12] = { |
| 2281 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2282 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2283 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2284 | }; |
| 2285 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2286 | /* |
| 2287 | STAC 9205 pin configs for |
| 2288 | 102801F1 |
| 2289 | 102801F2 |
| 2290 | 102801FC |
| 2291 | 102801FD |
| 2292 | 10280204 |
| 2293 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2294 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2295 | */ |
| 2296 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2297 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2298 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2299 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2300 | }; |
| 2301 | |
| 2302 | /* |
| 2303 | STAC 9205 pin configs for |
| 2304 | 102801F9 |
| 2305 | 102801FA |
| 2306 | 102801FE |
| 2307 | 102801FF (Dell Precision M4300) |
| 2308 | 10280206 |
| 2309 | 10280200 |
| 2310 | 10280201 |
| 2311 | */ |
| 2312 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2313 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2314 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2315 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2316 | }; |
| 2317 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2318 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2319 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2320 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2321 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2322 | }; |
| 2323 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2324 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2325 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2326 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2327 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2328 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2329 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2330 | }; |
| 2331 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2332 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2333 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2334 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2335 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2336 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2337 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2338 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2339 | }; |
| 2340 | |
| 2341 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2342 | /* SigmaTel reference board */ |
| 2343 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2344 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 2345 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 2346 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2347 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2348 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2349 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2350 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2351 | "unknown Dell", STAC_9205_DELL_M42), |
| 2352 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2353 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2354 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2355 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2356 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2357 | "Dell Precision", STAC_9205_DELL_M43), |
| 2358 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2359 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2360 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2361 | "unknown Dell", STAC_9205_DELL_M42), |
| 2362 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2363 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2364 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2365 | "Dell Precision", STAC_9205_DELL_M43), |
| 2366 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2367 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2368 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2369 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2370 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2371 | "Dell Precision", STAC_9205_DELL_M43), |
| 2372 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2373 | "Dell Precision", STAC_9205_DELL_M43), |
| 2374 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2375 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2376 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2377 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2378 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2379 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2380 | /* Gateway */ |
| 2381 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2382 | {} /* terminator */ |
| 2383 | }; |
| 2384 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2385 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2386 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2387 | { |
| 2388 | int i; |
| 2389 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2390 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2391 | if (!pincfgs) |
| 2392 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2393 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2394 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2395 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2396 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2397 | pincfgs[i]); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2398 | } |
| 2399 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2400 | /* |
| 2401 | * Analog playback callbacks |
| 2402 | */ |
| 2403 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2404 | struct hda_codec *codec, |
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; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2408 | if (spec->stream_delay) |
| 2409 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2410 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2411 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2412 | } |
| 2413 | |
| 2414 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2415 | struct hda_codec *codec, |
| 2416 | unsigned int stream_tag, |
| 2417 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2418 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2419 | { |
| 2420 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2421 | 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] | 2422 | } |
| 2423 | |
| 2424 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2425 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2426 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2427 | { |
| 2428 | struct sigmatel_spec *spec = codec->spec; |
| 2429 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2430 | } |
| 2431 | |
| 2432 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2433 | * Digital playback callbacks |
| 2434 | */ |
| 2435 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2436 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2437 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2438 | { |
| 2439 | struct sigmatel_spec *spec = codec->spec; |
| 2440 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2441 | } |
| 2442 | |
| 2443 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2444 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2445 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2446 | { |
| 2447 | struct sigmatel_spec *spec = codec->spec; |
| 2448 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2449 | } |
| 2450 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2451 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2452 | struct hda_codec *codec, |
| 2453 | unsigned int stream_tag, |
| 2454 | unsigned int format, |
| 2455 | struct snd_pcm_substream *substream) |
| 2456 | { |
| 2457 | struct sigmatel_spec *spec = codec->spec; |
| 2458 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2459 | stream_tag, format, substream); |
| 2460 | } |
| 2461 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2462 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2463 | struct hda_codec *codec, |
| 2464 | struct snd_pcm_substream *substream) |
| 2465 | { |
| 2466 | struct sigmatel_spec *spec = codec->spec; |
| 2467 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2468 | } |
| 2469 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2470 | |
| 2471 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2472 | * Analog capture callbacks |
| 2473 | */ |
| 2474 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2475 | struct hda_codec *codec, |
| 2476 | unsigned int stream_tag, |
| 2477 | unsigned int format, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2478 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2479 | { |
| 2480 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2481 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2482 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2483 | if (spec->powerdown_adcs) { |
| 2484 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2485 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2486 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2487 | } |
| 2488 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2489 | return 0; |
| 2490 | } |
| 2491 | |
| 2492 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2493 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2494 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2495 | { |
| 2496 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2497 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2498 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2499 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2500 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2501 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2502 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2503 | return 0; |
| 2504 | } |
| 2505 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2506 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2507 | .substreams = 1, |
| 2508 | .channels_min = 2, |
| 2509 | .channels_max = 2, |
| 2510 | /* NID is set in stac92xx_build_pcms */ |
| 2511 | .ops = { |
| 2512 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2513 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2514 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2515 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2516 | }, |
| 2517 | }; |
| 2518 | |
| 2519 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2520 | .substreams = 1, |
| 2521 | .channels_min = 2, |
| 2522 | .channels_max = 2, |
| 2523 | /* NID is set in stac92xx_build_pcms */ |
| 2524 | }; |
| 2525 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2526 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2527 | .substreams = 1, |
| 2528 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2529 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2530 | .nid = 0x02, /* NID to query formats and rates */ |
| 2531 | .ops = { |
| 2532 | .open = stac92xx_playback_pcm_open, |
| 2533 | .prepare = stac92xx_playback_pcm_prepare, |
| 2534 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2535 | }, |
| 2536 | }; |
| 2537 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2538 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2539 | .substreams = 1, |
| 2540 | .channels_min = 2, |
| 2541 | .channels_max = 2, |
| 2542 | .nid = 0x06, /* NID to query formats and rates */ |
| 2543 | .ops = { |
| 2544 | .open = stac92xx_playback_pcm_open, |
| 2545 | .prepare = stac92xx_playback_pcm_prepare, |
| 2546 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2547 | }, |
| 2548 | }; |
| 2549 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2550 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2551 | .channels_min = 2, |
| 2552 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2553 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2554 | .ops = { |
| 2555 | .prepare = stac92xx_capture_pcm_prepare, |
| 2556 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2557 | }, |
| 2558 | }; |
| 2559 | |
| 2560 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2561 | { |
| 2562 | struct sigmatel_spec *spec = codec->spec; |
| 2563 | struct hda_pcm *info = spec->pcm_rec; |
| 2564 | |
| 2565 | codec->num_pcms = 1; |
| 2566 | codec->pcm_info = info; |
| 2567 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2568 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2569 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2570 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2571 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2572 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2573 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2574 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2575 | |
| 2576 | if (spec->alt_switch) { |
| 2577 | codec->num_pcms++; |
| 2578 | info++; |
| 2579 | info->name = "STAC92xx Analog Alt"; |
| 2580 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2581 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2582 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2583 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2584 | codec->num_pcms++; |
| 2585 | info++; |
| 2586 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2587 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2588 | if (spec->multiout.dig_out_nid) { |
| 2589 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2590 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2591 | } |
| 2592 | if (spec->dig_in_nid) { |
| 2593 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2594 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2595 | } |
| 2596 | } |
| 2597 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2598 | return 0; |
| 2599 | } |
| 2600 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2601 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, |
| 2602 | hda_nid_t nid) |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2603 | { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2604 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2605 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2606 | if (pincap & AC_PINCAP_VREF_100) |
| 2607 | return AC_PINCTL_VREF_100; |
| 2608 | if (pincap & AC_PINCAP_VREF_80) |
| 2609 | return AC_PINCTL_VREF_80; |
| 2610 | if (pincap & AC_PINCAP_VREF_50) |
| 2611 | return AC_PINCTL_VREF_50; |
| 2612 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2613 | return AC_PINCTL_VREF_GRD; |
| 2614 | return 0; |
| 2615 | } |
| 2616 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2617 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2618 | |
| 2619 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2620 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2621 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2622 | } |
| 2623 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2624 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2625 | |
| 2626 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2627 | struct snd_ctl_elem_value *ucontrol) |
| 2628 | { |
| 2629 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2630 | struct sigmatel_spec *spec = codec->spec; |
| 2631 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2632 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2633 | return 0; |
| 2634 | } |
| 2635 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2636 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 2637 | unsigned char type); |
| 2638 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2639 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2640 | struct snd_ctl_elem_value *ucontrol) |
| 2641 | { |
| 2642 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2643 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2644 | int nid = kcontrol->private_value; |
| 2645 | |
| 2646 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2647 | |
| 2648 | /* check to be sure that the ports are upto date with |
| 2649 | * switch changes |
| 2650 | */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2651 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2652 | |
| 2653 | return 1; |
| 2654 | } |
| 2655 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2656 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 2657 | struct snd_ctl_elem_info *uinfo) |
| 2658 | { |
| 2659 | int i; |
| 2660 | static char *texts[] = { |
| 2661 | "Mic In", "Line In", "Line Out" |
| 2662 | }; |
| 2663 | |
| 2664 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2665 | struct sigmatel_spec *spec = codec->spec; |
| 2666 | hda_nid_t nid = kcontrol->private_value; |
| 2667 | |
| 2668 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 2669 | i = 3; |
| 2670 | else |
| 2671 | i = 2; |
| 2672 | |
| 2673 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2674 | uinfo->value.enumerated.items = i; |
| 2675 | uinfo->count = 1; |
| 2676 | if (uinfo->value.enumerated.item >= i) |
| 2677 | uinfo->value.enumerated.item = i-1; |
| 2678 | strcpy(uinfo->value.enumerated.name, |
| 2679 | texts[uinfo->value.enumerated.item]); |
| 2680 | |
| 2681 | return 0; |
| 2682 | } |
| 2683 | |
| 2684 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 2685 | struct snd_ctl_elem_value *ucontrol) |
| 2686 | { |
| 2687 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2688 | hda_nid_t nid = kcontrol->private_value; |
| 2689 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 2690 | |
| 2691 | if (vref == stac92xx_get_default_vref(codec, nid)) |
| 2692 | ucontrol->value.enumerated.item[0] = 0; |
| 2693 | else if (vref == AC_PINCTL_VREF_GRD) |
| 2694 | ucontrol->value.enumerated.item[0] = 1; |
| 2695 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 2696 | ucontrol->value.enumerated.item[0] = 2; |
| 2697 | |
| 2698 | return 0; |
| 2699 | } |
| 2700 | |
| 2701 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 2702 | struct snd_ctl_elem_value *ucontrol) |
| 2703 | { |
| 2704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2705 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 2706 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2707 | hda_nid_t nid = kcontrol->private_value; |
| 2708 | |
| 2709 | if (ucontrol->value.enumerated.item[0] == 0) |
| 2710 | new_vref = stac92xx_get_default_vref(codec, nid); |
| 2711 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 2712 | new_vref = AC_PINCTL_VREF_GRD; |
| 2713 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 2714 | new_vref = AC_PINCTL_VREF_HIZ; |
| 2715 | else |
| 2716 | return 0; |
| 2717 | |
| 2718 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 2719 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 2720 | return error; |
| 2721 | } |
| 2722 | |
| 2723 | return 0; |
| 2724 | } |
| 2725 | |
| 2726 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 2727 | struct snd_ctl_elem_info *uinfo) |
| 2728 | { |
| 2729 | static char *texts[2]; |
| 2730 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2731 | struct sigmatel_spec *spec = codec->spec; |
| 2732 | |
| 2733 | if (kcontrol->private_value == spec->line_switch) |
| 2734 | texts[0] = "Line In"; |
| 2735 | else |
| 2736 | texts[0] = "Mic In"; |
| 2737 | texts[1] = "Line Out"; |
| 2738 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2739 | uinfo->value.enumerated.items = 2; |
| 2740 | uinfo->count = 1; |
| 2741 | |
| 2742 | if (uinfo->value.enumerated.item >= 2) |
| 2743 | uinfo->value.enumerated.item = 1; |
| 2744 | strcpy(uinfo->value.enumerated.name, |
| 2745 | texts[uinfo->value.enumerated.item]); |
| 2746 | |
| 2747 | return 0; |
| 2748 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2749 | |
| 2750 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2751 | { |
| 2752 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2753 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2754 | hda_nid_t nid = kcontrol->private_value; |
| 2755 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2756 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2757 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2758 | return 0; |
| 2759 | } |
| 2760 | |
| 2761 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2762 | { |
| 2763 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2764 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2765 | hda_nid_t nid = kcontrol->private_value; |
| 2766 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 2767 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2768 | |
| 2769 | spec->io_switch[io_idx] = val; |
| 2770 | |
| 2771 | if (val) |
| 2772 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2773 | else { |
| 2774 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2775 | if (io_idx) /* set VREF for mic */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2776 | pinctl |= stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2777 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2778 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2779 | |
| 2780 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2781 | * appropriately according to the pin direction |
| 2782 | */ |
| 2783 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2784 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2785 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2786 | return 1; |
| 2787 | } |
| 2788 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2789 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2790 | |
| 2791 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2792 | struct snd_ctl_elem_value *ucontrol) |
| 2793 | { |
| 2794 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2795 | struct sigmatel_spec *spec = codec->spec; |
| 2796 | |
| 2797 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2798 | return 0; |
| 2799 | } |
| 2800 | |
| 2801 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2802 | struct snd_ctl_elem_value *ucontrol) |
| 2803 | { |
| 2804 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2805 | struct sigmatel_spec *spec = codec->spec; |
| 2806 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2807 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2808 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2809 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2810 | return 0; |
| 2811 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2812 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2813 | |
| 2814 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2815 | spec->clfe_swap ? 0x4 : 0x0); |
| 2816 | |
| 2817 | return 1; |
| 2818 | } |
| 2819 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2820 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2821 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2822 | .name = xname, \ |
| 2823 | .index = 0, \ |
| 2824 | .info = stac92xx_hp_switch_info, \ |
| 2825 | .get = stac92xx_hp_switch_get, \ |
| 2826 | .put = stac92xx_hp_switch_put, \ |
| 2827 | } |
| 2828 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2829 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2830 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2831 | .name = xname, \ |
| 2832 | .index = 0, \ |
| 2833 | .info = stac92xx_io_switch_info, \ |
| 2834 | .get = stac92xx_io_switch_get, \ |
| 2835 | .put = stac92xx_io_switch_put, \ |
| 2836 | .private_value = xpval, \ |
| 2837 | } |
| 2838 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2839 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2840 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2841 | .name = xname, \ |
| 2842 | .index = 0, \ |
| 2843 | .info = stac92xx_clfe_switch_info, \ |
| 2844 | .get = stac92xx_clfe_switch_get, \ |
| 2845 | .put = stac92xx_clfe_switch_put, \ |
| 2846 | .private_value = xpval, \ |
| 2847 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2848 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2849 | enum { |
| 2850 | STAC_CTL_WIDGET_VOL, |
| 2851 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2852 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2853 | STAC_CTL_WIDGET_AMP_MUX, |
| 2854 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2855 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2856 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2857 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2858 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2859 | }; |
| 2860 | |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2861 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2862 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2863 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2864 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2865 | STAC_AMP_MUX, |
| 2866 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2867 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2868 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2869 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2870 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2871 | }; |
| 2872 | |
| 2873 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2874 | static struct snd_kcontrol_new * |
| 2875 | stac_control_new(struct sigmatel_spec *spec, |
| 2876 | struct snd_kcontrol_new *ktemp, |
| 2877 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2878 | { |
Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2879 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2880 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2881 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2882 | knew = snd_array_new(&spec->kctls); |
| 2883 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2884 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2885 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2886 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2887 | if (!knew->name) { |
| 2888 | /* roolback */ |
| 2889 | memset(knew, 0, sizeof(*knew)); |
| 2890 | spec->kctls.alloced--; |
| 2891 | return NULL; |
| 2892 | } |
| 2893 | return knew; |
| 2894 | } |
| 2895 | |
| 2896 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2897 | struct snd_kcontrol_new *ktemp, |
| 2898 | int idx, const char *name, |
| 2899 | unsigned long val) |
| 2900 | { |
| 2901 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2902 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2903 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2904 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2905 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2906 | return 0; |
| 2907 | } |
| 2908 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2909 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2910 | int type, int idx, const char *name, |
| 2911 | unsigned long val) |
| 2912 | { |
| 2913 | return stac92xx_add_control_temp(spec, |
| 2914 | &stac92xx_control_templates[type], |
| 2915 | idx, name, val); |
| 2916 | } |
| 2917 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2918 | |
| 2919 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2920 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2921 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2922 | { |
| 2923 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2924 | } |
| 2925 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2926 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2927 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2928 | .name = "Input Source", |
| 2929 | .info = stac92xx_mux_enum_info, |
| 2930 | .get = stac92xx_mux_enum_get, |
| 2931 | .put = stac92xx_mux_enum_put, |
| 2932 | }; |
| 2933 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2934 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 2935 | hda_nid_t nid, int idx) |
| 2936 | { |
| 2937 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 2938 | int control = 0; |
| 2939 | struct sigmatel_spec *spec = codec->spec; |
| 2940 | char name[22]; |
| 2941 | |
| 2942 | if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { |
| 2943 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
| 2944 | && nid == spec->line_switch) |
| 2945 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2946 | else if (snd_hda_query_pin_caps(codec, nid) |
| 2947 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 2948 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 2949 | else if (nid == spec->mic_switch) |
| 2950 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2951 | } |
| 2952 | |
| 2953 | if (control) { |
| 2954 | strcpy(name, auto_pin_cfg_labels[idx]); |
| 2955 | return stac92xx_add_control(codec->spec, control, |
| 2956 | strcat(name, " Jack Mode"), nid); |
| 2957 | } |
| 2958 | |
| 2959 | return 0; |
| 2960 | } |
| 2961 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2962 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2963 | { |
| 2964 | struct snd_kcontrol_new *knew; |
| 2965 | struct hda_input_mux *imux = &spec->private_imux; |
| 2966 | |
| 2967 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2968 | return 0; /* no need for input source control */ |
| 2969 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2970 | stac_input_src_temp.name); |
| 2971 | if (!knew) |
| 2972 | return -ENOMEM; |
| 2973 | knew->count = spec->num_adcs; |
| 2974 | return 0; |
| 2975 | } |
| 2976 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2977 | /* check whether the line-input can be used as line-out */ |
| 2978 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2979 | { |
| 2980 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2981 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2982 | hda_nid_t nid; |
| 2983 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2984 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2985 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2986 | return 0; |
| 2987 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2988 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2989 | if (pincap & AC_PINCAP_OUT) |
| 2990 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2991 | return 0; |
| 2992 | } |
| 2993 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2994 | /* check whether the mic-input can be used as line-out */ |
| 2995 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2996 | { |
| 2997 | struct sigmatel_spec *spec = codec->spec; |
| 2998 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2999 | unsigned int def_conf, pincap; |
| 3000 | unsigned int mic_pin; |
| 3001 | |
| 3002 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 3003 | return 0; |
| 3004 | mic_pin = AUTO_PIN_MIC; |
| 3005 | for (;;) { |
| 3006 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3007 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3008 | /* some laptops have an internal analog microphone |
| 3009 | * which can't be used as a output */ |
| 3010 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 3011 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3012 | if (pincap & AC_PINCAP_OUT) |
| 3013 | return nid; |
| 3014 | } |
| 3015 | if (mic_pin == AUTO_PIN_MIC) |
| 3016 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 3017 | else |
| 3018 | break; |
| 3019 | } |
| 3020 | return 0; |
| 3021 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3022 | |
| 3023 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3024 | { |
| 3025 | int i; |
| 3026 | |
| 3027 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 3028 | if (spec->multiout.dac_nids[i] == nid) |
| 3029 | return 1; |
| 3030 | } |
| 3031 | |
| 3032 | return 0; |
| 3033 | } |
| 3034 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3035 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3036 | { |
| 3037 | int i; |
| 3038 | if (is_in_dac_nids(spec, nid)) |
| 3039 | return 1; |
| 3040 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 3041 | if (spec->hp_dacs[i] == nid) |
| 3042 | return 1; |
| 3043 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 3044 | if (spec->speaker_dacs[i] == nid) |
| 3045 | return 1; |
| 3046 | return 0; |
| 3047 | } |
| 3048 | |
| 3049 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 3050 | { |
| 3051 | struct sigmatel_spec *spec = codec->spec; |
| 3052 | int j, conn_len; |
| 3053 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 3054 | unsigned int wcaps, wtype; |
| 3055 | |
| 3056 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 3057 | HDA_MAX_CONNECTIONS); |
| 3058 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 3059 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3060 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 3061 | /* we check only analog outputs */ |
| 3062 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 3063 | continue; |
| 3064 | /* if this route has a free DAC, assign it */ |
| 3065 | if (!check_all_dac_nids(spec, conn[j])) { |
| 3066 | if (conn_len > 1) { |
| 3067 | /* select this DAC in the pin's input mux */ |
| 3068 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3069 | AC_VERB_SET_CONNECT_SEL, j); |
| 3070 | } |
| 3071 | return conn[j]; |
| 3072 | } |
| 3073 | } |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 3074 | /* if all DACs are already assigned, connect to the primary DAC */ |
| 3075 | if (conn_len > 1) { |
| 3076 | for (j = 0; j < conn_len; j++) { |
| 3077 | if (conn[j] == spec->multiout.dac_nids[0]) { |
| 3078 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3079 | AC_VERB_SET_CONNECT_SEL, j); |
| 3080 | break; |
| 3081 | } |
| 3082 | } |
| 3083 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3084 | return 0; |
| 3085 | } |
| 3086 | |
| 3087 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3088 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3089 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3090 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3091 | * Fill in the dac_nids table from the parsed pin configuration |
| 3092 | * This function only works when every pin in line_out_pins[] |
| 3093 | * contains atleast one DAC in its connection list. Some 92xx |
| 3094 | * codecs are not connected directly to a DAC, such as the 9200 |
| 3095 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3096 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3097 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3098 | { |
| 3099 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3100 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3101 | int i; |
| 3102 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3103 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3104 | for (i = 0; i < cfg->line_outs; i++) { |
| 3105 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3106 | dac = get_unassigned_dac(codec, nid); |
| 3107 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 3108 | if (spec->multiout.num_dacs > 0) { |
| 3109 | /* we have already working output pins, |
| 3110 | * so let's drop the broken ones again |
| 3111 | */ |
| 3112 | cfg->line_outs = spec->multiout.num_dacs; |
| 3113 | break; |
| 3114 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3115 | /* error out, no available DAC found */ |
| 3116 | snd_printk(KERN_ERR |
| 3117 | "%s: No available DAC for pin 0x%x\n", |
| 3118 | __func__, nid); |
| 3119 | return -ENODEV; |
| 3120 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3121 | add_spec_dacs(spec, dac); |
| 3122 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3123 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 3124 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3125 | nid = cfg->hp_pins[i]; |
| 3126 | dac = get_unassigned_dac(codec, nid); |
| 3127 | if (dac) { |
| 3128 | if (!spec->multiout.hp_nid) |
| 3129 | spec->multiout.hp_nid = dac; |
| 3130 | else |
| 3131 | add_spec_extra_dacs(spec, dac); |
| 3132 | } |
| 3133 | spec->hp_dacs[i] = dac; |
| 3134 | } |
| 3135 | |
| 3136 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 3137 | nid = cfg->speaker_pins[i]; |
| 3138 | dac = get_unassigned_dac(codec, nid); |
| 3139 | if (dac) |
| 3140 | add_spec_extra_dacs(spec, dac); |
| 3141 | spec->speaker_dacs[i] = dac; |
| 3142 | } |
| 3143 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3144 | /* add line-in as output */ |
| 3145 | nid = check_line_out_switch(codec); |
| 3146 | if (nid) { |
| 3147 | dac = get_unassigned_dac(codec, nid); |
| 3148 | if (dac) { |
| 3149 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 3150 | nid, cfg->line_outs); |
| 3151 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3152 | cfg->line_outs++; |
| 3153 | spec->line_switch = nid; |
| 3154 | add_spec_dacs(spec, dac); |
| 3155 | } |
| 3156 | } |
| 3157 | /* add mic as output */ |
| 3158 | nid = check_mic_out_switch(codec); |
| 3159 | if (nid) { |
| 3160 | dac = get_unassigned_dac(codec, nid); |
| 3161 | if (dac) { |
| 3162 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 3163 | nid, cfg->line_outs); |
| 3164 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3165 | cfg->line_outs++; |
| 3166 | spec->mic_switch = nid; |
| 3167 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3168 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3169 | } |
| 3170 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3171 | 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] | 3172 | spec->multiout.num_dacs, |
| 3173 | spec->multiout.dac_nids[0], |
| 3174 | spec->multiout.dac_nids[1], |
| 3175 | spec->multiout.dac_nids[2], |
| 3176 | spec->multiout.dac_nids[3], |
| 3177 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3178 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3179 | return 0; |
| 3180 | } |
| 3181 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3182 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3183 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 3184 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3185 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3186 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3187 | char name[32]; |
| 3188 | int err; |
| 3189 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3190 | if (!spec->check_volume_offset) { |
| 3191 | unsigned int caps, step, nums, db_scale; |
| 3192 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3193 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 3194 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 3195 | step = (step + 1) * 25; /* in .01dB unit */ |
| 3196 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 3197 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3198 | db_scale = nums * step; |
| 3199 | /* if dB scale is over -64dB, and finer enough, |
| 3200 | * let's reduce it to half |
| 3201 | */ |
| 3202 | if (db_scale > 6400 && nums >= 0x1f) |
| 3203 | spec->volume_offset = nums / 2; |
| 3204 | spec->check_volume_offset = 1; |
| 3205 | } |
| 3206 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3207 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3208 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3209 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3210 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3211 | if (err < 0) |
| 3212 | return err; |
| 3213 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3214 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3215 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3216 | if (err < 0) |
| 3217 | return err; |
| 3218 | return 0; |
| 3219 | } |
| 3220 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3221 | #define create_controls(codec, pfx, nid, chs) \ |
| 3222 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 3223 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3224 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3225 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3226 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3227 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3228 | return 1; |
| 3229 | } else { |
| 3230 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3231 | spec->multiout.num_dacs++; |
| 3232 | } |
| 3233 | return 0; |
| 3234 | } |
| 3235 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3236 | 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] | 3237 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3238 | int i; |
| 3239 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3240 | if (!spec->multiout.extra_out_nid[i]) { |
| 3241 | spec->multiout.extra_out_nid[i] = nid; |
| 3242 | return 0; |
| 3243 | } |
| 3244 | } |
| 3245 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3246 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3247 | } |
| 3248 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3249 | /* Create output controls |
| 3250 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3251 | */ |
| 3252 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3253 | const hda_nid_t *pins, |
| 3254 | const hda_nid_t *dac_nids, |
| 3255 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3256 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3257 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3258 | static const char *chname[4] = { |
| 3259 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3260 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3261 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3262 | int i, err; |
| 3263 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3264 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3265 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 3266 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3267 | wid_caps = get_wcaps(codec, pins[i]); |
| 3268 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3269 | spec->hp_detect = 1; |
| 3270 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3271 | nid = dac_nids[i]; |
| 3272 | if (!nid) |
| 3273 | continue; |
| 3274 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3275 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3276 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3277 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3278 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3279 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3280 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3281 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3282 | |
| 3283 | wid_caps = get_wcaps(codec, nid); |
| 3284 | |
| 3285 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3286 | err = stac92xx_add_control(spec, |
| 3287 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3288 | "Swap Center/LFE Playback Switch", nid); |
| 3289 | |
| 3290 | if (err < 0) |
| 3291 | return err; |
| 3292 | } |
| 3293 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3294 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3295 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3296 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3297 | switch (type) { |
| 3298 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3299 | name = "Headphone"; |
| 3300 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3301 | break; |
| 3302 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3303 | name = "Speaker"; |
| 3304 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3305 | break; |
| 3306 | default: |
| 3307 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3308 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3309 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3310 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3311 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3312 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3313 | return err; |
| 3314 | } |
| 3315 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3316 | return 0; |
| 3317 | } |
| 3318 | |
| 3319 | /* add playback controls from the parsed DAC table */ |
| 3320 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3321 | const struct auto_pin_cfg *cfg) |
| 3322 | { |
| 3323 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3324 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3325 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3326 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3327 | |
| 3328 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3329 | spec->multiout.dac_nids, |
| 3330 | cfg->line_out_type); |
| 3331 | if (err < 0) |
| 3332 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3333 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3334 | 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] | 3335 | err = stac92xx_add_control(spec, |
| 3336 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3337 | "Headphone as Line Out Switch", |
| 3338 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3339 | if (err < 0) |
| 3340 | return err; |
| 3341 | } |
| 3342 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3343 | for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { |
| 3344 | nid = cfg->input_pins[idx]; |
| 3345 | if (nid) { |
| 3346 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 3347 | if (err < 0) |
| 3348 | return err; |
| 3349 | } |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3350 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3351 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3352 | return 0; |
| 3353 | } |
| 3354 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3355 | /* add playback controls for Speaker and HP outputs */ |
| 3356 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3357 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3358 | { |
| 3359 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3360 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3361 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3362 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3363 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3364 | if (err < 0) |
| 3365 | return err; |
| 3366 | |
| 3367 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3368 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3369 | if (err < 0) |
| 3370 | return err; |
| 3371 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3372 | return 0; |
| 3373 | } |
| 3374 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3375 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3376 | static const char *stac92xx_mono_labels[4] = { |
| 3377 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3378 | }; |
| 3379 | |
| 3380 | /* create mono mux for mono out on capable codecs */ |
| 3381 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3382 | { |
| 3383 | struct sigmatel_spec *spec = codec->spec; |
| 3384 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3385 | int i, num_cons; |
| 3386 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3387 | |
| 3388 | num_cons = snd_hda_get_connections(codec, |
| 3389 | spec->mono_nid, |
| 3390 | con_lst, |
| 3391 | HDA_MAX_NUM_INPUTS); |
| 3392 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 3393 | return -EINVAL; |
| 3394 | |
| 3395 | for (i = 0; i < num_cons; i++) { |
| 3396 | mono_mux->items[mono_mux->num_items].label = |
| 3397 | stac92xx_mono_labels[i]; |
| 3398 | mono_mux->items[mono_mux->num_items].index = i; |
| 3399 | mono_mux->num_items++; |
| 3400 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3401 | |
| 3402 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3403 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3404 | } |
| 3405 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3406 | /* labels for amp mux outputs */ |
| 3407 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3408 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3409 | }; |
| 3410 | |
| 3411 | /* create amp out controls mux on capable codecs */ |
| 3412 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3413 | { |
| 3414 | struct sigmatel_spec *spec = codec->spec; |
| 3415 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3416 | int i, err; |
| 3417 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3418 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3419 | amp_mux->items[amp_mux->num_items].label = |
| 3420 | stac92xx_amp_labels[i]; |
| 3421 | amp_mux->items[amp_mux->num_items].index = i; |
| 3422 | amp_mux->num_items++; |
| 3423 | } |
| 3424 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3425 | if (spec->num_amps > 1) { |
| 3426 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3427 | "Amp Selector Capture Switch", 0); |
| 3428 | if (err < 0) |
| 3429 | return err; |
| 3430 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3431 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3432 | "Amp Capture Volume", |
| 3433 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3434 | } |
| 3435 | |
| 3436 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3437 | /* create PC beep volume controls */ |
| 3438 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3439 | hda_nid_t nid) |
| 3440 | { |
| 3441 | struct sigmatel_spec *spec = codec->spec; |
| 3442 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3443 | int err; |
| 3444 | |
| 3445 | /* check for mute support for the the amp */ |
| 3446 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3447 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3448 | "PC Beep Playback Switch", |
| 3449 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3450 | if (err < 0) |
| 3451 | return err; |
| 3452 | } |
| 3453 | |
| 3454 | /* check to see if there is volume support for the amp */ |
| 3455 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3456 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3457 | "PC Beep Playback Volume", |
| 3458 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3459 | if (err < 0) |
| 3460 | return err; |
| 3461 | } |
| 3462 | return 0; |
| 3463 | } |
| 3464 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3465 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3466 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3467 | |
| 3468 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3469 | struct snd_ctl_elem_value *ucontrol) |
| 3470 | { |
| 3471 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3472 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3473 | return 0; |
| 3474 | } |
| 3475 | |
| 3476 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3477 | struct snd_ctl_elem_value *ucontrol) |
| 3478 | { |
| 3479 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3480 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3481 | if (codec->beep->enabled != enabled) { |
| 3482 | codec->beep->enabled = enabled; |
| 3483 | return 1; |
| 3484 | } |
| 3485 | return 0; |
| 3486 | } |
| 3487 | |
| 3488 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3489 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3490 | .info = stac92xx_dig_beep_switch_info, |
| 3491 | .get = stac92xx_dig_beep_switch_get, |
| 3492 | .put = stac92xx_dig_beep_switch_put, |
| 3493 | }; |
| 3494 | |
| 3495 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3496 | { |
| 3497 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3498 | 0, "PC Beep Playback Switch", 0); |
| 3499 | } |
| 3500 | #endif |
| 3501 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3502 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3503 | { |
| 3504 | struct sigmatel_spec *spec = codec->spec; |
| 3505 | int wcaps, nid, i, err = 0; |
| 3506 | |
| 3507 | for (i = 0; i < spec->num_muxes; i++) { |
| 3508 | nid = spec->mux_nids[i]; |
| 3509 | wcaps = get_wcaps(codec, nid); |
| 3510 | |
| 3511 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3512 | err = stac92xx_add_control_idx(spec, |
| 3513 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3514 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3515 | if (err < 0) |
| 3516 | return err; |
| 3517 | } |
| 3518 | } |
| 3519 | return 0; |
| 3520 | }; |
| 3521 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3522 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3523 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3524 | }; |
| 3525 | |
| 3526 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3527 | { |
| 3528 | struct sigmatel_spec *spec = codec->spec; |
| 3529 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3530 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3531 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3532 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3533 | |
| 3534 | num_cons = snd_hda_get_connections(codec, |
| 3535 | spec->smux_nids[0], |
| 3536 | con_lst, |
| 3537 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3538 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3539 | return -EINVAL; |
| 3540 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3541 | if (!labels) |
| 3542 | labels = stac92xx_spdif_labels; |
| 3543 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3544 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3545 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3546 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3547 | spdif_mux->num_items++; |
| 3548 | } |
| 3549 | |
| 3550 | return 0; |
| 3551 | } |
| 3552 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3553 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3554 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3555 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3556 | "Digital Mic 3", "Digital Mic 4" |
| 3557 | }; |
| 3558 | |
| 3559 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3560 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3561 | const struct auto_pin_cfg *cfg) |
| 3562 | { |
| 3563 | struct sigmatel_spec *spec = codec->spec; |
| 3564 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3565 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3566 | int err, i, j; |
| 3567 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3568 | |
| 3569 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3570 | dimux->items[dimux->num_items].index = 0; |
| 3571 | dimux->num_items++; |
| 3572 | |
| 3573 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3574 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3575 | int index; |
| 3576 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3577 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3578 | unsigned int def_conf; |
| 3579 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3580 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3581 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3582 | continue; |
| 3583 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3584 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3585 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3586 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3587 | con_lst, |
| 3588 | HDA_MAX_NUM_INPUTS); |
| 3589 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3590 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3591 | index = j; |
| 3592 | goto found; |
| 3593 | } |
| 3594 | continue; |
| 3595 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3596 | wcaps = get_wcaps(codec, nid) & |
| 3597 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3598 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3599 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3600 | sprintf(name, "%s Capture Volume", |
| 3601 | stac92xx_dmic_labels[dimux->num_items]); |
| 3602 | |
| 3603 | err = stac92xx_add_control(spec, |
| 3604 | STAC_CTL_WIDGET_VOL, |
| 3605 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3606 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3607 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3608 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3609 | if (err < 0) |
| 3610 | return err; |
| 3611 | } |
| 3612 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3613 | dimux->items[dimux->num_items].label = |
| 3614 | stac92xx_dmic_labels[dimux->num_items]; |
| 3615 | dimux->items[dimux->num_items].index = index; |
| 3616 | dimux->num_items++; |
| 3617 | } |
| 3618 | |
| 3619 | return 0; |
| 3620 | } |
| 3621 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3622 | /* create playback/capture controls for input pins */ |
| 3623 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3624 | { |
| 3625 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3626 | struct hda_input_mux *imux = &spec->private_imux; |
| 3627 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3628 | int i, j, k; |
| 3629 | |
| 3630 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3631 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3632 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3633 | if (!cfg->input_pins[i]) |
| 3634 | continue; |
| 3635 | index = -1; |
| 3636 | for (j = 0; j < spec->num_muxes; j++) { |
| 3637 | int num_cons; |
| 3638 | num_cons = snd_hda_get_connections(codec, |
| 3639 | spec->mux_nids[j], |
| 3640 | con_lst, |
| 3641 | HDA_MAX_NUM_INPUTS); |
| 3642 | for (k = 0; k < num_cons; k++) |
| 3643 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3644 | index = k; |
| 3645 | goto found; |
| 3646 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3647 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3648 | continue; |
| 3649 | found: |
| 3650 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3651 | imux->items[imux->num_items].index = index; |
| 3652 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3653 | } |
| 3654 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3655 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3656 | /* |
| 3657 | * Set the current input for the muxes. |
| 3658 | * The STAC9221 has two input muxes with identical source |
| 3659 | * NID lists. Hopefully this won't get confused. |
| 3660 | */ |
| 3661 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3662 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3663 | AC_VERB_SET_CONNECT_SEL, |
| 3664 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3665 | } |
| 3666 | } |
| 3667 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3668 | return 0; |
| 3669 | } |
| 3670 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3671 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3672 | { |
| 3673 | struct sigmatel_spec *spec = codec->spec; |
| 3674 | int i; |
| 3675 | |
| 3676 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3677 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3678 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3679 | } |
| 3680 | } |
| 3681 | |
| 3682 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3683 | { |
| 3684 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3685 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3686 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3687 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3688 | hda_nid_t pin; |
| 3689 | pin = spec->autocfg.hp_pins[i]; |
| 3690 | if (pin) /* connect to front */ |
| 3691 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3692 | } |
| 3693 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3694 | hda_nid_t pin; |
| 3695 | pin = spec->autocfg.speaker_pins[i]; |
| 3696 | if (pin) /* connect to front */ |
| 3697 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3698 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3699 | } |
| 3700 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3701 | 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] | 3702 | { |
| 3703 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3704 | int hp_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3705 | int err; |
| 3706 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3707 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3708 | &spec->autocfg, |
| 3709 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3710 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3711 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3712 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3713 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3714 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3715 | * be set up as multi-channel outputs. |
| 3716 | */ |
| 3717 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3718 | spec->autocfg.hp_outs > 1) { |
| 3719 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3720 | * speaker_outs so that the following routines can handle |
| 3721 | * HP pins as primary outputs. |
| 3722 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3723 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3724 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3725 | sizeof(spec->autocfg.line_out_pins)); |
| 3726 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3727 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3728 | sizeof(spec->autocfg.hp_pins)); |
| 3729 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3730 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3731 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3732 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3733 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3734 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3735 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3736 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3737 | u32 caps = query_amp_caps(codec, |
| 3738 | spec->autocfg.mono_out_pin, dir); |
| 3739 | hda_nid_t conn_list[1]; |
| 3740 | |
| 3741 | /* get the mixer node and then the mono mux if it exists */ |
| 3742 | if (snd_hda_get_connections(codec, |
| 3743 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3744 | snd_hda_get_connections(codec, conn_list[0], |
| 3745 | conn_list, 1)) { |
| 3746 | |
| 3747 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3748 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3749 | >> AC_WCAP_TYPE_SHIFT; |
| 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 | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3840 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3841 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3842 | return err; |
| 3843 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3844 | if (spec->mono_nid > 0) { |
| 3845 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3846 | if (err < 0) |
| 3847 | return err; |
| 3848 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3849 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3850 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3851 | if (err < 0) |
| 3852 | return err; |
| 3853 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3854 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3855 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3856 | &spec->autocfg)) < 0) |
| 3857 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3858 | if (spec->num_muxes > 0) { |
| 3859 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3860 | if (err < 0) |
| 3861 | return err; |
| 3862 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3863 | if (spec->num_smuxes > 0) { |
| 3864 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3865 | if (err < 0) |
| 3866 | return err; |
| 3867 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3868 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3869 | err = stac92xx_add_input_source(spec); |
| 3870 | if (err < 0) |
| 3871 | return err; |
| 3872 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3873 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3874 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3875 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3876 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3877 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3878 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3879 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3880 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3881 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3882 | if (spec->kctls.list) |
| 3883 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3884 | |
| 3885 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3886 | if (!spec->dinput_mux) |
| 3887 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3888 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3889 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3890 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3891 | return 1; |
| 3892 | } |
| 3893 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3894 | /* add playback controls for HP output */ |
| 3895 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3896 | struct auto_pin_cfg *cfg) |
| 3897 | { |
| 3898 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3899 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3900 | unsigned int wid_caps; |
| 3901 | |
| 3902 | if (! pin) |
| 3903 | return 0; |
| 3904 | |
| 3905 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3906 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3907 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3908 | |
| 3909 | return 0; |
| 3910 | } |
| 3911 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3912 | /* add playback controls for LFE output */ |
| 3913 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3914 | struct auto_pin_cfg *cfg) |
| 3915 | { |
| 3916 | struct sigmatel_spec *spec = codec->spec; |
| 3917 | int err; |
| 3918 | hda_nid_t lfe_pin = 0x0; |
| 3919 | int i; |
| 3920 | |
| 3921 | /* |
| 3922 | * search speaker outs and line outs for a mono speaker pin |
| 3923 | * with an amp. If one is found, add LFE controls |
| 3924 | * for it. |
| 3925 | */ |
| 3926 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3927 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3928 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3929 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3930 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3931 | /* found a mono speaker with an amp, must be lfe */ |
| 3932 | lfe_pin = pin; |
| 3933 | } |
| 3934 | |
| 3935 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3936 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3937 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3938 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3939 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3940 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3941 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3942 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3943 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3944 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3945 | /* found a mono speaker with an amp, |
| 3946 | must be lfe */ |
| 3947 | lfe_pin = pin; |
| 3948 | } |
| 3949 | } |
| 3950 | } |
| 3951 | |
| 3952 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3953 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3954 | if (err < 0) |
| 3955 | return err; |
| 3956 | } |
| 3957 | |
| 3958 | return 0; |
| 3959 | } |
| 3960 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3961 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3962 | { |
| 3963 | struct sigmatel_spec *spec = codec->spec; |
| 3964 | int err; |
| 3965 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3966 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3967 | return err; |
| 3968 | |
| 3969 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3970 | return err; |
| 3971 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3972 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3973 | return err; |
| 3974 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3975 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3976 | return err; |
| 3977 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3978 | if (spec->num_muxes > 0) { |
| 3979 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3980 | if (err < 0) |
| 3981 | return err; |
| 3982 | } |
| 3983 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3984 | err = stac92xx_add_input_source(spec); |
| 3985 | if (err < 0) |
| 3986 | return err; |
| 3987 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3988 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3989 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3990 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3991 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3992 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3993 | if (spec->kctls.list) |
| 3994 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3995 | |
| 3996 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3997 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3998 | |
| 3999 | return 1; |
| 4000 | } |
| 4001 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4002 | /* |
| 4003 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 4004 | * funky external mute control using GPIO pins. |
| 4005 | */ |
| 4006 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4007 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4008 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4009 | { |
| 4010 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4011 | |
| 4012 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4013 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4014 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4015 | |
| 4016 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4017 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4018 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4019 | |
| 4020 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4021 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4022 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4023 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4024 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4025 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 4026 | |
| 4027 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4028 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4029 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4030 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4031 | |
| 4032 | msleep(1); |
| 4033 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4034 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4035 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4036 | } |
| 4037 | |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4038 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4039 | static void stac92xx_free_jack_priv(struct snd_jack *jack) |
| 4040 | { |
| 4041 | struct sigmatel_jack *jacks = jack->private_data; |
| 4042 | jacks->nid = 0; |
| 4043 | jacks->jack = NULL; |
| 4044 | } |
| 4045 | #endif |
| 4046 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4047 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 4048 | hda_nid_t nid, int type) |
| 4049 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4050 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4051 | struct sigmatel_spec *spec = codec->spec; |
| 4052 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4053 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4054 | int connectivity = get_defcfg_connect(def_conf); |
| 4055 | char name[32]; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4056 | int err; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4057 | |
| 4058 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 4059 | return 0; |
| 4060 | |
| 4061 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 4062 | jack = snd_array_new(&spec->jacks); |
| 4063 | if (!jack) |
| 4064 | return -ENOMEM; |
| 4065 | jack->nid = nid; |
| 4066 | jack->type = type; |
| 4067 | |
| 4068 | sprintf(name, "%s at %s %s Jack", |
| 4069 | snd_hda_get_jack_type(def_conf), |
| 4070 | snd_hda_get_jack_connectivity(def_conf), |
| 4071 | snd_hda_get_jack_location(def_conf)); |
| 4072 | |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4073 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
| 4074 | if (err < 0) { |
| 4075 | jack->nid = 0; |
| 4076 | return err; |
| 4077 | } |
| 4078 | jack->jack->private_data = jack; |
| 4079 | jack->jack->private_free = stac92xx_free_jack_priv; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4080 | #endif |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4081 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4082 | } |
| 4083 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4084 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 4085 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4086 | { |
| 4087 | struct sigmatel_event *event; |
| 4088 | |
| 4089 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 4090 | event = snd_array_new(&spec->events); |
| 4091 | if (!event) |
| 4092 | return -ENOMEM; |
| 4093 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4094 | event->type = type; |
| 4095 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4096 | event->data = data; |
| 4097 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4098 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4099 | } |
| 4100 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4101 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
| 4102 | hda_nid_t nid, unsigned char type) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4103 | { |
| 4104 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4105 | struct sigmatel_event *event = spec->events.list; |
| 4106 | int i; |
| 4107 | |
| 4108 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4109 | if (event->nid == nid && event->type == type) |
| 4110 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4111 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4112 | return NULL; |
| 4113 | } |
| 4114 | |
| 4115 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 4116 | unsigned char tag) |
| 4117 | { |
| 4118 | struct sigmatel_spec *spec = codec->spec; |
| 4119 | struct sigmatel_event *event = spec->events.list; |
| 4120 | int i; |
| 4121 | |
| 4122 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4123 | if (event->tag == tag) |
| 4124 | return event; |
| 4125 | } |
| 4126 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4127 | } |
| 4128 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4129 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4130 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4131 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4132 | struct sigmatel_event *event; |
| 4133 | int tag; |
| 4134 | |
| 4135 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
| 4136 | return; |
| 4137 | event = stac_get_event(codec, nid, type); |
| 4138 | if (event) |
| 4139 | tag = event->tag; |
| 4140 | else |
| 4141 | tag = stac_add_event(codec->spec, nid, type, 0); |
| 4142 | if (tag < 0) |
| 4143 | return; |
| 4144 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4145 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4146 | AC_USRSP_EN | tag); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4147 | } |
| 4148 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4149 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 4150 | { |
| 4151 | int i; |
| 4152 | for (i = 0; i < cfg->hp_outs; i++) |
| 4153 | if (cfg->hp_pins[i] == nid) |
| 4154 | return 1; /* nid is a HP-Out */ |
| 4155 | |
| 4156 | return 0; /* nid is not a HP-Out */ |
| 4157 | }; |
| 4158 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4159 | static void stac92xx_power_down(struct hda_codec *codec) |
| 4160 | { |
| 4161 | struct sigmatel_spec *spec = codec->spec; |
| 4162 | |
| 4163 | /* power down inactive DACs */ |
| 4164 | hda_nid_t *dac; |
| 4165 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4166 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4167 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4168 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4169 | } |
| 4170 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4171 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4172 | int enable); |
| 4173 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4174 | /* override some hints from the hwdep entry */ |
| 4175 | static void stac_store_hints(struct hda_codec *codec) |
| 4176 | { |
| 4177 | struct sigmatel_spec *spec = codec->spec; |
| 4178 | const char *p; |
| 4179 | int val; |
| 4180 | |
| 4181 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 4182 | if (val >= 0) |
| 4183 | spec->hp_detect = val; |
| 4184 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 4185 | if (p) { |
| 4186 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 4187 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 4188 | spec->gpio_mask; |
| 4189 | } |
| 4190 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 4191 | if (p) |
| 4192 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4193 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 4194 | if (p) |
| 4195 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4196 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 4197 | if (p) |
| 4198 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4199 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 4200 | if (val >= 0) |
| 4201 | spec->eapd_switch = val; |
| 4202 | } |
| 4203 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4204 | static int stac92xx_init(struct hda_codec *codec) |
| 4205 | { |
| 4206 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4207 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4208 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4209 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4210 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4211 | snd_hda_sequence_write(codec, spec->init); |
| 4212 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4213 | /* power down adcs initially */ |
| 4214 | if (spec->powerdown_adcs) |
| 4215 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4216 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4217 | spec->adc_nids[i], 0, |
| 4218 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4219 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4220 | /* override some hints */ |
| 4221 | stac_store_hints(codec); |
| 4222 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4223 | /* set up GPIO */ |
| 4224 | gpio = spec->gpio_data; |
| 4225 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4226 | * otherwise, unsol event will turn it on/off dynamically |
| 4227 | */ |
| 4228 | if (!spec->eapd_switch) |
| 4229 | gpio |= spec->eapd_mask; |
| 4230 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4231 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4232 | /* set up pins */ |
| 4233 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4234 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4235 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4236 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4237 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4238 | } |
Takashi Iwai | 0a07aca | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4239 | /* force to enable the first line-out; the others are set up |
| 4240 | * in unsol_event |
| 4241 | */ |
| 4242 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4243 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4244 | /* fake event to set up pins */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4245 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4246 | STAC_HP_EVENT); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4247 | } else { |
| 4248 | stac92xx_auto_init_multi_out(codec); |
| 4249 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4250 | for (i = 0; i < cfg->hp_outs; i++) |
| 4251 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4252 | } |
| 4253 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4254 | hda_nid_t nid = cfg->input_pins[i]; |
| 4255 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4256 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4257 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4258 | /* for mic pins, force to initialize */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4259 | pinctl = stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4260 | pinctl |= AC_PINCTL_IN_EN; |
| 4261 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4262 | } else { |
| 4263 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4264 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4265 | /* if PINCTL already set then skip */ |
Takashi Iwai | 5dd17cb9 | 2009-05-07 16:22:53 +0200 | [diff] [blame] | 4266 | /* Also, if both INPUT and OUTPUT are set, |
| 4267 | * it must be a BIOS bug; need to override, too |
| 4268 | */ |
| 4269 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 4270 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 4271 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4272 | pinctl |= AC_PINCTL_IN_EN; |
| 4273 | stac92xx_auto_set_pinctl(codec, nid, |
| 4274 | pinctl); |
| 4275 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4276 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4277 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4278 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 4279 | enable_pin_detect(codec, nid, |
| 4280 | STAC_INSERT_EVENT); |
| 4281 | stac_issue_unsol_event(codec, nid, |
| 4282 | STAC_INSERT_EVENT); |
| 4283 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4284 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4285 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4286 | for (i = 0; i < spec->num_dmics; i++) |
| 4287 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4288 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4289 | if (cfg->dig_out_pins[0]) |
| 4290 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4291 | AC_PINCTL_OUT_EN); |
| 4292 | if (cfg->dig_in_pin) |
| 4293 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4294 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4295 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4296 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4297 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4298 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4299 | /* power on when no jack detection is available */ |
| 4300 | if (!spec->hp_detect) { |
| 4301 | stac_toggle_power_map(codec, nid, 1); |
| 4302 | continue; |
| 4303 | } |
| 4304 | |
| 4305 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4306 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4307 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4308 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4309 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4310 | /* outputs are only ports capable of power management |
| 4311 | * any attempts on powering down a input port cause the |
| 4312 | * referenced VREF to act quirky. |
| 4313 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4314 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4315 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4316 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4317 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4318 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4319 | def_conf = get_defcfg_connect(def_conf); |
| 4320 | /* skip any ports that don't have jacks since presence |
| 4321 | * detection is useless */ |
| 4322 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4323 | if (def_conf != AC_JACK_PORT_NONE) |
| 4324 | stac_toggle_power_map(codec, nid, 1); |
| 4325 | continue; |
| 4326 | } |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4327 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
| 4328 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
| 4329 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); |
| 4330 | } |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4331 | } |
| 4332 | if (spec->dac_list) |
| 4333 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4334 | return 0; |
| 4335 | } |
| 4336 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4337 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4338 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4339 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4340 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4341 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4342 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4343 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4344 | int i; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4345 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
| 4346 | if (jacks->jack) |
| 4347 | snd_device_free(codec->bus->card, jacks->jack); |
| 4348 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4349 | } |
| 4350 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4351 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4352 | } |
| 4353 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4354 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4355 | { |
| 4356 | struct sigmatel_spec *spec = codec->spec; |
| 4357 | |
| 4358 | if (spec->kctls.list) { |
| 4359 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4360 | int i; |
| 4361 | for (i = 0; i < spec->kctls.used; i++) |
| 4362 | kfree(kctl[i].name); |
| 4363 | } |
| 4364 | snd_array_free(&spec->kctls); |
| 4365 | } |
| 4366 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4367 | static void stac92xx_free(struct hda_codec *codec) |
| 4368 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4369 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4370 | |
| 4371 | if (! spec) |
| 4372 | return; |
| 4373 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4374 | stac92xx_free_jacks(codec); |
| 4375 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4376 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4377 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4378 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4379 | } |
| 4380 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4381 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4382 | unsigned int flag) |
| 4383 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4384 | unsigned int old_ctl, pin_ctl; |
| 4385 | |
| 4386 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4387 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4388 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4389 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4390 | /* |
| 4391 | * we need to check the current set-up direction of |
| 4392 | * shared input pins since they can be switched via |
| 4393 | * "xxx as Output" mixer switch |
| 4394 | */ |
| 4395 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4396 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4397 | return; |
| 4398 | } |
| 4399 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4400 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4401 | /* if setting pin direction bits, clear the current |
| 4402 | direction bits first */ |
| 4403 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4404 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4405 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4406 | pin_ctl |= flag; |
| 4407 | if (old_ctl != pin_ctl) |
| 4408 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4409 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4410 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4411 | } |
| 4412 | |
| 4413 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4414 | unsigned int flag) |
| 4415 | { |
| 4416 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4417 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4418 | if (pin_ctl & flag) |
| 4419 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4420 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4421 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4422 | } |
| 4423 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4424 | 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] | 4425 | { |
| 4426 | if (!nid) |
| 4427 | return 0; |
| 4428 | 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] | 4429 | & (1 << 31)) |
| 4430 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4431 | return 0; |
| 4432 | } |
| 4433 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4434 | /* return non-zero if the hp-pin of the given array index isn't |
| 4435 | * a jack-detection target |
| 4436 | */ |
| 4437 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4438 | { |
| 4439 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4440 | |
| 4441 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4442 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4443 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4444 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4445 | return 1; |
| 4446 | /* ignore if the pin is set as line-out */ |
| 4447 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4448 | return 1; |
| 4449 | return 0; |
| 4450 | } |
| 4451 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4452 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4453 | { |
| 4454 | struct sigmatel_spec *spec = codec->spec; |
| 4455 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4456 | int i, presence; |
| 4457 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4458 | presence = 0; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4459 | if (spec->gpio_mute) |
| 4460 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4461 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4462 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4463 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4464 | if (presence) |
| 4465 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4466 | if (no_hp_sensing(spec, i)) |
| 4467 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4468 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4469 | if (presence) { |
| 4470 | unsigned int pinctl; |
| 4471 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4472 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4473 | if (pinctl & AC_PINCTL_IN_EN) |
| 4474 | presence = 0; /* mic- or line-input */ |
| 4475 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4476 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4477 | |
| 4478 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4479 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4480 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4481 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4482 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4483 | for (i = 0; i < cfg->line_outs; i++) |
| 4484 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4485 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4486 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4487 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4488 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4489 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4490 | stac_gpio_set(codec, spec->gpio_mask, |
| 4491 | spec->gpio_dir, spec->gpio_data & |
| 4492 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4493 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4494 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4495 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4496 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4497 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4498 | for (i = 0; i < cfg->line_outs; i++) |
| 4499 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4500 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4501 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4502 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4503 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4504 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4505 | stac_gpio_set(codec, spec->gpio_mask, |
| 4506 | spec->gpio_dir, spec->gpio_data | |
| 4507 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4508 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4509 | /* toggle hp outs */ |
| 4510 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4511 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4512 | if (no_hp_sensing(spec, i)) |
| 4513 | continue; |
| 4514 | if (presence) |
| 4515 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4516 | #if 0 /* FIXME */ |
| 4517 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4518 | * on some devices since they use the HP pin actually for line/speaker |
| 4519 | * outs although the default pin config shows a different pin (that is |
| 4520 | * wrong and useless). |
| 4521 | * |
| 4522 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4523 | * But, disabling the code below just works around it, and I'm too tired of |
| 4524 | * bug reports with such devices... |
| 4525 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4526 | else |
| 4527 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4528 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4529 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4530 | } |
| 4531 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4532 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4533 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4534 | { |
| 4535 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4536 | unsigned int idx, val; |
| 4537 | |
| 4538 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4539 | if (spec->pwr_nids[idx] == nid) |
| 4540 | break; |
| 4541 | } |
| 4542 | if (idx >= spec->num_pwrs) |
| 4543 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4544 | |
| 4545 | /* several codecs have two power down bits */ |
| 4546 | if (spec->pwr_mapping) |
| 4547 | idx = spec->pwr_mapping[idx]; |
| 4548 | else |
| 4549 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4550 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4551 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4552 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4553 | val &= ~idx; |
| 4554 | else |
| 4555 | val |= idx; |
| 4556 | |
| 4557 | /* power down unused output ports */ |
| 4558 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4559 | } |
| 4560 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4561 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4562 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4563 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4564 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4565 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4566 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4567 | { |
| 4568 | struct sigmatel_spec *spec = codec->spec; |
| 4569 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4570 | |
| 4571 | if (jacks) { |
| 4572 | int i; |
| 4573 | for (i = 0; i < spec->jacks.used; i++) { |
| 4574 | if (jacks->nid == nid) { |
| 4575 | unsigned int pin_ctl = |
| 4576 | snd_hda_codec_read(codec, nid, |
| 4577 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4578 | 0x00); |
| 4579 | int type = jacks->type; |
| 4580 | if (type == (SND_JACK_LINEOUT |
| 4581 | | SND_JACK_HEADPHONE)) |
| 4582 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4583 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4584 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4585 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4586 | ? type : 0); |
| 4587 | } |
| 4588 | jacks++; |
| 4589 | } |
| 4590 | } |
| 4591 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4592 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4593 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 4594 | unsigned char type) |
| 4595 | { |
| 4596 | struct sigmatel_event *event = stac_get_event(codec, nid, type); |
| 4597 | if (!event) |
| 4598 | return; |
| 4599 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4600 | } |
| 4601 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4602 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4603 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4604 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4605 | struct sigmatel_event *event; |
| 4606 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4607 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4608 | tag = (res >> 26) & 0x7f; |
| 4609 | event = stac_get_event_from_tag(codec, tag); |
| 4610 | if (!event) |
| 4611 | return; |
| 4612 | |
| 4613 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4614 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4615 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4616 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4617 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4618 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4619 | if (spec->num_pwrs > 0) |
| 4620 | stac92xx_pin_sense(codec, event->nid); |
| 4621 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 4622 | |
| 4623 | switch (codec->subsystem_id) { |
| 4624 | case 0x103c308f: |
| 4625 | if (event->nid == 0xb) { |
| 4626 | int pin = AC_PINCTL_IN_EN; |
| 4627 | |
| 4628 | if (get_pin_presence(codec, 0xa) |
| 4629 | && get_pin_presence(codec, 0xb)) |
| 4630 | pin |= AC_PINCTL_VREF_80; |
| 4631 | if (!get_pin_presence(codec, 0xb)) |
| 4632 | pin |= AC_PINCTL_VREF_80; |
| 4633 | |
| 4634 | /* toggle VREF state based on mic + hp pin |
| 4635 | * status |
| 4636 | */ |
| 4637 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 4638 | } |
| 4639 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4640 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4641 | case STAC_VREF_EVENT: |
| 4642 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4643 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4644 | /* toggle VREF state based on GPIOx status */ |
| 4645 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4646 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4647 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4648 | } |
| 4649 | } |
| 4650 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4651 | #ifdef CONFIG_PROC_FS |
| 4652 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4653 | struct hda_codec *codec, hda_nid_t nid) |
| 4654 | { |
| 4655 | if (nid == codec->afg) |
| 4656 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4657 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4658 | } |
| 4659 | |
| 4660 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4661 | struct hda_codec *codec, |
| 4662 | unsigned int verb) |
| 4663 | { |
| 4664 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4665 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4666 | } |
| 4667 | |
| 4668 | /* stac92hd71bxx, stac92hd73xx */ |
| 4669 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4670 | struct hda_codec *codec, hda_nid_t nid) |
| 4671 | { |
| 4672 | stac92hd_proc_hook(buffer, codec, nid); |
| 4673 | if (nid == codec->afg) |
| 4674 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4675 | } |
| 4676 | |
| 4677 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4678 | struct hda_codec *codec, hda_nid_t nid) |
| 4679 | { |
| 4680 | if (nid == codec->afg) |
| 4681 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4682 | } |
| 4683 | |
| 4684 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4685 | struct hda_codec *codec, hda_nid_t nid) |
| 4686 | { |
| 4687 | if (nid == codec->afg) |
| 4688 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4689 | } |
| 4690 | #else |
| 4691 | #define stac92hd_proc_hook NULL |
| 4692 | #define stac92hd7x_proc_hook NULL |
| 4693 | #define stac9205_proc_hook NULL |
| 4694 | #define stac927x_proc_hook NULL |
| 4695 | #endif |
| 4696 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4697 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4698 | static int stac92xx_resume(struct hda_codec *codec) |
| 4699 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4700 | struct sigmatel_spec *spec = codec->spec; |
| 4701 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4702 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4703 | snd_hda_codec_resume_amp(codec); |
| 4704 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4705 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4706 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4707 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4708 | STAC_HP_EVENT); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4709 | return 0; |
| 4710 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4711 | |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4712 | /* |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4713 | * using power check for controlling mute led of HP notebooks |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4714 | * check for mute state only on Speakers (nid = 0x10) |
| 4715 | * |
| 4716 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
| 4717 | * the LED is NOT working properly ! |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4718 | * |
| 4719 | * Changed name to reflect that it now works for any designated |
| 4720 | * model, not just HP HDX. |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4721 | */ |
| 4722 | |
| 4723 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4724 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4725 | hda_nid_t nid) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4726 | { |
| 4727 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4728 | |
| 4729 | if (nid == 0x10) { |
| 4730 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4731 | HDA_AMP_MUTE) |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 4732 | spec->gpio_data &= ~spec->gpio_led; /* orange */ |
Takashi Iwai | ba84bfc | 2009-05-30 08:59:03 +0200 | [diff] [blame] | 4733 | else |
| 4734 | spec->gpio_data |= spec->gpio_led; /* white */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4735 | |
| 4736 | stac_gpio_set(codec, spec->gpio_mask, |
| 4737 | spec->gpio_dir, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4738 | spec->gpio_data); |
| 4739 | } |
| 4740 | |
| 4741 | return 0; |
| 4742 | } |
| 4743 | #endif |
| 4744 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4745 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4746 | { |
| 4747 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame^] | 4748 | int i; |
| 4749 | hda_nid_t nid; |
| 4750 | |
| 4751 | /* reset each pin before powering down DAC/ADC to avoid click noise */ |
| 4752 | nid = codec->start_nid; |
| 4753 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 4754 | unsigned int wcaps = get_wcaps(codec, nid); |
| 4755 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> |
| 4756 | AC_WCAP_TYPE_SHIFT; |
| 4757 | if (wid_type == AC_WID_PIN) |
| 4758 | snd_hda_codec_read(codec, nid, 0, |
| 4759 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); |
| 4760 | } |
| 4761 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4762 | if (spec->eapd_mask) |
| 4763 | stac_gpio_set(codec, spec->gpio_mask, |
| 4764 | spec->gpio_dir, spec->gpio_data & |
| 4765 | ~spec->eapd_mask); |
| 4766 | return 0; |
| 4767 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4768 | #endif |
| 4769 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4770 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4771 | .build_controls = stac92xx_build_controls, |
| 4772 | .build_pcms = stac92xx_build_pcms, |
| 4773 | .init = stac92xx_init, |
| 4774 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4775 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4776 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4777 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4778 | .resume = stac92xx_resume, |
| 4779 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4780 | }; |
| 4781 | |
| 4782 | static int patch_stac9200(struct hda_codec *codec) |
| 4783 | { |
| 4784 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4785 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4786 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4787 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4788 | if (spec == NULL) |
| 4789 | return -ENOMEM; |
| 4790 | |
| 4791 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4792 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4793 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4794 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4795 | stac9200_models, |
| 4796 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4797 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4798 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4799 | else |
| 4800 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4801 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4802 | |
| 4803 | spec->multiout.max_channels = 2; |
| 4804 | spec->multiout.num_dacs = 1; |
| 4805 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4806 | spec->adc_nids = stac9200_adc_nids; |
| 4807 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4808 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4809 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4810 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4811 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4812 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4813 | if (spec->board_config == STAC_9200_M4 || |
| 4814 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4815 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4816 | spec->init = stac9200_eapd_init; |
| 4817 | else |
| 4818 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4819 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4820 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4821 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4822 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4823 | spec->gpio_data = 0x00; |
| 4824 | } |
| 4825 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4826 | err = stac9200_parse_auto_config(codec); |
| 4827 | if (err < 0) { |
| 4828 | stac92xx_free(codec); |
| 4829 | return err; |
| 4830 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4831 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4832 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 4833 | * do detection and HP/speaker toggle because the hardware does it. |
| 4834 | */ |
| 4835 | if (spec->board_config == STAC_9200_PANASONIC) |
| 4836 | spec->hp_detect = 0; |
| 4837 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4838 | codec->patch_ops = stac92xx_patch_ops; |
| 4839 | |
| 4840 | return 0; |
| 4841 | } |
| 4842 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4843 | static int patch_stac925x(struct hda_codec *codec) |
| 4844 | { |
| 4845 | struct sigmatel_spec *spec; |
| 4846 | int err; |
| 4847 | |
| 4848 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4849 | if (spec == NULL) |
| 4850 | return -ENOMEM; |
| 4851 | |
| 4852 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4853 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4854 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4855 | |
| 4856 | /* Check first for codec ID */ |
| 4857 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4858 | STAC_925x_MODELS, |
| 4859 | stac925x_models, |
| 4860 | stac925x_codec_id_cfg_tbl); |
| 4861 | |
| 4862 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4863 | if (spec->board_config < 0) |
| 4864 | spec->board_config = snd_hda_check_board_config(codec, |
| 4865 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4866 | stac925x_models, |
| 4867 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4868 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4869 | if (spec->board_config < 0) |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4870 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4871 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4872 | else |
| 4873 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4874 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4875 | |
| 4876 | spec->multiout.max_channels = 2; |
| 4877 | spec->multiout.num_dacs = 1; |
| 4878 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4879 | spec->adc_nids = stac925x_adc_nids; |
| 4880 | spec->mux_nids = stac925x_mux_nids; |
| 4881 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4882 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4883 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4884 | switch (codec->vendor_id) { |
| 4885 | case 0x83847632: /* STAC9202 */ |
| 4886 | case 0x83847633: /* STAC9202D */ |
| 4887 | case 0x83847636: /* STAC9251 */ |
| 4888 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4889 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4890 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4891 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4892 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4893 | break; |
| 4894 | default: |
| 4895 | spec->num_dmics = 0; |
| 4896 | break; |
| 4897 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4898 | |
| 4899 | spec->init = stac925x_core_init; |
| 4900 | spec->mixer = stac925x_mixer; |
| 4901 | |
| 4902 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4903 | if (!err) { |
| 4904 | if (spec->board_config < 0) { |
| 4905 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4906 | "available, default to model=ref\n"); |
| 4907 | spec->board_config = STAC_925x_REF; |
| 4908 | goto again; |
| 4909 | } |
| 4910 | err = -EINVAL; |
| 4911 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4912 | if (err < 0) { |
| 4913 | stac92xx_free(codec); |
| 4914 | return err; |
| 4915 | } |
| 4916 | |
| 4917 | codec->patch_ops = stac92xx_patch_ops; |
| 4918 | |
| 4919 | return 0; |
| 4920 | } |
| 4921 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4922 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4923 | .num_items = 4, |
| 4924 | .items = { |
| 4925 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4926 | { "Digital Mic 1", 0x09 }, |
| 4927 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4928 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4929 | } |
| 4930 | }; |
| 4931 | |
| 4932 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4933 | { |
| 4934 | struct sigmatel_spec *spec; |
| 4935 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4936 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4937 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4938 | |
| 4939 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4940 | if (spec == NULL) |
| 4941 | return -ENOMEM; |
| 4942 | |
| 4943 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4944 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4945 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4946 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4947 | spec->board_config = snd_hda_check_board_config(codec, |
| 4948 | STAC_92HD73XX_MODELS, |
| 4949 | stac92hd73xx_models, |
| 4950 | stac92hd73xx_cfg_tbl); |
| 4951 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4952 | if (spec->board_config < 0) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4953 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4954 | " STAC92HD73XX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4955 | else |
| 4956 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4957 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4958 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4959 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4960 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4961 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4962 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4963 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4964 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4965 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4966 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4967 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4968 | case 0x3: /* 6 Channel */ |
| 4969 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4970 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4971 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4972 | break; |
| 4973 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4974 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4975 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4976 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4977 | break; |
| 4978 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4979 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4980 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4981 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 4982 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4983 | } |
| 4984 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4985 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4986 | spec->aloopback_mask = 0x01; |
| 4987 | spec->aloopback_shift = 8; |
| 4988 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4989 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4990 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4991 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4992 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4993 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4994 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4995 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4996 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4997 | |
| 4998 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4999 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5000 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5001 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 5002 | sizeof(stac92hd73xx_dmux)); |
| 5003 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5004 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5005 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 5006 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5007 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5008 | case STAC_DELL_M6_AMIC: |
| 5009 | case STAC_DELL_M6_DMIC: |
| 5010 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5011 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5012 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 5013 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5014 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5015 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5016 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5017 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5018 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5019 | switch (spec->board_config) { |
| 5020 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5021 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5022 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5023 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5024 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5025 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5026 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5027 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5028 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5029 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5030 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5031 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 5032 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5033 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5034 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5035 | break; |
| 5036 | } |
| 5037 | break; |
| 5038 | default: |
| 5039 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5040 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5041 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5042 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5043 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 5044 | /* GPIO0 High = Enable EAPD */ |
| 5045 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 5046 | spec->gpio_data = 0x01; |
| 5047 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5048 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5049 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5050 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 5051 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 5052 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5053 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5054 | |
| 5055 | if (!err) { |
| 5056 | if (spec->board_config < 0) { |
| 5057 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5058 | "available, default to model=ref\n"); |
| 5059 | spec->board_config = STAC_92HD73XX_REF; |
| 5060 | goto again; |
| 5061 | } |
| 5062 | err = -EINVAL; |
| 5063 | } |
| 5064 | |
| 5065 | if (err < 0) { |
| 5066 | stac92xx_free(codec); |
| 5067 | return err; |
| 5068 | } |
| 5069 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 5070 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 5071 | spec->hp_detect = 0; |
| 5072 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5073 | codec->patch_ops = stac92xx_patch_ops; |
| 5074 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5075 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5076 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5077 | return 0; |
| 5078 | } |
| 5079 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5080 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 5081 | .num_items = 3, |
| 5082 | .items = { |
| 5083 | { "Analog Inputs", 0x03 }, |
| 5084 | { "Digital Mic 1", 0x04 }, |
| 5085 | { "Digital Mic 2", 0x05 }, |
| 5086 | } |
| 5087 | }; |
| 5088 | |
| 5089 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 5090 | { |
| 5091 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5092 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5093 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5094 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5095 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5096 | |
| 5097 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5098 | if (spec == NULL) |
| 5099 | return -ENOMEM; |
| 5100 | |
| 5101 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5102 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5103 | spec->mono_nid = 0x19; |
| 5104 | spec->digbeep_nid = 0x21; |
| 5105 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 5106 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 5107 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 5108 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5109 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5110 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 5111 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5112 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5113 | |
| 5114 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5115 | spec->mixer = stac92hd83xxx_mixer; |
| 5116 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 5117 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 5118 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5119 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5120 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 5121 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 5122 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 5123 | spec->board_config = snd_hda_check_board_config(codec, |
| 5124 | STAC_92HD83XXX_MODELS, |
| 5125 | stac92hd83xxx_models, |
| 5126 | stac92hd83xxx_cfg_tbl); |
| 5127 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5128 | if (spec->board_config < 0) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5129 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5130 | " STAC92HD83XXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5131 | else |
| 5132 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5133 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5134 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5135 | switch (codec->vendor_id) { |
| 5136 | case 0x111d7604: |
| 5137 | case 0x111d7605: |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5138 | case 0x111d76d5: |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5139 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 5140 | break; |
| 5141 | spec->num_pwrs = 0; |
| 5142 | break; |
| 5143 | } |
| 5144 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5145 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 5146 | if (!err) { |
| 5147 | if (spec->board_config < 0) { |
| 5148 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5149 | "available, default to model=ref\n"); |
| 5150 | spec->board_config = STAC_92HD83XXX_REF; |
| 5151 | goto again; |
| 5152 | } |
| 5153 | err = -EINVAL; |
| 5154 | } |
| 5155 | |
| 5156 | if (err < 0) { |
| 5157 | stac92xx_free(codec); |
| 5158 | return err; |
| 5159 | } |
| 5160 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5161 | switch (spec->board_config) { |
| 5162 | case STAC_DELL_S14: |
| 5163 | nid = 0xf; |
| 5164 | break; |
| 5165 | default: |
| 5166 | nid = 0xe; |
| 5167 | break; |
| 5168 | } |
| 5169 | |
| 5170 | num_dacs = snd_hda_get_connections(codec, nid, |
| 5171 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
| 5172 | |
| 5173 | /* set port X to select the last DAC |
| 5174 | */ |
| 5175 | snd_hda_codec_write_cache(codec, nid, 0, |
| 5176 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 5177 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5178 | codec->patch_ops = stac92xx_patch_ops; |
| 5179 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5180 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 5181 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5182 | return 0; |
| 5183 | } |
| 5184 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5185 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 5186 | .num_items = 3, |
| 5187 | .items = { |
| 5188 | { "Analog Inputs", 0x00 }, |
| 5189 | { "Digital Mic 1", 0x02 }, |
| 5190 | { "Digital Mic 2", 0x03 }, |
| 5191 | } |
| 5192 | }; |
| 5193 | |
| 5194 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5195 | .num_items = 4, |
| 5196 | .items = { |
| 5197 | { "Analog Inputs", 0x00 }, |
| 5198 | { "Mixer", 0x01 }, |
| 5199 | { "Digital Mic 1", 0x02 }, |
| 5200 | { "Digital Mic 2", 0x03 }, |
| 5201 | } |
| 5202 | }; |
| 5203 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5204 | /* get the pin connection (fixed, none, etc) */ |
| 5205 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 5206 | { |
| 5207 | struct sigmatel_spec *spec = codec->spec; |
| 5208 | unsigned int cfg; |
| 5209 | |
| 5210 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 5211 | return get_defcfg_connect(cfg); |
| 5212 | } |
| 5213 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5214 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 5215 | hda_nid_t *nids, int num_nids) |
| 5216 | { |
| 5217 | struct sigmatel_spec *spec = codec->spec; |
| 5218 | int idx, num; |
| 5219 | unsigned int def_conf; |
| 5220 | |
| 5221 | for (num = 0; num < num_nids; num++) { |
| 5222 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5223 | if (spec->pin_nids[idx] == nids[num]) |
| 5224 | break; |
| 5225 | if (idx >= spec->num_pins) |
| 5226 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5227 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5228 | if (def_conf == AC_JACK_PORT_NONE) |
| 5229 | break; |
| 5230 | } |
| 5231 | return num; |
| 5232 | } |
| 5233 | |
| 5234 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 5235 | hda_nid_t dig0pin) |
| 5236 | { |
| 5237 | struct sigmatel_spec *spec = codec->spec; |
| 5238 | int idx; |
| 5239 | |
| 5240 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5241 | if (spec->pin_nids[idx] == dig0pin) |
| 5242 | break; |
| 5243 | if ((idx + 2) >= spec->num_pins) |
| 5244 | return 0; |
| 5245 | |
| 5246 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5247 | 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] | 5248 | return 2; |
| 5249 | |
| 5250 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5251 | 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] | 5252 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5253 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5254 | return 1; |
| 5255 | else |
| 5256 | return 0; |
| 5257 | } |
| 5258 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5259 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 5260 | { |
| 5261 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5262 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5263 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5264 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5265 | |
| 5266 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5267 | if (spec == NULL) |
| 5268 | return -ENOMEM; |
| 5269 | |
| 5270 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5271 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5272 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 5273 | switch (codec->vendor_id) { |
| 5274 | case 0x111d76b6: |
| 5275 | case 0x111d76b7: |
| 5276 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 5277 | break; |
| 5278 | case 0x111d7603: |
| 5279 | case 0x111d7608: |
| 5280 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 5281 | spec->num_pins--; |
| 5282 | /* fallthrough */ |
| 5283 | default: |
| 5284 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 5285 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5286 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5287 | spec->board_config = snd_hda_check_board_config(codec, |
| 5288 | STAC_92HD71BXX_MODELS, |
| 5289 | stac92hd71bxx_models, |
| 5290 | stac92hd71bxx_cfg_tbl); |
| 5291 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5292 | if (spec->board_config < 0) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5293 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5294 | " STAC92HD71BXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5295 | else |
| 5296 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5297 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5298 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5299 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5300 | /* GPIO0 = EAPD */ |
| 5301 | spec->gpio_mask = 0x01; |
| 5302 | spec->gpio_dir = 0x01; |
| 5303 | spec->gpio_data = 0x01; |
| 5304 | } |
| 5305 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5306 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5307 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5308 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5309 | switch (codec->vendor_id) { |
| 5310 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5311 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5312 | unmute_init++; |
| 5313 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5314 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5315 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5316 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 5317 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5318 | spec->mixer = stac92hd71bxx_mixer; |
| 5319 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5320 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5321 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5322 | stac92hd71bxx_dmic_nids, |
| 5323 | STAC92HD71BXX_NUM_DMICS); |
| 5324 | if (spec->num_dmics) { |
| 5325 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5326 | spec->dinput_mux = &spec->private_dimux; |
| 5327 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5328 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5329 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5330 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5331 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5332 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5333 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5334 | switch (spec->board_config) { |
| 5335 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5336 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5337 | err = stac_add_event(spec, codec->afg, |
| 5338 | STAC_VREF_EVENT, 0x02); |
| 5339 | if (err < 0) |
| 5340 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5341 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5342 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5343 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5344 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5345 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5346 | spec->gpio_mask |= 0x02; |
| 5347 | break; |
| 5348 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5349 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5350 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5351 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5352 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5353 | /* no output amps */ |
| 5354 | spec->num_pwrs = 0; |
| 5355 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5356 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5357 | |
| 5358 | /* disable VSW */ |
| 5359 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5360 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5361 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5362 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5363 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5364 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5365 | stac92hd71bxx_dmic_nids, |
| 5366 | STAC92HD71BXX_NUM_DMICS - 1); |
| 5367 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5368 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5369 | break; |
| 5370 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5371 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5372 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5373 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5374 | /* no output amps */ |
| 5375 | spec->num_pwrs = 0; |
| 5376 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5377 | default: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5378 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5379 | sizeof(stac92hd71bxx_dmux_amixer)); |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5380 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5381 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 5382 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5383 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5384 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5385 | stac92hd71bxx_dmic_nids, |
| 5386 | STAC92HD71BXX_NUM_DMICS); |
| 5387 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5388 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5389 | } |
| 5390 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5391 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5392 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5393 | |
Takashi Iwai | b20f3b8 | 2009-06-02 01:20:22 +0200 | [diff] [blame] | 5394 | /* Some HP machines seem to have unstable codec communications |
| 5395 | * especially with ATI fglrx driver. For recovering from the |
| 5396 | * CORB/RIRB stall, allow the BUS reset and keep always sync |
| 5397 | */ |
| 5398 | if (spec->board_config == STAC_HP_DV5) { |
| 5399 | codec->bus->sync_write = 1; |
| 5400 | codec->bus->allow_bus_reset = 1; |
| 5401 | } |
| 5402 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5403 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5404 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5405 | spec->aloopback_shift = 0; |
| 5406 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5407 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5408 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5409 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5410 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5411 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5412 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5413 | |
| 5414 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5415 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5416 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5417 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5418 | switch (spec->board_config) { |
| 5419 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5420 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5421 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5422 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5423 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5424 | /* fallthru */ |
| 5425 | case STAC_DELL_M4_2: |
| 5426 | spec->num_dmics = 0; |
| 5427 | spec->num_smuxes = 0; |
| 5428 | spec->num_dmuxes = 0; |
| 5429 | break; |
| 5430 | case STAC_DELL_M4_1: |
| 5431 | case STAC_DELL_M4_3: |
| 5432 | spec->num_dmics = 1; |
| 5433 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5434 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5435 | break; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5436 | case STAC_HP_DV4_1222NR: |
| 5437 | spec->num_dmics = 1; |
| 5438 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 5439 | * bug reports to fix if needed |
| 5440 | */ |
| 5441 | spec->num_smuxes = 1; |
| 5442 | spec->num_dmuxes = 1; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5443 | spec->gpio_led = 0x01; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5444 | /* fallthrough */ |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5445 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5446 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5447 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5448 | break; |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5449 | case STAC_HP_HDX: |
| 5450 | spec->num_dmics = 1; |
| 5451 | spec->num_dmuxes = 1; |
| 5452 | spec->num_smuxes = 1; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5453 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5454 | spec->gpio_led = 0x08; |
| 5455 | break; |
| 5456 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5457 | |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5458 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5459 | if (spec->gpio_led) { |
| 5460 | spec->gpio_mask |= spec->gpio_led; |
| 5461 | spec->gpio_dir |= spec->gpio_led; |
| 5462 | spec->gpio_data |= spec->gpio_led; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5463 | /* register check_power_status callback. */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5464 | codec->patch_ops.check_power_status = |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5465 | stac92xx_hp_check_power_status; |
| 5466 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5467 | #endif |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5468 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5469 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5470 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5471 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5472 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5473 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5474 | if (!err) { |
| 5475 | if (spec->board_config < 0) { |
| 5476 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5477 | "available, default to model=ref\n"); |
| 5478 | spec->board_config = STAC_92HD71BXX_REF; |
| 5479 | goto again; |
| 5480 | } |
| 5481 | err = -EINVAL; |
| 5482 | } |
| 5483 | |
| 5484 | if (err < 0) { |
| 5485 | stac92xx_free(codec); |
| 5486 | return err; |
| 5487 | } |
| 5488 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5489 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5490 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5491 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5492 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5493 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5494 | static int patch_stac922x(struct hda_codec *codec) |
| 5495 | { |
| 5496 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5497 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5498 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5499 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5500 | if (spec == NULL) |
| 5501 | return -ENOMEM; |
| 5502 | |
| 5503 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5504 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5505 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5506 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5507 | stac922x_models, |
| 5508 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5509 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5510 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5511 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5512 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5513 | * codec SSID to distinguish the exact models |
| 5514 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5515 | 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] | 5516 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5517 | |
| 5518 | case 0x106b0800: |
| 5519 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5520 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5521 | case 0x106b0600: |
| 5522 | case 0x106b0700: |
| 5523 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5524 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5525 | case 0x106b0e00: |
| 5526 | case 0x106b0f00: |
| 5527 | case 0x106b1600: |
| 5528 | case 0x106b1700: |
| 5529 | case 0x106b0200: |
| 5530 | case 0x106b1e00: |
| 5531 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5532 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5533 | case 0x106b1a00: |
| 5534 | case 0x00000100: |
| 5535 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5536 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5537 | case 0x106b0a00: |
| 5538 | case 0x106b2200: |
| 5539 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5540 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5541 | default: |
| 5542 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5543 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5544 | } |
| 5545 | } |
| 5546 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5547 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5548 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5549 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 5550 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5551 | else |
| 5552 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5553 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5554 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5555 | spec->adc_nids = stac922x_adc_nids; |
| 5556 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5557 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5558 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5559 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5560 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5561 | |
| 5562 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5563 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5564 | |
| 5565 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5566 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5567 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5568 | if (!err) { |
| 5569 | if (spec->board_config < 0) { |
| 5570 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5571 | "available, default to model=ref\n"); |
| 5572 | spec->board_config = STAC_D945_REF; |
| 5573 | goto again; |
| 5574 | } |
| 5575 | err = -EINVAL; |
| 5576 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5577 | if (err < 0) { |
| 5578 | stac92xx_free(codec); |
| 5579 | return err; |
| 5580 | } |
| 5581 | |
| 5582 | codec->patch_ops = stac92xx_patch_ops; |
| 5583 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5584 | /* Fix Mux capture level; max to 2 */ |
| 5585 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5586 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5587 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5588 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5589 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5590 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5591 | return 0; |
| 5592 | } |
| 5593 | |
| 5594 | static int patch_stac927x(struct hda_codec *codec) |
| 5595 | { |
| 5596 | struct sigmatel_spec *spec; |
| 5597 | int err; |
| 5598 | |
| 5599 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5600 | if (spec == NULL) |
| 5601 | return -ENOMEM; |
| 5602 | |
| 5603 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5604 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5605 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5606 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5607 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5608 | stac927x_models, |
| 5609 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5610 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5611 | if (spec->board_config < 0) |
Herton Ronaldo Krzesinski | c98041f | 2009-02-11 20:33:15 -0200 | [diff] [blame] | 5612 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5613 | "STAC927x, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5614 | else |
| 5615 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5616 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5617 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5618 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5619 | spec->adc_nids = stac927x_adc_nids; |
| 5620 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5621 | spec->mux_nids = stac927x_mux_nids; |
| 5622 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5623 | spec->smux_nids = stac927x_smux_nids; |
| 5624 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5625 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5626 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5627 | spec->multiout.dac_nids = spec->dac_nids; |
| 5628 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5629 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5630 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5631 | case STAC_D965_5ST: |
| 5632 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5633 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5634 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5635 | spec->num_dmics = 0; |
| 5636 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5637 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5638 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5639 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5640 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5641 | switch (codec->subsystem_id) { |
| 5642 | case 0x10280209: |
| 5643 | case 0x1028022e: |
| 5644 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5645 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5646 | break; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5647 | } |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5648 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5649 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5650 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5651 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5652 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5653 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5654 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5655 | case STAC_DELL_3ST: |
| 5656 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5657 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5658 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5659 | spec->dmic_nids = stac927x_dmic_nids; |
| 5660 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5661 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5662 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5663 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5664 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5665 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5666 | break; |
| 5667 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5668 | if (spec->board_config > STAC_D965_REF) { |
| 5669 | /* GPIO0 High = Enable EAPD */ |
| 5670 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5671 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5672 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5673 | spec->num_dmics = 0; |
| 5674 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5675 | spec->init = stac927x_core_init; |
| 5676 | spec->mixer = stac927x_mixer; |
| 5677 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5678 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5679 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5680 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5681 | spec->aloopback_mask = 0x40; |
| 5682 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5683 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5684 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5685 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5686 | if (!err) { |
| 5687 | if (spec->board_config < 0) { |
| 5688 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5689 | "available, default to model=ref\n"); |
| 5690 | spec->board_config = STAC_D965_REF; |
| 5691 | goto again; |
| 5692 | } |
| 5693 | err = -EINVAL; |
| 5694 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5695 | if (err < 0) { |
| 5696 | stac92xx_free(codec); |
| 5697 | return err; |
| 5698 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5699 | |
| 5700 | codec->patch_ops = stac92xx_patch_ops; |
| 5701 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5702 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5703 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5704 | /* |
| 5705 | * !!FIXME!! |
| 5706 | * The STAC927x seem to require fairly long delays for certain |
| 5707 | * command sequences. With too short delays (even if the answer |
| 5708 | * is set to RIRB properly), it results in the silence output |
| 5709 | * on some hardwares like Dell. |
| 5710 | * |
| 5711 | * The below flag enables the longer delay (see get_response |
| 5712 | * in hda_intel.c). |
| 5713 | */ |
| 5714 | codec->bus->needs_damn_long_delay = 1; |
| 5715 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5716 | /* no jack detecion for ref-no-jd model */ |
| 5717 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5718 | spec->hp_detect = 0; |
| 5719 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5720 | return 0; |
| 5721 | } |
| 5722 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5723 | static int patch_stac9205(struct hda_codec *codec) |
| 5724 | { |
| 5725 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5726 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5727 | |
| 5728 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5729 | if (spec == NULL) |
| 5730 | return -ENOMEM; |
| 5731 | |
| 5732 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5733 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5734 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5735 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5736 | stac9205_models, |
| 5737 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5738 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5739 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5740 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5741 | else |
| 5742 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5743 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5744 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5745 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5746 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5747 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5748 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5749 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5750 | spec->smux_nids = stac9205_smux_nids; |
| 5751 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5752 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5753 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5754 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5755 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5756 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5757 | |
| 5758 | spec->init = stac9205_core_init; |
| 5759 | spec->mixer = stac9205_mixer; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5760 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5761 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5762 | spec->aloopback_mask = 0x40; |
| 5763 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5764 | /* Turn on/off EAPD per HP plugging */ |
| 5765 | if (spec->board_config != STAC_9205_EAPD) |
| 5766 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5767 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5768 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5769 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5770 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5771 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5772 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5773 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5774 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5775 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5776 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5777 | if (err < 0) |
| 5778 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5779 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5780 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5781 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5782 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5783 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5784 | |
| 5785 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5786 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5787 | spec->gpio_mask = 0x1b; |
| 5788 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5789 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5790 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5791 | */ |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5792 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5793 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5794 | case STAC_9205_REF: |
| 5795 | /* SPDIF-In enabled */ |
| 5796 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5797 | default: |
| 5798 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5799 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5800 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5801 | break; |
| 5802 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5803 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5804 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5805 | if (!err) { |
| 5806 | if (spec->board_config < 0) { |
| 5807 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5808 | "available, default to model=ref\n"); |
| 5809 | spec->board_config = STAC_9205_REF; |
| 5810 | goto again; |
| 5811 | } |
| 5812 | err = -EINVAL; |
| 5813 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5814 | if (err < 0) { |
| 5815 | stac92xx_free(codec); |
| 5816 | return err; |
| 5817 | } |
| 5818 | |
| 5819 | codec->patch_ops = stac92xx_patch_ops; |
| 5820 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5821 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5822 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5823 | return 0; |
| 5824 | } |
| 5825 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5826 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5827 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5828 | */ |
| 5829 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5830 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5831 | {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] | 5832 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5833 | {} |
| 5834 | }; |
| 5835 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5836 | static struct snd_kcontrol_new stac9872_mixer[] = { |
| 5837 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5838 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5839 | { } /* end */ |
| 5840 | }; |
| 5841 | |
| 5842 | static hda_nid_t stac9872_pin_nids[] = { |
| 5843 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 5844 | 0x11, 0x13, 0x14, |
| 5845 | }; |
| 5846 | |
| 5847 | static hda_nid_t stac9872_adc_nids[] = { |
| 5848 | 0x8 /*,0x6*/ |
| 5849 | }; |
| 5850 | |
| 5851 | static hda_nid_t stac9872_mux_nids[] = { |
| 5852 | 0x15 |
| 5853 | }; |
| 5854 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5855 | static unsigned int stac9872_vaio_pin_configs[9] = { |
| 5856 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
| 5857 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
| 5858 | 0x90a7013e |
| 5859 | }; |
| 5860 | |
| 5861 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 5862 | [STAC_9872_AUTO] = "auto", |
| 5863 | [STAC_9872_VAIO] = "vaio", |
| 5864 | }; |
| 5865 | |
| 5866 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { |
| 5867 | [STAC_9872_VAIO] = stac9872_vaio_pin_configs, |
| 5868 | }; |
| 5869 | |
| 5870 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 5871 | {} /* terminator */ |
| 5872 | }; |
| 5873 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5874 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5875 | { |
| 5876 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5877 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5878 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5879 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5880 | if (spec == NULL) |
| 5881 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5882 | codec->spec = spec; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5883 | |
| 5884 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5885 | stac9872_models, |
| 5886 | stac9872_cfg_tbl); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5887 | if (spec->board_config < 0) |
| 5888 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " |
| 5889 | "using BIOS defaults\n"); |
| 5890 | else |
| 5891 | stac92xx_set_config_regs(codec, |
| 5892 | stac9872_brd_tbl[spec->board_config]); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5893 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5894 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 5895 | spec->pin_nids = stac9872_pin_nids; |
| 5896 | spec->multiout.dac_nids = spec->dac_nids; |
| 5897 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 5898 | spec->adc_nids = stac9872_adc_nids; |
| 5899 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 5900 | spec->mux_nids = stac9872_mux_nids; |
| 5901 | spec->mixer = stac9872_mixer; |
| 5902 | spec->init = stac9872_core_init; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5903 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5904 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 5905 | if (err < 0) { |
| 5906 | stac92xx_free(codec); |
| 5907 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5908 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5909 | spec->input_mux = &spec->private_imux; |
| 5910 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5911 | return 0; |
| 5912 | } |
| 5913 | |
| 5914 | |
| 5915 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5916 | * patch entries |
| 5917 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5918 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5919 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5920 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5921 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5922 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5923 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5924 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5925 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5926 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5927 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5928 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5929 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5930 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5931 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5932 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5933 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5934 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5935 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5936 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5937 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5938 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5939 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5940 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5941 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5942 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5943 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5944 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5945 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5946 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5947 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5948 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5949 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5950 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5951 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5952 | * currently not fully supported. |
| 5953 | */ |
| 5954 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5955 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5956 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 5957 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5958 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5959 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5960 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5961 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5962 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5963 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5964 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5965 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5966 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5967 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5968 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5969 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5970 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5971 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5972 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5973 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5974 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5975 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5976 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5977 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5978 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5979 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5980 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5981 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5982 | {} /* terminator */ |
| 5983 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5984 | |
| 5985 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 5986 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 5987 | |
| 5988 | MODULE_LICENSE("GPL"); |
| 5989 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 5990 | |
| 5991 | static struct hda_codec_preset_list sigmatel_list = { |
| 5992 | .preset = snd_hda_preset_sigmatel, |
| 5993 | .owner = THIS_MODULE, |
| 5994 | }; |
| 5995 | |
| 5996 | static int __init patch_sigmatel_init(void) |
| 5997 | { |
| 5998 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 5999 | } |
| 6000 | |
| 6001 | static void __exit patch_sigmatel_exit(void) |
| 6002 | { |
| 6003 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 6004 | } |
| 6005 | |
| 6006 | module_init(patch_sigmatel_init) |
| 6007 | module_exit(patch_sigmatel_exit) |