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, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 102 | STAC_92HD71BXX_MODELS |
| 103 | }; |
| 104 | |
| 105 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 106 | STAC_925x_AUTO, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 107 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 108 | STAC_M1, |
| 109 | STAC_M1_2, |
| 110 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 111 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 112 | STAC_M3, |
| 113 | STAC_M5, |
| 114 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 115 | STAC_925x_MODELS |
| 116 | }; |
| 117 | |
| 118 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 119 | STAC_922X_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 120 | STAC_D945_REF, |
| 121 | STAC_D945GTP3, |
| 122 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 123 | STAC_INTEL_MAC_V1, |
| 124 | STAC_INTEL_MAC_V2, |
| 125 | STAC_INTEL_MAC_V3, |
| 126 | STAC_INTEL_MAC_V4, |
| 127 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 128 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 129 | * is given, one of the above models will be |
| 130 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 131 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 132 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 133 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 134 | STAC_MACBOOK_PRO_V1, |
| 135 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 136 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 137 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 138 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 139 | STAC_922X_DELL_D81, |
| 140 | STAC_922X_DELL_D82, |
| 141 | STAC_922X_DELL_M81, |
| 142 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 143 | STAC_922X_MODELS |
| 144 | }; |
| 145 | |
| 146 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 147 | STAC_927X_AUTO, |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 148 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 149 | STAC_D965_REF, |
| 150 | STAC_D965_3ST, |
| 151 | STAC_D965_5ST, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 152 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 153 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 154 | STAC_927X_MODELS |
| 155 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 156 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 157 | struct sigmatel_event { |
| 158 | hda_nid_t nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 159 | unsigned char type; |
| 160 | unsigned char tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 161 | int data; |
| 162 | }; |
| 163 | |
| 164 | struct sigmatel_jack { |
| 165 | hda_nid_t nid; |
| 166 | int type; |
| 167 | struct snd_jack *jack; |
| 168 | }; |
| 169 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 170 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 171 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 172 | unsigned int num_mixers; |
| 173 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 174 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 175 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 176 | unsigned int surr_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 177 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 178 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 179 | unsigned int spdif_mute: 1; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 180 | unsigned int check_volume_offset:1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 181 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 182 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 183 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 184 | unsigned int gpio_mask; |
| 185 | unsigned int gpio_dir; |
| 186 | unsigned int gpio_data; |
| 187 | unsigned int gpio_mute; |
| 188 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 189 | /* stream */ |
| 190 | unsigned int stream_delay; |
| 191 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 192 | /* analog loopback */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 193 | struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 194 | unsigned char aloopback_mask; |
| 195 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 196 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 197 | /* power management */ |
| 198 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 199 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 200 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 201 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 202 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 203 | /* jack detection */ |
| 204 | struct snd_array jacks; |
| 205 | |
| 206 | /* events */ |
| 207 | struct snd_array events; |
| 208 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 209 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 210 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 211 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 212 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 213 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 214 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 215 | hda_nid_t hp_dacs[5]; |
| 216 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 217 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 218 | int volume_offset; |
| 219 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 220 | /* capture */ |
| 221 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 222 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 223 | hda_nid_t *mux_nids; |
| 224 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 225 | hda_nid_t *dmic_nids; |
| 226 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 227 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 228 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 229 | hda_nid_t *smux_nids; |
| 230 | unsigned int num_smuxes; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 231 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 232 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 233 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 234 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 235 | hda_nid_t anabeep_nid; |
| 236 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 237 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 238 | /* pin widgets */ |
| 239 | hda_nid_t *pin_nids; |
| 240 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 241 | |
| 242 | /* codec specific stuff */ |
| 243 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 244 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 245 | |
| 246 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 247 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 248 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 249 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 250 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 251 | struct hda_input_mux *sinput_mux; |
| 252 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 253 | unsigned int cur_amux; |
| 254 | hda_nid_t *amp_nids; |
| 255 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 256 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 257 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 258 | /* i/o switches */ |
| 259 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 260 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 261 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 262 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 263 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 264 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 265 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 266 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 267 | |
| 268 | /* dynamic controls and input_mux */ |
| 269 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 270 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 271 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 272 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 273 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 274 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 275 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 276 | }; |
| 277 | |
| 278 | static hda_nid_t stac9200_adc_nids[1] = { |
| 279 | 0x03, |
| 280 | }; |
| 281 | |
| 282 | static hda_nid_t stac9200_mux_nids[1] = { |
| 283 | 0x0c, |
| 284 | }; |
| 285 | |
| 286 | static hda_nid_t stac9200_dac_nids[1] = { |
| 287 | 0x02, |
| 288 | }; |
| 289 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 290 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 291 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 292 | 0x0f, 0x10, 0x11 |
| 293 | }; |
| 294 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 295 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 296 | 0x26, 0, |
| 297 | }; |
| 298 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 299 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 300 | 0x1a, 0x1b |
| 301 | }; |
| 302 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 303 | #define DELL_M6_AMP 2 |
| 304 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 305 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 306 | }; |
| 307 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 308 | #define STAC92HD73XX_NUM_DMICS 2 |
| 309 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 310 | 0x13, 0x14, 0 |
| 311 | }; |
| 312 | |
| 313 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 314 | |
| 315 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 316 | 0x28, 0x29, 0x2a, 0x2b, |
| 317 | }; |
| 318 | |
| 319 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 320 | 0x20, 0x21, |
| 321 | }; |
| 322 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 323 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 324 | 0x22, 0x23, |
| 325 | }; |
| 326 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 327 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 328 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 329 | 0x11, 0x12, 0 |
| 330 | }; |
| 331 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 332 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 333 | |
| 334 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 335 | 0x17, 0x18, |
| 336 | }; |
| 337 | |
| 338 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 339 | 0x15, 0x16, |
| 340 | }; |
| 341 | |
| 342 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 343 | 0xa, 0xb, 0xd, 0xe, |
| 344 | }; |
| 345 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 346 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 347 | 0x1e, 0, |
| 348 | }; |
| 349 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 350 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 351 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 352 | }; |
| 353 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 354 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 355 | 0xc, |
| 356 | }; |
| 357 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 358 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 359 | 0x0a, 0x0d, 0x0f |
| 360 | }; |
| 361 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 362 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 363 | 0x12, 0x13, |
| 364 | }; |
| 365 | |
| 366 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 367 | 0x1a, 0x1b |
| 368 | }; |
| 369 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 370 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 371 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 372 | }; |
| 373 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 374 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 375 | 0x24, 0x25, |
| 376 | }; |
| 377 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 378 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 379 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 380 | 0x18, 0x19, 0 |
| 381 | }; |
| 382 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 383 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 384 | 0x22, 0 |
| 385 | }; |
| 386 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 387 | static hda_nid_t stac925x_adc_nids[1] = { |
| 388 | 0x03, |
| 389 | }; |
| 390 | |
| 391 | static hda_nid_t stac925x_mux_nids[1] = { |
| 392 | 0x0f, |
| 393 | }; |
| 394 | |
| 395 | static hda_nid_t stac925x_dac_nids[1] = { |
| 396 | 0x02, |
| 397 | }; |
| 398 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 399 | #define STAC925X_NUM_DMICS 1 |
| 400 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 401 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 402 | }; |
| 403 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 404 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 405 | 0x14, |
| 406 | }; |
| 407 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 408 | static hda_nid_t stac922x_adc_nids[2] = { |
| 409 | 0x06, 0x07, |
| 410 | }; |
| 411 | |
| 412 | static hda_nid_t stac922x_mux_nids[2] = { |
| 413 | 0x12, 0x13, |
| 414 | }; |
| 415 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 416 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 417 | 0x1f, 0, |
| 418 | }; |
| 419 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 420 | static hda_nid_t stac927x_adc_nids[3] = { |
| 421 | 0x07, 0x08, 0x09 |
| 422 | }; |
| 423 | |
| 424 | static hda_nid_t stac927x_mux_nids[3] = { |
| 425 | 0x15, 0x16, 0x17 |
| 426 | }; |
| 427 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 428 | static hda_nid_t stac927x_smux_nids[1] = { |
| 429 | 0x21, |
| 430 | }; |
| 431 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 432 | static hda_nid_t stac927x_dac_nids[6] = { |
| 433 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 434 | }; |
| 435 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 436 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 437 | 0x1b, |
| 438 | }; |
| 439 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 440 | #define STAC927X_NUM_DMICS 2 |
| 441 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 442 | 0x13, 0x14, 0 |
| 443 | }; |
| 444 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 445 | static const char *stac927x_spdif_labels[5] = { |
| 446 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 447 | "Analog Mux 2", "Analog Mux 3" |
| 448 | }; |
| 449 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 450 | static hda_nid_t stac9205_adc_nids[2] = { |
| 451 | 0x12, 0x13 |
| 452 | }; |
| 453 | |
| 454 | static hda_nid_t stac9205_mux_nids[2] = { |
| 455 | 0x19, 0x1a |
| 456 | }; |
| 457 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 458 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 459 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 460 | }; |
| 461 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 462 | static hda_nid_t stac9205_smux_nids[1] = { |
| 463 | 0x21, |
| 464 | }; |
| 465 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 466 | #define STAC9205_NUM_DMICS 2 |
| 467 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 468 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 469 | }; |
| 470 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 471 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 472 | 0x08, 0x09, 0x0d, 0x0e, |
| 473 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 474 | }; |
| 475 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 476 | static hda_nid_t stac925x_pin_nids[8] = { |
| 477 | 0x07, 0x08, 0x0a, 0x0b, |
| 478 | 0x0c, 0x0d, 0x10, 0x11, |
| 479 | }; |
| 480 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 481 | static hda_nid_t stac922x_pin_nids[10] = { |
| 482 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 483 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 484 | }; |
| 485 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 486 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 487 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 488 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 489 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 490 | }; |
| 491 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 492 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 493 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 494 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 495 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 496 | |
| 497 | #define STAC92HD71BXX_NUM_PINS 13 |
| 498 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 499 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 500 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 501 | 0x1f, 0x20, 0x27 |
| 502 | }; |
| 503 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 504 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 505 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 506 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 507 | }; |
| 508 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 509 | static hda_nid_t stac927x_pin_nids[14] = { |
| 510 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 511 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 512 | 0x14, 0x21, 0x22, 0x23, |
| 513 | }; |
| 514 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 515 | static hda_nid_t stac9205_pin_nids[12] = { |
| 516 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 517 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 518 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 519 | }; |
| 520 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 521 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 522 | |
| 523 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 524 | struct snd_ctl_elem_value *ucontrol) |
| 525 | { |
| 526 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 527 | struct sigmatel_spec *spec = codec->spec; |
| 528 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 529 | |
| 530 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 531 | kcontrol->private_value |= nid; |
| 532 | |
| 533 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 534 | } |
| 535 | |
| 536 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 537 | struct snd_ctl_elem_value *ucontrol) |
| 538 | { |
| 539 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 540 | struct sigmatel_spec *spec = codec->spec; |
| 541 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 542 | |
| 543 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 544 | kcontrol->private_value |= nid; |
| 545 | |
| 546 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 547 | } |
| 548 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 549 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 550 | struct snd_ctl_elem_info *uinfo) |
| 551 | { |
| 552 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 553 | struct sigmatel_spec *spec = codec->spec; |
| 554 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 555 | } |
| 556 | |
| 557 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 558 | struct snd_ctl_elem_value *ucontrol) |
| 559 | { |
| 560 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 561 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 562 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 563 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 564 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 569 | struct snd_ctl_elem_value *ucontrol) |
| 570 | { |
| 571 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 572 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 573 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 574 | |
| 575 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 576 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 577 | } |
| 578 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 579 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 580 | struct snd_ctl_elem_info *uinfo) |
| 581 | { |
| 582 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 583 | struct sigmatel_spec *spec = codec->spec; |
| 584 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 585 | } |
| 586 | |
| 587 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 588 | struct snd_ctl_elem_value *ucontrol) |
| 589 | { |
| 590 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 591 | struct sigmatel_spec *spec = codec->spec; |
| 592 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 593 | |
| 594 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 599 | struct snd_ctl_elem_value *ucontrol) |
| 600 | { |
| 601 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 602 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 603 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 604 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 605 | int err, val; |
| 606 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 607 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 608 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 609 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 610 | if (err < 0) |
| 611 | return err; |
| 612 | |
| 613 | if (spec->spdif_mute) { |
| 614 | if (smux_idx == 0) |
| 615 | nid = spec->multiout.dig_out_nid; |
| 616 | else |
| 617 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 618 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 619 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 620 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 621 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 622 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 623 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 624 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 625 | } |
| 626 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 627 | } |
| 628 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 629 | 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] | 630 | { |
| 631 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 632 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 633 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 634 | } |
| 635 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 636 | 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] | 637 | { |
| 638 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 639 | struct sigmatel_spec *spec = codec->spec; |
| 640 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 641 | |
| 642 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 643 | return 0; |
| 644 | } |
| 645 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 646 | 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] | 647 | { |
| 648 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 649 | struct sigmatel_spec *spec = codec->spec; |
| 650 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 651 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 652 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 653 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 654 | } |
| 655 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 656 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 657 | struct snd_ctl_elem_info *uinfo) |
| 658 | { |
| 659 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 660 | struct sigmatel_spec *spec = codec->spec; |
| 661 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 662 | } |
| 663 | |
| 664 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 665 | struct snd_ctl_elem_value *ucontrol) |
| 666 | { |
| 667 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 668 | struct sigmatel_spec *spec = codec->spec; |
| 669 | |
| 670 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 675 | struct snd_ctl_elem_value *ucontrol) |
| 676 | { |
| 677 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 678 | struct sigmatel_spec *spec = codec->spec; |
| 679 | |
| 680 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 681 | spec->mono_nid, &spec->cur_mmux); |
| 682 | } |
| 683 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 684 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 685 | struct snd_ctl_elem_info *uinfo) |
| 686 | { |
| 687 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 688 | struct sigmatel_spec *spec = codec->spec; |
| 689 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 690 | } |
| 691 | |
| 692 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 693 | struct snd_ctl_elem_value *ucontrol) |
| 694 | { |
| 695 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 696 | struct sigmatel_spec *spec = codec->spec; |
| 697 | |
| 698 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 699 | return 0; |
| 700 | } |
| 701 | |
| 702 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 703 | struct snd_ctl_elem_value *ucontrol) |
| 704 | { |
| 705 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 706 | struct sigmatel_spec *spec = codec->spec; |
| 707 | struct snd_kcontrol *ctl = |
| 708 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 709 | if (!ctl) |
| 710 | return -EINVAL; |
| 711 | |
| 712 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 713 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 714 | |
| 715 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 716 | 0, &spec->cur_amux); |
| 717 | } |
| 718 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 719 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 720 | |
| 721 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 722 | struct snd_ctl_elem_value *ucontrol) |
| 723 | { |
| 724 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 725 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 726 | struct sigmatel_spec *spec = codec->spec; |
| 727 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 728 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 729 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 730 | return 0; |
| 731 | } |
| 732 | |
| 733 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 734 | struct snd_ctl_elem_value *ucontrol) |
| 735 | { |
| 736 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 737 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 738 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 739 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 740 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 741 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 742 | idx_val = spec->aloopback_mask << idx; |
| 743 | if (ucontrol->value.integer.value[0]) |
| 744 | val = spec->aloopback | idx_val; |
| 745 | else |
| 746 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 747 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 748 | return 0; |
| 749 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 750 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 751 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 752 | /* Only return the bits defined by the shift value of the |
| 753 | * first two bytes of the mask |
| 754 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 755 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 756 | kcontrol->private_value & 0xFFFF, 0x0); |
| 757 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 758 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 759 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 760 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 761 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 762 | } else { |
| 763 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 764 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 768 | kcontrol->private_value >> 16, dac_mode); |
| 769 | |
| 770 | return 1; |
| 771 | } |
| 772 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 773 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 774 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 775 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 776 | {} |
| 777 | }; |
| 778 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 779 | static struct hda_verb stac9200_eapd_init[] = { |
| 780 | /* set dac0mux for dac converter */ |
| 781 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 782 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 783 | {} |
| 784 | }; |
| 785 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 786 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 787 | /* set master volume and direct control */ |
| 788 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 789 | /* setup adcs to point to mixer */ |
| 790 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 791 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 792 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 793 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 794 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 795 | /* setup import muxs */ |
| 796 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 797 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 798 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 799 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 800 | {} |
| 801 | }; |
| 802 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 803 | static struct hda_verb dell_eq_core_init[] = { |
| 804 | /* set master volume to max value without distortion |
| 805 | * and direct control */ |
| 806 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 807 | /* setup adcs to point to mixer */ |
| 808 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 809 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 810 | /* setup import muxs */ |
| 811 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 812 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 813 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 814 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 815 | {} |
| 816 | }; |
| 817 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 818 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 819 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 820 | /* setup adcs to point to mixer */ |
| 821 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 822 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 823 | /* setup import muxs */ |
| 824 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 825 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 826 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 827 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 828 | {} |
| 829 | }; |
| 830 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 831 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 832 | /* set master volume and direct control */ |
| 833 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 834 | /* setup adcs to point to mixer */ |
| 835 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 836 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 837 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 838 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 839 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 840 | /* setup import muxs */ |
| 841 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 842 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 843 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 844 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 845 | {} |
| 846 | }; |
| 847 | |
| 848 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 849 | /* set master volume and direct control */ |
| 850 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 851 | /* dac3 is connected to import3 mux */ |
| 852 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 853 | /* setup adcs to point to mixer */ |
| 854 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 855 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 856 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 857 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 858 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 859 | /* setup import muxs */ |
| 860 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 861 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 862 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 863 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 864 | {} |
| 865 | }; |
| 866 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 867 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 868 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 869 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 870 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 871 | |
| 872 | /* power state controls amps */ |
| 873 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 874 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 875 | }; |
| 876 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 877 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 878 | /* set master volume and direct control */ |
| 879 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 880 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 881 | }; |
| 882 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 883 | #define HD_DISABLE_PORTF 1 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 884 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 885 | /* start of config #1 */ |
| 886 | |
| 887 | /* connect port 0f to audio mixer */ |
| 888 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 889 | /* start of config #2 */ |
| 890 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 891 | /* set master volume and direct control */ |
| 892 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 893 | {} |
| 894 | }; |
| 895 | |
| 896 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 897 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 898 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 899 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 900 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 901 | {} |
| 902 | }; |
| 903 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 904 | static struct hda_verb stac925x_core_init[] = { |
| 905 | /* set dac0mux for dac converter */ |
| 906 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 907 | /* mute the master volume */ |
| 908 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 909 | {} |
| 910 | }; |
| 911 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 912 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 913 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 914 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 915 | {} |
| 916 | }; |
| 917 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 918 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 919 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 920 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 921 | /* unmute node 0x1b */ |
| 922 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 923 | /* select node 0x03 as DAC */ |
| 924 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 925 | {} |
| 926 | }; |
| 927 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 928 | static struct hda_verb stac927x_core_init[] = { |
| 929 | /* set master volume and direct control */ |
| 930 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 931 | /* enable analog pc beep path */ |
| 932 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 933 | {} |
| 934 | }; |
| 935 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 936 | static struct hda_verb stac9205_core_init[] = { |
| 937 | /* set master volume and direct control */ |
| 938 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 939 | /* enable analog pc beep path */ |
| 940 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 941 | {} |
| 942 | }; |
| 943 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 944 | #define STAC_MONO_MUX \ |
| 945 | { \ |
| 946 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 947 | .name = "Mono Mux", \ |
| 948 | .count = 1, \ |
| 949 | .info = stac92xx_mono_mux_enum_info, \ |
| 950 | .get = stac92xx_mono_mux_enum_get, \ |
| 951 | .put = stac92xx_mono_mux_enum_put, \ |
| 952 | } |
| 953 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 954 | #define STAC_AMP_MUX \ |
| 955 | { \ |
| 956 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 957 | .name = "Amp Selector Capture Switch", \ |
| 958 | .count = 1, \ |
| 959 | .info = stac92xx_amp_mux_enum_info, \ |
| 960 | .get = stac92xx_amp_mux_enum_get, \ |
| 961 | .put = stac92xx_amp_mux_enum_put, \ |
| 962 | } |
| 963 | |
| 964 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 965 | { \ |
| 966 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 967 | .name = xname, \ |
| 968 | .index = 0, \ |
| 969 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 970 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 971 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 972 | .info = stac92xx_amp_volume_info, \ |
| 973 | .get = stac92xx_amp_volume_get, \ |
| 974 | .put = stac92xx_amp_volume_put, \ |
| 975 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 976 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 977 | } |
| 978 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 979 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 980 | { \ |
| 981 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 982 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 983 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 984 | .info = stac92xx_aloopback_info, \ |
| 985 | .get = stac92xx_aloopback_get, \ |
| 986 | .put = stac92xx_aloopback_put, \ |
| 987 | .private_value = verb_read | (verb_write << 16), \ |
| 988 | } |
| 989 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 990 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 991 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 992 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 993 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 994 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 995 | { } /* end */ |
| 996 | }; |
| 997 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 998 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 999 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1000 | /* start of config #1 */ |
| 1001 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1002 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1003 | |
| 1004 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1005 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1006 | |
| 1007 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1008 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1009 | |
| 1010 | /* start of config #2 */ |
| 1011 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1012 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1013 | |
| 1014 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1015 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1016 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1017 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1018 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1019 | |
| 1020 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1021 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1022 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1023 | { } /* end */ |
| 1024 | }; |
| 1025 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1026 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1027 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1028 | {} |
| 1029 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1030 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1031 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1032 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1033 | {} |
| 1034 | }; |
| 1035 | |
| 1036 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1037 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1038 | {} |
| 1039 | }; |
| 1040 | |
| 1041 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1042 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1043 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1044 | |
| 1045 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1046 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1047 | |
| 1048 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1049 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1050 | |
| 1051 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1052 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1053 | |
| 1054 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1055 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1056 | |
| 1057 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1058 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1059 | |
| 1060 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1061 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1062 | { } /* end */ |
| 1063 | }; |
| 1064 | |
| 1065 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1066 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1067 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1068 | |
| 1069 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1070 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1071 | |
| 1072 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1073 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1074 | |
| 1075 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1076 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1077 | |
| 1078 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1079 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1080 | |
| 1081 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1082 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1083 | |
| 1084 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1085 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1086 | { } /* end */ |
| 1087 | }; |
| 1088 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1089 | |
| 1090 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1091 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1092 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1093 | |
| 1094 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1095 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1096 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1097 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1098 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1099 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1100 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1101 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1102 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1103 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1104 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1105 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1106 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1107 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1108 | |
| 1109 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1110 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1111 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1112 | */ |
| 1113 | { } /* end */ |
| 1114 | }; |
| 1115 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1116 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1117 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1118 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1119 | |
| 1120 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1121 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1122 | /* analog pc-beep replaced with digital beep support */ |
| 1123 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1124 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1125 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1126 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1127 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1128 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1129 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1130 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1131 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1132 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1133 | |
| 1134 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1135 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1136 | |
| 1137 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1138 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1139 | { } /* end */ |
| 1140 | }; |
| 1141 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1142 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1143 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1144 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1145 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1146 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1147 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1148 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1149 | |
| 1150 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1151 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1152 | { } /* end */ |
| 1153 | }; |
| 1154 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1155 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1156 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1157 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1158 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1159 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1160 | { } /* end */ |
| 1161 | }; |
| 1162 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1163 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1164 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1165 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1166 | |
| 1167 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1168 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1169 | { } /* end */ |
| 1170 | }; |
| 1171 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1172 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1173 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1174 | {} |
| 1175 | }; |
| 1176 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1177 | /* This needs to be generated dynamically based on sequence */ |
| 1178 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1179 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1180 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1181 | |
| 1182 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1183 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1184 | { } /* end */ |
| 1185 | }; |
| 1186 | |
| 1187 | |
| 1188 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1189 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1190 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1191 | |
| 1192 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1193 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1194 | |
| 1195 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1196 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1197 | { } /* end */ |
| 1198 | }; |
| 1199 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1200 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1201 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1202 | {} |
| 1203 | }; |
| 1204 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1205 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1206 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1207 | .name = "Digital Input Source", |
| 1208 | /* count set later */ |
| 1209 | .info = stac92xx_dmux_enum_info, |
| 1210 | .get = stac92xx_dmux_enum_get, |
| 1211 | .put = stac92xx_dmux_enum_put, |
| 1212 | }; |
| 1213 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1214 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1215 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1216 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1217 | /* count set later */ |
| 1218 | .info = stac92xx_smux_enum_info, |
| 1219 | .get = stac92xx_smux_enum_get, |
| 1220 | .put = stac92xx_smux_enum_put, |
| 1221 | }; |
| 1222 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1223 | static const char *slave_vols[] = { |
| 1224 | "Front Playback Volume", |
| 1225 | "Surround Playback Volume", |
| 1226 | "Center Playback Volume", |
| 1227 | "LFE Playback Volume", |
| 1228 | "Side Playback Volume", |
| 1229 | "Headphone Playback Volume", |
Takashi Iwai | 14b9759 | 2009-03-06 09:42:07 +0100 | [diff] [blame] | 1230 | "Headphone2 Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1231 | "Speaker Playback Volume", |
| 1232 | "External Speaker Playback Volume", |
| 1233 | "Speaker2 Playback Volume", |
| 1234 | NULL |
| 1235 | }; |
| 1236 | |
| 1237 | static const char *slave_sws[] = { |
| 1238 | "Front Playback Switch", |
| 1239 | "Surround Playback Switch", |
| 1240 | "Center Playback Switch", |
| 1241 | "LFE Playback Switch", |
| 1242 | "Side Playback Switch", |
| 1243 | "Headphone Playback Switch", |
Takashi Iwai | 14b9759 | 2009-03-06 09:42:07 +0100 | [diff] [blame] | 1244 | "Headphone2 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1245 | "Speaker Playback Switch", |
| 1246 | "External Speaker Playback Switch", |
| 1247 | "Speaker2 Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1248 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1249 | NULL |
| 1250 | }; |
| 1251 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1252 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1253 | 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] | 1254 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1255 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1256 | { |
| 1257 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1258 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1259 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1260 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1261 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1262 | |
| 1263 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1264 | if (err < 0) |
| 1265 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1266 | |
| 1267 | for (i = 0; i < spec->num_mixers; i++) { |
| 1268 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1269 | if (err < 0) |
| 1270 | return err; |
| 1271 | } |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1272 | if (spec->num_dmuxes > 0) { |
| 1273 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1274 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1275 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1276 | if (err < 0) |
| 1277 | return err; |
| 1278 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1279 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1280 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1281 | struct hda_input_mux *smux = &spec->private_smux; |
| 1282 | /* check for mute support on SPDIF out */ |
| 1283 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1284 | smux->items[smux->num_items].label = "Off"; |
| 1285 | smux->items[smux->num_items].index = 0; |
| 1286 | smux->num_items++; |
| 1287 | spec->spdif_mute = 1; |
| 1288 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1289 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1290 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1291 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1292 | if (err < 0) |
| 1293 | return err; |
| 1294 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1295 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1296 | if (spec->multiout.dig_out_nid) { |
| 1297 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1298 | if (err < 0) |
| 1299 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1300 | err = snd_hda_create_spdif_share_sw(codec, |
| 1301 | &spec->multiout); |
| 1302 | if (err < 0) |
| 1303 | return err; |
| 1304 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1305 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1306 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1307 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1308 | if (err < 0) |
| 1309 | return err; |
| 1310 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1311 | |
| 1312 | /* if we have no master control, let's create it */ |
| 1313 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1314 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1315 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1316 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1317 | /* correct volume offset */ |
| 1318 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1319 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1320 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1321 | if (err < 0) |
| 1322 | return err; |
| 1323 | } |
| 1324 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1325 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1326 | NULL, slave_sws); |
| 1327 | if (err < 0) |
| 1328 | return err; |
| 1329 | } |
| 1330 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1331 | if (spec->aloopback_ctl && |
| 1332 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1333 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1334 | if (err < 0) |
| 1335 | return err; |
| 1336 | } |
| 1337 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1338 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1339 | |
| 1340 | /* create jack input elements */ |
| 1341 | if (spec->hp_detect) { |
| 1342 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1343 | int type = SND_JACK_HEADPHONE; |
| 1344 | nid = cfg->hp_pins[i]; |
| 1345 | /* jack detection */ |
| 1346 | if (cfg->hp_outs == i) |
| 1347 | type |= SND_JACK_LINEOUT; |
| 1348 | err = stac92xx_add_jack(codec, nid, type); |
| 1349 | if (err < 0) |
| 1350 | return err; |
| 1351 | } |
| 1352 | } |
| 1353 | for (i = 0; i < cfg->line_outs; i++) { |
| 1354 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1355 | SND_JACK_LINEOUT); |
| 1356 | if (err < 0) |
| 1357 | return err; |
| 1358 | } |
| 1359 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1360 | nid = cfg->input_pins[i]; |
| 1361 | if (nid) { |
| 1362 | err = stac92xx_add_jack(codec, nid, |
| 1363 | SND_JACK_MICROPHONE); |
| 1364 | if (err < 0) |
| 1365 | return err; |
| 1366 | } |
| 1367 | } |
| 1368 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1369 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1370 | } |
| 1371 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1372 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1373 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1374 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1375 | }; |
| 1376 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1377 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1378 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1379 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1380 | }; |
| 1381 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1382 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1383 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1384 | }; |
| 1385 | |
| 1386 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1387 | STAC 9200 pin configs for |
| 1388 | 102801A8 |
| 1389 | 102801DE |
| 1390 | 102801E8 |
| 1391 | */ |
| 1392 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1393 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1394 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1395 | }; |
| 1396 | |
| 1397 | /* |
| 1398 | STAC 9200 pin configs for |
| 1399 | 102801C0 |
| 1400 | 102801C1 |
| 1401 | */ |
| 1402 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1403 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1404 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1405 | }; |
| 1406 | |
| 1407 | /* |
| 1408 | STAC 9200 pin configs for |
| 1409 | 102801C4 (Dell Dimension E310) |
| 1410 | 102801C5 |
| 1411 | 102801C7 |
| 1412 | 102801D9 |
| 1413 | 102801DA |
| 1414 | 102801E3 |
| 1415 | */ |
| 1416 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1417 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1418 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1419 | }; |
| 1420 | |
| 1421 | |
| 1422 | /* |
| 1423 | STAC 9200-32 pin configs for |
| 1424 | 102801B5 (Dell Inspiron 630m) |
| 1425 | 102801D8 (Dell Inspiron 640m) |
| 1426 | */ |
| 1427 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1428 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1429 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1430 | }; |
| 1431 | |
| 1432 | /* |
| 1433 | STAC 9200-32 pin configs for |
| 1434 | 102801C2 (Dell Latitude D620) |
| 1435 | 102801C8 |
| 1436 | 102801CC (Dell Latitude D820) |
| 1437 | 102801D4 |
| 1438 | 102801D6 |
| 1439 | */ |
| 1440 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1441 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1442 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1443 | }; |
| 1444 | |
| 1445 | /* |
| 1446 | STAC 9200-32 pin configs for |
| 1447 | 102801CE (Dell XPS M1710) |
| 1448 | 102801CF (Dell Precision M90) |
| 1449 | */ |
| 1450 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1451 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1452 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1453 | }; |
| 1454 | |
| 1455 | /* |
| 1456 | STAC 9200-32 pin configs for |
| 1457 | 102801C9 |
| 1458 | 102801CA |
| 1459 | 102801CB (Dell Latitude 120L) |
| 1460 | 102801D3 |
| 1461 | */ |
| 1462 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1463 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1464 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1465 | }; |
| 1466 | |
| 1467 | /* |
| 1468 | STAC 9200-32 pin configs for |
| 1469 | 102801BD (Dell Inspiron E1505n) |
| 1470 | 102801EE |
| 1471 | 102801EF |
| 1472 | */ |
| 1473 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1474 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1475 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1476 | }; |
| 1477 | |
| 1478 | /* |
| 1479 | STAC 9200-32 pin configs for |
| 1480 | 102801F5 (Dell Inspiron 1501) |
| 1481 | 102801F6 |
| 1482 | */ |
| 1483 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1484 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1485 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1486 | }; |
| 1487 | |
| 1488 | /* |
| 1489 | STAC 9200-32 |
| 1490 | 102801CD (Dell Inspiron E1705/9400) |
| 1491 | */ |
| 1492 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1493 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1494 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1495 | }; |
| 1496 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1497 | static unsigned int oqo9200_pin_configs[8] = { |
| 1498 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1499 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1500 | }; |
| 1501 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1502 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1503 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1504 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1505 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1506 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1507 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1508 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1509 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1510 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1511 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1512 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1513 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1514 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1515 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1516 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1517 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1518 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1519 | }; |
| 1520 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1521 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1522 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1523 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1524 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1525 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1526 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1527 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1528 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1529 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1530 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1531 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1532 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1533 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1534 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1535 | [STAC_9200_M4] = "gateway-m4", |
| 1536 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1537 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1538 | }; |
| 1539 | |
| 1540 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1541 | /* SigmaTel reference board */ |
| 1542 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1543 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1544 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1545 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1546 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1547 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1548 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1550 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1551 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1552 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1553 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1554 | "unknown Dell", STAC_9200_DELL_D22), |
| 1555 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1556 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1557 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1558 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1559 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1560 | "unknown Dell", STAC_9200_DELL_D23), |
| 1561 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1562 | "unknown Dell", STAC_9200_DELL_D23), |
| 1563 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1564 | "unknown Dell", STAC_9200_DELL_M22), |
| 1565 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1566 | "unknown Dell", STAC_9200_DELL_M24), |
| 1567 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1568 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1569 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1570 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1571 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1572 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1573 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1574 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1575 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1576 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1577 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1578 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1579 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1580 | "unknown Dell", STAC_9200_DELL_M22), |
| 1581 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1582 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1583 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1584 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1585 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1586 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1587 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1588 | "unknown Dell", STAC_9200_DELL_D23), |
| 1589 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1590 | "unknown Dell", STAC_9200_DELL_D23), |
| 1591 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1592 | "unknown Dell", STAC_9200_DELL_D21), |
| 1593 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1594 | "unknown Dell", STAC_9200_DELL_D23), |
| 1595 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1596 | "unknown Dell", STAC_9200_DELL_D21), |
| 1597 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1598 | "unknown Dell", STAC_9200_DELL_M25), |
| 1599 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1600 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1601 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1602 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1603 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1604 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1605 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1606 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1607 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1608 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1609 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1610 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1611 | /* OQO Mobile */ |
| 1612 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1613 | {} /* terminator */ |
| 1614 | }; |
| 1615 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1616 | static unsigned int ref925x_pin_configs[8] = { |
| 1617 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1618 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1619 | }; |
| 1620 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1621 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1622 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1623 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1624 | }; |
| 1625 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1626 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1627 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1628 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1629 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1630 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1631 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1632 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1633 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1634 | }; |
| 1635 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1636 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1637 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1638 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1639 | }; |
| 1640 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1641 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1642 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1643 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1644 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1645 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1646 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1647 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1648 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1649 | }; |
| 1650 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1651 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1652 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1653 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1654 | }; |
| 1655 | |
| 1656 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1657 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1658 | [STAC_M1] = stac925xM1_pin_configs, |
| 1659 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1660 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1661 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1662 | [STAC_M3] = stac925xM3_pin_configs, |
| 1663 | [STAC_M5] = stac925xM5_pin_configs, |
| 1664 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1665 | }; |
| 1666 | |
| 1667 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1668 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1669 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1670 | [STAC_M1] = "m1", |
| 1671 | [STAC_M1_2] = "m1-2", |
| 1672 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1673 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1674 | [STAC_M3] = "m3", |
| 1675 | [STAC_M5] = "m5", |
| 1676 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1677 | }; |
| 1678 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1679 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1681 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1682 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1683 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1684 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1685 | /* Not sure about the brand name for those */ |
| 1686 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1687 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1688 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1689 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1690 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1691 | }; |
| 1692 | |
| 1693 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1694 | /* SigmaTel reference board */ |
| 1695 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1696 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1697 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1698 | |
| 1699 | /* Default table for unknown ID */ |
| 1700 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1701 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1702 | {} /* terminator */ |
| 1703 | }; |
| 1704 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1705 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1706 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1707 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1708 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1709 | 0x01452050, |
| 1710 | }; |
| 1711 | |
| 1712 | static unsigned int dell_m6_pin_configs[13] = { |
| 1713 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1714 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1715 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1716 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1717 | }; |
| 1718 | |
| 1719 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1720 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1721 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1722 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1723 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1724 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1725 | }; |
| 1726 | |
| 1727 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1728 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1729 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1730 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1731 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1732 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1733 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1734 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1735 | }; |
| 1736 | |
| 1737 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1738 | /* SigmaTel reference board */ |
| 1739 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1740 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1741 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1742 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1743 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1744 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1745 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1746 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1747 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1748 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1749 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1750 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1751 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1752 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1753 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1754 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1755 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1756 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1757 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1758 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1759 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1760 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1761 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1762 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1763 | {} /* terminator */ |
| 1764 | }; |
| 1765 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1766 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1767 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1768 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1769 | 0x01451160, 0x98560170, |
| 1770 | }; |
| 1771 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1772 | static unsigned int dell_s14_pin_configs[10] = { |
| 1773 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1774 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1775 | 0x40f000f0, 0x40f000f0, |
| 1776 | }; |
| 1777 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1778 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1779 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1780 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1781 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1782 | }; |
| 1783 | |
| 1784 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1785 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1786 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1787 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1788 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1789 | }; |
| 1790 | |
| 1791 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1792 | /* SigmaTel reference board */ |
| 1793 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1794 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1795 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1796 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1797 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1798 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1799 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1800 | }; |
| 1801 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1802 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1803 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1804 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1805 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1806 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1807 | }; |
| 1808 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1809 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1810 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1811 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1812 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1813 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1814 | }; |
| 1815 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1816 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1817 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1818 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1819 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1820 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1821 | }; |
| 1822 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1823 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1824 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1825 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1826 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1827 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1828 | }; |
| 1829 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1830 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1831 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1832 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1833 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1834 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1835 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1836 | [STAC_HP_DV5] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1837 | }; |
| 1838 | |
| 1839 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1840 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1841 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1842 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1843 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1844 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1845 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1846 | [STAC_HP_DV5] = "hp-dv5", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1847 | }; |
| 1848 | |
| 1849 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1850 | /* SigmaTel reference board */ |
| 1851 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1852 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1853 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1854 | "DFI LanParty", STAC_92HD71BXX_REF), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1855 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1856 | "HP dv4-7", STAC_HP_DV5), |
| 1857 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1858 | "HP dv4-7", STAC_HP_DV5), |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1859 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1860 | "HP mini 1000", STAC_HP_M4), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1861 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1862 | "unknown Dell", STAC_DELL_M4_1), |
| 1863 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1864 | "unknown Dell", STAC_DELL_M4_1), |
| 1865 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1866 | "unknown Dell", STAC_DELL_M4_1), |
| 1867 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1868 | "unknown Dell", STAC_DELL_M4_1), |
| 1869 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1870 | "unknown Dell", STAC_DELL_M4_1), |
| 1871 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1872 | "unknown Dell", STAC_DELL_M4_1), |
| 1873 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1874 | "unknown Dell", STAC_DELL_M4_1), |
| 1875 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1876 | "unknown Dell", STAC_DELL_M4_2), |
| 1877 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1878 | "unknown Dell", STAC_DELL_M4_2), |
| 1879 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1880 | "unknown Dell", STAC_DELL_M4_2), |
| 1881 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1882 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1883 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1884 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1885 | {} /* terminator */ |
| 1886 | }; |
| 1887 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1888 | static unsigned int ref922x_pin_configs[10] = { |
| 1889 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1890 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1891 | 0x40000100, 0x40000100, |
| 1892 | }; |
| 1893 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1894 | /* |
| 1895 | STAC 922X pin configs for |
| 1896 | 102801A7 |
| 1897 | 102801AB |
| 1898 | 102801A9 |
| 1899 | 102801D1 |
| 1900 | 102801D2 |
| 1901 | */ |
| 1902 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1903 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1904 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1905 | 0x01813122, 0x400001f2, |
| 1906 | }; |
| 1907 | |
| 1908 | /* |
| 1909 | STAC 922X pin configs for |
| 1910 | 102801AC |
| 1911 | 102801D0 |
| 1912 | */ |
| 1913 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1914 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1915 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1916 | 0x01813122, 0x400001f1, |
| 1917 | }; |
| 1918 | |
| 1919 | /* |
| 1920 | STAC 922X pin configs for |
| 1921 | 102801BF |
| 1922 | */ |
| 1923 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1924 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1925 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1926 | 0x40C003f1, 0x405003f0, |
| 1927 | }; |
| 1928 | |
| 1929 | /* |
| 1930 | STAC 9221 A1 pin configs for |
| 1931 | 102801D7 (Dell XPS M1210) |
| 1932 | */ |
| 1933 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1934 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1935 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1936 | 0x508003f3, 0x405003f4, |
| 1937 | }; |
| 1938 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1939 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1940 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1941 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1942 | 0x02a19120, 0x40000100, |
| 1943 | }; |
| 1944 | |
| 1945 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1946 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1947 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1948 | 0x02a19320, 0x40000100, |
| 1949 | }; |
| 1950 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1951 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1952 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1953 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1954 | 0x400000fc, 0x400000fb, |
| 1955 | }; |
| 1956 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1957 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1958 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1959 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1960 | 0x400000fc, 0x400000fb, |
| 1961 | }; |
| 1962 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1963 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1964 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1965 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 1966 | 0x400000fc, 0x400000fb, |
| 1967 | }; |
| 1968 | |
| 1969 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 1970 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1971 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1972 | 0x400000fc, 0x400000fb, |
| 1973 | }; |
| 1974 | |
| 1975 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 1976 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1977 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1978 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1979 | }; |
| 1980 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1981 | static unsigned int ecs202_pin_configs[10] = { |
| 1982 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 1983 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 1984 | 0x9037012e, 0x40e000f2, |
| 1985 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1986 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1987 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1988 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1989 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 1990 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1991 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 1992 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 1993 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 1994 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 1995 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1996 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1997 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1998 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 1999 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2000 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2001 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2002 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2003 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2004 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2005 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2006 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2007 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2008 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2009 | }; |
| 2010 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2011 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2012 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2013 | [STAC_D945_REF] = "ref", |
| 2014 | [STAC_D945GTP5] = "5stack", |
| 2015 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2016 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2017 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2018 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2019 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2020 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2021 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2022 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2023 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2024 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2025 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2026 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2027 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2028 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2029 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2030 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2031 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2032 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2033 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2034 | }; |
| 2035 | |
| 2036 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2037 | /* SigmaTel reference board */ |
| 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2039 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2040 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2041 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2042 | /* Intel 945G based systems */ |
| 2043 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2044 | "Intel D945G", STAC_D945GTP3), |
| 2045 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2046 | "Intel D945G", STAC_D945GTP3), |
| 2047 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2048 | "Intel D945G", STAC_D945GTP3), |
| 2049 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2050 | "Intel D945G", STAC_D945GTP3), |
| 2051 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2052 | "Intel D945G", STAC_D945GTP3), |
| 2053 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2054 | "Intel D945G", STAC_D945GTP3), |
| 2055 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2056 | "Intel D945G", STAC_D945GTP3), |
| 2057 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2058 | "Intel D945G", STAC_D945GTP3), |
| 2059 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2060 | "Intel D945G", STAC_D945GTP3), |
| 2061 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2062 | "Intel D945G", STAC_D945GTP3), |
| 2063 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2064 | "Intel D945G", STAC_D945GTP3), |
| 2065 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2066 | "Intel D945G", STAC_D945GTP3), |
| 2067 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2068 | "Intel D945G", STAC_D945GTP3), |
| 2069 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2070 | "Intel D945G", STAC_D945GTP3), |
| 2071 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2072 | "Intel D945G", STAC_D945GTP3), |
| 2073 | /* Intel D945G 5-stack systems */ |
| 2074 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2075 | "Intel D945G", STAC_D945GTP5), |
| 2076 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2077 | "Intel D945G", STAC_D945GTP5), |
| 2078 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2079 | "Intel D945G", STAC_D945GTP5), |
| 2080 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2081 | "Intel D945G", STAC_D945GTP5), |
| 2082 | /* Intel 945P based systems */ |
| 2083 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2084 | "Intel D945P", STAC_D945GTP3), |
| 2085 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2086 | "Intel D945P", STAC_D945GTP3), |
| 2087 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2088 | "Intel D945P", STAC_D945GTP3), |
| 2089 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2090 | "Intel D945P", STAC_D945GTP3), |
| 2091 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2092 | "Intel D945P", STAC_D945GTP3), |
| 2093 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2094 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2095 | /* other intel */ |
| 2096 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2097 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2098 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2099 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2100 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2101 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2102 | /* Dell systems */ |
| 2103 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2104 | "unknown Dell", STAC_922X_DELL_D81), |
| 2105 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2106 | "unknown Dell", STAC_922X_DELL_D81), |
| 2107 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2108 | "unknown Dell", STAC_922X_DELL_D81), |
| 2109 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2110 | "unknown Dell", STAC_922X_DELL_D82), |
| 2111 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2112 | "unknown Dell", STAC_922X_DELL_M81), |
| 2113 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2114 | "unknown Dell", STAC_922X_DELL_D82), |
| 2115 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2116 | "unknown Dell", STAC_922X_DELL_D81), |
| 2117 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2118 | "unknown Dell", STAC_922X_DELL_D81), |
| 2119 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2120 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2121 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2122 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2123 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2124 | {} /* terminator */ |
| 2125 | }; |
| 2126 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2127 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2128 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2129 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2130 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2131 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2132 | }; |
| 2133 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2134 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2135 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2136 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2137 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2138 | 0x40000100, 0x40000100 |
| 2139 | }; |
| 2140 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2141 | static unsigned int d965_5st_pin_configs[14] = { |
| 2142 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2143 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2144 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2145 | 0x40000100, 0x40000100 |
| 2146 | }; |
| 2147 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2148 | static unsigned int dell_3st_pin_configs[14] = { |
| 2149 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2150 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2151 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2152 | 0x40c003fc, 0x40000100 |
| 2153 | }; |
| 2154 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2155 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2156 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2157 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2158 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2159 | [STAC_D965_5ST] = d965_5st_pin_configs, |
| 2160 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2161 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2162 | }; |
| 2163 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2164 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2165 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2166 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2167 | [STAC_D965_REF] = "ref", |
| 2168 | [STAC_D965_3ST] = "3stack", |
| 2169 | [STAC_D965_5ST] = "5stack", |
| 2170 | [STAC_DELL_3ST] = "dell-3stack", |
| 2171 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2172 | }; |
| 2173 | |
| 2174 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2175 | /* SigmaTel reference board */ |
| 2176 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2177 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2178 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2179 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2180 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2181 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2182 | 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] | 2183 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2184 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2185 | "Intel D965", STAC_D965_3ST), |
| 2186 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2187 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2188 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2189 | 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] | 2190 | 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] | 2191 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2192 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2193 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2194 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2195 | 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] | 2196 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2197 | 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] | 2198 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2199 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2200 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2201 | 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] | 2202 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2203 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2204 | "Intel D965", STAC_D965_5ST), |
| 2205 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2206 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2207 | {} /* terminator */ |
| 2208 | }; |
| 2209 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2210 | static unsigned int ref9205_pin_configs[12] = { |
| 2211 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2212 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2213 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2214 | }; |
| 2215 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2216 | /* |
| 2217 | STAC 9205 pin configs for |
| 2218 | 102801F1 |
| 2219 | 102801F2 |
| 2220 | 102801FC |
| 2221 | 102801FD |
| 2222 | 10280204 |
| 2223 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2224 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2225 | */ |
| 2226 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2227 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2228 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2229 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2230 | }; |
| 2231 | |
| 2232 | /* |
| 2233 | STAC 9205 pin configs for |
| 2234 | 102801F9 |
| 2235 | 102801FA |
| 2236 | 102801FE |
| 2237 | 102801FF (Dell Precision M4300) |
| 2238 | 10280206 |
| 2239 | 10280200 |
| 2240 | 10280201 |
| 2241 | */ |
| 2242 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2243 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2244 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2245 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2246 | }; |
| 2247 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2248 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2249 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2250 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2251 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2252 | }; |
| 2253 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2254 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2255 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2256 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2257 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2258 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2259 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2260 | }; |
| 2261 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2262 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2263 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2264 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2265 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2266 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2267 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2268 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2269 | }; |
| 2270 | |
| 2271 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2272 | /* SigmaTel reference board */ |
| 2273 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2274 | "DFI LanParty", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2275 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2276 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2277 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2278 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2279 | "unknown Dell", STAC_9205_DELL_M42), |
| 2280 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2281 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2282 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2283 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2284 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2285 | "Dell Precision", STAC_9205_DELL_M43), |
| 2286 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2287 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2288 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2289 | "unknown Dell", STAC_9205_DELL_M42), |
| 2290 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2291 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2292 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2293 | "Dell Precision", STAC_9205_DELL_M43), |
| 2294 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2295 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2296 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2297 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2298 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2299 | "Dell Precision", STAC_9205_DELL_M43), |
| 2300 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2301 | "Dell Precision", STAC_9205_DELL_M43), |
| 2302 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2303 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2304 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2305 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2306 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2307 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2308 | /* Gateway */ |
| 2309 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2310 | {} /* terminator */ |
| 2311 | }; |
| 2312 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2313 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2314 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2315 | { |
| 2316 | int i; |
| 2317 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2318 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2319 | if (!pincfgs) |
| 2320 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2321 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2322 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2323 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2324 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2325 | pincfgs[i]); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2326 | } |
| 2327 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2328 | /* |
| 2329 | * Analog playback callbacks |
| 2330 | */ |
| 2331 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2332 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2333 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2334 | { |
| 2335 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2336 | if (spec->stream_delay) |
| 2337 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2338 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2339 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2340 | } |
| 2341 | |
| 2342 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2343 | struct hda_codec *codec, |
| 2344 | unsigned int stream_tag, |
| 2345 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2346 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2347 | { |
| 2348 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2349 | 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] | 2350 | } |
| 2351 | |
| 2352 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2353 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2354 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2355 | { |
| 2356 | struct sigmatel_spec *spec = codec->spec; |
| 2357 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2358 | } |
| 2359 | |
| 2360 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2361 | * Digital playback callbacks |
| 2362 | */ |
| 2363 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2364 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2365 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2366 | { |
| 2367 | struct sigmatel_spec *spec = codec->spec; |
| 2368 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2369 | } |
| 2370 | |
| 2371 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2372 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2373 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2374 | { |
| 2375 | struct sigmatel_spec *spec = codec->spec; |
| 2376 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2377 | } |
| 2378 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2379 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2380 | struct hda_codec *codec, |
| 2381 | unsigned int stream_tag, |
| 2382 | unsigned int format, |
| 2383 | struct snd_pcm_substream *substream) |
| 2384 | { |
| 2385 | struct sigmatel_spec *spec = codec->spec; |
| 2386 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2387 | stream_tag, format, substream); |
| 2388 | } |
| 2389 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2390 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2391 | struct hda_codec *codec, |
| 2392 | struct snd_pcm_substream *substream) |
| 2393 | { |
| 2394 | struct sigmatel_spec *spec = codec->spec; |
| 2395 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2396 | } |
| 2397 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2398 | |
| 2399 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2400 | * Analog capture callbacks |
| 2401 | */ |
| 2402 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2403 | struct hda_codec *codec, |
| 2404 | unsigned int stream_tag, |
| 2405 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2406 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2407 | { |
| 2408 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2409 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2410 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2411 | if (spec->powerdown_adcs) { |
| 2412 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2413 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2414 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2415 | } |
| 2416 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2417 | return 0; |
| 2418 | } |
| 2419 | |
| 2420 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2421 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2422 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2423 | { |
| 2424 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2425 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2426 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2427 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2428 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2429 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2430 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2431 | return 0; |
| 2432 | } |
| 2433 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2434 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2435 | .substreams = 1, |
| 2436 | .channels_min = 2, |
| 2437 | .channels_max = 2, |
| 2438 | /* NID is set in stac92xx_build_pcms */ |
| 2439 | .ops = { |
| 2440 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2441 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2442 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2443 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2444 | }, |
| 2445 | }; |
| 2446 | |
| 2447 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2448 | .substreams = 1, |
| 2449 | .channels_min = 2, |
| 2450 | .channels_max = 2, |
| 2451 | /* NID is set in stac92xx_build_pcms */ |
| 2452 | }; |
| 2453 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2454 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2455 | .substreams = 1, |
| 2456 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2457 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2458 | .nid = 0x02, /* NID to query formats and rates */ |
| 2459 | .ops = { |
| 2460 | .open = stac92xx_playback_pcm_open, |
| 2461 | .prepare = stac92xx_playback_pcm_prepare, |
| 2462 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2463 | }, |
| 2464 | }; |
| 2465 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2466 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2467 | .substreams = 1, |
| 2468 | .channels_min = 2, |
| 2469 | .channels_max = 2, |
| 2470 | .nid = 0x06, /* NID to query formats and rates */ |
| 2471 | .ops = { |
| 2472 | .open = stac92xx_playback_pcm_open, |
| 2473 | .prepare = stac92xx_playback_pcm_prepare, |
| 2474 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2475 | }, |
| 2476 | }; |
| 2477 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2478 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2479 | .channels_min = 2, |
| 2480 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2481 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2482 | .ops = { |
| 2483 | .prepare = stac92xx_capture_pcm_prepare, |
| 2484 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2485 | }, |
| 2486 | }; |
| 2487 | |
| 2488 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2489 | { |
| 2490 | struct sigmatel_spec *spec = codec->spec; |
| 2491 | struct hda_pcm *info = spec->pcm_rec; |
| 2492 | |
| 2493 | codec->num_pcms = 1; |
| 2494 | codec->pcm_info = info; |
| 2495 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2496 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2497 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2498 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2499 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2500 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2501 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2502 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2503 | |
| 2504 | if (spec->alt_switch) { |
| 2505 | codec->num_pcms++; |
| 2506 | info++; |
| 2507 | info->name = "STAC92xx Analog Alt"; |
| 2508 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2509 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2510 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2511 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2512 | codec->num_pcms++; |
| 2513 | info++; |
| 2514 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2515 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2516 | if (spec->multiout.dig_out_nid) { |
| 2517 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2518 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2519 | } |
| 2520 | if (spec->dig_in_nid) { |
| 2521 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2522 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2523 | } |
| 2524 | } |
| 2525 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2526 | return 0; |
| 2527 | } |
| 2528 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2529 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 2530 | { |
| 2531 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 2532 | AC_PAR_PIN_CAP); |
| 2533 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2534 | if (pincap & AC_PINCAP_VREF_100) |
| 2535 | return AC_PINCTL_VREF_100; |
| 2536 | if (pincap & AC_PINCAP_VREF_80) |
| 2537 | return AC_PINCTL_VREF_80; |
| 2538 | if (pincap & AC_PINCAP_VREF_50) |
| 2539 | return AC_PINCTL_VREF_50; |
| 2540 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2541 | return AC_PINCTL_VREF_GRD; |
| 2542 | return 0; |
| 2543 | } |
| 2544 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2545 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2546 | |
| 2547 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2548 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2549 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2550 | } |
| 2551 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2552 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2553 | |
| 2554 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2555 | struct snd_ctl_elem_value *ucontrol) |
| 2556 | { |
| 2557 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2558 | struct sigmatel_spec *spec = codec->spec; |
| 2559 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2560 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2561 | return 0; |
| 2562 | } |
| 2563 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2564 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 2565 | unsigned char type); |
| 2566 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2567 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2568 | struct snd_ctl_elem_value *ucontrol) |
| 2569 | { |
| 2570 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2571 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2572 | int nid = kcontrol->private_value; |
| 2573 | |
| 2574 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2575 | |
| 2576 | /* check to be sure that the ports are upto date with |
| 2577 | * switch changes |
| 2578 | */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2579 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2580 | |
| 2581 | return 1; |
| 2582 | } |
| 2583 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 2584 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2585 | |
| 2586 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2587 | { |
| 2588 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2589 | struct sigmatel_spec *spec = codec->spec; |
| 2590 | int io_idx = kcontrol-> private_value & 0xff; |
| 2591 | |
| 2592 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 2593 | return 0; |
| 2594 | } |
| 2595 | |
| 2596 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2597 | { |
| 2598 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2599 | struct sigmatel_spec *spec = codec->spec; |
| 2600 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 2601 | int io_idx = kcontrol-> private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2602 | unsigned short val = !!ucontrol->value.integer.value[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2603 | |
| 2604 | spec->io_switch[io_idx] = val; |
| 2605 | |
| 2606 | if (val) |
| 2607 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2608 | else { |
| 2609 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2610 | if (io_idx) /* set VREF for mic */ |
| 2611 | pinctl |= stac92xx_get_vref(codec, nid); |
| 2612 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2613 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2614 | |
| 2615 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2616 | * appropriately according to the pin direction |
| 2617 | */ |
| 2618 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2619 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2620 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2621 | return 1; |
| 2622 | } |
| 2623 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2624 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2625 | |
| 2626 | static int stac92xx_clfe_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 | |
| 2632 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2633 | return 0; |
| 2634 | } |
| 2635 | |
| 2636 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2637 | struct snd_ctl_elem_value *ucontrol) |
| 2638 | { |
| 2639 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2640 | struct sigmatel_spec *spec = codec->spec; |
| 2641 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2642 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2643 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2644 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2645 | return 0; |
| 2646 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2647 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2648 | |
| 2649 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2650 | spec->clfe_swap ? 0x4 : 0x0); |
| 2651 | |
| 2652 | return 1; |
| 2653 | } |
| 2654 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2655 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2656 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2657 | .name = xname, \ |
| 2658 | .index = 0, \ |
| 2659 | .info = stac92xx_hp_switch_info, \ |
| 2660 | .get = stac92xx_hp_switch_get, \ |
| 2661 | .put = stac92xx_hp_switch_put, \ |
| 2662 | } |
| 2663 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2664 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2665 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2666 | .name = xname, \ |
| 2667 | .index = 0, \ |
| 2668 | .info = stac92xx_io_switch_info, \ |
| 2669 | .get = stac92xx_io_switch_get, \ |
| 2670 | .put = stac92xx_io_switch_put, \ |
| 2671 | .private_value = xpval, \ |
| 2672 | } |
| 2673 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2674 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2675 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2676 | .name = xname, \ |
| 2677 | .index = 0, \ |
| 2678 | .info = stac92xx_clfe_switch_info, \ |
| 2679 | .get = stac92xx_clfe_switch_get, \ |
| 2680 | .put = stac92xx_clfe_switch_put, \ |
| 2681 | .private_value = xpval, \ |
| 2682 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2683 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2684 | enum { |
| 2685 | STAC_CTL_WIDGET_VOL, |
| 2686 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2687 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2688 | STAC_CTL_WIDGET_AMP_MUX, |
| 2689 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2690 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2691 | STAC_CTL_WIDGET_IO_SWITCH, |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2692 | STAC_CTL_WIDGET_CLFE_SWITCH |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2693 | }; |
| 2694 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2695 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2696 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2697 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2698 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2699 | STAC_AMP_MUX, |
| 2700 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2701 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2702 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2703 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2704 | }; |
| 2705 | |
| 2706 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2707 | static struct snd_kcontrol_new * |
| 2708 | stac_control_new(struct sigmatel_spec *spec, |
| 2709 | struct snd_kcontrol_new *ktemp, |
| 2710 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2711 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2712 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2713 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2714 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2715 | knew = snd_array_new(&spec->kctls); |
| 2716 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2717 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2718 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2719 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2720 | if (!knew->name) { |
| 2721 | /* roolback */ |
| 2722 | memset(knew, 0, sizeof(*knew)); |
| 2723 | spec->kctls.alloced--; |
| 2724 | return NULL; |
| 2725 | } |
| 2726 | return knew; |
| 2727 | } |
| 2728 | |
| 2729 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2730 | struct snd_kcontrol_new *ktemp, |
| 2731 | int idx, const char *name, |
| 2732 | unsigned long val) |
| 2733 | { |
| 2734 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2735 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2736 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2737 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2738 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2739 | return 0; |
| 2740 | } |
| 2741 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2742 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2743 | int type, int idx, const char *name, |
| 2744 | unsigned long val) |
| 2745 | { |
| 2746 | return stac92xx_add_control_temp(spec, |
| 2747 | &stac92xx_control_templates[type], |
| 2748 | idx, name, val); |
| 2749 | } |
| 2750 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2751 | |
| 2752 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2753 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2754 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2755 | { |
| 2756 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2757 | } |
| 2758 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2759 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2760 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2761 | .name = "Input Source", |
| 2762 | .info = stac92xx_mux_enum_info, |
| 2763 | .get = stac92xx_mux_enum_get, |
| 2764 | .put = stac92xx_mux_enum_put, |
| 2765 | }; |
| 2766 | |
| 2767 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2768 | { |
| 2769 | struct snd_kcontrol_new *knew; |
| 2770 | struct hda_input_mux *imux = &spec->private_imux; |
| 2771 | |
| 2772 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2773 | return 0; /* no need for input source control */ |
| 2774 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2775 | stac_input_src_temp.name); |
| 2776 | if (!knew) |
| 2777 | return -ENOMEM; |
| 2778 | knew->count = spec->num_adcs; |
| 2779 | return 0; |
| 2780 | } |
| 2781 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2782 | /* check whether the line-input can be used as line-out */ |
| 2783 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2784 | { |
| 2785 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2786 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2787 | hda_nid_t nid; |
| 2788 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2789 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2790 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2791 | return 0; |
| 2792 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
| 2793 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
| 2794 | if (pincap & AC_PINCAP_OUT) |
| 2795 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2796 | return 0; |
| 2797 | } |
| 2798 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2799 | /* check whether the mic-input can be used as line-out */ |
| 2800 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2801 | { |
| 2802 | struct sigmatel_spec *spec = codec->spec; |
| 2803 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2804 | unsigned int def_conf, pincap; |
| 2805 | unsigned int mic_pin; |
| 2806 | |
| 2807 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2808 | return 0; |
| 2809 | mic_pin = AUTO_PIN_MIC; |
| 2810 | for (;;) { |
| 2811 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2812 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2813 | /* some laptops have an internal analog microphone |
| 2814 | * which can't be used as a output */ |
| 2815 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
| 2816 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
| 2817 | if (pincap & AC_PINCAP_OUT) |
| 2818 | return nid; |
| 2819 | } |
| 2820 | if (mic_pin == AUTO_PIN_MIC) |
| 2821 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 2822 | else |
| 2823 | break; |
| 2824 | } |
| 2825 | return 0; |
| 2826 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2827 | |
| 2828 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2829 | { |
| 2830 | int i; |
| 2831 | |
| 2832 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 2833 | if (spec->multiout.dac_nids[i] == nid) |
| 2834 | return 1; |
| 2835 | } |
| 2836 | |
| 2837 | return 0; |
| 2838 | } |
| 2839 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2840 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2841 | { |
| 2842 | int i; |
| 2843 | if (is_in_dac_nids(spec, nid)) |
| 2844 | return 1; |
| 2845 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 2846 | if (spec->hp_dacs[i] == nid) |
| 2847 | return 1; |
| 2848 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 2849 | if (spec->speaker_dacs[i] == nid) |
| 2850 | return 1; |
| 2851 | return 0; |
| 2852 | } |
| 2853 | |
| 2854 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 2855 | { |
| 2856 | struct sigmatel_spec *spec = codec->spec; |
| 2857 | int j, conn_len; |
| 2858 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 2859 | unsigned int wcaps, wtype; |
| 2860 | |
| 2861 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 2862 | HDA_MAX_CONNECTIONS); |
| 2863 | for (j = 0; j < conn_len; j++) { |
| 2864 | wcaps = snd_hda_param_read(codec, conn[j], |
| 2865 | AC_PAR_AUDIO_WIDGET_CAP); |
| 2866 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 2867 | /* we check only analog outputs */ |
| 2868 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 2869 | continue; |
| 2870 | /* if this route has a free DAC, assign it */ |
| 2871 | if (!check_all_dac_nids(spec, conn[j])) { |
| 2872 | if (conn_len > 1) { |
| 2873 | /* select this DAC in the pin's input mux */ |
| 2874 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2875 | AC_VERB_SET_CONNECT_SEL, j); |
| 2876 | } |
| 2877 | return conn[j]; |
| 2878 | } |
| 2879 | } |
| 2880 | return 0; |
| 2881 | } |
| 2882 | |
| 2883 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 2884 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 2885 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2886 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2887 | * Fill in the dac_nids table from the parsed pin configuration |
| 2888 | * This function only works when every pin in line_out_pins[] |
| 2889 | * contains atleast one DAC in its connection list. Some 92xx |
| 2890 | * codecs are not connected directly to a DAC, such as the 9200 |
| 2891 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2892 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2893 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2894 | { |
| 2895 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2896 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2897 | int i; |
| 2898 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2899 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2900 | for (i = 0; i < cfg->line_outs; i++) { |
| 2901 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2902 | dac = get_unassigned_dac(codec, nid); |
| 2903 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2904 | if (spec->multiout.num_dacs > 0) { |
| 2905 | /* we have already working output pins, |
| 2906 | * so let's drop the broken ones again |
| 2907 | */ |
| 2908 | cfg->line_outs = spec->multiout.num_dacs; |
| 2909 | break; |
| 2910 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2911 | /* error out, no available DAC found */ |
| 2912 | snd_printk(KERN_ERR |
| 2913 | "%s: No available DAC for pin 0x%x\n", |
| 2914 | __func__, nid); |
| 2915 | return -ENODEV; |
| 2916 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2917 | add_spec_dacs(spec, dac); |
| 2918 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2919 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2920 | /* add line-in as output */ |
| 2921 | nid = check_line_out_switch(codec); |
| 2922 | if (nid) { |
| 2923 | dac = get_unassigned_dac(codec, nid); |
| 2924 | if (dac) { |
| 2925 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 2926 | nid, cfg->line_outs); |
| 2927 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 2928 | cfg->line_outs++; |
| 2929 | spec->line_switch = nid; |
| 2930 | add_spec_dacs(spec, dac); |
| 2931 | } |
| 2932 | } |
| 2933 | /* add mic as output */ |
| 2934 | nid = check_mic_out_switch(codec); |
| 2935 | if (nid) { |
| 2936 | dac = get_unassigned_dac(codec, nid); |
| 2937 | if (dac) { |
| 2938 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 2939 | nid, cfg->line_outs); |
| 2940 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 2941 | cfg->line_outs++; |
| 2942 | spec->mic_switch = nid; |
| 2943 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2944 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2945 | } |
| 2946 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2947 | for (i = 0; i < cfg->hp_outs; i++) { |
| 2948 | nid = cfg->hp_pins[i]; |
| 2949 | dac = get_unassigned_dac(codec, nid); |
| 2950 | if (dac) { |
| 2951 | if (!spec->multiout.hp_nid) |
| 2952 | spec->multiout.hp_nid = dac; |
| 2953 | else |
| 2954 | add_spec_extra_dacs(spec, dac); |
| 2955 | } |
| 2956 | spec->hp_dacs[i] = dac; |
| 2957 | } |
| 2958 | |
| 2959 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 2960 | nid = cfg->speaker_pins[i]; |
| 2961 | dac = get_unassigned_dac(codec, nid); |
| 2962 | if (dac) |
| 2963 | add_spec_extra_dacs(spec, dac); |
| 2964 | spec->speaker_dacs[i] = dac; |
| 2965 | } |
| 2966 | |
| 2967 | 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] | 2968 | spec->multiout.num_dacs, |
| 2969 | spec->multiout.dac_nids[0], |
| 2970 | spec->multiout.dac_nids[1], |
| 2971 | spec->multiout.dac_nids[2], |
| 2972 | spec->multiout.dac_nids[3], |
| 2973 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2974 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2975 | return 0; |
| 2976 | } |
| 2977 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2978 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2979 | static int create_controls(struct hda_codec *codec, const char *pfx, |
| 2980 | hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2981 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2982 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2983 | char name[32]; |
| 2984 | int err; |
| 2985 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2986 | if (!spec->check_volume_offset) { |
| 2987 | unsigned int caps, step, nums, db_scale; |
| 2988 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 2989 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 2990 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 2991 | step = (step + 1) * 25; /* in .01dB unit */ |
| 2992 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 2993 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 2994 | db_scale = nums * step; |
| 2995 | /* if dB scale is over -64dB, and finer enough, |
| 2996 | * let's reduce it to half |
| 2997 | */ |
| 2998 | if (db_scale > 6400 && nums >= 0x1f) |
| 2999 | spec->volume_offset = nums / 2; |
| 3000 | spec->check_volume_offset = 1; |
| 3001 | } |
| 3002 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3003 | sprintf(name, "%s Playback Volume", pfx); |
| 3004 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3005 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3006 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3007 | if (err < 0) |
| 3008 | return err; |
| 3009 | sprintf(name, "%s Playback Switch", pfx); |
| 3010 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 3011 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3012 | if (err < 0) |
| 3013 | return err; |
| 3014 | return 0; |
| 3015 | } |
| 3016 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3017 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3018 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3019 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3020 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3021 | return 1; |
| 3022 | } else { |
| 3023 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3024 | spec->multiout.num_dacs++; |
| 3025 | } |
| 3026 | return 0; |
| 3027 | } |
| 3028 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3029 | 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] | 3030 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3031 | int i; |
| 3032 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3033 | if (!spec->multiout.extra_out_nid[i]) { |
| 3034 | spec->multiout.extra_out_nid[i] = nid; |
| 3035 | return 0; |
| 3036 | } |
| 3037 | } |
| 3038 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3039 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3040 | } |
| 3041 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3042 | /* Create output controls |
| 3043 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3044 | */ |
| 3045 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3046 | const hda_nid_t *pins, |
| 3047 | const hda_nid_t *dac_nids, |
| 3048 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3049 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3050 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3051 | static const char *chname[4] = { |
| 3052 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3053 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3054 | static const char *hp_pfxs[] = { |
| 3055 | "Headphone", "Headphone2", "Headphone3", "Headphone4" |
| 3056 | }; |
| 3057 | static const char *speaker_pfxs[] = { |
| 3058 | "Speaker", "External Speaker", "Speaker2", "Speaker3" |
| 3059 | }; |
| 3060 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3061 | int i, err; |
| 3062 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3063 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3064 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
| 3065 | nid = dac_nids[i]; |
| 3066 | if (!nid) |
| 3067 | continue; |
| 3068 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3069 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3070 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3071 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3072 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3073 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3074 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3075 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3076 | |
| 3077 | wid_caps = get_wcaps(codec, nid); |
| 3078 | |
| 3079 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3080 | err = stac92xx_add_control(spec, |
| 3081 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3082 | "Swap Center/LFE Playback Switch", nid); |
| 3083 | |
| 3084 | if (err < 0) |
| 3085 | return err; |
| 3086 | } |
| 3087 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3088 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3089 | const char *name; |
| 3090 | switch (type) { |
| 3091 | case AUTO_PIN_HP_OUT: |
| 3092 | name = hp_pfxs[i]; |
| 3093 | break; |
| 3094 | case AUTO_PIN_SPEAKER_OUT: |
| 3095 | name = speaker_pfxs[i]; |
| 3096 | break; |
| 3097 | default: |
| 3098 | name = chname[i]; |
| 3099 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3100 | } |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3101 | err = create_controls(codec, name, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3102 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3103 | return err; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3104 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3105 | wid_caps = get_wcaps(codec, pins[i]); |
| 3106 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3107 | spec->hp_detect = 1; |
| 3108 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3109 | } |
| 3110 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3111 | return 0; |
| 3112 | } |
| 3113 | |
| 3114 | /* add playback controls from the parsed DAC table */ |
| 3115 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3116 | const struct auto_pin_cfg *cfg) |
| 3117 | { |
| 3118 | struct sigmatel_spec *spec = codec->spec; |
| 3119 | int err; |
| 3120 | |
| 3121 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3122 | spec->multiout.dac_nids, |
| 3123 | cfg->line_out_type); |
| 3124 | if (err < 0) |
| 3125 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3126 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3127 | 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] | 3128 | err = stac92xx_add_control(spec, |
| 3129 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3130 | "Headphone as Line Out Switch", |
| 3131 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3132 | if (err < 0) |
| 3133 | return err; |
| 3134 | } |
| 3135 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3136 | if (spec->line_switch) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3137 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
| 3138 | "Line In as Output Switch", |
| 3139 | spec->line_switch << 8); |
| 3140 | if (err < 0) |
| 3141 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3142 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3143 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3144 | if (spec->mic_switch) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3145 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
| 3146 | "Mic as Output Switch", |
| 3147 | (spec->mic_switch << 8) | 1); |
| 3148 | if (err < 0) |
| 3149 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3150 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3151 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3152 | return 0; |
| 3153 | } |
| 3154 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3155 | /* add playback controls for Speaker and HP outputs */ |
| 3156 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3157 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3158 | { |
| 3159 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3160 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3161 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3162 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3163 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3164 | if (err < 0) |
| 3165 | return err; |
| 3166 | |
| 3167 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3168 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3169 | if (err < 0) |
| 3170 | return err; |
| 3171 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3172 | return 0; |
| 3173 | } |
| 3174 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3175 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3176 | static const char *stac92xx_mono_labels[4] = { |
| 3177 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3178 | }; |
| 3179 | |
| 3180 | /* create mono mux for mono out on capable codecs */ |
| 3181 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3182 | { |
| 3183 | struct sigmatel_spec *spec = codec->spec; |
| 3184 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3185 | int i, num_cons; |
| 3186 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3187 | |
| 3188 | num_cons = snd_hda_get_connections(codec, |
| 3189 | spec->mono_nid, |
| 3190 | con_lst, |
| 3191 | HDA_MAX_NUM_INPUTS); |
| 3192 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 3193 | return -EINVAL; |
| 3194 | |
| 3195 | for (i = 0; i < num_cons; i++) { |
| 3196 | mono_mux->items[mono_mux->num_items].label = |
| 3197 | stac92xx_mono_labels[i]; |
| 3198 | mono_mux->items[mono_mux->num_items].index = i; |
| 3199 | mono_mux->num_items++; |
| 3200 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3201 | |
| 3202 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3203 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3204 | } |
| 3205 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3206 | /* labels for amp mux outputs */ |
| 3207 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3208 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3209 | }; |
| 3210 | |
| 3211 | /* create amp out controls mux on capable codecs */ |
| 3212 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3213 | { |
| 3214 | struct sigmatel_spec *spec = codec->spec; |
| 3215 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3216 | int i, err; |
| 3217 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3218 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3219 | amp_mux->items[amp_mux->num_items].label = |
| 3220 | stac92xx_amp_labels[i]; |
| 3221 | amp_mux->items[amp_mux->num_items].index = i; |
| 3222 | amp_mux->num_items++; |
| 3223 | } |
| 3224 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3225 | if (spec->num_amps > 1) { |
| 3226 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3227 | "Amp Selector Capture Switch", 0); |
| 3228 | if (err < 0) |
| 3229 | return err; |
| 3230 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3231 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3232 | "Amp Capture Volume", |
| 3233 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3234 | } |
| 3235 | |
| 3236 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3237 | /* create PC beep volume controls */ |
| 3238 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3239 | hda_nid_t nid) |
| 3240 | { |
| 3241 | struct sigmatel_spec *spec = codec->spec; |
| 3242 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3243 | int err; |
| 3244 | |
| 3245 | /* check for mute support for the the amp */ |
| 3246 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3247 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3248 | "PC Beep Playback Switch", |
| 3249 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3250 | if (err < 0) |
| 3251 | return err; |
| 3252 | } |
| 3253 | |
| 3254 | /* check to see if there is volume support for the amp */ |
| 3255 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3256 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3257 | "PC Beep Playback Volume", |
| 3258 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3259 | if (err < 0) |
| 3260 | return err; |
| 3261 | } |
| 3262 | return 0; |
| 3263 | } |
| 3264 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3265 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3266 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3267 | |
| 3268 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3269 | struct snd_ctl_elem_value *ucontrol) |
| 3270 | { |
| 3271 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3272 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3273 | return 0; |
| 3274 | } |
| 3275 | |
| 3276 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3277 | struct snd_ctl_elem_value *ucontrol) |
| 3278 | { |
| 3279 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3280 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3281 | if (codec->beep->enabled != enabled) { |
| 3282 | codec->beep->enabled = enabled; |
| 3283 | return 1; |
| 3284 | } |
| 3285 | return 0; |
| 3286 | } |
| 3287 | |
| 3288 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3289 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3290 | .info = stac92xx_dig_beep_switch_info, |
| 3291 | .get = stac92xx_dig_beep_switch_get, |
| 3292 | .put = stac92xx_dig_beep_switch_put, |
| 3293 | }; |
| 3294 | |
| 3295 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3296 | { |
| 3297 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3298 | 0, "PC Beep Playback Switch", 0); |
| 3299 | } |
| 3300 | #endif |
| 3301 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3302 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3303 | { |
| 3304 | struct sigmatel_spec *spec = codec->spec; |
| 3305 | int wcaps, nid, i, err = 0; |
| 3306 | |
| 3307 | for (i = 0; i < spec->num_muxes; i++) { |
| 3308 | nid = spec->mux_nids[i]; |
| 3309 | wcaps = get_wcaps(codec, nid); |
| 3310 | |
| 3311 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3312 | err = stac92xx_add_control_idx(spec, |
| 3313 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3314 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3315 | if (err < 0) |
| 3316 | return err; |
| 3317 | } |
| 3318 | } |
| 3319 | return 0; |
| 3320 | }; |
| 3321 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3322 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3323 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3324 | }; |
| 3325 | |
| 3326 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3327 | { |
| 3328 | struct sigmatel_spec *spec = codec->spec; |
| 3329 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3330 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3331 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3332 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3333 | |
| 3334 | num_cons = snd_hda_get_connections(codec, |
| 3335 | spec->smux_nids[0], |
| 3336 | con_lst, |
| 3337 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3338 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3339 | return -EINVAL; |
| 3340 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3341 | if (!labels) |
| 3342 | labels = stac92xx_spdif_labels; |
| 3343 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3344 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3345 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3346 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3347 | spdif_mux->num_items++; |
| 3348 | } |
| 3349 | |
| 3350 | return 0; |
| 3351 | } |
| 3352 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3353 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3354 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3355 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3356 | "Digital Mic 3", "Digital Mic 4" |
| 3357 | }; |
| 3358 | |
| 3359 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3360 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3361 | const struct auto_pin_cfg *cfg) |
| 3362 | { |
| 3363 | struct sigmatel_spec *spec = codec->spec; |
| 3364 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3365 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3366 | int err, i, j; |
| 3367 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3368 | |
| 3369 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3370 | dimux->items[dimux->num_items].index = 0; |
| 3371 | dimux->num_items++; |
| 3372 | |
| 3373 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3374 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3375 | int index; |
| 3376 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3377 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3378 | unsigned int def_conf; |
| 3379 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3380 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3381 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3382 | continue; |
| 3383 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3384 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3385 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3386 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3387 | con_lst, |
| 3388 | HDA_MAX_NUM_INPUTS); |
| 3389 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3390 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3391 | index = j; |
| 3392 | goto found; |
| 3393 | } |
| 3394 | continue; |
| 3395 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3396 | wcaps = get_wcaps(codec, nid) & |
| 3397 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3398 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3399 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3400 | sprintf(name, "%s Capture Volume", |
| 3401 | stac92xx_dmic_labels[dimux->num_items]); |
| 3402 | |
| 3403 | err = stac92xx_add_control(spec, |
| 3404 | STAC_CTL_WIDGET_VOL, |
| 3405 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3406 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3407 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3408 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3409 | if (err < 0) |
| 3410 | return err; |
| 3411 | } |
| 3412 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3413 | dimux->items[dimux->num_items].label = |
| 3414 | stac92xx_dmic_labels[dimux->num_items]; |
| 3415 | dimux->items[dimux->num_items].index = index; |
| 3416 | dimux->num_items++; |
| 3417 | } |
| 3418 | |
| 3419 | return 0; |
| 3420 | } |
| 3421 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3422 | /* create playback/capture controls for input pins */ |
| 3423 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3424 | { |
| 3425 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3426 | struct hda_input_mux *imux = &spec->private_imux; |
| 3427 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3428 | int i, j, k; |
| 3429 | |
| 3430 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3431 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3432 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3433 | if (!cfg->input_pins[i]) |
| 3434 | continue; |
| 3435 | index = -1; |
| 3436 | for (j = 0; j < spec->num_muxes; j++) { |
| 3437 | int num_cons; |
| 3438 | num_cons = snd_hda_get_connections(codec, |
| 3439 | spec->mux_nids[j], |
| 3440 | con_lst, |
| 3441 | HDA_MAX_NUM_INPUTS); |
| 3442 | for (k = 0; k < num_cons; k++) |
| 3443 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3444 | index = k; |
| 3445 | goto found; |
| 3446 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3447 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3448 | continue; |
| 3449 | found: |
| 3450 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3451 | imux->items[imux->num_items].index = index; |
| 3452 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3453 | } |
| 3454 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3455 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3456 | /* |
| 3457 | * Set the current input for the muxes. |
| 3458 | * The STAC9221 has two input muxes with identical source |
| 3459 | * NID lists. Hopefully this won't get confused. |
| 3460 | */ |
| 3461 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3462 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3463 | AC_VERB_SET_CONNECT_SEL, |
| 3464 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3465 | } |
| 3466 | } |
| 3467 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3468 | return 0; |
| 3469 | } |
| 3470 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3471 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3472 | { |
| 3473 | struct sigmatel_spec *spec = codec->spec; |
| 3474 | int i; |
| 3475 | |
| 3476 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3477 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3478 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3479 | } |
| 3480 | } |
| 3481 | |
| 3482 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3483 | { |
| 3484 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3485 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3486 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3487 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3488 | hda_nid_t pin; |
| 3489 | pin = spec->autocfg.hp_pins[i]; |
| 3490 | if (pin) /* connect to front */ |
| 3491 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3492 | } |
| 3493 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3494 | hda_nid_t pin; |
| 3495 | pin = spec->autocfg.speaker_pins[i]; |
| 3496 | if (pin) /* connect to front */ |
| 3497 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3498 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3499 | } |
| 3500 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3501 | 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] | 3502 | { |
| 3503 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3504 | int hp_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3505 | int err; |
| 3506 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3507 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3508 | &spec->autocfg, |
| 3509 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3510 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3511 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3512 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3513 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3514 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3515 | * be set up as multi-channel outputs. |
| 3516 | */ |
| 3517 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3518 | spec->autocfg.hp_outs > 1) { |
| 3519 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3520 | * speaker_outs so that the following routines can handle |
| 3521 | * HP pins as primary outputs. |
| 3522 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3523 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3524 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3525 | sizeof(spec->autocfg.line_out_pins)); |
| 3526 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3527 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3528 | sizeof(spec->autocfg.hp_pins)); |
| 3529 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3530 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3531 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3532 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3533 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3534 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3535 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3536 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3537 | u32 caps = query_amp_caps(codec, |
| 3538 | spec->autocfg.mono_out_pin, dir); |
| 3539 | hda_nid_t conn_list[1]; |
| 3540 | |
| 3541 | /* get the mixer node and then the mono mux if it exists */ |
| 3542 | if (snd_hda_get_connections(codec, |
| 3543 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3544 | snd_hda_get_connections(codec, conn_list[0], |
| 3545 | conn_list, 1)) { |
| 3546 | |
| 3547 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3548 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3549 | >> AC_WCAP_TYPE_SHIFT; |
| 3550 | /* LR swap check, some stac925x have a mux that |
| 3551 | * changes the DACs output path instead of the |
| 3552 | * mono-mux path. |
| 3553 | */ |
| 3554 | if (wid_type == AC_WID_AUD_SEL && |
| 3555 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3556 | spec->mono_nid = conn_list[0]; |
| 3557 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3558 | if (dir) { |
| 3559 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3560 | |
| 3561 | /* most mono outs have a least a mute/unmute switch */ |
| 3562 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3563 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3564 | "Mono Playback Switch", |
| 3565 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3566 | if (err < 0) |
| 3567 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3568 | /* check for volume support for the amp */ |
| 3569 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3570 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3571 | err = stac92xx_add_control(spec, |
| 3572 | STAC_CTL_WIDGET_VOL, |
| 3573 | "Mono Playback Volume", |
| 3574 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3575 | if (err < 0) |
| 3576 | return err; |
| 3577 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3578 | } |
| 3579 | |
| 3580 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3581 | AC_PINCTL_OUT_EN); |
| 3582 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3583 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3584 | if (!spec->multiout.num_dacs) { |
| 3585 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3586 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3587 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3588 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3589 | &spec->autocfg); |
| 3590 | if (err < 0) |
| 3591 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3592 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3593 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3594 | /* setup analog beep controls */ |
| 3595 | if (spec->anabeep_nid > 0) { |
| 3596 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3597 | spec->anabeep_nid); |
| 3598 | if (err < 0) |
| 3599 | return err; |
| 3600 | } |
| 3601 | |
| 3602 | /* setup digital beep controls and input device */ |
| 3603 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3604 | if (spec->digbeep_nid > 0) { |
| 3605 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3606 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3607 | |
| 3608 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3609 | if (err < 0) |
| 3610 | return err; |
| 3611 | err = snd_hda_attach_beep_device(codec, nid); |
| 3612 | if (err < 0) |
| 3613 | return err; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3614 | /* if no beep switch is available, make its own one */ |
| 3615 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3616 | if (codec->beep && |
| 3617 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3618 | err = stac92xx_beep_switch_ctl(codec); |
| 3619 | if (err < 0) |
| 3620 | return err; |
| 3621 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3622 | } |
| 3623 | #endif |
| 3624 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3625 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3626 | if (err < 0) |
| 3627 | return err; |
| 3628 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3629 | /* All output parsing done, now restore the swapped hp pins */ |
| 3630 | if (hp_swap) { |
| 3631 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3632 | sizeof(spec->autocfg.hp_pins)); |
| 3633 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3634 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3635 | spec->autocfg.line_outs = 0; |
| 3636 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3637 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame^] | 3638 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3639 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3640 | return err; |
| 3641 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3642 | if (spec->mono_nid > 0) { |
| 3643 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3644 | if (err < 0) |
| 3645 | return err; |
| 3646 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3647 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3648 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3649 | if (err < 0) |
| 3650 | return err; |
| 3651 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3652 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3653 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3654 | &spec->autocfg)) < 0) |
| 3655 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3656 | if (spec->num_muxes > 0) { |
| 3657 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3658 | if (err < 0) |
| 3659 | return err; |
| 3660 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3661 | if (spec->num_smuxes > 0) { |
| 3662 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3663 | if (err < 0) |
| 3664 | return err; |
| 3665 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3666 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3667 | err = stac92xx_add_input_source(spec); |
| 3668 | if (err < 0) |
| 3669 | return err; |
| 3670 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3671 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3672 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3673 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3674 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3675 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3676 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3677 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3678 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3679 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3680 | if (spec->kctls.list) |
| 3681 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3682 | |
| 3683 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3684 | if (!spec->dinput_mux) |
| 3685 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3686 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3687 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3688 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3689 | return 1; |
| 3690 | } |
| 3691 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3692 | /* add playback controls for HP output */ |
| 3693 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3694 | struct auto_pin_cfg *cfg) |
| 3695 | { |
| 3696 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3697 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3698 | unsigned int wid_caps; |
| 3699 | |
| 3700 | if (! pin) |
| 3701 | return 0; |
| 3702 | |
| 3703 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3704 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3705 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3706 | |
| 3707 | return 0; |
| 3708 | } |
| 3709 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3710 | /* add playback controls for LFE output */ |
| 3711 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3712 | struct auto_pin_cfg *cfg) |
| 3713 | { |
| 3714 | struct sigmatel_spec *spec = codec->spec; |
| 3715 | int err; |
| 3716 | hda_nid_t lfe_pin = 0x0; |
| 3717 | int i; |
| 3718 | |
| 3719 | /* |
| 3720 | * search speaker outs and line outs for a mono speaker pin |
| 3721 | * with an amp. If one is found, add LFE controls |
| 3722 | * for it. |
| 3723 | */ |
| 3724 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3725 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3726 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3727 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3728 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3729 | /* found a mono speaker with an amp, must be lfe */ |
| 3730 | lfe_pin = pin; |
| 3731 | } |
| 3732 | |
| 3733 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3734 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3735 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3736 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3737 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3738 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3739 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3740 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3741 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3742 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3743 | /* found a mono speaker with an amp, |
| 3744 | must be lfe */ |
| 3745 | lfe_pin = pin; |
| 3746 | } |
| 3747 | } |
| 3748 | } |
| 3749 | |
| 3750 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3751 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3752 | if (err < 0) |
| 3753 | return err; |
| 3754 | } |
| 3755 | |
| 3756 | return 0; |
| 3757 | } |
| 3758 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3759 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3760 | { |
| 3761 | struct sigmatel_spec *spec = codec->spec; |
| 3762 | int err; |
| 3763 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3764 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3765 | return err; |
| 3766 | |
| 3767 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3768 | return err; |
| 3769 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3770 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3771 | return err; |
| 3772 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3773 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3774 | return err; |
| 3775 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3776 | if (spec->num_muxes > 0) { |
| 3777 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3778 | if (err < 0) |
| 3779 | return err; |
| 3780 | } |
| 3781 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3782 | err = stac92xx_add_input_source(spec); |
| 3783 | if (err < 0) |
| 3784 | return err; |
| 3785 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3786 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3787 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3788 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3789 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3790 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3791 | if (spec->kctls.list) |
| 3792 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3793 | |
| 3794 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3795 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3796 | |
| 3797 | return 1; |
| 3798 | } |
| 3799 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3800 | /* |
| 3801 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 3802 | * funky external mute control using GPIO pins. |
| 3803 | */ |
| 3804 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3805 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3806 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3807 | { |
| 3808 | unsigned int gpiostate, gpiomask, gpiodir; |
| 3809 | |
| 3810 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 3811 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3812 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3813 | |
| 3814 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 3815 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3816 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3817 | |
| 3818 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 3819 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3820 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3821 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3822 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3823 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 3824 | |
| 3825 | snd_hda_codec_write(codec, codec->afg, 0, |
| 3826 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3827 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3828 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3829 | |
| 3830 | msleep(1); |
| 3831 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3832 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3833 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3834 | } |
| 3835 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3836 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 3837 | hda_nid_t nid, int type) |
| 3838 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3839 | #ifdef CONFIG_SND_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3840 | struct sigmatel_spec *spec = codec->spec; |
| 3841 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3842 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3843 | int connectivity = get_defcfg_connect(def_conf); |
| 3844 | char name[32]; |
| 3845 | |
| 3846 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 3847 | return 0; |
| 3848 | |
| 3849 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 3850 | jack = snd_array_new(&spec->jacks); |
| 3851 | if (!jack) |
| 3852 | return -ENOMEM; |
| 3853 | jack->nid = nid; |
| 3854 | jack->type = type; |
| 3855 | |
| 3856 | sprintf(name, "%s at %s %s Jack", |
| 3857 | snd_hda_get_jack_type(def_conf), |
| 3858 | snd_hda_get_jack_connectivity(def_conf), |
| 3859 | snd_hda_get_jack_location(def_conf)); |
| 3860 | |
| 3861 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3862 | #else |
| 3863 | return 0; |
| 3864 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3865 | } |
| 3866 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3867 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 3868 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3869 | { |
| 3870 | struct sigmatel_event *event; |
| 3871 | |
| 3872 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 3873 | event = snd_array_new(&spec->events); |
| 3874 | if (!event) |
| 3875 | return -ENOMEM; |
| 3876 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3877 | event->type = type; |
| 3878 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3879 | event->data = data; |
| 3880 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3881 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3882 | } |
| 3883 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3884 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
| 3885 | hda_nid_t nid, unsigned char type) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3886 | { |
| 3887 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3888 | struct sigmatel_event *event = spec->events.list; |
| 3889 | int i; |
| 3890 | |
| 3891 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3892 | if (event->nid == nid && event->type == type) |
| 3893 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3894 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3895 | return NULL; |
| 3896 | } |
| 3897 | |
| 3898 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 3899 | unsigned char tag) |
| 3900 | { |
| 3901 | struct sigmatel_spec *spec = codec->spec; |
| 3902 | struct sigmatel_event *event = spec->events.list; |
| 3903 | int i; |
| 3904 | |
| 3905 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3906 | if (event->tag == tag) |
| 3907 | return event; |
| 3908 | } |
| 3909 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3910 | } |
| 3911 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3912 | 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] | 3913 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3914 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3915 | struct sigmatel_event *event; |
| 3916 | int tag; |
| 3917 | |
| 3918 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
| 3919 | return; |
| 3920 | event = stac_get_event(codec, nid, type); |
| 3921 | if (event) |
| 3922 | tag = event->tag; |
| 3923 | else |
| 3924 | tag = stac_add_event(codec->spec, nid, type, 0); |
| 3925 | if (tag < 0) |
| 3926 | return; |
| 3927 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3928 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3929 | AC_USRSP_EN | tag); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3930 | } |
| 3931 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3932 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3933 | { |
| 3934 | int i; |
| 3935 | for (i = 0; i < cfg->hp_outs; i++) |
| 3936 | if (cfg->hp_pins[i] == nid) |
| 3937 | return 1; /* nid is a HP-Out */ |
| 3938 | |
| 3939 | return 0; /* nid is not a HP-Out */ |
| 3940 | }; |
| 3941 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3942 | static void stac92xx_power_down(struct hda_codec *codec) |
| 3943 | { |
| 3944 | struct sigmatel_spec *spec = codec->spec; |
| 3945 | |
| 3946 | /* power down inactive DACs */ |
| 3947 | hda_nid_t *dac; |
| 3948 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3949 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3950 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3951 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3952 | } |
| 3953 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3954 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 3955 | int enable); |
| 3956 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 3957 | /* override some hints from the hwdep entry */ |
| 3958 | static void stac_store_hints(struct hda_codec *codec) |
| 3959 | { |
| 3960 | struct sigmatel_spec *spec = codec->spec; |
| 3961 | const char *p; |
| 3962 | int val; |
| 3963 | |
| 3964 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 3965 | if (val >= 0) |
| 3966 | spec->hp_detect = val; |
| 3967 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 3968 | if (p) { |
| 3969 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 3970 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 3971 | spec->gpio_mask; |
| 3972 | } |
| 3973 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 3974 | if (p) |
| 3975 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 3976 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 3977 | if (p) |
| 3978 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 3979 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 3980 | if (p) |
| 3981 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 3982 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 3983 | if (val >= 0) |
| 3984 | spec->eapd_switch = val; |
| 3985 | } |
| 3986 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3987 | static int stac92xx_init(struct hda_codec *codec) |
| 3988 | { |
| 3989 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3990 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3991 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3992 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3993 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3994 | snd_hda_sequence_write(codec, spec->init); |
| 3995 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3996 | /* power down adcs initially */ |
| 3997 | if (spec->powerdown_adcs) |
| 3998 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3999 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4000 | spec->adc_nids[i], 0, |
| 4001 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4002 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4003 | /* override some hints */ |
| 4004 | stac_store_hints(codec); |
| 4005 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4006 | /* set up GPIO */ |
| 4007 | gpio = spec->gpio_data; |
| 4008 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4009 | * otherwise, unsol event will turn it on/off dynamically |
| 4010 | */ |
| 4011 | if (!spec->eapd_switch) |
| 4012 | gpio |= spec->eapd_mask; |
| 4013 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4014 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4015 | /* set up pins */ |
| 4016 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4017 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4018 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4019 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4020 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4021 | } |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4022 | /* force to enable the first line-out; the others are set up |
| 4023 | * in unsol_event |
| 4024 | */ |
| 4025 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4026 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4027 | /* fake event to set up pins */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4028 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4029 | STAC_HP_EVENT); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4030 | } else { |
| 4031 | stac92xx_auto_init_multi_out(codec); |
| 4032 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4033 | for (i = 0; i < cfg->hp_outs; i++) |
| 4034 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4035 | } |
| 4036 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4037 | hda_nid_t nid = cfg->input_pins[i]; |
| 4038 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4039 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4040 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4041 | /* for mic pins, force to initialize */ |
| 4042 | pinctl = stac92xx_get_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4043 | pinctl |= AC_PINCTL_IN_EN; |
| 4044 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4045 | } else { |
| 4046 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4047 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4048 | /* if PINCTL already set then skip */ |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4049 | if (!(pinctl & AC_PINCTL_IN_EN)) { |
| 4050 | pinctl |= AC_PINCTL_IN_EN; |
| 4051 | stac92xx_auto_set_pinctl(codec, nid, |
| 4052 | pinctl); |
| 4053 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4054 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4055 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4056 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 4057 | enable_pin_detect(codec, nid, |
| 4058 | STAC_INSERT_EVENT); |
| 4059 | stac_issue_unsol_event(codec, nid, |
| 4060 | STAC_INSERT_EVENT); |
| 4061 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4062 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4063 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4064 | for (i = 0; i < spec->num_dmics; i++) |
| 4065 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4066 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4067 | if (cfg->dig_out_pins[0]) |
| 4068 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4069 | AC_PINCTL_OUT_EN); |
| 4070 | if (cfg->dig_in_pin) |
| 4071 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4072 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4073 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4074 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4075 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4076 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4077 | /* power on when no jack detection is available */ |
| 4078 | if (!spec->hp_detect) { |
| 4079 | stac_toggle_power_map(codec, nid, 1); |
| 4080 | continue; |
| 4081 | } |
| 4082 | |
| 4083 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4084 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4085 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4086 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4087 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4088 | /* outputs are only ports capable of power management |
| 4089 | * any attempts on powering down a input port cause the |
| 4090 | * referenced VREF to act quirky. |
| 4091 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4092 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4093 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4094 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4095 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4096 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4097 | def_conf = get_defcfg_connect(def_conf); |
| 4098 | /* skip any ports that don't have jacks since presence |
| 4099 | * detection is useless */ |
| 4100 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4101 | if (def_conf != AC_JACK_PORT_NONE) |
| 4102 | stac_toggle_power_map(codec, nid, 1); |
| 4103 | continue; |
| 4104 | } |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4105 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
| 4106 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
| 4107 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); |
| 4108 | } |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4109 | } |
| 4110 | if (spec->dac_list) |
| 4111 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4112 | return 0; |
| 4113 | } |
| 4114 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4115 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4116 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4117 | #ifdef CONFIG_SND_JACK |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4118 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4119 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4120 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4121 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4122 | int i; |
| 4123 | for (i = 0; i < spec->jacks.used; i++) |
| 4124 | snd_device_free(codec->bus->card, &jacks[i].jack); |
| 4125 | } |
| 4126 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4127 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4128 | } |
| 4129 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4130 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4131 | { |
| 4132 | struct sigmatel_spec *spec = codec->spec; |
| 4133 | |
| 4134 | if (spec->kctls.list) { |
| 4135 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4136 | int i; |
| 4137 | for (i = 0; i < spec->kctls.used; i++) |
| 4138 | kfree(kctl[i].name); |
| 4139 | } |
| 4140 | snd_array_free(&spec->kctls); |
| 4141 | } |
| 4142 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4143 | static void stac92xx_free(struct hda_codec *codec) |
| 4144 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4145 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4146 | |
| 4147 | if (! spec) |
| 4148 | return; |
| 4149 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4150 | stac92xx_free_jacks(codec); |
| 4151 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4152 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4153 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4154 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4155 | } |
| 4156 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4157 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4158 | unsigned int flag) |
| 4159 | { |
Takashi Iwai | 8ce84198 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4160 | unsigned int old_ctl, pin_ctl; |
| 4161 | |
| 4162 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4163 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4164 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4165 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4166 | /* |
| 4167 | * we need to check the current set-up direction of |
| 4168 | * shared input pins since they can be switched via |
| 4169 | * "xxx as Output" mixer switch |
| 4170 | */ |
| 4171 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4172 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4173 | return; |
| 4174 | } |
| 4175 | |
Takashi Iwai | 8ce84198 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4176 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4177 | /* if setting pin direction bits, clear the current |
| 4178 | direction bits first */ |
| 4179 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4180 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4181 | |
Takashi Iwai | 8ce84198 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4182 | pin_ctl |= flag; |
| 4183 | if (old_ctl != pin_ctl) |
| 4184 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4185 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4186 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4187 | } |
| 4188 | |
| 4189 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4190 | unsigned int flag) |
| 4191 | { |
| 4192 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4193 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce84198 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4194 | if (pin_ctl & flag) |
| 4195 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4196 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4197 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4198 | } |
| 4199 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4200 | 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] | 4201 | { |
| 4202 | if (!nid) |
| 4203 | return 0; |
| 4204 | 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] | 4205 | & (1 << 31)) |
| 4206 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4207 | return 0; |
| 4208 | } |
| 4209 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4210 | /* return non-zero if the hp-pin of the given array index isn't |
| 4211 | * a jack-detection target |
| 4212 | */ |
| 4213 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4214 | { |
| 4215 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4216 | |
| 4217 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4218 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4219 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4220 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4221 | return 1; |
| 4222 | /* ignore if the pin is set as line-out */ |
| 4223 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4224 | return 1; |
| 4225 | return 0; |
| 4226 | } |
| 4227 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4228 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4229 | { |
| 4230 | struct sigmatel_spec *spec = codec->spec; |
| 4231 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4232 | int i, presence; |
| 4233 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4234 | presence = 0; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4235 | if (spec->gpio_mute) |
| 4236 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4237 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4238 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4239 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4240 | if (presence) |
| 4241 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4242 | if (no_hp_sensing(spec, i)) |
| 4243 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4244 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4245 | if (presence) { |
| 4246 | unsigned int pinctl; |
| 4247 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4248 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4249 | if (pinctl & AC_PINCTL_IN_EN) |
| 4250 | presence = 0; /* mic- or line-input */ |
| 4251 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4252 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4253 | |
| 4254 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4255 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4256 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4257 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4258 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4259 | for (i = 0; i < cfg->line_outs; i++) |
| 4260 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4261 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4262 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4263 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4264 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4265 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4266 | stac_gpio_set(codec, spec->gpio_mask, |
| 4267 | spec->gpio_dir, spec->gpio_data & |
| 4268 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4269 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4270 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4271 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4272 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4273 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4274 | for (i = 0; i < cfg->line_outs; i++) |
| 4275 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4276 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4277 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4278 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4279 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4280 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4281 | stac_gpio_set(codec, spec->gpio_mask, |
| 4282 | spec->gpio_dir, spec->gpio_data | |
| 4283 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4284 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4285 | /* toggle hp outs */ |
| 4286 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4287 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4288 | if (no_hp_sensing(spec, i)) |
| 4289 | continue; |
| 4290 | if (presence) |
| 4291 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4292 | #if 0 /* FIXME */ |
| 4293 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4294 | * on some devices since they use the HP pin actually for line/speaker |
| 4295 | * outs although the default pin config shows a different pin (that is |
| 4296 | * wrong and useless). |
| 4297 | * |
| 4298 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4299 | * But, disabling the code below just works around it, and I'm too tired of |
| 4300 | * bug reports with such devices... |
| 4301 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4302 | else |
| 4303 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4304 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4305 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4306 | } |
| 4307 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4308 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4309 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4310 | { |
| 4311 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4312 | unsigned int idx, val; |
| 4313 | |
| 4314 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4315 | if (spec->pwr_nids[idx] == nid) |
| 4316 | break; |
| 4317 | } |
| 4318 | if (idx >= spec->num_pwrs) |
| 4319 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4320 | |
| 4321 | /* several codecs have two power down bits */ |
| 4322 | if (spec->pwr_mapping) |
| 4323 | idx = spec->pwr_mapping[idx]; |
| 4324 | else |
| 4325 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4326 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4327 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4328 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4329 | val &= ~idx; |
| 4330 | else |
| 4331 | val |= idx; |
| 4332 | |
| 4333 | /* power down unused output ports */ |
| 4334 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4335 | } |
| 4336 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4337 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4338 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4339 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4340 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4341 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4342 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4343 | { |
| 4344 | struct sigmatel_spec *spec = codec->spec; |
| 4345 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4346 | |
| 4347 | if (jacks) { |
| 4348 | int i; |
| 4349 | for (i = 0; i < spec->jacks.used; i++) { |
| 4350 | if (jacks->nid == nid) { |
| 4351 | unsigned int pin_ctl = |
| 4352 | snd_hda_codec_read(codec, nid, |
| 4353 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4354 | 0x00); |
| 4355 | int type = jacks->type; |
| 4356 | if (type == (SND_JACK_LINEOUT |
| 4357 | | SND_JACK_HEADPHONE)) |
| 4358 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4359 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4360 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4361 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4362 | ? type : 0); |
| 4363 | } |
| 4364 | jacks++; |
| 4365 | } |
| 4366 | } |
| 4367 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4368 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4369 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 4370 | unsigned char type) |
| 4371 | { |
| 4372 | struct sigmatel_event *event = stac_get_event(codec, nid, type); |
| 4373 | if (!event) |
| 4374 | return; |
| 4375 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4376 | } |
| 4377 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4378 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4379 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4380 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4381 | struct sigmatel_event *event; |
| 4382 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4383 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4384 | tag = (res >> 26) & 0x7f; |
| 4385 | event = stac_get_event_from_tag(codec, tag); |
| 4386 | if (!event) |
| 4387 | return; |
| 4388 | |
| 4389 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4390 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4391 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4392 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4393 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4394 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4395 | if (spec->num_pwrs > 0) |
| 4396 | stac92xx_pin_sense(codec, event->nid); |
| 4397 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4398 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4399 | case STAC_VREF_EVENT: |
| 4400 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4401 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4402 | /* toggle VREF state based on GPIOx status */ |
| 4403 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4404 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4405 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4406 | } |
| 4407 | } |
| 4408 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4409 | #ifdef CONFIG_PROC_FS |
| 4410 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4411 | struct hda_codec *codec, hda_nid_t nid) |
| 4412 | { |
| 4413 | if (nid == codec->afg) |
| 4414 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4415 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4416 | } |
| 4417 | |
| 4418 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4419 | struct hda_codec *codec, |
| 4420 | unsigned int verb) |
| 4421 | { |
| 4422 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4423 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4424 | } |
| 4425 | |
| 4426 | /* stac92hd71bxx, stac92hd73xx */ |
| 4427 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4428 | struct hda_codec *codec, hda_nid_t nid) |
| 4429 | { |
| 4430 | stac92hd_proc_hook(buffer, codec, nid); |
| 4431 | if (nid == codec->afg) |
| 4432 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4433 | } |
| 4434 | |
| 4435 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4436 | struct hda_codec *codec, hda_nid_t nid) |
| 4437 | { |
| 4438 | if (nid == codec->afg) |
| 4439 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4440 | } |
| 4441 | |
| 4442 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4443 | struct hda_codec *codec, hda_nid_t nid) |
| 4444 | { |
| 4445 | if (nid == codec->afg) |
| 4446 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4447 | } |
| 4448 | #else |
| 4449 | #define stac92hd_proc_hook NULL |
| 4450 | #define stac92hd7x_proc_hook NULL |
| 4451 | #define stac9205_proc_hook NULL |
| 4452 | #define stac927x_proc_hook NULL |
| 4453 | #endif |
| 4454 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4455 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4456 | static int stac92xx_resume(struct hda_codec *codec) |
| 4457 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4458 | struct sigmatel_spec *spec = codec->spec; |
| 4459 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4460 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4461 | snd_hda_codec_resume_amp(codec); |
| 4462 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4463 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4464 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4465 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4466 | STAC_HP_EVENT); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4467 | return 0; |
| 4468 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4469 | |
| 4470 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4471 | { |
| 4472 | struct sigmatel_spec *spec = codec->spec; |
| 4473 | if (spec->eapd_mask) |
| 4474 | stac_gpio_set(codec, spec->gpio_mask, |
| 4475 | spec->gpio_dir, spec->gpio_data & |
| 4476 | ~spec->eapd_mask); |
| 4477 | return 0; |
| 4478 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4479 | #endif |
| 4480 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4481 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4482 | .build_controls = stac92xx_build_controls, |
| 4483 | .build_pcms = stac92xx_build_pcms, |
| 4484 | .init = stac92xx_init, |
| 4485 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4486 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4487 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4488 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4489 | .resume = stac92xx_resume, |
| 4490 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4491 | }; |
| 4492 | |
| 4493 | static int patch_stac9200(struct hda_codec *codec) |
| 4494 | { |
| 4495 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4496 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4497 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4498 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4499 | if (spec == NULL) |
| 4500 | return -ENOMEM; |
| 4501 | |
| 4502 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4503 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4504 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4505 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4506 | stac9200_models, |
| 4507 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4508 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4509 | 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] | 4510 | else |
| 4511 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4512 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4513 | |
| 4514 | spec->multiout.max_channels = 2; |
| 4515 | spec->multiout.num_dacs = 1; |
| 4516 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4517 | spec->adc_nids = stac9200_adc_nids; |
| 4518 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4519 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4520 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4521 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4522 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4523 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4524 | if (spec->board_config == STAC_9200_M4 || |
| 4525 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4526 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4527 | spec->init = stac9200_eapd_init; |
| 4528 | else |
| 4529 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4530 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4531 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4532 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4533 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4534 | spec->gpio_data = 0x00; |
| 4535 | } |
| 4536 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4537 | err = stac9200_parse_auto_config(codec); |
| 4538 | if (err < 0) { |
| 4539 | stac92xx_free(codec); |
| 4540 | return err; |
| 4541 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4542 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4543 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 4544 | * do detection and HP/speaker toggle because the hardware does it. |
| 4545 | */ |
| 4546 | if (spec->board_config == STAC_9200_PANASONIC) |
| 4547 | spec->hp_detect = 0; |
| 4548 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4549 | codec->patch_ops = stac92xx_patch_ops; |
| 4550 | |
| 4551 | return 0; |
| 4552 | } |
| 4553 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4554 | static int patch_stac925x(struct hda_codec *codec) |
| 4555 | { |
| 4556 | struct sigmatel_spec *spec; |
| 4557 | int err; |
| 4558 | |
| 4559 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4560 | if (spec == NULL) |
| 4561 | return -ENOMEM; |
| 4562 | |
| 4563 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4564 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4565 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4566 | |
| 4567 | /* Check first for codec ID */ |
| 4568 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4569 | STAC_925x_MODELS, |
| 4570 | stac925x_models, |
| 4571 | stac925x_codec_id_cfg_tbl); |
| 4572 | |
| 4573 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4574 | if (spec->board_config < 0) |
| 4575 | spec->board_config = snd_hda_check_board_config(codec, |
| 4576 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4577 | stac925x_models, |
| 4578 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4579 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4580 | if (spec->board_config < 0) |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4581 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4582 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4583 | else |
| 4584 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4585 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4586 | |
| 4587 | spec->multiout.max_channels = 2; |
| 4588 | spec->multiout.num_dacs = 1; |
| 4589 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4590 | spec->adc_nids = stac925x_adc_nids; |
| 4591 | spec->mux_nids = stac925x_mux_nids; |
| 4592 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4593 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4594 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4595 | switch (codec->vendor_id) { |
| 4596 | case 0x83847632: /* STAC9202 */ |
| 4597 | case 0x83847633: /* STAC9202D */ |
| 4598 | case 0x83847636: /* STAC9251 */ |
| 4599 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4600 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4601 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4602 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4603 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4604 | break; |
| 4605 | default: |
| 4606 | spec->num_dmics = 0; |
| 4607 | break; |
| 4608 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4609 | |
| 4610 | spec->init = stac925x_core_init; |
| 4611 | spec->mixer = stac925x_mixer; |
| 4612 | |
| 4613 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4614 | if (!err) { |
| 4615 | if (spec->board_config < 0) { |
| 4616 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4617 | "available, default to model=ref\n"); |
| 4618 | spec->board_config = STAC_925x_REF; |
| 4619 | goto again; |
| 4620 | } |
| 4621 | err = -EINVAL; |
| 4622 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4623 | if (err < 0) { |
| 4624 | stac92xx_free(codec); |
| 4625 | return err; |
| 4626 | } |
| 4627 | |
| 4628 | codec->patch_ops = stac92xx_patch_ops; |
| 4629 | |
| 4630 | return 0; |
| 4631 | } |
| 4632 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4633 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4634 | .num_items = 4, |
| 4635 | .items = { |
| 4636 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4637 | { "Digital Mic 1", 0x09 }, |
| 4638 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4639 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4640 | } |
| 4641 | }; |
| 4642 | |
| 4643 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4644 | { |
| 4645 | struct sigmatel_spec *spec; |
| 4646 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4647 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4648 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4649 | |
| 4650 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4651 | if (spec == NULL) |
| 4652 | return -ENOMEM; |
| 4653 | |
| 4654 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4655 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4656 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4657 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4658 | spec->board_config = snd_hda_check_board_config(codec, |
| 4659 | STAC_92HD73XX_MODELS, |
| 4660 | stac92hd73xx_models, |
| 4661 | stac92hd73xx_cfg_tbl); |
| 4662 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4663 | if (spec->board_config < 0) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4664 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4665 | " STAC92HD73XX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4666 | else |
| 4667 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4668 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4669 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4670 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4671 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4672 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4673 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4674 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4675 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4676 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4677 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4678 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4679 | case 0x3: /* 6 Channel */ |
| 4680 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4681 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4682 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4683 | break; |
| 4684 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4685 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4686 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4687 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4688 | break; |
| 4689 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4690 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4691 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4692 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 4693 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4694 | } |
| 4695 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4696 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4697 | spec->aloopback_mask = 0x01; |
| 4698 | spec->aloopback_shift = 8; |
| 4699 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4700 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4701 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4702 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4703 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4704 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4705 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4706 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4707 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4708 | |
| 4709 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4710 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4711 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4712 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 4713 | sizeof(stac92hd73xx_dmux)); |
| 4714 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4715 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4716 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4717 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4718 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4719 | case STAC_DELL_M6_AMIC: |
| 4720 | case STAC_DELL_M6_DMIC: |
| 4721 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4722 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4723 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 4724 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4725 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4726 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4727 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4728 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4729 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4730 | switch (spec->board_config) { |
| 4731 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4732 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4733 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4734 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4735 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4736 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4737 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4738 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4739 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4740 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4741 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4742 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 4743 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4744 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4745 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4746 | break; |
| 4747 | } |
| 4748 | break; |
| 4749 | default: |
| 4750 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4751 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4752 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4753 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4754 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 4755 | /* GPIO0 High = Enable EAPD */ |
| 4756 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 4757 | spec->gpio_data = 0x01; |
| 4758 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4759 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4760 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4761 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 4762 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 4763 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4764 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4765 | |
| 4766 | if (!err) { |
| 4767 | if (spec->board_config < 0) { |
| 4768 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4769 | "available, default to model=ref\n"); |
| 4770 | spec->board_config = STAC_92HD73XX_REF; |
| 4771 | goto again; |
| 4772 | } |
| 4773 | err = -EINVAL; |
| 4774 | } |
| 4775 | |
| 4776 | if (err < 0) { |
| 4777 | stac92xx_free(codec); |
| 4778 | return err; |
| 4779 | } |
| 4780 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 4781 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 4782 | spec->hp_detect = 0; |
| 4783 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4784 | codec->patch_ops = stac92xx_patch_ops; |
| 4785 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4786 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 4787 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4788 | return 0; |
| 4789 | } |
| 4790 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4791 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 4792 | .num_items = 3, |
| 4793 | .items = { |
| 4794 | { "Analog Inputs", 0x03 }, |
| 4795 | { "Digital Mic 1", 0x04 }, |
| 4796 | { "Digital Mic 2", 0x05 }, |
| 4797 | } |
| 4798 | }; |
| 4799 | |
| 4800 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 4801 | { |
| 4802 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 4803 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4804 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 4805 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 4806 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4807 | |
| 4808 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4809 | if (spec == NULL) |
| 4810 | return -ENOMEM; |
| 4811 | |
| 4812 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4813 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4814 | spec->mono_nid = 0x19; |
| 4815 | spec->digbeep_nid = 0x21; |
| 4816 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 4817 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 4818 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 4819 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 4820 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4821 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 4822 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4823 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4824 | |
| 4825 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4826 | spec->mixer = stac92hd83xxx_mixer; |
| 4827 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 4828 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 4829 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 4830 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4831 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 4832 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 4833 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 4834 | spec->board_config = snd_hda_check_board_config(codec, |
| 4835 | STAC_92HD83XXX_MODELS, |
| 4836 | stac92hd83xxx_models, |
| 4837 | stac92hd83xxx_cfg_tbl); |
| 4838 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4839 | if (spec->board_config < 0) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4840 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4841 | " STAC92HD83XXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4842 | else |
| 4843 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4844 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4845 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 4846 | switch (codec->vendor_id) { |
| 4847 | case 0x111d7604: |
| 4848 | case 0x111d7605: |
| 4849 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 4850 | break; |
| 4851 | spec->num_pwrs = 0; |
| 4852 | break; |
| 4853 | } |
| 4854 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4855 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 4856 | if (!err) { |
| 4857 | if (spec->board_config < 0) { |
| 4858 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4859 | "available, default to model=ref\n"); |
| 4860 | spec->board_config = STAC_92HD83XXX_REF; |
| 4861 | goto again; |
| 4862 | } |
| 4863 | err = -EINVAL; |
| 4864 | } |
| 4865 | |
| 4866 | if (err < 0) { |
| 4867 | stac92xx_free(codec); |
| 4868 | return err; |
| 4869 | } |
| 4870 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 4871 | switch (spec->board_config) { |
| 4872 | case STAC_DELL_S14: |
| 4873 | nid = 0xf; |
| 4874 | break; |
| 4875 | default: |
| 4876 | nid = 0xe; |
| 4877 | break; |
| 4878 | } |
| 4879 | |
| 4880 | num_dacs = snd_hda_get_connections(codec, nid, |
| 4881 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
| 4882 | |
| 4883 | /* set port X to select the last DAC |
| 4884 | */ |
| 4885 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4886 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 4887 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4888 | codec->patch_ops = stac92xx_patch_ops; |
| 4889 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4890 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 4891 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4892 | return 0; |
| 4893 | } |
| 4894 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4895 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 4896 | .num_items = 3, |
| 4897 | .items = { |
| 4898 | { "Analog Inputs", 0x00 }, |
| 4899 | { "Digital Mic 1", 0x02 }, |
| 4900 | { "Digital Mic 2", 0x03 }, |
| 4901 | } |
| 4902 | }; |
| 4903 | |
| 4904 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4905 | .num_items = 4, |
| 4906 | .items = { |
| 4907 | { "Analog Inputs", 0x00 }, |
| 4908 | { "Mixer", 0x01 }, |
| 4909 | { "Digital Mic 1", 0x02 }, |
| 4910 | { "Digital Mic 2", 0x03 }, |
| 4911 | } |
| 4912 | }; |
| 4913 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4914 | /* get the pin connection (fixed, none, etc) */ |
| 4915 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 4916 | { |
| 4917 | struct sigmatel_spec *spec = codec->spec; |
| 4918 | unsigned int cfg; |
| 4919 | |
| 4920 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 4921 | return get_defcfg_connect(cfg); |
| 4922 | } |
| 4923 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4924 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 4925 | hda_nid_t *nids, int num_nids) |
| 4926 | { |
| 4927 | struct sigmatel_spec *spec = codec->spec; |
| 4928 | int idx, num; |
| 4929 | unsigned int def_conf; |
| 4930 | |
| 4931 | for (num = 0; num < num_nids; num++) { |
| 4932 | for (idx = 0; idx < spec->num_pins; idx++) |
| 4933 | if (spec->pin_nids[idx] == nids[num]) |
| 4934 | break; |
| 4935 | if (idx >= spec->num_pins) |
| 4936 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4937 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4938 | if (def_conf == AC_JACK_PORT_NONE) |
| 4939 | break; |
| 4940 | } |
| 4941 | return num; |
| 4942 | } |
| 4943 | |
| 4944 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 4945 | hda_nid_t dig0pin) |
| 4946 | { |
| 4947 | struct sigmatel_spec *spec = codec->spec; |
| 4948 | int idx; |
| 4949 | |
| 4950 | for (idx = 0; idx < spec->num_pins; idx++) |
| 4951 | if (spec->pin_nids[idx] == dig0pin) |
| 4952 | break; |
| 4953 | if ((idx + 2) >= spec->num_pins) |
| 4954 | return 0; |
| 4955 | |
| 4956 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4957 | 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] | 4958 | return 2; |
| 4959 | |
| 4960 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4961 | 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] | 4962 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4963 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4964 | return 1; |
| 4965 | else |
| 4966 | return 0; |
| 4967 | } |
| 4968 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4969 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 4970 | { |
| 4971 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 4972 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4973 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4974 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4975 | |
| 4976 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4977 | if (spec == NULL) |
| 4978 | return -ENOMEM; |
| 4979 | |
| 4980 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4981 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 4982 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 4983 | switch (codec->vendor_id) { |
| 4984 | case 0x111d76b6: |
| 4985 | case 0x111d76b7: |
| 4986 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 4987 | break; |
| 4988 | case 0x111d7603: |
| 4989 | case 0x111d7608: |
| 4990 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 4991 | spec->num_pins--; |
| 4992 | /* fallthrough */ |
| 4993 | default: |
| 4994 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 4995 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4996 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4997 | spec->board_config = snd_hda_check_board_config(codec, |
| 4998 | STAC_92HD71BXX_MODELS, |
| 4999 | stac92hd71bxx_models, |
| 5000 | stac92hd71bxx_cfg_tbl); |
| 5001 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5002 | if (spec->board_config < 0) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5003 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5004 | " STAC92HD71BXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5005 | else |
| 5006 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5007 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5008 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5009 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5010 | /* GPIO0 = EAPD */ |
| 5011 | spec->gpio_mask = 0x01; |
| 5012 | spec->gpio_dir = 0x01; |
| 5013 | spec->gpio_data = 0x01; |
| 5014 | } |
| 5015 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5016 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5017 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5018 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5019 | switch (codec->vendor_id) { |
| 5020 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5021 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5022 | unmute_init++; |
| 5023 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5024 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5025 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5026 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 5027 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5028 | spec->mixer = stac92hd71bxx_mixer; |
| 5029 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5030 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5031 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5032 | stac92hd71bxx_dmic_nids, |
| 5033 | STAC92HD71BXX_NUM_DMICS); |
| 5034 | if (spec->num_dmics) { |
| 5035 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5036 | spec->dinput_mux = &spec->private_dimux; |
| 5037 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5038 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5039 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5040 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5041 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5042 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5043 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5044 | switch (spec->board_config) { |
| 5045 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5046 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5047 | err = stac_add_event(spec, codec->afg, |
| 5048 | STAC_VREF_EVENT, 0x02); |
| 5049 | if (err < 0) |
| 5050 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5051 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5052 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5053 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5054 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5055 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5056 | spec->gpio_mask |= 0x02; |
| 5057 | break; |
| 5058 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5059 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5060 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5061 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5062 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5063 | /* no output amps */ |
| 5064 | spec->num_pwrs = 0; |
| 5065 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5066 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5067 | |
| 5068 | /* disable VSW */ |
| 5069 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5070 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5071 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5072 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5073 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5074 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5075 | stac92hd71bxx_dmic_nids, |
| 5076 | STAC92HD71BXX_NUM_DMICS - 1); |
| 5077 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5078 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5079 | break; |
| 5080 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5081 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5082 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5083 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5084 | /* no output amps */ |
| 5085 | spec->num_pwrs = 0; |
| 5086 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5087 | default: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5088 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5089 | sizeof(stac92hd71bxx_dmux_amixer)); |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5090 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5091 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 5092 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5093 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5094 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5095 | stac92hd71bxx_dmic_nids, |
| 5096 | STAC92HD71BXX_NUM_DMICS); |
| 5097 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5098 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5099 | } |
| 5100 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5101 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5102 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5103 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5104 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5105 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5106 | spec->aloopback_shift = 0; |
| 5107 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5108 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5109 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5110 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5111 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5112 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5113 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5114 | |
| 5115 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5116 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5117 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5118 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5119 | switch (spec->board_config) { |
| 5120 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5121 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5122 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5123 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5124 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5125 | /* fallthru */ |
| 5126 | case STAC_DELL_M4_2: |
| 5127 | spec->num_dmics = 0; |
| 5128 | spec->num_smuxes = 0; |
| 5129 | spec->num_dmuxes = 0; |
| 5130 | break; |
| 5131 | case STAC_DELL_M4_1: |
| 5132 | case STAC_DELL_M4_3: |
| 5133 | spec->num_dmics = 1; |
| 5134 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5135 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5136 | break; |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5137 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5138 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5139 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5140 | break; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5141 | }; |
| 5142 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5143 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5144 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5145 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5146 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5147 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5148 | if (!err) { |
| 5149 | if (spec->board_config < 0) { |
| 5150 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5151 | "available, default to model=ref\n"); |
| 5152 | spec->board_config = STAC_92HD71BXX_REF; |
| 5153 | goto again; |
| 5154 | } |
| 5155 | err = -EINVAL; |
| 5156 | } |
| 5157 | |
| 5158 | if (err < 0) { |
| 5159 | stac92xx_free(codec); |
| 5160 | return err; |
| 5161 | } |
| 5162 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5163 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5164 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5165 | return 0; |
| 5166 | }; |
| 5167 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5168 | static int patch_stac922x(struct hda_codec *codec) |
| 5169 | { |
| 5170 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5171 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5172 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5173 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5174 | if (spec == NULL) |
| 5175 | return -ENOMEM; |
| 5176 | |
| 5177 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5178 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5179 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5180 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5181 | stac922x_models, |
| 5182 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5183 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5184 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5185 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5186 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5187 | * codec SSID to distinguish the exact models |
| 5188 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5189 | 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] | 5190 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5191 | |
| 5192 | case 0x106b0800: |
| 5193 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5194 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5195 | case 0x106b0600: |
| 5196 | case 0x106b0700: |
| 5197 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5198 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5199 | case 0x106b0e00: |
| 5200 | case 0x106b0f00: |
| 5201 | case 0x106b1600: |
| 5202 | case 0x106b1700: |
| 5203 | case 0x106b0200: |
| 5204 | case 0x106b1e00: |
| 5205 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5206 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5207 | case 0x106b1a00: |
| 5208 | case 0x00000100: |
| 5209 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5210 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5211 | case 0x106b0a00: |
| 5212 | case 0x106b2200: |
| 5213 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5214 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5215 | default: |
| 5216 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5217 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5218 | } |
| 5219 | } |
| 5220 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5221 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5222 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5223 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 5224 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5225 | else |
| 5226 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5227 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5228 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5229 | spec->adc_nids = stac922x_adc_nids; |
| 5230 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5231 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5232 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5233 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5234 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5235 | |
| 5236 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5237 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5238 | |
| 5239 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5240 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5241 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5242 | if (!err) { |
| 5243 | if (spec->board_config < 0) { |
| 5244 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5245 | "available, default to model=ref\n"); |
| 5246 | spec->board_config = STAC_D945_REF; |
| 5247 | goto again; |
| 5248 | } |
| 5249 | err = -EINVAL; |
| 5250 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5251 | if (err < 0) { |
| 5252 | stac92xx_free(codec); |
| 5253 | return err; |
| 5254 | } |
| 5255 | |
| 5256 | codec->patch_ops = stac92xx_patch_ops; |
| 5257 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5258 | /* Fix Mux capture level; max to 2 */ |
| 5259 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5260 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5261 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5262 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5263 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5264 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5265 | return 0; |
| 5266 | } |
| 5267 | |
| 5268 | static int patch_stac927x(struct hda_codec *codec) |
| 5269 | { |
| 5270 | struct sigmatel_spec *spec; |
| 5271 | int err; |
| 5272 | |
| 5273 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5274 | if (spec == NULL) |
| 5275 | return -ENOMEM; |
| 5276 | |
| 5277 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5278 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5279 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5280 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5281 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5282 | stac927x_models, |
| 5283 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5284 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5285 | if (spec->board_config < 0) |
Herton Ronaldo Krzesinski | c98041f | 2009-02-11 20:33:15 -0200 | [diff] [blame] | 5286 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5287 | "STAC927x, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5288 | else |
| 5289 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5290 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5291 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5292 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5293 | spec->adc_nids = stac927x_adc_nids; |
| 5294 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5295 | spec->mux_nids = stac927x_mux_nids; |
| 5296 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5297 | spec->smux_nids = stac927x_smux_nids; |
| 5298 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5299 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5300 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5301 | spec->multiout.dac_nids = spec->dac_nids; |
| 5302 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5303 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5304 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5305 | case STAC_D965_5ST: |
| 5306 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5307 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5308 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5309 | spec->num_dmics = 0; |
| 5310 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5311 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5312 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5313 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5314 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5315 | switch (codec->subsystem_id) { |
| 5316 | case 0x10280209: |
| 5317 | case 0x1028022e: |
| 5318 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5319 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5320 | break; |
| 5321 | }; |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5322 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5323 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5324 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5325 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5326 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5327 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5328 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5329 | case STAC_DELL_3ST: |
| 5330 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5331 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5332 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5333 | spec->dmic_nids = stac927x_dmic_nids; |
| 5334 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5335 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5336 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5337 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5338 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5339 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5340 | break; |
| 5341 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5342 | if (spec->board_config > STAC_D965_REF) { |
| 5343 | /* GPIO0 High = Enable EAPD */ |
| 5344 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5345 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5346 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5347 | spec->num_dmics = 0; |
| 5348 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5349 | spec->init = stac927x_core_init; |
| 5350 | spec->mixer = stac927x_mixer; |
| 5351 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5352 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5353 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5354 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5355 | spec->aloopback_mask = 0x40; |
| 5356 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5357 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5358 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5359 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5360 | if (!err) { |
| 5361 | if (spec->board_config < 0) { |
| 5362 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5363 | "available, default to model=ref\n"); |
| 5364 | spec->board_config = STAC_D965_REF; |
| 5365 | goto again; |
| 5366 | } |
| 5367 | err = -EINVAL; |
| 5368 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5369 | if (err < 0) { |
| 5370 | stac92xx_free(codec); |
| 5371 | return err; |
| 5372 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5373 | |
| 5374 | codec->patch_ops = stac92xx_patch_ops; |
| 5375 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5376 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5377 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5378 | /* |
| 5379 | * !!FIXME!! |
| 5380 | * The STAC927x seem to require fairly long delays for certain |
| 5381 | * command sequences. With too short delays (even if the answer |
| 5382 | * is set to RIRB properly), it results in the silence output |
| 5383 | * on some hardwares like Dell. |
| 5384 | * |
| 5385 | * The below flag enables the longer delay (see get_response |
| 5386 | * in hda_intel.c). |
| 5387 | */ |
| 5388 | codec->bus->needs_damn_long_delay = 1; |
| 5389 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5390 | /* no jack detecion for ref-no-jd model */ |
| 5391 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5392 | spec->hp_detect = 0; |
| 5393 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5394 | return 0; |
| 5395 | } |
| 5396 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5397 | static int patch_stac9205(struct hda_codec *codec) |
| 5398 | { |
| 5399 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5400 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5401 | |
| 5402 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5403 | if (spec == NULL) |
| 5404 | return -ENOMEM; |
| 5405 | |
| 5406 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5407 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5408 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5409 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5410 | stac9205_models, |
| 5411 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5412 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5413 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5414 | 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] | 5415 | else |
| 5416 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5417 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5418 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5419 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5420 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5421 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5422 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5423 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5424 | spec->smux_nids = stac9205_smux_nids; |
| 5425 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5426 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5427 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5428 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5429 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5430 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5431 | |
| 5432 | spec->init = stac9205_core_init; |
| 5433 | spec->mixer = stac9205_mixer; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5434 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5435 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5436 | spec->aloopback_mask = 0x40; |
| 5437 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5438 | /* Turn on/off EAPD per HP plugging */ |
| 5439 | if (spec->board_config != STAC_9205_EAPD) |
| 5440 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5441 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5442 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5443 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5444 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5445 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5446 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5447 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5448 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5449 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5450 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5451 | if (err < 0) |
| 5452 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5453 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5454 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5455 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5456 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5457 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5458 | |
| 5459 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5460 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5461 | spec->gpio_mask = 0x1b; |
| 5462 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5463 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5464 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5465 | */ |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5466 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5467 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5468 | case STAC_9205_REF: |
| 5469 | /* SPDIF-In enabled */ |
| 5470 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5471 | default: |
| 5472 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5473 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5474 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5475 | break; |
| 5476 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5477 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5478 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5479 | if (!err) { |
| 5480 | if (spec->board_config < 0) { |
| 5481 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5482 | "available, default to model=ref\n"); |
| 5483 | spec->board_config = STAC_9205_REF; |
| 5484 | goto again; |
| 5485 | } |
| 5486 | err = -EINVAL; |
| 5487 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5488 | if (err < 0) { |
| 5489 | stac92xx_free(codec); |
| 5490 | return err; |
| 5491 | } |
| 5492 | |
| 5493 | codec->patch_ops = stac92xx_patch_ops; |
| 5494 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5495 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5496 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5497 | return 0; |
| 5498 | } |
| 5499 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5500 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5501 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5502 | */ |
| 5503 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5504 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5505 | {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] | 5506 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5507 | {} |
| 5508 | }; |
| 5509 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5510 | static struct snd_kcontrol_new stac9872_mixer[] = { |
| 5511 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5512 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5513 | { } /* end */ |
| 5514 | }; |
| 5515 | |
| 5516 | static hda_nid_t stac9872_pin_nids[] = { |
| 5517 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 5518 | 0x11, 0x13, 0x14, |
| 5519 | }; |
| 5520 | |
| 5521 | static hda_nid_t stac9872_adc_nids[] = { |
| 5522 | 0x8 /*,0x6*/ |
| 5523 | }; |
| 5524 | |
| 5525 | static hda_nid_t stac9872_mux_nids[] = { |
| 5526 | 0x15 |
| 5527 | }; |
| 5528 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5529 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5530 | { |
| 5531 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5532 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5533 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5534 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5535 | if (spec == NULL) |
| 5536 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5537 | codec->spec = spec; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5538 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5539 | #if 0 /* no model right now */ |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5540 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5541 | stac9872_models, |
| 5542 | stac9872_cfg_tbl); |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5543 | #endif |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5544 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5545 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 5546 | spec->pin_nids = stac9872_pin_nids; |
| 5547 | spec->multiout.dac_nids = spec->dac_nids; |
| 5548 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 5549 | spec->adc_nids = stac9872_adc_nids; |
| 5550 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 5551 | spec->mux_nids = stac9872_mux_nids; |
| 5552 | spec->mixer = stac9872_mixer; |
| 5553 | spec->init = stac9872_core_init; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5554 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5555 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 5556 | if (err < 0) { |
| 5557 | stac92xx_free(codec); |
| 5558 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5559 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5560 | spec->input_mux = &spec->private_imux; |
| 5561 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5562 | return 0; |
| 5563 | } |
| 5564 | |
| 5565 | |
| 5566 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5567 | * patch entries |
| 5568 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5569 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5570 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5571 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5572 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5573 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5574 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5575 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5576 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5577 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5578 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5579 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5580 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5581 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5582 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5583 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5584 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5585 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5586 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5587 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5588 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5589 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5590 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5591 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5592 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5593 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5594 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5595 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5596 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5597 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5598 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5599 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5600 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5601 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5602 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5603 | * currently not fully supported. |
| 5604 | */ |
| 5605 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5606 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5607 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5608 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5609 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5610 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5611 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5612 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5613 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5614 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5615 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5616 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5617 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5618 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5619 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5620 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5621 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5622 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5623 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5624 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5625 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5626 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5627 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5628 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5629 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5630 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5631 | {} /* terminator */ |
| 5632 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5633 | |
| 5634 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 5635 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 5636 | |
| 5637 | MODULE_LICENSE("GPL"); |
| 5638 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 5639 | |
| 5640 | static struct hda_codec_preset_list sigmatel_list = { |
| 5641 | .preset = snd_hda_preset_sigmatel, |
| 5642 | .owner = THIS_MODULE, |
| 5643 | }; |
| 5644 | |
| 5645 | static int __init patch_sigmatel_init(void) |
| 5646 | { |
| 5647 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 5648 | } |
| 5649 | |
| 5650 | static void __exit patch_sigmatel_exit(void) |
| 5651 | { |
| 5652 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 5653 | } |
| 5654 | |
| 5655 | module_init(patch_sigmatel_init) |
| 5656 | module_exit(patch_sigmatel_exit) |