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 */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 193 | unsigned char aloopback_mask; |
| 194 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 195 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 196 | /* power management */ |
| 197 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 198 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 199 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 200 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 201 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 202 | /* jack detection */ |
| 203 | struct snd_array jacks; |
| 204 | |
| 205 | /* events */ |
| 206 | struct snd_array events; |
| 207 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 208 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 209 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 210 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 211 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 212 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 213 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 214 | hda_nid_t hp_dacs[5]; |
| 215 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 216 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 217 | int volume_offset; |
| 218 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 219 | /* capture */ |
| 220 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 221 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 222 | hda_nid_t *mux_nids; |
| 223 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 224 | hda_nid_t *dmic_nids; |
| 225 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 226 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 227 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 228 | hda_nid_t *smux_nids; |
| 229 | unsigned int num_smuxes; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 230 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 231 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 232 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 233 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 234 | hda_nid_t anabeep_nid; |
| 235 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 236 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 237 | /* pin widgets */ |
| 238 | hda_nid_t *pin_nids; |
| 239 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 240 | |
| 241 | /* codec specific stuff */ |
| 242 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 243 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 244 | |
| 245 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 246 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 247 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 248 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 249 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 250 | struct hda_input_mux *sinput_mux; |
| 251 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 252 | unsigned int cur_amux; |
| 253 | hda_nid_t *amp_nids; |
| 254 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 255 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 256 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 257 | /* i/o switches */ |
| 258 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 259 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 260 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 261 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 262 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 263 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 264 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 265 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 266 | |
| 267 | /* dynamic controls and input_mux */ |
| 268 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 269 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 270 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 271 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 272 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 273 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 274 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | static hda_nid_t stac9200_adc_nids[1] = { |
| 278 | 0x03, |
| 279 | }; |
| 280 | |
| 281 | static hda_nid_t stac9200_mux_nids[1] = { |
| 282 | 0x0c, |
| 283 | }; |
| 284 | |
| 285 | static hda_nid_t stac9200_dac_nids[1] = { |
| 286 | 0x02, |
| 287 | }; |
| 288 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 289 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 290 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 291 | 0x0f, 0x10, 0x11 |
| 292 | }; |
| 293 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 294 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 295 | 0x26, 0, |
| 296 | }; |
| 297 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 298 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 299 | 0x1a, 0x1b |
| 300 | }; |
| 301 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 302 | #define DELL_M6_AMP 2 |
| 303 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 304 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 305 | }; |
| 306 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 307 | #define STAC92HD73XX_NUM_DMICS 2 |
| 308 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 309 | 0x13, 0x14, 0 |
| 310 | }; |
| 311 | |
| 312 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 313 | |
| 314 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 315 | 0x28, 0x29, 0x2a, 0x2b, |
| 316 | }; |
| 317 | |
| 318 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 319 | 0x20, 0x21, |
| 320 | }; |
| 321 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 322 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 323 | 0x22, 0x23, |
| 324 | }; |
| 325 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 326 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 327 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 328 | 0x11, 0x12, 0 |
| 329 | }; |
| 330 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 331 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 332 | |
| 333 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 334 | 0x17, 0x18, |
| 335 | }; |
| 336 | |
| 337 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 338 | 0x15, 0x16, |
| 339 | }; |
| 340 | |
| 341 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 342 | 0xa, 0xb, 0xd, 0xe, |
| 343 | }; |
| 344 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 345 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 346 | 0x1e, 0, |
| 347 | }; |
| 348 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 349 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 350 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 351 | }; |
| 352 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 353 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 354 | 0xc, |
| 355 | }; |
| 356 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 357 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 358 | 0x0a, 0x0d, 0x0f |
| 359 | }; |
| 360 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 361 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 362 | 0x12, 0x13, |
| 363 | }; |
| 364 | |
| 365 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 366 | 0x1a, 0x1b |
| 367 | }; |
| 368 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 369 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 370 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 371 | }; |
| 372 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 373 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 374 | 0x24, 0x25, |
| 375 | }; |
| 376 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 377 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 378 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 379 | 0x18, 0x19, 0 |
| 380 | }; |
| 381 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 382 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 383 | 0x22, 0 |
| 384 | }; |
| 385 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 386 | static hda_nid_t stac925x_adc_nids[1] = { |
| 387 | 0x03, |
| 388 | }; |
| 389 | |
| 390 | static hda_nid_t stac925x_mux_nids[1] = { |
| 391 | 0x0f, |
| 392 | }; |
| 393 | |
| 394 | static hda_nid_t stac925x_dac_nids[1] = { |
| 395 | 0x02, |
| 396 | }; |
| 397 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 398 | #define STAC925X_NUM_DMICS 1 |
| 399 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 400 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 401 | }; |
| 402 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 403 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 404 | 0x14, |
| 405 | }; |
| 406 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 407 | static hda_nid_t stac922x_adc_nids[2] = { |
| 408 | 0x06, 0x07, |
| 409 | }; |
| 410 | |
| 411 | static hda_nid_t stac922x_mux_nids[2] = { |
| 412 | 0x12, 0x13, |
| 413 | }; |
| 414 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 415 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 416 | 0x1f, 0, |
| 417 | }; |
| 418 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 419 | static hda_nid_t stac927x_adc_nids[3] = { |
| 420 | 0x07, 0x08, 0x09 |
| 421 | }; |
| 422 | |
| 423 | static hda_nid_t stac927x_mux_nids[3] = { |
| 424 | 0x15, 0x16, 0x17 |
| 425 | }; |
| 426 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 427 | static hda_nid_t stac927x_smux_nids[1] = { |
| 428 | 0x21, |
| 429 | }; |
| 430 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 431 | static hda_nid_t stac927x_dac_nids[6] = { |
| 432 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 433 | }; |
| 434 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 435 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 436 | 0x1b, |
| 437 | }; |
| 438 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 439 | #define STAC927X_NUM_DMICS 2 |
| 440 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 441 | 0x13, 0x14, 0 |
| 442 | }; |
| 443 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 444 | static const char *stac927x_spdif_labels[5] = { |
| 445 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 446 | "Analog Mux 2", "Analog Mux 3" |
| 447 | }; |
| 448 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 449 | static hda_nid_t stac9205_adc_nids[2] = { |
| 450 | 0x12, 0x13 |
| 451 | }; |
| 452 | |
| 453 | static hda_nid_t stac9205_mux_nids[2] = { |
| 454 | 0x19, 0x1a |
| 455 | }; |
| 456 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 457 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 458 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 459 | }; |
| 460 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 461 | static hda_nid_t stac9205_smux_nids[1] = { |
| 462 | 0x21, |
| 463 | }; |
| 464 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 465 | #define STAC9205_NUM_DMICS 2 |
| 466 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 467 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 468 | }; |
| 469 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 470 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 471 | 0x08, 0x09, 0x0d, 0x0e, |
| 472 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 473 | }; |
| 474 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 475 | static hda_nid_t stac925x_pin_nids[8] = { |
| 476 | 0x07, 0x08, 0x0a, 0x0b, |
| 477 | 0x0c, 0x0d, 0x10, 0x11, |
| 478 | }; |
| 479 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 480 | static hda_nid_t stac922x_pin_nids[10] = { |
| 481 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 482 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 483 | }; |
| 484 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 485 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 486 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 487 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 488 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 489 | }; |
| 490 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 491 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 492 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 493 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 494 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 495 | |
| 496 | #define STAC92HD71BXX_NUM_PINS 13 |
| 497 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 498 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 499 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 500 | 0x1f, 0x20, 0x27 |
| 501 | }; |
| 502 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 503 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 504 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 505 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 506 | }; |
| 507 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 508 | static hda_nid_t stac927x_pin_nids[14] = { |
| 509 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 510 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 511 | 0x14, 0x21, 0x22, 0x23, |
| 512 | }; |
| 513 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 514 | static hda_nid_t stac9205_pin_nids[12] = { |
| 515 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 516 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 517 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 518 | }; |
| 519 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 520 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 521 | |
| 522 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 523 | struct snd_ctl_elem_value *ucontrol) |
| 524 | { |
| 525 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 526 | struct sigmatel_spec *spec = codec->spec; |
| 527 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 528 | |
| 529 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 530 | kcontrol->private_value |= nid; |
| 531 | |
| 532 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 533 | } |
| 534 | |
| 535 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 536 | struct snd_ctl_elem_value *ucontrol) |
| 537 | { |
| 538 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 539 | struct sigmatel_spec *spec = codec->spec; |
| 540 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 541 | |
| 542 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 543 | kcontrol->private_value |= nid; |
| 544 | |
| 545 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 546 | } |
| 547 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 548 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 549 | struct snd_ctl_elem_info *uinfo) |
| 550 | { |
| 551 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 552 | struct sigmatel_spec *spec = codec->spec; |
| 553 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 554 | } |
| 555 | |
| 556 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 557 | struct snd_ctl_elem_value *ucontrol) |
| 558 | { |
| 559 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 560 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 561 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 562 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 563 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 568 | struct snd_ctl_elem_value *ucontrol) |
| 569 | { |
| 570 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 571 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 572 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 573 | |
| 574 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 575 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 576 | } |
| 577 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 578 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 579 | struct snd_ctl_elem_info *uinfo) |
| 580 | { |
| 581 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 582 | struct sigmatel_spec *spec = codec->spec; |
| 583 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 584 | } |
| 585 | |
| 586 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 587 | struct snd_ctl_elem_value *ucontrol) |
| 588 | { |
| 589 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 590 | struct sigmatel_spec *spec = codec->spec; |
| 591 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 592 | |
| 593 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 598 | struct snd_ctl_elem_value *ucontrol) |
| 599 | { |
| 600 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 601 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 602 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 603 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 604 | int err, val; |
| 605 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 606 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 607 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 608 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 609 | if (err < 0) |
| 610 | return err; |
| 611 | |
| 612 | if (spec->spdif_mute) { |
| 613 | if (smux_idx == 0) |
| 614 | nid = spec->multiout.dig_out_nid; |
| 615 | else |
| 616 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 617 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 618 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 619 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 620 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 621 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 622 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 623 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 624 | } |
| 625 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 626 | } |
| 627 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 628 | 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] | 629 | { |
| 630 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 631 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 632 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 633 | } |
| 634 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 635 | 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] | 636 | { |
| 637 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 638 | struct sigmatel_spec *spec = codec->spec; |
| 639 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 640 | |
| 641 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 642 | return 0; |
| 643 | } |
| 644 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 645 | 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] | 646 | { |
| 647 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 648 | struct sigmatel_spec *spec = codec->spec; |
| 649 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 650 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 651 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 652 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 653 | } |
| 654 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 655 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 656 | struct snd_ctl_elem_info *uinfo) |
| 657 | { |
| 658 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 659 | struct sigmatel_spec *spec = codec->spec; |
| 660 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 661 | } |
| 662 | |
| 663 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 664 | struct snd_ctl_elem_value *ucontrol) |
| 665 | { |
| 666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 667 | struct sigmatel_spec *spec = codec->spec; |
| 668 | |
| 669 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 670 | return 0; |
| 671 | } |
| 672 | |
| 673 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 674 | struct snd_ctl_elem_value *ucontrol) |
| 675 | { |
| 676 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 677 | struct sigmatel_spec *spec = codec->spec; |
| 678 | |
| 679 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 680 | spec->mono_nid, &spec->cur_mmux); |
| 681 | } |
| 682 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 683 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 684 | struct snd_ctl_elem_info *uinfo) |
| 685 | { |
| 686 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 687 | struct sigmatel_spec *spec = codec->spec; |
| 688 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 689 | } |
| 690 | |
| 691 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 692 | struct snd_ctl_elem_value *ucontrol) |
| 693 | { |
| 694 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 695 | struct sigmatel_spec *spec = codec->spec; |
| 696 | |
| 697 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 698 | return 0; |
| 699 | } |
| 700 | |
| 701 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 702 | struct snd_ctl_elem_value *ucontrol) |
| 703 | { |
| 704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 705 | struct sigmatel_spec *spec = codec->spec; |
| 706 | struct snd_kcontrol *ctl = |
| 707 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 708 | if (!ctl) |
| 709 | return -EINVAL; |
| 710 | |
| 711 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 712 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 713 | |
| 714 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 715 | 0, &spec->cur_amux); |
| 716 | } |
| 717 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 718 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 719 | |
| 720 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 721 | struct snd_ctl_elem_value *ucontrol) |
| 722 | { |
| 723 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 724 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 725 | struct sigmatel_spec *spec = codec->spec; |
| 726 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 727 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 728 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 729 | return 0; |
| 730 | } |
| 731 | |
| 732 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 733 | struct snd_ctl_elem_value *ucontrol) |
| 734 | { |
| 735 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 736 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 737 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 738 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 739 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 740 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 741 | idx_val = spec->aloopback_mask << idx; |
| 742 | if (ucontrol->value.integer.value[0]) |
| 743 | val = spec->aloopback | idx_val; |
| 744 | else |
| 745 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 746 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 747 | return 0; |
| 748 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 749 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 750 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 751 | /* Only return the bits defined by the shift value of the |
| 752 | * first two bytes of the mask |
| 753 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 754 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 755 | kcontrol->private_value & 0xFFFF, 0x0); |
| 756 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 757 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 758 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 759 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 760 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 761 | } else { |
| 762 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 763 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 767 | kcontrol->private_value >> 16, dac_mode); |
| 768 | |
| 769 | return 1; |
| 770 | } |
| 771 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 772 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 773 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 774 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 775 | {} |
| 776 | }; |
| 777 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 778 | static struct hda_verb stac9200_eapd_init[] = { |
| 779 | /* set dac0mux for dac converter */ |
| 780 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 781 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 782 | {} |
| 783 | }; |
| 784 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 785 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 786 | /* set master volume and direct control */ |
| 787 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 788 | /* setup adcs to point to mixer */ |
| 789 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 790 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 791 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 792 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 793 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 794 | /* setup import muxs */ |
| 795 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 796 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 797 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 798 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 799 | {} |
| 800 | }; |
| 801 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 802 | static struct hda_verb dell_eq_core_init[] = { |
| 803 | /* set master volume to max value without distortion |
| 804 | * and direct control */ |
| 805 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 806 | /* setup adcs to point to mixer */ |
| 807 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 808 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 809 | /* setup import muxs */ |
| 810 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 811 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 812 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 813 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 814 | {} |
| 815 | }; |
| 816 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 817 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 818 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 819 | /* setup adcs to point to mixer */ |
| 820 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 821 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 822 | /* setup import muxs */ |
| 823 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 824 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 825 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 826 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 827 | {} |
| 828 | }; |
| 829 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 830 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 831 | /* set master volume and direct control */ |
| 832 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 833 | /* setup adcs to point to mixer */ |
| 834 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 835 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 836 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 837 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 838 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 839 | /* setup import muxs */ |
| 840 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 841 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 842 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 843 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 844 | {} |
| 845 | }; |
| 846 | |
| 847 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 848 | /* set master volume and direct control */ |
| 849 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 850 | /* dac3 is connected to import3 mux */ |
| 851 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 852 | /* setup adcs to point to mixer */ |
| 853 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 854 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 855 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 856 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 857 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 858 | /* setup import muxs */ |
| 859 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 860 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 861 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 862 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 863 | {} |
| 864 | }; |
| 865 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 866 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 867 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 868 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 869 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 870 | |
| 871 | /* power state controls amps */ |
| 872 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 873 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 874 | }; |
| 875 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 876 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 877 | /* set master volume and direct control */ |
| 878 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 879 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 880 | }; |
| 881 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 882 | #define HD_DISABLE_PORTF 1 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 883 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 884 | /* start of config #1 */ |
| 885 | |
| 886 | /* connect port 0f to audio mixer */ |
| 887 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 888 | /* start of config #2 */ |
| 889 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 890 | /* set master volume and direct control */ |
| 891 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 892 | {} |
| 893 | }; |
| 894 | |
| 895 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 896 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 897 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 898 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 899 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 900 | {} |
| 901 | }; |
| 902 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 903 | static struct hda_verb stac925x_core_init[] = { |
| 904 | /* set dac0mux for dac converter */ |
| 905 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 906 | /* mute the master volume */ |
| 907 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 908 | {} |
| 909 | }; |
| 910 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 911 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 912 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 913 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 914 | {} |
| 915 | }; |
| 916 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 917 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 918 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 919 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 920 | /* unmute node 0x1b */ |
| 921 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 922 | /* select node 0x03 as DAC */ |
| 923 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 924 | {} |
| 925 | }; |
| 926 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 927 | static struct hda_verb stac927x_core_init[] = { |
| 928 | /* set master volume and direct control */ |
| 929 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 930 | /* enable analog pc beep path */ |
| 931 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 932 | {} |
| 933 | }; |
| 934 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 935 | static struct hda_verb stac9205_core_init[] = { |
| 936 | /* set master volume and direct control */ |
| 937 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 938 | /* enable analog pc beep path */ |
| 939 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 940 | {} |
| 941 | }; |
| 942 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 943 | #define STAC_MONO_MUX \ |
| 944 | { \ |
| 945 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 946 | .name = "Mono Mux", \ |
| 947 | .count = 1, \ |
| 948 | .info = stac92xx_mono_mux_enum_info, \ |
| 949 | .get = stac92xx_mono_mux_enum_get, \ |
| 950 | .put = stac92xx_mono_mux_enum_put, \ |
| 951 | } |
| 952 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 953 | #define STAC_AMP_MUX \ |
| 954 | { \ |
| 955 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 956 | .name = "Amp Selector Capture Switch", \ |
| 957 | .count = 1, \ |
| 958 | .info = stac92xx_amp_mux_enum_info, \ |
| 959 | .get = stac92xx_amp_mux_enum_get, \ |
| 960 | .put = stac92xx_amp_mux_enum_put, \ |
| 961 | } |
| 962 | |
| 963 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 964 | { \ |
| 965 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 966 | .name = xname, \ |
| 967 | .index = 0, \ |
| 968 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 969 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 970 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 971 | .info = stac92xx_amp_volume_info, \ |
| 972 | .get = stac92xx_amp_volume_get, \ |
| 973 | .put = stac92xx_amp_volume_put, \ |
| 974 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 975 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 976 | } |
| 977 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 978 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 979 | { \ |
| 980 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 981 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 982 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 983 | .info = stac92xx_aloopback_info, \ |
| 984 | .get = stac92xx_aloopback_get, \ |
| 985 | .put = stac92xx_aloopback_put, \ |
| 986 | .private_value = verb_read | (verb_write << 16), \ |
| 987 | } |
| 988 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 989 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 990 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 991 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 992 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 993 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 994 | { } /* end */ |
| 995 | }; |
| 996 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 997 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 998 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 999 | /* start of config #1 */ |
| 1000 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1001 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1002 | |
| 1003 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1004 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1005 | |
| 1006 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1007 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1008 | |
| 1009 | /* start of config #2 */ |
| 1010 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1011 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1012 | |
| 1013 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1014 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1015 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1016 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1017 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1018 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1019 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1020 | |
| 1021 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1022 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1023 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1024 | { } /* end */ |
| 1025 | }; |
| 1026 | |
| 1027 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1028 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1029 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1030 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1031 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1032 | |
| 1033 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1034 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1035 | |
| 1036 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1037 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1038 | |
| 1039 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1040 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1041 | |
| 1042 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1043 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1044 | |
| 1045 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1046 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1047 | |
| 1048 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1049 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1050 | { } /* end */ |
| 1051 | }; |
| 1052 | |
| 1053 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1054 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1055 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1056 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1057 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1058 | |
| 1059 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1060 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1061 | |
| 1062 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1063 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1064 | |
| 1065 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1066 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1067 | |
| 1068 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1069 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1070 | |
| 1071 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1072 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1073 | |
| 1074 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1075 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1076 | { } /* end */ |
| 1077 | }; |
| 1078 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1079 | |
| 1080 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1081 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1082 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1083 | |
| 1084 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1085 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1086 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1087 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1088 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1089 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1090 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1091 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1092 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1093 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1094 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1095 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1096 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1097 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1098 | |
| 1099 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1100 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1101 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1102 | */ |
| 1103 | { } /* end */ |
| 1104 | }; |
| 1105 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1106 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1107 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1108 | |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1109 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1110 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1111 | |
| 1112 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1113 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1114 | /* analog pc-beep replaced with digital beep support */ |
| 1115 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1116 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1117 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1118 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1119 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1120 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1121 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1122 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1123 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1124 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1125 | |
| 1126 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1127 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1128 | |
| 1129 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1130 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1131 | { } /* end */ |
| 1132 | }; |
| 1133 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1134 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1135 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
| 1136 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1137 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1138 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1139 | |
| 1140 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1141 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1142 | { } /* end */ |
| 1143 | }; |
| 1144 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1145 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1146 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1147 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1148 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1149 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1150 | { } /* end */ |
| 1151 | }; |
| 1152 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1153 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1154 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1155 | |
| 1156 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1157 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1158 | |
| 1159 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1160 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1161 | { } /* end */ |
| 1162 | }; |
| 1163 | |
| 1164 | /* This needs to be generated dynamically based on sequence */ |
| 1165 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1166 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1167 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1168 | |
| 1169 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1170 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1171 | { } /* end */ |
| 1172 | }; |
| 1173 | |
| 1174 | |
| 1175 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1176 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1177 | |
| 1178 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1179 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1180 | |
| 1181 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1182 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1183 | |
| 1184 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1185 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1186 | { } /* end */ |
| 1187 | }; |
| 1188 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1189 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1190 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1191 | .name = "Digital Input Source", |
| 1192 | /* count set later */ |
| 1193 | .info = stac92xx_dmux_enum_info, |
| 1194 | .get = stac92xx_dmux_enum_get, |
| 1195 | .put = stac92xx_dmux_enum_put, |
| 1196 | }; |
| 1197 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1198 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1199 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1200 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1201 | /* count set later */ |
| 1202 | .info = stac92xx_smux_enum_info, |
| 1203 | .get = stac92xx_smux_enum_get, |
| 1204 | .put = stac92xx_smux_enum_put, |
| 1205 | }; |
| 1206 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1207 | static const char *slave_vols[] = { |
| 1208 | "Front Playback Volume", |
| 1209 | "Surround Playback Volume", |
| 1210 | "Center Playback Volume", |
| 1211 | "LFE Playback Volume", |
| 1212 | "Side Playback Volume", |
| 1213 | "Headphone Playback Volume", |
| 1214 | "Headphone Playback Volume", |
| 1215 | "Speaker Playback Volume", |
| 1216 | "External Speaker Playback Volume", |
| 1217 | "Speaker2 Playback Volume", |
| 1218 | NULL |
| 1219 | }; |
| 1220 | |
| 1221 | static const char *slave_sws[] = { |
| 1222 | "Front Playback Switch", |
| 1223 | "Surround Playback Switch", |
| 1224 | "Center Playback Switch", |
| 1225 | "LFE Playback Switch", |
| 1226 | "Side Playback Switch", |
| 1227 | "Headphone Playback Switch", |
| 1228 | "Headphone Playback Switch", |
| 1229 | "Speaker Playback Switch", |
| 1230 | "External Speaker Playback Switch", |
| 1231 | "Speaker2 Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1232 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1233 | NULL |
| 1234 | }; |
| 1235 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1236 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1237 | 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] | 1238 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1239 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1240 | { |
| 1241 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1242 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1243 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1244 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1245 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1246 | |
| 1247 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1248 | if (err < 0) |
| 1249 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1250 | |
| 1251 | for (i = 0; i < spec->num_mixers; i++) { |
| 1252 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1253 | if (err < 0) |
| 1254 | return err; |
| 1255 | } |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1256 | if (spec->num_dmuxes > 0) { |
| 1257 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1258 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1259 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1260 | if (err < 0) |
| 1261 | return err; |
| 1262 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1263 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1264 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1265 | struct hda_input_mux *smux = &spec->private_smux; |
| 1266 | /* check for mute support on SPDIF out */ |
| 1267 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1268 | smux->items[smux->num_items].label = "Off"; |
| 1269 | smux->items[smux->num_items].index = 0; |
| 1270 | smux->num_items++; |
| 1271 | spec->spdif_mute = 1; |
| 1272 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1273 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1274 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1275 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1276 | if (err < 0) |
| 1277 | return err; |
| 1278 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1279 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1280 | if (spec->multiout.dig_out_nid) { |
| 1281 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1282 | if (err < 0) |
| 1283 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1284 | err = snd_hda_create_spdif_share_sw(codec, |
| 1285 | &spec->multiout); |
| 1286 | if (err < 0) |
| 1287 | return err; |
| 1288 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1289 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1290 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1291 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1292 | if (err < 0) |
| 1293 | return err; |
| 1294 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1295 | |
| 1296 | /* if we have no master control, let's create it */ |
| 1297 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1298 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1299 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1300 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1301 | /* correct volume offset */ |
| 1302 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1303 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1304 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1305 | if (err < 0) |
| 1306 | return err; |
| 1307 | } |
| 1308 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1309 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1310 | NULL, slave_sws); |
| 1311 | if (err < 0) |
| 1312 | return err; |
| 1313 | } |
| 1314 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1315 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1316 | |
| 1317 | /* create jack input elements */ |
| 1318 | if (spec->hp_detect) { |
| 1319 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1320 | int type = SND_JACK_HEADPHONE; |
| 1321 | nid = cfg->hp_pins[i]; |
| 1322 | /* jack detection */ |
| 1323 | if (cfg->hp_outs == i) |
| 1324 | type |= SND_JACK_LINEOUT; |
| 1325 | err = stac92xx_add_jack(codec, nid, type); |
| 1326 | if (err < 0) |
| 1327 | return err; |
| 1328 | } |
| 1329 | } |
| 1330 | for (i = 0; i < cfg->line_outs; i++) { |
| 1331 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1332 | SND_JACK_LINEOUT); |
| 1333 | if (err < 0) |
| 1334 | return err; |
| 1335 | } |
| 1336 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1337 | nid = cfg->input_pins[i]; |
| 1338 | if (nid) { |
| 1339 | err = stac92xx_add_jack(codec, nid, |
| 1340 | SND_JACK_MICROPHONE); |
| 1341 | if (err < 0) |
| 1342 | return err; |
| 1343 | } |
| 1344 | } |
| 1345 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1346 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1347 | } |
| 1348 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1349 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1350 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1351 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1352 | }; |
| 1353 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1354 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1355 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1356 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1357 | }; |
| 1358 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1359 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1360 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1361 | }; |
| 1362 | |
| 1363 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1364 | STAC 9200 pin configs for |
| 1365 | 102801A8 |
| 1366 | 102801DE |
| 1367 | 102801E8 |
| 1368 | */ |
| 1369 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1370 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1371 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1372 | }; |
| 1373 | |
| 1374 | /* |
| 1375 | STAC 9200 pin configs for |
| 1376 | 102801C0 |
| 1377 | 102801C1 |
| 1378 | */ |
| 1379 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1380 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1381 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1382 | }; |
| 1383 | |
| 1384 | /* |
| 1385 | STAC 9200 pin configs for |
| 1386 | 102801C4 (Dell Dimension E310) |
| 1387 | 102801C5 |
| 1388 | 102801C7 |
| 1389 | 102801D9 |
| 1390 | 102801DA |
| 1391 | 102801E3 |
| 1392 | */ |
| 1393 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1394 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1395 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1396 | }; |
| 1397 | |
| 1398 | |
| 1399 | /* |
| 1400 | STAC 9200-32 pin configs for |
| 1401 | 102801B5 (Dell Inspiron 630m) |
| 1402 | 102801D8 (Dell Inspiron 640m) |
| 1403 | */ |
| 1404 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1405 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1406 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1407 | }; |
| 1408 | |
| 1409 | /* |
| 1410 | STAC 9200-32 pin configs for |
| 1411 | 102801C2 (Dell Latitude D620) |
| 1412 | 102801C8 |
| 1413 | 102801CC (Dell Latitude D820) |
| 1414 | 102801D4 |
| 1415 | 102801D6 |
| 1416 | */ |
| 1417 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1418 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1419 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1420 | }; |
| 1421 | |
| 1422 | /* |
| 1423 | STAC 9200-32 pin configs for |
| 1424 | 102801CE (Dell XPS M1710) |
| 1425 | 102801CF (Dell Precision M90) |
| 1426 | */ |
| 1427 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1428 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1429 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1430 | }; |
| 1431 | |
| 1432 | /* |
| 1433 | STAC 9200-32 pin configs for |
| 1434 | 102801C9 |
| 1435 | 102801CA |
| 1436 | 102801CB (Dell Latitude 120L) |
| 1437 | 102801D3 |
| 1438 | */ |
| 1439 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1440 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1441 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1442 | }; |
| 1443 | |
| 1444 | /* |
| 1445 | STAC 9200-32 pin configs for |
| 1446 | 102801BD (Dell Inspiron E1505n) |
| 1447 | 102801EE |
| 1448 | 102801EF |
| 1449 | */ |
| 1450 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1451 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1452 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1453 | }; |
| 1454 | |
| 1455 | /* |
| 1456 | STAC 9200-32 pin configs for |
| 1457 | 102801F5 (Dell Inspiron 1501) |
| 1458 | 102801F6 |
| 1459 | */ |
| 1460 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1461 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1462 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1463 | }; |
| 1464 | |
| 1465 | /* |
| 1466 | STAC 9200-32 |
| 1467 | 102801CD (Dell Inspiron E1705/9400) |
| 1468 | */ |
| 1469 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1470 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1471 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1472 | }; |
| 1473 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1474 | static unsigned int oqo9200_pin_configs[8] = { |
| 1475 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1476 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1477 | }; |
| 1478 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1479 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1480 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1481 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1482 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1483 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1484 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1485 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1486 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1487 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1488 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1489 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1490 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1491 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1492 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1493 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1494 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1495 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1496 | }; |
| 1497 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1498 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 1499 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1500 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1501 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1502 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1503 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1504 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1505 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1506 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1507 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1508 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1509 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1510 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1511 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1512 | [STAC_9200_M4] = "gateway-m4", |
| 1513 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1514 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1515 | }; |
| 1516 | |
| 1517 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1518 | /* SigmaTel reference board */ |
| 1519 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1520 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1521 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1522 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1523 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1524 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1525 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1526 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1527 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1528 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1529 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1530 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1531 | "unknown Dell", STAC_9200_DELL_D22), |
| 1532 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1533 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1534 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1535 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1536 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1537 | "unknown Dell", STAC_9200_DELL_D23), |
| 1538 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1539 | "unknown Dell", STAC_9200_DELL_D23), |
| 1540 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1541 | "unknown Dell", STAC_9200_DELL_M22), |
| 1542 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1543 | "unknown Dell", STAC_9200_DELL_M24), |
| 1544 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1545 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1546 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1547 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1548 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1549 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1550 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1551 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1552 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1553 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1554 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1555 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1556 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1557 | "unknown Dell", STAC_9200_DELL_M22), |
| 1558 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1559 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1560 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1561 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1562 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1563 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1564 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1565 | "unknown Dell", STAC_9200_DELL_D23), |
| 1566 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1567 | "unknown Dell", STAC_9200_DELL_D23), |
| 1568 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1569 | "unknown Dell", STAC_9200_DELL_D21), |
| 1570 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1571 | "unknown Dell", STAC_9200_DELL_D23), |
| 1572 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1573 | "unknown Dell", STAC_9200_DELL_D21), |
| 1574 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1575 | "unknown Dell", STAC_9200_DELL_M25), |
| 1576 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1577 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1578 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1579 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1580 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1581 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1582 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1583 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1584 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1585 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1586 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1587 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1588 | /* OQO Mobile */ |
| 1589 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1590 | {} /* terminator */ |
| 1591 | }; |
| 1592 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1593 | static unsigned int ref925x_pin_configs[8] = { |
| 1594 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1595 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1596 | }; |
| 1597 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1598 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1599 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1600 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1601 | }; |
| 1602 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1603 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1604 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1605 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1606 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1607 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1608 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1609 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1610 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1611 | }; |
| 1612 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1613 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1614 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1615 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1616 | }; |
| 1617 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1618 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1619 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1620 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1621 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1622 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1623 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1624 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1625 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1626 | }; |
| 1627 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1628 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1629 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1630 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1631 | }; |
| 1632 | |
| 1633 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1634 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1635 | [STAC_M1] = stac925xM1_pin_configs, |
| 1636 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1637 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1638 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1639 | [STAC_M3] = stac925xM3_pin_configs, |
| 1640 | [STAC_M5] = stac925xM5_pin_configs, |
| 1641 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1642 | }; |
| 1643 | |
| 1644 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 1645 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1646 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1647 | [STAC_M1] = "m1", |
| 1648 | [STAC_M1_2] = "m1-2", |
| 1649 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1650 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1651 | [STAC_M3] = "m3", |
| 1652 | [STAC_M5] = "m5", |
| 1653 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1654 | }; |
| 1655 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1656 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1657 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1658 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1659 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1660 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1661 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1662 | /* Not sure about the brand name for those */ |
| 1663 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1664 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1665 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1666 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1667 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1668 | }; |
| 1669 | |
| 1670 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1671 | /* SigmaTel reference board */ |
| 1672 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1673 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1674 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1675 | |
| 1676 | /* Default table for unknown ID */ |
| 1677 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1678 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1679 | {} /* terminator */ |
| 1680 | }; |
| 1681 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1682 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1683 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1684 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1685 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1686 | 0x01452050, |
| 1687 | }; |
| 1688 | |
| 1689 | static unsigned int dell_m6_pin_configs[13] = { |
| 1690 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1691 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1692 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1693 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1694 | }; |
| 1695 | |
| 1696 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1697 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1698 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1699 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1700 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1701 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1702 | }; |
| 1703 | |
| 1704 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 1705 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1706 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1707 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1708 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1709 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1710 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1711 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1712 | }; |
| 1713 | |
| 1714 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1715 | /* SigmaTel reference board */ |
| 1716 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1717 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1718 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1719 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1720 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1721 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1722 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1723 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1724 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1725 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1726 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1727 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1728 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1729 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1730 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1731 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1732 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1733 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1734 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1735 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1736 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1737 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1738 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1739 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1740 | {} /* terminator */ |
| 1741 | }; |
| 1742 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1743 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1744 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1745 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1746 | 0x01451160, 0x98560170, |
| 1747 | }; |
| 1748 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1749 | static unsigned int dell_s14_pin_configs[10] = { |
| 1750 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1751 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1752 | 0x40f000f0, 0x40f000f0, |
| 1753 | }; |
| 1754 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1755 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1756 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1757 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1758 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1759 | }; |
| 1760 | |
| 1761 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 1762 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1763 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1764 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1765 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1766 | }; |
| 1767 | |
| 1768 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1769 | /* SigmaTel reference board */ |
| 1770 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1771 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1772 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1773 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1774 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1775 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1776 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1777 | }; |
| 1778 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1779 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1780 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1781 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1782 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1783 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1784 | }; |
| 1785 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1786 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1787 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1788 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1789 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1790 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1791 | }; |
| 1792 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1793 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1794 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1795 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1796 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1797 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1798 | }; |
| 1799 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1800 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1801 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1802 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1803 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1804 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1805 | }; |
| 1806 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1807 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1808 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1809 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1810 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1811 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1812 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1813 | [STAC_HP_DV5] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1814 | }; |
| 1815 | |
| 1816 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 1817 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1818 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1819 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1820 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1821 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1822 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1823 | [STAC_HP_DV5] = "hp-dv5", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1824 | }; |
| 1825 | |
| 1826 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1827 | /* SigmaTel reference board */ |
| 1828 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1829 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1830 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1831 | "DFI LanParty", STAC_92HD71BXX_REF), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1832 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1833 | "HP dv4-7", STAC_HP_DV5), |
| 1834 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1835 | "HP dv4-7", STAC_HP_DV5), |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1836 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1837 | "HP mini 1000", STAC_HP_M4), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1838 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1839 | "unknown Dell", STAC_DELL_M4_1), |
| 1840 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1841 | "unknown Dell", STAC_DELL_M4_1), |
| 1842 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1843 | "unknown Dell", STAC_DELL_M4_1), |
| 1844 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1845 | "unknown Dell", STAC_DELL_M4_1), |
| 1846 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1847 | "unknown Dell", STAC_DELL_M4_1), |
| 1848 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1849 | "unknown Dell", STAC_DELL_M4_1), |
| 1850 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1851 | "unknown Dell", STAC_DELL_M4_1), |
| 1852 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1853 | "unknown Dell", STAC_DELL_M4_2), |
| 1854 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1855 | "unknown Dell", STAC_DELL_M4_2), |
| 1856 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1857 | "unknown Dell", STAC_DELL_M4_2), |
| 1858 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1859 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1860 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1861 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1862 | {} /* terminator */ |
| 1863 | }; |
| 1864 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1865 | static unsigned int ref922x_pin_configs[10] = { |
| 1866 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1867 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1868 | 0x40000100, 0x40000100, |
| 1869 | }; |
| 1870 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1871 | /* |
| 1872 | STAC 922X pin configs for |
| 1873 | 102801A7 |
| 1874 | 102801AB |
| 1875 | 102801A9 |
| 1876 | 102801D1 |
| 1877 | 102801D2 |
| 1878 | */ |
| 1879 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1880 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1881 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1882 | 0x01813122, 0x400001f2, |
| 1883 | }; |
| 1884 | |
| 1885 | /* |
| 1886 | STAC 922X pin configs for |
| 1887 | 102801AC |
| 1888 | 102801D0 |
| 1889 | */ |
| 1890 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1891 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1892 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1893 | 0x01813122, 0x400001f1, |
| 1894 | }; |
| 1895 | |
| 1896 | /* |
| 1897 | STAC 922X pin configs for |
| 1898 | 102801BF |
| 1899 | */ |
| 1900 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1901 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1902 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1903 | 0x40C003f1, 0x405003f0, |
| 1904 | }; |
| 1905 | |
| 1906 | /* |
| 1907 | STAC 9221 A1 pin configs for |
| 1908 | 102801D7 (Dell XPS M1210) |
| 1909 | */ |
| 1910 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1911 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1912 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1913 | 0x508003f3, 0x405003f4, |
| 1914 | }; |
| 1915 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1916 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1917 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1918 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1919 | 0x02a19120, 0x40000100, |
| 1920 | }; |
| 1921 | |
| 1922 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1923 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1924 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1925 | 0x02a19320, 0x40000100, |
| 1926 | }; |
| 1927 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1928 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1929 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1930 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1931 | 0x400000fc, 0x400000fb, |
| 1932 | }; |
| 1933 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1934 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1935 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1936 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1937 | 0x400000fc, 0x400000fb, |
| 1938 | }; |
| 1939 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1940 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1941 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1942 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 1943 | 0x400000fc, 0x400000fb, |
| 1944 | }; |
| 1945 | |
| 1946 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 1947 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1948 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1949 | 0x400000fc, 0x400000fb, |
| 1950 | }; |
| 1951 | |
| 1952 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 1953 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1954 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1955 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1956 | }; |
| 1957 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1958 | static unsigned int ecs202_pin_configs[10] = { |
| 1959 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 1960 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 1961 | 0x9037012e, 0x40e000f2, |
| 1962 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1963 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1964 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1965 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1966 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 1967 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1968 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 1969 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 1970 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 1971 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 1972 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1973 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1974 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1975 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 1976 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 1977 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 1978 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 1979 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 1980 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1981 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1982 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 1983 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 1984 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 1985 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1986 | }; |
| 1987 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1988 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 1989 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1990 | [STAC_D945_REF] = "ref", |
| 1991 | [STAC_D945GTP5] = "5stack", |
| 1992 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1993 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 1994 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 1995 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 1996 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 1997 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1998 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1999 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2000 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2001 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2002 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2003 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2004 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2005 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2006 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2007 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2008 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2009 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2010 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2011 | }; |
| 2012 | |
| 2013 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2014 | /* SigmaTel reference board */ |
| 2015 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2016 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2017 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2018 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2019 | /* Intel 945G based systems */ |
| 2020 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2021 | "Intel D945G", STAC_D945GTP3), |
| 2022 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2023 | "Intel D945G", STAC_D945GTP3), |
| 2024 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2025 | "Intel D945G", STAC_D945GTP3), |
| 2026 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2027 | "Intel D945G", STAC_D945GTP3), |
| 2028 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2029 | "Intel D945G", STAC_D945GTP3), |
| 2030 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2031 | "Intel D945G", STAC_D945GTP3), |
| 2032 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2033 | "Intel D945G", STAC_D945GTP3), |
| 2034 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2035 | "Intel D945G", STAC_D945GTP3), |
| 2036 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2037 | "Intel D945G", STAC_D945GTP3), |
| 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2039 | "Intel D945G", STAC_D945GTP3), |
| 2040 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2041 | "Intel D945G", STAC_D945GTP3), |
| 2042 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2043 | "Intel D945G", STAC_D945GTP3), |
| 2044 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2045 | "Intel D945G", STAC_D945GTP3), |
| 2046 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2047 | "Intel D945G", STAC_D945GTP3), |
| 2048 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2049 | "Intel D945G", STAC_D945GTP3), |
| 2050 | /* Intel D945G 5-stack systems */ |
| 2051 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2052 | "Intel D945G", STAC_D945GTP5), |
| 2053 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2054 | "Intel D945G", STAC_D945GTP5), |
| 2055 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2056 | "Intel D945G", STAC_D945GTP5), |
| 2057 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2058 | "Intel D945G", STAC_D945GTP5), |
| 2059 | /* Intel 945P based systems */ |
| 2060 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2061 | "Intel D945P", STAC_D945GTP3), |
| 2062 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2063 | "Intel D945P", STAC_D945GTP3), |
| 2064 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2065 | "Intel D945P", STAC_D945GTP3), |
| 2066 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2067 | "Intel D945P", STAC_D945GTP3), |
| 2068 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2069 | "Intel D945P", STAC_D945GTP3), |
| 2070 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2071 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2072 | /* other intel */ |
| 2073 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2074 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2075 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2076 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2077 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2078 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2079 | /* Dell systems */ |
| 2080 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2081 | "unknown Dell", STAC_922X_DELL_D81), |
| 2082 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2083 | "unknown Dell", STAC_922X_DELL_D81), |
| 2084 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2085 | "unknown Dell", STAC_922X_DELL_D81), |
| 2086 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2087 | "unknown Dell", STAC_922X_DELL_D82), |
| 2088 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2089 | "unknown Dell", STAC_922X_DELL_M81), |
| 2090 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2091 | "unknown Dell", STAC_922X_DELL_D82), |
| 2092 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2093 | "unknown Dell", STAC_922X_DELL_D81), |
| 2094 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2095 | "unknown Dell", STAC_922X_DELL_D81), |
| 2096 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2097 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2098 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2099 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2100 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2101 | {} /* terminator */ |
| 2102 | }; |
| 2103 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2104 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2105 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2106 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2107 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2108 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2109 | }; |
| 2110 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2111 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2112 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2113 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2114 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2115 | 0x40000100, 0x40000100 |
| 2116 | }; |
| 2117 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2118 | static unsigned int d965_5st_pin_configs[14] = { |
| 2119 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2120 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2121 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2122 | 0x40000100, 0x40000100 |
| 2123 | }; |
| 2124 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2125 | static unsigned int dell_3st_pin_configs[14] = { |
| 2126 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2127 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2128 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2129 | 0x40c003fc, 0x40000100 |
| 2130 | }; |
| 2131 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2132 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2133 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2134 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2135 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2136 | [STAC_D965_5ST] = d965_5st_pin_configs, |
| 2137 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2138 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2139 | }; |
| 2140 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2141 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 2142 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2143 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2144 | [STAC_D965_REF] = "ref", |
| 2145 | [STAC_D965_3ST] = "3stack", |
| 2146 | [STAC_D965_5ST] = "5stack", |
| 2147 | [STAC_DELL_3ST] = "dell-3stack", |
| 2148 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2149 | }; |
| 2150 | |
| 2151 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2152 | /* SigmaTel reference board */ |
| 2153 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2154 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2155 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2156 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2157 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2158 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2159 | 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] | 2160 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2161 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2162 | "Intel D965", STAC_D965_3ST), |
| 2163 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2164 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2165 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2166 | 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] | 2167 | 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] | 2168 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2169 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2170 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2171 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2172 | 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] | 2173 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2174 | 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] | 2175 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2176 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2177 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2178 | 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] | 2179 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2180 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2181 | "Intel D965", STAC_D965_5ST), |
| 2182 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2183 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2184 | {} /* terminator */ |
| 2185 | }; |
| 2186 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2187 | static unsigned int ref9205_pin_configs[12] = { |
| 2188 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2189 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2190 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2191 | }; |
| 2192 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2193 | /* |
| 2194 | STAC 9205 pin configs for |
| 2195 | 102801F1 |
| 2196 | 102801F2 |
| 2197 | 102801FC |
| 2198 | 102801FD |
| 2199 | 10280204 |
| 2200 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2201 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2202 | */ |
| 2203 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2204 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2205 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2206 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2207 | }; |
| 2208 | |
| 2209 | /* |
| 2210 | STAC 9205 pin configs for |
| 2211 | 102801F9 |
| 2212 | 102801FA |
| 2213 | 102801FE |
| 2214 | 102801FF (Dell Precision M4300) |
| 2215 | 10280206 |
| 2216 | 10280200 |
| 2217 | 10280201 |
| 2218 | */ |
| 2219 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2220 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2221 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2222 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2223 | }; |
| 2224 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2225 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2226 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2227 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2228 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2229 | }; |
| 2230 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2231 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2232 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2233 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2234 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2235 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2236 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2237 | }; |
| 2238 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2239 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame^] | 2240 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2241 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2242 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2243 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2244 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2245 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2246 | }; |
| 2247 | |
| 2248 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2249 | /* SigmaTel reference board */ |
| 2250 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2251 | "DFI LanParty", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2252 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2253 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2254 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2255 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2256 | "unknown Dell", STAC_9205_DELL_M42), |
| 2257 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2258 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2259 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2260 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2261 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2262 | "Dell Precision", STAC_9205_DELL_M43), |
| 2263 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2264 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2265 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2266 | "unknown Dell", STAC_9205_DELL_M42), |
| 2267 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2268 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2269 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2270 | "Dell Precision", STAC_9205_DELL_M43), |
| 2271 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2272 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2273 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2274 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2275 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2276 | "Dell Precision", STAC_9205_DELL_M43), |
| 2277 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2278 | "Dell Precision", STAC_9205_DELL_M43), |
| 2279 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2280 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2281 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2282 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2283 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2284 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2285 | /* Gateway */ |
| 2286 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2287 | {} /* terminator */ |
| 2288 | }; |
| 2289 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2290 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2291 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2292 | { |
| 2293 | int i; |
| 2294 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2295 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2296 | if (!pincfgs) |
| 2297 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2298 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2299 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2300 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2301 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2302 | pincfgs[i]); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2303 | } |
| 2304 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2305 | /* |
| 2306 | * Analog playback callbacks |
| 2307 | */ |
| 2308 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2309 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2310 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2311 | { |
| 2312 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2313 | if (spec->stream_delay) |
| 2314 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2315 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2316 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2317 | } |
| 2318 | |
| 2319 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2320 | struct hda_codec *codec, |
| 2321 | unsigned int stream_tag, |
| 2322 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2323 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2324 | { |
| 2325 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2326 | 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] | 2327 | } |
| 2328 | |
| 2329 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2330 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2331 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2332 | { |
| 2333 | struct sigmatel_spec *spec = codec->spec; |
| 2334 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2335 | } |
| 2336 | |
| 2337 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2338 | * Digital playback callbacks |
| 2339 | */ |
| 2340 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2341 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2342 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2343 | { |
| 2344 | struct sigmatel_spec *spec = codec->spec; |
| 2345 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2346 | } |
| 2347 | |
| 2348 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2349 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2350 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2351 | { |
| 2352 | struct sigmatel_spec *spec = codec->spec; |
| 2353 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2354 | } |
| 2355 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2356 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2357 | struct hda_codec *codec, |
| 2358 | unsigned int stream_tag, |
| 2359 | unsigned int format, |
| 2360 | struct snd_pcm_substream *substream) |
| 2361 | { |
| 2362 | struct sigmatel_spec *spec = codec->spec; |
| 2363 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2364 | stream_tag, format, substream); |
| 2365 | } |
| 2366 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2367 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2368 | struct hda_codec *codec, |
| 2369 | struct snd_pcm_substream *substream) |
| 2370 | { |
| 2371 | struct sigmatel_spec *spec = codec->spec; |
| 2372 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2373 | } |
| 2374 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2375 | |
| 2376 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2377 | * Analog capture callbacks |
| 2378 | */ |
| 2379 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2380 | struct hda_codec *codec, |
| 2381 | unsigned int stream_tag, |
| 2382 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2383 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2384 | { |
| 2385 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2386 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2387 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2388 | if (spec->powerdown_adcs) { |
| 2389 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2390 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2391 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2392 | } |
| 2393 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2394 | return 0; |
| 2395 | } |
| 2396 | |
| 2397 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2398 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2399 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2400 | { |
| 2401 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2402 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2403 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2404 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2405 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2406 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2407 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2408 | return 0; |
| 2409 | } |
| 2410 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2411 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2412 | .substreams = 1, |
| 2413 | .channels_min = 2, |
| 2414 | .channels_max = 2, |
| 2415 | /* NID is set in stac92xx_build_pcms */ |
| 2416 | .ops = { |
| 2417 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2418 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2419 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2420 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2421 | }, |
| 2422 | }; |
| 2423 | |
| 2424 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2425 | .substreams = 1, |
| 2426 | .channels_min = 2, |
| 2427 | .channels_max = 2, |
| 2428 | /* NID is set in stac92xx_build_pcms */ |
| 2429 | }; |
| 2430 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2431 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2432 | .substreams = 1, |
| 2433 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2434 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2435 | .nid = 0x02, /* NID to query formats and rates */ |
| 2436 | .ops = { |
| 2437 | .open = stac92xx_playback_pcm_open, |
| 2438 | .prepare = stac92xx_playback_pcm_prepare, |
| 2439 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2440 | }, |
| 2441 | }; |
| 2442 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2443 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2444 | .substreams = 1, |
| 2445 | .channels_min = 2, |
| 2446 | .channels_max = 2, |
| 2447 | .nid = 0x06, /* NID to query formats and rates */ |
| 2448 | .ops = { |
| 2449 | .open = stac92xx_playback_pcm_open, |
| 2450 | .prepare = stac92xx_playback_pcm_prepare, |
| 2451 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2452 | }, |
| 2453 | }; |
| 2454 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2455 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2456 | .channels_min = 2, |
| 2457 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2458 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2459 | .ops = { |
| 2460 | .prepare = stac92xx_capture_pcm_prepare, |
| 2461 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2462 | }, |
| 2463 | }; |
| 2464 | |
| 2465 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2466 | { |
| 2467 | struct sigmatel_spec *spec = codec->spec; |
| 2468 | struct hda_pcm *info = spec->pcm_rec; |
| 2469 | |
| 2470 | codec->num_pcms = 1; |
| 2471 | codec->pcm_info = info; |
| 2472 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2473 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2474 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2475 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2476 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2477 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2478 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2479 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2480 | |
| 2481 | if (spec->alt_switch) { |
| 2482 | codec->num_pcms++; |
| 2483 | info++; |
| 2484 | info->name = "STAC92xx Analog Alt"; |
| 2485 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2486 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2487 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2488 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2489 | codec->num_pcms++; |
| 2490 | info++; |
| 2491 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2492 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2493 | if (spec->multiout.dig_out_nid) { |
| 2494 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2495 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2496 | } |
| 2497 | if (spec->dig_in_nid) { |
| 2498 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2499 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2500 | } |
| 2501 | } |
| 2502 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2503 | return 0; |
| 2504 | } |
| 2505 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2506 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 2507 | { |
| 2508 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 2509 | AC_PAR_PIN_CAP); |
| 2510 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2511 | if (pincap & AC_PINCAP_VREF_100) |
| 2512 | return AC_PINCTL_VREF_100; |
| 2513 | if (pincap & AC_PINCAP_VREF_80) |
| 2514 | return AC_PINCTL_VREF_80; |
| 2515 | if (pincap & AC_PINCAP_VREF_50) |
| 2516 | return AC_PINCTL_VREF_50; |
| 2517 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2518 | return AC_PINCTL_VREF_GRD; |
| 2519 | return 0; |
| 2520 | } |
| 2521 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2522 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2523 | |
| 2524 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2525 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2526 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2527 | } |
| 2528 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2529 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2530 | |
| 2531 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2532 | struct snd_ctl_elem_value *ucontrol) |
| 2533 | { |
| 2534 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2535 | struct sigmatel_spec *spec = codec->spec; |
| 2536 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2537 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2538 | return 0; |
| 2539 | } |
| 2540 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2541 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 2542 | unsigned char type); |
| 2543 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2544 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2545 | struct snd_ctl_elem_value *ucontrol) |
| 2546 | { |
| 2547 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2548 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2549 | int nid = kcontrol->private_value; |
| 2550 | |
| 2551 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2552 | |
| 2553 | /* check to be sure that the ports are upto date with |
| 2554 | * switch changes |
| 2555 | */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2556 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2557 | |
| 2558 | return 1; |
| 2559 | } |
| 2560 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 2561 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2562 | |
| 2563 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2564 | { |
| 2565 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2566 | struct sigmatel_spec *spec = codec->spec; |
| 2567 | int io_idx = kcontrol-> private_value & 0xff; |
| 2568 | |
| 2569 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 2570 | return 0; |
| 2571 | } |
| 2572 | |
| 2573 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2574 | { |
| 2575 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2576 | struct sigmatel_spec *spec = codec->spec; |
| 2577 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 2578 | int io_idx = kcontrol-> private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2579 | unsigned short val = !!ucontrol->value.integer.value[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2580 | |
| 2581 | spec->io_switch[io_idx] = val; |
| 2582 | |
| 2583 | if (val) |
| 2584 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2585 | else { |
| 2586 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2587 | if (io_idx) /* set VREF for mic */ |
| 2588 | pinctl |= stac92xx_get_vref(codec, nid); |
| 2589 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2590 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2591 | |
| 2592 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2593 | * appropriately according to the pin direction |
| 2594 | */ |
| 2595 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2596 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2597 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2598 | return 1; |
| 2599 | } |
| 2600 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2601 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2602 | |
| 2603 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2604 | struct snd_ctl_elem_value *ucontrol) |
| 2605 | { |
| 2606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2607 | struct sigmatel_spec *spec = codec->spec; |
| 2608 | |
| 2609 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2610 | return 0; |
| 2611 | } |
| 2612 | |
| 2613 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2614 | struct snd_ctl_elem_value *ucontrol) |
| 2615 | { |
| 2616 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2617 | struct sigmatel_spec *spec = codec->spec; |
| 2618 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2619 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2620 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2621 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2622 | return 0; |
| 2623 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2624 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2625 | |
| 2626 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2627 | spec->clfe_swap ? 0x4 : 0x0); |
| 2628 | |
| 2629 | return 1; |
| 2630 | } |
| 2631 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2632 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2633 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2634 | .name = xname, \ |
| 2635 | .index = 0, \ |
| 2636 | .info = stac92xx_hp_switch_info, \ |
| 2637 | .get = stac92xx_hp_switch_get, \ |
| 2638 | .put = stac92xx_hp_switch_put, \ |
| 2639 | } |
| 2640 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2641 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2642 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2643 | .name = xname, \ |
| 2644 | .index = 0, \ |
| 2645 | .info = stac92xx_io_switch_info, \ |
| 2646 | .get = stac92xx_io_switch_get, \ |
| 2647 | .put = stac92xx_io_switch_put, \ |
| 2648 | .private_value = xpval, \ |
| 2649 | } |
| 2650 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2651 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2652 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2653 | .name = xname, \ |
| 2654 | .index = 0, \ |
| 2655 | .info = stac92xx_clfe_switch_info, \ |
| 2656 | .get = stac92xx_clfe_switch_get, \ |
| 2657 | .put = stac92xx_clfe_switch_put, \ |
| 2658 | .private_value = xpval, \ |
| 2659 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2660 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2661 | enum { |
| 2662 | STAC_CTL_WIDGET_VOL, |
| 2663 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2664 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2665 | STAC_CTL_WIDGET_AMP_MUX, |
| 2666 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2667 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2668 | STAC_CTL_WIDGET_IO_SWITCH, |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2669 | STAC_CTL_WIDGET_CLFE_SWITCH |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2670 | }; |
| 2671 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2672 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2673 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2674 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2675 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2676 | STAC_AMP_MUX, |
| 2677 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2678 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2679 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2680 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2681 | }; |
| 2682 | |
| 2683 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2684 | static struct snd_kcontrol_new * |
| 2685 | stac_control_new(struct sigmatel_spec *spec, |
| 2686 | struct snd_kcontrol_new *ktemp, |
| 2687 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2688 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2689 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2690 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2691 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2692 | knew = snd_array_new(&spec->kctls); |
| 2693 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2694 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2695 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2696 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2697 | if (!knew->name) { |
| 2698 | /* roolback */ |
| 2699 | memset(knew, 0, sizeof(*knew)); |
| 2700 | spec->kctls.alloced--; |
| 2701 | return NULL; |
| 2702 | } |
| 2703 | return knew; |
| 2704 | } |
| 2705 | |
| 2706 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2707 | struct snd_kcontrol_new *ktemp, |
| 2708 | int idx, const char *name, |
| 2709 | unsigned long val) |
| 2710 | { |
| 2711 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2712 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2713 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2714 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2715 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2716 | return 0; |
| 2717 | } |
| 2718 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2719 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2720 | int type, int idx, const char *name, |
| 2721 | unsigned long val) |
| 2722 | { |
| 2723 | return stac92xx_add_control_temp(spec, |
| 2724 | &stac92xx_control_templates[type], |
| 2725 | idx, name, val); |
| 2726 | } |
| 2727 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2728 | |
| 2729 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2730 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2731 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2732 | { |
| 2733 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2734 | } |
| 2735 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2736 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2737 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2738 | .name = "Input Source", |
| 2739 | .info = stac92xx_mux_enum_info, |
| 2740 | .get = stac92xx_mux_enum_get, |
| 2741 | .put = stac92xx_mux_enum_put, |
| 2742 | }; |
| 2743 | |
| 2744 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2745 | { |
| 2746 | struct snd_kcontrol_new *knew; |
| 2747 | struct hda_input_mux *imux = &spec->private_imux; |
| 2748 | |
| 2749 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2750 | return 0; /* no need for input source control */ |
| 2751 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2752 | stac_input_src_temp.name); |
| 2753 | if (!knew) |
| 2754 | return -ENOMEM; |
| 2755 | knew->count = spec->num_adcs; |
| 2756 | return 0; |
| 2757 | } |
| 2758 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2759 | /* check whether the line-input can be used as line-out */ |
| 2760 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2761 | { |
| 2762 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2763 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2764 | hda_nid_t nid; |
| 2765 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2766 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2767 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2768 | return 0; |
| 2769 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
| 2770 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
| 2771 | if (pincap & AC_PINCAP_OUT) |
| 2772 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2773 | return 0; |
| 2774 | } |
| 2775 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2776 | /* check whether the mic-input can be used as line-out */ |
| 2777 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 2778 | { |
| 2779 | struct sigmatel_spec *spec = codec->spec; |
| 2780 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2781 | unsigned int def_conf, pincap; |
| 2782 | unsigned int mic_pin; |
| 2783 | |
| 2784 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2785 | return 0; |
| 2786 | mic_pin = AUTO_PIN_MIC; |
| 2787 | for (;;) { |
| 2788 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2789 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2790 | /* some laptops have an internal analog microphone |
| 2791 | * which can't be used as a output */ |
| 2792 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
| 2793 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
| 2794 | if (pincap & AC_PINCAP_OUT) |
| 2795 | return nid; |
| 2796 | } |
| 2797 | if (mic_pin == AUTO_PIN_MIC) |
| 2798 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 2799 | else |
| 2800 | break; |
| 2801 | } |
| 2802 | return 0; |
| 2803 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2804 | |
| 2805 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2806 | { |
| 2807 | int i; |
| 2808 | |
| 2809 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 2810 | if (spec->multiout.dac_nids[i] == nid) |
| 2811 | return 1; |
| 2812 | } |
| 2813 | |
| 2814 | return 0; |
| 2815 | } |
| 2816 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2817 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2818 | { |
| 2819 | int i; |
| 2820 | if (is_in_dac_nids(spec, nid)) |
| 2821 | return 1; |
| 2822 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 2823 | if (spec->hp_dacs[i] == nid) |
| 2824 | return 1; |
| 2825 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 2826 | if (spec->speaker_dacs[i] == nid) |
| 2827 | return 1; |
| 2828 | return 0; |
| 2829 | } |
| 2830 | |
| 2831 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 2832 | { |
| 2833 | struct sigmatel_spec *spec = codec->spec; |
| 2834 | int j, conn_len; |
| 2835 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 2836 | unsigned int wcaps, wtype; |
| 2837 | |
| 2838 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 2839 | HDA_MAX_CONNECTIONS); |
| 2840 | for (j = 0; j < conn_len; j++) { |
| 2841 | wcaps = snd_hda_param_read(codec, conn[j], |
| 2842 | AC_PAR_AUDIO_WIDGET_CAP); |
| 2843 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 2844 | /* we check only analog outputs */ |
| 2845 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 2846 | continue; |
| 2847 | /* if this route has a free DAC, assign it */ |
| 2848 | if (!check_all_dac_nids(spec, conn[j])) { |
| 2849 | if (conn_len > 1) { |
| 2850 | /* select this DAC in the pin's input mux */ |
| 2851 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2852 | AC_VERB_SET_CONNECT_SEL, j); |
| 2853 | } |
| 2854 | return conn[j]; |
| 2855 | } |
| 2856 | } |
| 2857 | return 0; |
| 2858 | } |
| 2859 | |
| 2860 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 2861 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 2862 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2863 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2864 | * Fill in the dac_nids table from the parsed pin configuration |
| 2865 | * This function only works when every pin in line_out_pins[] |
| 2866 | * contains atleast one DAC in its connection list. Some 92xx |
| 2867 | * codecs are not connected directly to a DAC, such as the 9200 |
| 2868 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2869 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2870 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2871 | { |
| 2872 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2873 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2874 | int i; |
| 2875 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2876 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2877 | for (i = 0; i < cfg->line_outs; i++) { |
| 2878 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2879 | dac = get_unassigned_dac(codec, nid); |
| 2880 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2881 | if (spec->multiout.num_dacs > 0) { |
| 2882 | /* we have already working output pins, |
| 2883 | * so let's drop the broken ones again |
| 2884 | */ |
| 2885 | cfg->line_outs = spec->multiout.num_dacs; |
| 2886 | break; |
| 2887 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2888 | /* error out, no available DAC found */ |
| 2889 | snd_printk(KERN_ERR |
| 2890 | "%s: No available DAC for pin 0x%x\n", |
| 2891 | __func__, nid); |
| 2892 | return -ENODEV; |
| 2893 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2894 | add_spec_dacs(spec, dac); |
| 2895 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2896 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2897 | /* add line-in as output */ |
| 2898 | nid = check_line_out_switch(codec); |
| 2899 | if (nid) { |
| 2900 | dac = get_unassigned_dac(codec, nid); |
| 2901 | if (dac) { |
| 2902 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 2903 | nid, cfg->line_outs); |
| 2904 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 2905 | cfg->line_outs++; |
| 2906 | spec->line_switch = nid; |
| 2907 | add_spec_dacs(spec, dac); |
| 2908 | } |
| 2909 | } |
| 2910 | /* add mic as output */ |
| 2911 | nid = check_mic_out_switch(codec); |
| 2912 | if (nid) { |
| 2913 | dac = get_unassigned_dac(codec, nid); |
| 2914 | if (dac) { |
| 2915 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 2916 | nid, cfg->line_outs); |
| 2917 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 2918 | cfg->line_outs++; |
| 2919 | spec->mic_switch = nid; |
| 2920 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2921 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2922 | } |
| 2923 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2924 | for (i = 0; i < cfg->hp_outs; i++) { |
| 2925 | nid = cfg->hp_pins[i]; |
| 2926 | dac = get_unassigned_dac(codec, nid); |
| 2927 | if (dac) { |
| 2928 | if (!spec->multiout.hp_nid) |
| 2929 | spec->multiout.hp_nid = dac; |
| 2930 | else |
| 2931 | add_spec_extra_dacs(spec, dac); |
| 2932 | } |
| 2933 | spec->hp_dacs[i] = dac; |
| 2934 | } |
| 2935 | |
| 2936 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 2937 | nid = cfg->speaker_pins[i]; |
| 2938 | dac = get_unassigned_dac(codec, nid); |
| 2939 | if (dac) |
| 2940 | add_spec_extra_dacs(spec, dac); |
| 2941 | spec->speaker_dacs[i] = dac; |
| 2942 | } |
| 2943 | |
| 2944 | 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] | 2945 | spec->multiout.num_dacs, |
| 2946 | spec->multiout.dac_nids[0], |
| 2947 | spec->multiout.dac_nids[1], |
| 2948 | spec->multiout.dac_nids[2], |
| 2949 | spec->multiout.dac_nids[3], |
| 2950 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2951 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2952 | return 0; |
| 2953 | } |
| 2954 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2955 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2956 | static int create_controls(struct hda_codec *codec, const char *pfx, |
| 2957 | hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2958 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2959 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2960 | char name[32]; |
| 2961 | int err; |
| 2962 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2963 | if (!spec->check_volume_offset) { |
| 2964 | unsigned int caps, step, nums, db_scale; |
| 2965 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 2966 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 2967 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 2968 | step = (step + 1) * 25; /* in .01dB unit */ |
| 2969 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 2970 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 2971 | db_scale = nums * step; |
| 2972 | /* if dB scale is over -64dB, and finer enough, |
| 2973 | * let's reduce it to half |
| 2974 | */ |
| 2975 | if (db_scale > 6400 && nums >= 0x1f) |
| 2976 | spec->volume_offset = nums / 2; |
| 2977 | spec->check_volume_offset = 1; |
| 2978 | } |
| 2979 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2980 | sprintf(name, "%s Playback Volume", pfx); |
| 2981 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2982 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 2983 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2984 | if (err < 0) |
| 2985 | return err; |
| 2986 | sprintf(name, "%s Playback Switch", pfx); |
| 2987 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 2988 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2989 | if (err < 0) |
| 2990 | return err; |
| 2991 | return 0; |
| 2992 | } |
| 2993 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2994 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2995 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2996 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2997 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 2998 | return 1; |
| 2999 | } else { |
| 3000 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3001 | spec->multiout.num_dacs++; |
| 3002 | } |
| 3003 | return 0; |
| 3004 | } |
| 3005 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3006 | 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] | 3007 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3008 | int i; |
| 3009 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3010 | if (!spec->multiout.extra_out_nid[i]) { |
| 3011 | spec->multiout.extra_out_nid[i] = nid; |
| 3012 | return 0; |
| 3013 | } |
| 3014 | } |
| 3015 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3016 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3017 | } |
| 3018 | |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3019 | static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3020 | { |
| 3021 | int i; |
| 3022 | |
| 3023 | if (spec->autocfg.line_outs != 1) |
| 3024 | return 0; |
| 3025 | if (spec->multiout.hp_nid == nid) |
| 3026 | return 0; |
| 3027 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) |
| 3028 | if (spec->multiout.extra_out_nid[i] == nid) |
| 3029 | return 0; |
| 3030 | return 1; |
| 3031 | } |
| 3032 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3033 | /* add playback controls from the parsed DAC table */ |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3034 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3035 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3036 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3037 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3038 | static const char *chname[4] = { |
| 3039 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3040 | }; |
Matthew Ranostay | d21995e | 2008-10-13 13:22:45 -0400 | [diff] [blame] | 3041 | hda_nid_t nid = 0; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3042 | int i, err; |
| 3043 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3044 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3045 | for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3046 | nid = spec->multiout.dac_nids[i]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3047 | if (i == 2) { |
| 3048 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3049 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3050 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3051 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3052 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3053 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3054 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3055 | |
| 3056 | wid_caps = get_wcaps(codec, nid); |
| 3057 | |
| 3058 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3059 | err = stac92xx_add_control(spec, |
| 3060 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3061 | "Swap Center/LFE Playback Switch", nid); |
| 3062 | |
| 3063 | if (err < 0) |
| 3064 | return err; |
| 3065 | } |
| 3066 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3067 | } else { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3068 | const char *name = chname[i]; |
| 3069 | /* if it's a single DAC, assign a better name */ |
| 3070 | if (!i && is_unique_dac(spec, nid)) { |
| 3071 | switch (cfg->line_out_type) { |
| 3072 | case AUTO_PIN_HP_OUT: |
| 3073 | name = "Headphone"; |
| 3074 | break; |
| 3075 | case AUTO_PIN_SPEAKER_OUT: |
| 3076 | name = "Speaker"; |
| 3077 | break; |
| 3078 | } |
| 3079 | } |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3080 | err = create_controls(codec, name, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3081 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3082 | return err; |
| 3083 | } |
| 3084 | } |
| 3085 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3086 | 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] | 3087 | err = stac92xx_add_control(spec, |
| 3088 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3089 | "Headphone as Line Out Switch", |
| 3090 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3091 | if (err < 0) |
| 3092 | return err; |
| 3093 | } |
| 3094 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3095 | if (spec->line_switch) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3096 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
| 3097 | "Line In as Output Switch", |
| 3098 | spec->line_switch << 8); |
| 3099 | if (err < 0) |
| 3100 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3101 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3102 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3103 | if (spec->mic_switch) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3104 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
| 3105 | "Mic as Output Switch", |
| 3106 | (spec->mic_switch << 8) | 1); |
| 3107 | if (err < 0) |
| 3108 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3109 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3110 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3111 | return 0; |
| 3112 | } |
| 3113 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3114 | /* add playback controls for Speaker and HP outputs */ |
| 3115 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3116 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3117 | { |
| 3118 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3119 | hda_nid_t nid; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3120 | int i, err, nums; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3121 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3122 | nums = 0; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3123 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3124 | static const char *pfxs[] = { |
| 3125 | "Headphone", "Headphone2", "Headphone3", |
| 3126 | }; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3127 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
| 3128 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3129 | spec->hp_detect = 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3130 | if (nums >= ARRAY_SIZE(pfxs)) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3131 | continue; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3132 | nid = spec->hp_dacs[i]; |
| 3133 | if (!nid) |
| 3134 | continue; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3135 | err = create_controls(codec, pfxs[nums++], nid, 3); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3136 | if (err < 0) |
| 3137 | return err; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3138 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3139 | nums = 0; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3140 | for (i = 0; i < cfg->speaker_outs; i++) { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3141 | static const char *pfxs[] = { |
| 3142 | "Speaker", "External Speaker", "Speaker2", |
| 3143 | }; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3144 | if (nums >= ARRAY_SIZE(pfxs)) |
| 3145 | continue; |
| 3146 | nid = spec->speaker_dacs[i]; |
| 3147 | if (!nid) |
| 3148 | continue; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3149 | err = create_controls(codec, pfxs[nums++], nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3150 | if (err < 0) |
| 3151 | return err; |
| 3152 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3153 | return 0; |
| 3154 | } |
| 3155 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3156 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3157 | static const char *stac92xx_mono_labels[4] = { |
| 3158 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3159 | }; |
| 3160 | |
| 3161 | /* create mono mux for mono out on capable codecs */ |
| 3162 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3163 | { |
| 3164 | struct sigmatel_spec *spec = codec->spec; |
| 3165 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3166 | int i, num_cons; |
| 3167 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3168 | |
| 3169 | num_cons = snd_hda_get_connections(codec, |
| 3170 | spec->mono_nid, |
| 3171 | con_lst, |
| 3172 | HDA_MAX_NUM_INPUTS); |
| 3173 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 3174 | return -EINVAL; |
| 3175 | |
| 3176 | for (i = 0; i < num_cons; i++) { |
| 3177 | mono_mux->items[mono_mux->num_items].label = |
| 3178 | stac92xx_mono_labels[i]; |
| 3179 | mono_mux->items[mono_mux->num_items].index = i; |
| 3180 | mono_mux->num_items++; |
| 3181 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3182 | |
| 3183 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3184 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3185 | } |
| 3186 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3187 | /* labels for amp mux outputs */ |
| 3188 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3189 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3190 | }; |
| 3191 | |
| 3192 | /* create amp out controls mux on capable codecs */ |
| 3193 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3194 | { |
| 3195 | struct sigmatel_spec *spec = codec->spec; |
| 3196 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3197 | int i, err; |
| 3198 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3199 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3200 | amp_mux->items[amp_mux->num_items].label = |
| 3201 | stac92xx_amp_labels[i]; |
| 3202 | amp_mux->items[amp_mux->num_items].index = i; |
| 3203 | amp_mux->num_items++; |
| 3204 | } |
| 3205 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3206 | if (spec->num_amps > 1) { |
| 3207 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3208 | "Amp Selector Capture Switch", 0); |
| 3209 | if (err < 0) |
| 3210 | return err; |
| 3211 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3212 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3213 | "Amp Capture Volume", |
| 3214 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3215 | } |
| 3216 | |
| 3217 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3218 | /* create PC beep volume controls */ |
| 3219 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3220 | hda_nid_t nid) |
| 3221 | { |
| 3222 | struct sigmatel_spec *spec = codec->spec; |
| 3223 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3224 | int err; |
| 3225 | |
| 3226 | /* check for mute support for the the amp */ |
| 3227 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3228 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3229 | "PC Beep Playback Switch", |
| 3230 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3231 | if (err < 0) |
| 3232 | return err; |
| 3233 | } |
| 3234 | |
| 3235 | /* check to see if there is volume support for the amp */ |
| 3236 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3237 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3238 | "PC Beep Playback Volume", |
| 3239 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3240 | if (err < 0) |
| 3241 | return err; |
| 3242 | } |
| 3243 | return 0; |
| 3244 | } |
| 3245 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3246 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3247 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3248 | |
| 3249 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3250 | struct snd_ctl_elem_value *ucontrol) |
| 3251 | { |
| 3252 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3253 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3254 | return 0; |
| 3255 | } |
| 3256 | |
| 3257 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3258 | struct snd_ctl_elem_value *ucontrol) |
| 3259 | { |
| 3260 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3261 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3262 | if (codec->beep->enabled != enabled) { |
| 3263 | codec->beep->enabled = enabled; |
| 3264 | return 1; |
| 3265 | } |
| 3266 | return 0; |
| 3267 | } |
| 3268 | |
| 3269 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3270 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3271 | .info = stac92xx_dig_beep_switch_info, |
| 3272 | .get = stac92xx_dig_beep_switch_get, |
| 3273 | .put = stac92xx_dig_beep_switch_put, |
| 3274 | }; |
| 3275 | |
| 3276 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3277 | { |
| 3278 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3279 | 0, "PC Beep Playback Switch", 0); |
| 3280 | } |
| 3281 | #endif |
| 3282 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3283 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3284 | { |
| 3285 | struct sigmatel_spec *spec = codec->spec; |
| 3286 | int wcaps, nid, i, err = 0; |
| 3287 | |
| 3288 | for (i = 0; i < spec->num_muxes; i++) { |
| 3289 | nid = spec->mux_nids[i]; |
| 3290 | wcaps = get_wcaps(codec, nid); |
| 3291 | |
| 3292 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3293 | err = stac92xx_add_control_idx(spec, |
| 3294 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3295 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3296 | if (err < 0) |
| 3297 | return err; |
| 3298 | } |
| 3299 | } |
| 3300 | return 0; |
| 3301 | }; |
| 3302 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3303 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3304 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3305 | }; |
| 3306 | |
| 3307 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3308 | { |
| 3309 | struct sigmatel_spec *spec = codec->spec; |
| 3310 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3311 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3312 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3313 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3314 | |
| 3315 | num_cons = snd_hda_get_connections(codec, |
| 3316 | spec->smux_nids[0], |
| 3317 | con_lst, |
| 3318 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3319 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3320 | return -EINVAL; |
| 3321 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3322 | if (!labels) |
| 3323 | labels = stac92xx_spdif_labels; |
| 3324 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3325 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3326 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3327 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3328 | spdif_mux->num_items++; |
| 3329 | } |
| 3330 | |
| 3331 | return 0; |
| 3332 | } |
| 3333 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3334 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3335 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3336 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3337 | "Digital Mic 3", "Digital Mic 4" |
| 3338 | }; |
| 3339 | |
| 3340 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3341 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3342 | const struct auto_pin_cfg *cfg) |
| 3343 | { |
| 3344 | struct sigmatel_spec *spec = codec->spec; |
| 3345 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3346 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3347 | int err, i, j; |
| 3348 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3349 | |
| 3350 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3351 | dimux->items[dimux->num_items].index = 0; |
| 3352 | dimux->num_items++; |
| 3353 | |
| 3354 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3355 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3356 | int index; |
| 3357 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3358 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3359 | unsigned int def_conf; |
| 3360 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3361 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3362 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3363 | continue; |
| 3364 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3365 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3366 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3367 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3368 | con_lst, |
| 3369 | HDA_MAX_NUM_INPUTS); |
| 3370 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3371 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3372 | index = j; |
| 3373 | goto found; |
| 3374 | } |
| 3375 | continue; |
| 3376 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3377 | wcaps = get_wcaps(codec, nid) & |
| 3378 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3379 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3380 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3381 | sprintf(name, "%s Capture Volume", |
| 3382 | stac92xx_dmic_labels[dimux->num_items]); |
| 3383 | |
| 3384 | err = stac92xx_add_control(spec, |
| 3385 | STAC_CTL_WIDGET_VOL, |
| 3386 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3387 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3388 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3389 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3390 | if (err < 0) |
| 3391 | return err; |
| 3392 | } |
| 3393 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3394 | dimux->items[dimux->num_items].label = |
| 3395 | stac92xx_dmic_labels[dimux->num_items]; |
| 3396 | dimux->items[dimux->num_items].index = index; |
| 3397 | dimux->num_items++; |
| 3398 | } |
| 3399 | |
| 3400 | return 0; |
| 3401 | } |
| 3402 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3403 | /* create playback/capture controls for input pins */ |
| 3404 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3405 | { |
| 3406 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3407 | struct hda_input_mux *imux = &spec->private_imux; |
| 3408 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3409 | int i, j, k; |
| 3410 | |
| 3411 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3412 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3413 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3414 | if (!cfg->input_pins[i]) |
| 3415 | continue; |
| 3416 | index = -1; |
| 3417 | for (j = 0; j < spec->num_muxes; j++) { |
| 3418 | int num_cons; |
| 3419 | num_cons = snd_hda_get_connections(codec, |
| 3420 | spec->mux_nids[j], |
| 3421 | con_lst, |
| 3422 | HDA_MAX_NUM_INPUTS); |
| 3423 | for (k = 0; k < num_cons; k++) |
| 3424 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3425 | index = k; |
| 3426 | goto found; |
| 3427 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3428 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3429 | continue; |
| 3430 | found: |
| 3431 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3432 | imux->items[imux->num_items].index = index; |
| 3433 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3434 | } |
| 3435 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3436 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3437 | /* |
| 3438 | * Set the current input for the muxes. |
| 3439 | * The STAC9221 has two input muxes with identical source |
| 3440 | * NID lists. Hopefully this won't get confused. |
| 3441 | */ |
| 3442 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3443 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3444 | AC_VERB_SET_CONNECT_SEL, |
| 3445 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3446 | } |
| 3447 | } |
| 3448 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3449 | return 0; |
| 3450 | } |
| 3451 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3452 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3453 | { |
| 3454 | struct sigmatel_spec *spec = codec->spec; |
| 3455 | int i; |
| 3456 | |
| 3457 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3458 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3459 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3460 | } |
| 3461 | } |
| 3462 | |
| 3463 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3464 | { |
| 3465 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3466 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3467 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3468 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3469 | hda_nid_t pin; |
| 3470 | pin = spec->autocfg.hp_pins[i]; |
| 3471 | if (pin) /* connect to front */ |
| 3472 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3473 | } |
| 3474 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3475 | hda_nid_t pin; |
| 3476 | pin = spec->autocfg.speaker_pins[i]; |
| 3477 | if (pin) /* connect to front */ |
| 3478 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3479 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3480 | } |
| 3481 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3482 | 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] | 3483 | { |
| 3484 | struct sigmatel_spec *spec = codec->spec; |
| 3485 | int err; |
| 3486 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3487 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3488 | &spec->autocfg, |
| 3489 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3490 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3491 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3492 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3493 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3494 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3495 | * be set up as multi-channel outputs. |
| 3496 | */ |
| 3497 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3498 | spec->autocfg.hp_outs > 1) { |
| 3499 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3500 | * speaker_outs so that the following routines can handle |
| 3501 | * HP pins as primary outputs. |
| 3502 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3503 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3504 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3505 | sizeof(spec->autocfg.line_out_pins)); |
| 3506 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3507 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3508 | sizeof(spec->autocfg.hp_pins)); |
| 3509 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3510 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3511 | spec->autocfg.hp_outs = 0; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3512 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3513 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3514 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3515 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3516 | u32 caps = query_amp_caps(codec, |
| 3517 | spec->autocfg.mono_out_pin, dir); |
| 3518 | hda_nid_t conn_list[1]; |
| 3519 | |
| 3520 | /* get the mixer node and then the mono mux if it exists */ |
| 3521 | if (snd_hda_get_connections(codec, |
| 3522 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3523 | snd_hda_get_connections(codec, conn_list[0], |
| 3524 | conn_list, 1)) { |
| 3525 | |
| 3526 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3527 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3528 | >> AC_WCAP_TYPE_SHIFT; |
| 3529 | /* LR swap check, some stac925x have a mux that |
| 3530 | * changes the DACs output path instead of the |
| 3531 | * mono-mux path. |
| 3532 | */ |
| 3533 | if (wid_type == AC_WID_AUD_SEL && |
| 3534 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3535 | spec->mono_nid = conn_list[0]; |
| 3536 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3537 | if (dir) { |
| 3538 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3539 | |
| 3540 | /* most mono outs have a least a mute/unmute switch */ |
| 3541 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3542 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3543 | "Mono Playback Switch", |
| 3544 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3545 | if (err < 0) |
| 3546 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3547 | /* check for volume support for the amp */ |
| 3548 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3549 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3550 | err = stac92xx_add_control(spec, |
| 3551 | STAC_CTL_WIDGET_VOL, |
| 3552 | "Mono Playback Volume", |
| 3553 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3554 | if (err < 0) |
| 3555 | return err; |
| 3556 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3557 | } |
| 3558 | |
| 3559 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3560 | AC_PINCTL_OUT_EN); |
| 3561 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3562 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3563 | if (!spec->multiout.num_dacs) { |
| 3564 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3565 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3566 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3567 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3568 | &spec->autocfg); |
| 3569 | if (err < 0) |
| 3570 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3571 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3572 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3573 | /* setup analog beep controls */ |
| 3574 | if (spec->anabeep_nid > 0) { |
| 3575 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3576 | spec->anabeep_nid); |
| 3577 | if (err < 0) |
| 3578 | return err; |
| 3579 | } |
| 3580 | |
| 3581 | /* setup digital beep controls and input device */ |
| 3582 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3583 | if (spec->digbeep_nid > 0) { |
| 3584 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3585 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3586 | |
| 3587 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3588 | if (err < 0) |
| 3589 | return err; |
| 3590 | err = snd_hda_attach_beep_device(codec, nid); |
| 3591 | if (err < 0) |
| 3592 | return err; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3593 | /* if no beep switch is available, make its own one */ |
| 3594 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3595 | if (codec->beep && |
| 3596 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3597 | err = stac92xx_beep_switch_ctl(codec); |
| 3598 | if (err < 0) |
| 3599 | return err; |
| 3600 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3601 | } |
| 3602 | #endif |
| 3603 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3604 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
| 3605 | |
| 3606 | if (err < 0) |
| 3607 | return err; |
| 3608 | |
| 3609 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
| 3610 | |
| 3611 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3612 | return err; |
| 3613 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3614 | if (spec->mono_nid > 0) { |
| 3615 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3616 | if (err < 0) |
| 3617 | return err; |
| 3618 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3619 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3620 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3621 | if (err < 0) |
| 3622 | return err; |
| 3623 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3624 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3625 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3626 | &spec->autocfg)) < 0) |
| 3627 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3628 | if (spec->num_muxes > 0) { |
| 3629 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3630 | if (err < 0) |
| 3631 | return err; |
| 3632 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3633 | if (spec->num_smuxes > 0) { |
| 3634 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3635 | if (err < 0) |
| 3636 | return err; |
| 3637 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3638 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3639 | err = stac92xx_add_input_source(spec); |
| 3640 | if (err < 0) |
| 3641 | return err; |
| 3642 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3643 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3644 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3645 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3646 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3647 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3648 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3649 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3650 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3651 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3652 | if (spec->kctls.list) |
| 3653 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3654 | |
| 3655 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3656 | if (!spec->dinput_mux) |
| 3657 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3658 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3659 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3660 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3661 | return 1; |
| 3662 | } |
| 3663 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3664 | /* add playback controls for HP output */ |
| 3665 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3666 | struct auto_pin_cfg *cfg) |
| 3667 | { |
| 3668 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3669 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3670 | unsigned int wid_caps; |
| 3671 | |
| 3672 | if (! pin) |
| 3673 | return 0; |
| 3674 | |
| 3675 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3676 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3677 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3678 | |
| 3679 | return 0; |
| 3680 | } |
| 3681 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3682 | /* add playback controls for LFE output */ |
| 3683 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3684 | struct auto_pin_cfg *cfg) |
| 3685 | { |
| 3686 | struct sigmatel_spec *spec = codec->spec; |
| 3687 | int err; |
| 3688 | hda_nid_t lfe_pin = 0x0; |
| 3689 | int i; |
| 3690 | |
| 3691 | /* |
| 3692 | * search speaker outs and line outs for a mono speaker pin |
| 3693 | * with an amp. If one is found, add LFE controls |
| 3694 | * for it. |
| 3695 | */ |
| 3696 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3697 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3698 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3699 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3700 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3701 | /* found a mono speaker with an amp, must be lfe */ |
| 3702 | lfe_pin = pin; |
| 3703 | } |
| 3704 | |
| 3705 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3706 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3707 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3708 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3709 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3710 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3711 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3712 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3713 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3714 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3715 | /* found a mono speaker with an amp, |
| 3716 | must be lfe */ |
| 3717 | lfe_pin = pin; |
| 3718 | } |
| 3719 | } |
| 3720 | } |
| 3721 | |
| 3722 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3723 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3724 | if (err < 0) |
| 3725 | return err; |
| 3726 | } |
| 3727 | |
| 3728 | return 0; |
| 3729 | } |
| 3730 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3731 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3732 | { |
| 3733 | struct sigmatel_spec *spec = codec->spec; |
| 3734 | int err; |
| 3735 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3736 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3737 | return err; |
| 3738 | |
| 3739 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3740 | return err; |
| 3741 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3742 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3743 | return err; |
| 3744 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3745 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3746 | return err; |
| 3747 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3748 | if (spec->num_muxes > 0) { |
| 3749 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3750 | if (err < 0) |
| 3751 | return err; |
| 3752 | } |
| 3753 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3754 | err = stac92xx_add_input_source(spec); |
| 3755 | if (err < 0) |
| 3756 | return err; |
| 3757 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3758 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3759 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3760 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3761 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3762 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3763 | if (spec->kctls.list) |
| 3764 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3765 | |
| 3766 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3767 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3768 | |
| 3769 | return 1; |
| 3770 | } |
| 3771 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3772 | /* |
| 3773 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 3774 | * funky external mute control using GPIO pins. |
| 3775 | */ |
| 3776 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3777 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3778 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3779 | { |
| 3780 | unsigned int gpiostate, gpiomask, gpiodir; |
| 3781 | |
| 3782 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 3783 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3784 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3785 | |
| 3786 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 3787 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3788 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3789 | |
| 3790 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 3791 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3792 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3793 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3794 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3795 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 3796 | |
| 3797 | snd_hda_codec_write(codec, codec->afg, 0, |
| 3798 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3799 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3800 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3801 | |
| 3802 | msleep(1); |
| 3803 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3804 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3805 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3806 | } |
| 3807 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3808 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 3809 | hda_nid_t nid, int type) |
| 3810 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3811 | #ifdef CONFIG_SND_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3812 | struct sigmatel_spec *spec = codec->spec; |
| 3813 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3814 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3815 | int connectivity = get_defcfg_connect(def_conf); |
| 3816 | char name[32]; |
| 3817 | |
| 3818 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 3819 | return 0; |
| 3820 | |
| 3821 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 3822 | jack = snd_array_new(&spec->jacks); |
| 3823 | if (!jack) |
| 3824 | return -ENOMEM; |
| 3825 | jack->nid = nid; |
| 3826 | jack->type = type; |
| 3827 | |
| 3828 | sprintf(name, "%s at %s %s Jack", |
| 3829 | snd_hda_get_jack_type(def_conf), |
| 3830 | snd_hda_get_jack_connectivity(def_conf), |
| 3831 | snd_hda_get_jack_location(def_conf)); |
| 3832 | |
| 3833 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3834 | #else |
| 3835 | return 0; |
| 3836 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3837 | } |
| 3838 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3839 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 3840 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3841 | { |
| 3842 | struct sigmatel_event *event; |
| 3843 | |
| 3844 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 3845 | event = snd_array_new(&spec->events); |
| 3846 | if (!event) |
| 3847 | return -ENOMEM; |
| 3848 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3849 | event->type = type; |
| 3850 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3851 | event->data = data; |
| 3852 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3853 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3854 | } |
| 3855 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3856 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
| 3857 | hda_nid_t nid, unsigned char type) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3858 | { |
| 3859 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3860 | struct sigmatel_event *event = spec->events.list; |
| 3861 | int i; |
| 3862 | |
| 3863 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3864 | if (event->nid == nid && event->type == type) |
| 3865 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3866 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3867 | return NULL; |
| 3868 | } |
| 3869 | |
| 3870 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 3871 | unsigned char tag) |
| 3872 | { |
| 3873 | struct sigmatel_spec *spec = codec->spec; |
| 3874 | struct sigmatel_event *event = spec->events.list; |
| 3875 | int i; |
| 3876 | |
| 3877 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3878 | if (event->tag == tag) |
| 3879 | return event; |
| 3880 | } |
| 3881 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3882 | } |
| 3883 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3884 | 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] | 3885 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3886 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3887 | struct sigmatel_event *event; |
| 3888 | int tag; |
| 3889 | |
| 3890 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
| 3891 | return; |
| 3892 | event = stac_get_event(codec, nid, type); |
| 3893 | if (event) |
| 3894 | tag = event->tag; |
| 3895 | else |
| 3896 | tag = stac_add_event(codec->spec, nid, type, 0); |
| 3897 | if (tag < 0) |
| 3898 | return; |
| 3899 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3900 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3901 | AC_USRSP_EN | tag); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3902 | } |
| 3903 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3904 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3905 | { |
| 3906 | int i; |
| 3907 | for (i = 0; i < cfg->hp_outs; i++) |
| 3908 | if (cfg->hp_pins[i] == nid) |
| 3909 | return 1; /* nid is a HP-Out */ |
| 3910 | |
| 3911 | return 0; /* nid is not a HP-Out */ |
| 3912 | }; |
| 3913 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3914 | static void stac92xx_power_down(struct hda_codec *codec) |
| 3915 | { |
| 3916 | struct sigmatel_spec *spec = codec->spec; |
| 3917 | |
| 3918 | /* power down inactive DACs */ |
| 3919 | hda_nid_t *dac; |
| 3920 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3921 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3922 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3923 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3924 | } |
| 3925 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3926 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 3927 | int enable); |
| 3928 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3929 | static int stac92xx_init(struct hda_codec *codec) |
| 3930 | { |
| 3931 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3932 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3933 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3934 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3935 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3936 | snd_hda_sequence_write(codec, spec->init); |
| 3937 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3938 | /* power down adcs initially */ |
| 3939 | if (spec->powerdown_adcs) |
| 3940 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3941 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3942 | spec->adc_nids[i], 0, |
| 3943 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3944 | |
| 3945 | /* set up GPIO */ |
| 3946 | gpio = spec->gpio_data; |
| 3947 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 3948 | * otherwise, unsol event will turn it on/off dynamically |
| 3949 | */ |
| 3950 | if (!spec->eapd_switch) |
| 3951 | gpio |= spec->eapd_mask; |
| 3952 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 3953 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3954 | /* set up pins */ |
| 3955 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3956 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3957 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3958 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3959 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3960 | } |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 3961 | /* force to enable the first line-out; the others are set up |
| 3962 | * in unsol_event |
| 3963 | */ |
| 3964 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3965 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3966 | /* fake event to set up pins */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3967 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 3968 | STAC_HP_EVENT); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3969 | } else { |
| 3970 | stac92xx_auto_init_multi_out(codec); |
| 3971 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 3972 | for (i = 0; i < cfg->hp_outs; i++) |
| 3973 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3974 | } |
| 3975 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3976 | hda_nid_t nid = cfg->input_pins[i]; |
| 3977 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 3978 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 3979 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 3980 | /* for mic pins, force to initialize */ |
| 3981 | pinctl = stac92xx_get_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 3982 | pinctl |= AC_PINCTL_IN_EN; |
| 3983 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 3984 | } else { |
| 3985 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 3986 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3987 | /* if PINCTL already set then skip */ |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 3988 | if (!(pinctl & AC_PINCTL_IN_EN)) { |
| 3989 | pinctl |= AC_PINCTL_IN_EN; |
| 3990 | stac92xx_auto_set_pinctl(codec, nid, |
| 3991 | pinctl); |
| 3992 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 3993 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3994 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 3995 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 3996 | enable_pin_detect(codec, nid, |
| 3997 | STAC_INSERT_EVENT); |
| 3998 | stac_issue_unsol_event(codec, nid, |
| 3999 | STAC_INSERT_EVENT); |
| 4000 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4001 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4002 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4003 | for (i = 0; i < spec->num_dmics; i++) |
| 4004 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4005 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4006 | if (cfg->dig_out_pins[0]) |
| 4007 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4008 | AC_PINCTL_OUT_EN); |
| 4009 | if (cfg->dig_in_pin) |
| 4010 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4011 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4012 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4013 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4014 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4015 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4016 | /* power on when no jack detection is available */ |
| 4017 | if (!spec->hp_detect) { |
| 4018 | stac_toggle_power_map(codec, nid, 1); |
| 4019 | continue; |
| 4020 | } |
| 4021 | |
| 4022 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4023 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4024 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4025 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4026 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4027 | /* outputs are only ports capable of power management |
| 4028 | * any attempts on powering down a input port cause the |
| 4029 | * referenced VREF to act quirky. |
| 4030 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4031 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4032 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4033 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4034 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4035 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4036 | def_conf = get_defcfg_connect(def_conf); |
| 4037 | /* skip any ports that don't have jacks since presence |
| 4038 | * detection is useless */ |
| 4039 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4040 | if (def_conf != AC_JACK_PORT_NONE) |
| 4041 | stac_toggle_power_map(codec, nid, 1); |
| 4042 | continue; |
| 4043 | } |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4044 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
| 4045 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
| 4046 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); |
| 4047 | } |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4048 | } |
| 4049 | if (spec->dac_list) |
| 4050 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4051 | return 0; |
| 4052 | } |
| 4053 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4054 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4055 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4056 | #ifdef CONFIG_SND_JACK |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4057 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4058 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4059 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4060 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4061 | int i; |
| 4062 | for (i = 0; i < spec->jacks.used; i++) |
| 4063 | snd_device_free(codec->bus->card, &jacks[i].jack); |
| 4064 | } |
| 4065 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4066 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4067 | } |
| 4068 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4069 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4070 | { |
| 4071 | struct sigmatel_spec *spec = codec->spec; |
| 4072 | |
| 4073 | if (spec->kctls.list) { |
| 4074 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4075 | int i; |
| 4076 | for (i = 0; i < spec->kctls.used; i++) |
| 4077 | kfree(kctl[i].name); |
| 4078 | } |
| 4079 | snd_array_free(&spec->kctls); |
| 4080 | } |
| 4081 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4082 | static void stac92xx_free(struct hda_codec *codec) |
| 4083 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4084 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4085 | |
| 4086 | if (! spec) |
| 4087 | return; |
| 4088 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4089 | stac92xx_free_jacks(codec); |
| 4090 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4091 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4092 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4093 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4094 | } |
| 4095 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4096 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4097 | unsigned int flag) |
| 4098 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4099 | unsigned int old_ctl, pin_ctl; |
| 4100 | |
| 4101 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4102 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4103 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4104 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4105 | /* |
| 4106 | * we need to check the current set-up direction of |
| 4107 | * shared input pins since they can be switched via |
| 4108 | * "xxx as Output" mixer switch |
| 4109 | */ |
| 4110 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4111 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4112 | return; |
| 4113 | } |
| 4114 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4115 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4116 | /* if setting pin direction bits, clear the current |
| 4117 | direction bits first */ |
| 4118 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4119 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4120 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4121 | pin_ctl |= flag; |
| 4122 | if (old_ctl != pin_ctl) |
| 4123 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4124 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4125 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4126 | } |
| 4127 | |
| 4128 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4129 | unsigned int flag) |
| 4130 | { |
| 4131 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4132 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4133 | if (pin_ctl & flag) |
| 4134 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4135 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4136 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4137 | } |
| 4138 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4139 | 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] | 4140 | { |
| 4141 | if (!nid) |
| 4142 | return 0; |
| 4143 | 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] | 4144 | & (1 << 31)) |
| 4145 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4146 | return 0; |
| 4147 | } |
| 4148 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4149 | /* return non-zero if the hp-pin of the given array index isn't |
| 4150 | * a jack-detection target |
| 4151 | */ |
| 4152 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4153 | { |
| 4154 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4155 | |
| 4156 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4157 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4158 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4159 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4160 | return 1; |
| 4161 | /* ignore if the pin is set as line-out */ |
| 4162 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4163 | return 1; |
| 4164 | return 0; |
| 4165 | } |
| 4166 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4167 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4168 | { |
| 4169 | struct sigmatel_spec *spec = codec->spec; |
| 4170 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4171 | int i, presence; |
| 4172 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4173 | presence = 0; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4174 | if (spec->gpio_mute) |
| 4175 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4176 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4177 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4178 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4179 | if (presence) |
| 4180 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4181 | if (no_hp_sensing(spec, i)) |
| 4182 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4183 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4184 | if (presence) { |
| 4185 | unsigned int pinctl; |
| 4186 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4187 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4188 | if (pinctl & AC_PINCTL_IN_EN) |
| 4189 | presence = 0; /* mic- or line-input */ |
| 4190 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4191 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4192 | |
| 4193 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4194 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4195 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4196 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4197 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4198 | for (i = 0; i < cfg->line_outs; i++) |
| 4199 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4200 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4201 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4202 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4203 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4204 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4205 | stac_gpio_set(codec, spec->gpio_mask, |
| 4206 | spec->gpio_dir, spec->gpio_data & |
| 4207 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4208 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4209 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4210 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4211 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4212 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4213 | for (i = 0; i < cfg->line_outs; i++) |
| 4214 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4215 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4216 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4217 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4218 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4219 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4220 | stac_gpio_set(codec, spec->gpio_mask, |
| 4221 | spec->gpio_dir, spec->gpio_data | |
| 4222 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4223 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4224 | /* toggle hp outs */ |
| 4225 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4226 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4227 | if (no_hp_sensing(spec, i)) |
| 4228 | continue; |
| 4229 | if (presence) |
| 4230 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4231 | #if 0 /* FIXME */ |
| 4232 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4233 | * on some devices since they use the HP pin actually for line/speaker |
| 4234 | * outs although the default pin config shows a different pin (that is |
| 4235 | * wrong and useless). |
| 4236 | * |
| 4237 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4238 | * But, disabling the code below just works around it, and I'm too tired of |
| 4239 | * bug reports with such devices... |
| 4240 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4241 | else |
| 4242 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4243 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4244 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4245 | } |
| 4246 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4247 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4248 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4249 | { |
| 4250 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4251 | unsigned int idx, val; |
| 4252 | |
| 4253 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4254 | if (spec->pwr_nids[idx] == nid) |
| 4255 | break; |
| 4256 | } |
| 4257 | if (idx >= spec->num_pwrs) |
| 4258 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4259 | |
| 4260 | /* several codecs have two power down bits */ |
| 4261 | if (spec->pwr_mapping) |
| 4262 | idx = spec->pwr_mapping[idx]; |
| 4263 | else |
| 4264 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4265 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4266 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4267 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4268 | val &= ~idx; |
| 4269 | else |
| 4270 | val |= idx; |
| 4271 | |
| 4272 | /* power down unused output ports */ |
| 4273 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4274 | } |
| 4275 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4276 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4277 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4278 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4279 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4280 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4281 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4282 | { |
| 4283 | struct sigmatel_spec *spec = codec->spec; |
| 4284 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4285 | |
| 4286 | if (jacks) { |
| 4287 | int i; |
| 4288 | for (i = 0; i < spec->jacks.used; i++) { |
| 4289 | if (jacks->nid == nid) { |
| 4290 | unsigned int pin_ctl = |
| 4291 | snd_hda_codec_read(codec, nid, |
| 4292 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4293 | 0x00); |
| 4294 | int type = jacks->type; |
| 4295 | if (type == (SND_JACK_LINEOUT |
| 4296 | | SND_JACK_HEADPHONE)) |
| 4297 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4298 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4299 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4300 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4301 | ? type : 0); |
| 4302 | } |
| 4303 | jacks++; |
| 4304 | } |
| 4305 | } |
| 4306 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4307 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4308 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 4309 | unsigned char type) |
| 4310 | { |
| 4311 | struct sigmatel_event *event = stac_get_event(codec, nid, type); |
| 4312 | if (!event) |
| 4313 | return; |
| 4314 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4315 | } |
| 4316 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4317 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4318 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4319 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4320 | struct sigmatel_event *event; |
| 4321 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4322 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4323 | tag = (res >> 26) & 0x7f; |
| 4324 | event = stac_get_event_from_tag(codec, tag); |
| 4325 | if (!event) |
| 4326 | return; |
| 4327 | |
| 4328 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4329 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4330 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4331 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4332 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4333 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4334 | if (spec->num_pwrs > 0) |
| 4335 | stac92xx_pin_sense(codec, event->nid); |
| 4336 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4337 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4338 | case STAC_VREF_EVENT: |
| 4339 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4340 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4341 | /* toggle VREF state based on GPIOx status */ |
| 4342 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4343 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4344 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4345 | } |
| 4346 | } |
| 4347 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4348 | #ifdef CONFIG_PROC_FS |
| 4349 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4350 | struct hda_codec *codec, hda_nid_t nid) |
| 4351 | { |
| 4352 | if (nid == codec->afg) |
| 4353 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4354 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4355 | } |
| 4356 | |
| 4357 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4358 | struct hda_codec *codec, |
| 4359 | unsigned int verb) |
| 4360 | { |
| 4361 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4362 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4363 | } |
| 4364 | |
| 4365 | /* stac92hd71bxx, stac92hd73xx */ |
| 4366 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4367 | struct hda_codec *codec, hda_nid_t nid) |
| 4368 | { |
| 4369 | stac92hd_proc_hook(buffer, codec, nid); |
| 4370 | if (nid == codec->afg) |
| 4371 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4372 | } |
| 4373 | |
| 4374 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4375 | struct hda_codec *codec, hda_nid_t nid) |
| 4376 | { |
| 4377 | if (nid == codec->afg) |
| 4378 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4379 | } |
| 4380 | |
| 4381 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4382 | struct hda_codec *codec, hda_nid_t nid) |
| 4383 | { |
| 4384 | if (nid == codec->afg) |
| 4385 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4386 | } |
| 4387 | #else |
| 4388 | #define stac92hd_proc_hook NULL |
| 4389 | #define stac92hd7x_proc_hook NULL |
| 4390 | #define stac9205_proc_hook NULL |
| 4391 | #define stac927x_proc_hook NULL |
| 4392 | #endif |
| 4393 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4394 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4395 | static int stac92xx_resume(struct hda_codec *codec) |
| 4396 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4397 | struct sigmatel_spec *spec = codec->spec; |
| 4398 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4399 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4400 | snd_hda_codec_resume_amp(codec); |
| 4401 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4402 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4403 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4404 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4405 | STAC_HP_EVENT); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4406 | return 0; |
| 4407 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4408 | |
| 4409 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4410 | { |
| 4411 | struct sigmatel_spec *spec = codec->spec; |
| 4412 | if (spec->eapd_mask) |
| 4413 | stac_gpio_set(codec, spec->gpio_mask, |
| 4414 | spec->gpio_dir, spec->gpio_data & |
| 4415 | ~spec->eapd_mask); |
| 4416 | return 0; |
| 4417 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4418 | #endif |
| 4419 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4420 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4421 | .build_controls = stac92xx_build_controls, |
| 4422 | .build_pcms = stac92xx_build_pcms, |
| 4423 | .init = stac92xx_init, |
| 4424 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4425 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4426 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4427 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4428 | .resume = stac92xx_resume, |
| 4429 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4430 | }; |
| 4431 | |
| 4432 | static int patch_stac9200(struct hda_codec *codec) |
| 4433 | { |
| 4434 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4435 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4436 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4437 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4438 | if (spec == NULL) |
| 4439 | return -ENOMEM; |
| 4440 | |
| 4441 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4442 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4443 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4444 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4445 | stac9200_models, |
| 4446 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4447 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4448 | 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] | 4449 | else |
| 4450 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4451 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4452 | |
| 4453 | spec->multiout.max_channels = 2; |
| 4454 | spec->multiout.num_dacs = 1; |
| 4455 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4456 | spec->adc_nids = stac9200_adc_nids; |
| 4457 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4458 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4459 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4460 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4461 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4462 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4463 | if (spec->board_config == STAC_9200_M4 || |
| 4464 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4465 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4466 | spec->init = stac9200_eapd_init; |
| 4467 | else |
| 4468 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4469 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4470 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4471 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4472 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4473 | spec->gpio_data = 0x00; |
| 4474 | } |
| 4475 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4476 | err = stac9200_parse_auto_config(codec); |
| 4477 | if (err < 0) { |
| 4478 | stac92xx_free(codec); |
| 4479 | return err; |
| 4480 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4481 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4482 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 4483 | * do detection and HP/speaker toggle because the hardware does it. |
| 4484 | */ |
| 4485 | if (spec->board_config == STAC_9200_PANASONIC) |
| 4486 | spec->hp_detect = 0; |
| 4487 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4488 | codec->patch_ops = stac92xx_patch_ops; |
| 4489 | |
| 4490 | return 0; |
| 4491 | } |
| 4492 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4493 | static int patch_stac925x(struct hda_codec *codec) |
| 4494 | { |
| 4495 | struct sigmatel_spec *spec; |
| 4496 | int err; |
| 4497 | |
| 4498 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 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(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4504 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4505 | |
| 4506 | /* Check first for codec ID */ |
| 4507 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4508 | STAC_925x_MODELS, |
| 4509 | stac925x_models, |
| 4510 | stac925x_codec_id_cfg_tbl); |
| 4511 | |
| 4512 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4513 | if (spec->board_config < 0) |
| 4514 | spec->board_config = snd_hda_check_board_config(codec, |
| 4515 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4516 | stac925x_models, |
| 4517 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4518 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4519 | if (spec->board_config < 0) |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4520 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4521 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4522 | else |
| 4523 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4524 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4525 | |
| 4526 | spec->multiout.max_channels = 2; |
| 4527 | spec->multiout.num_dacs = 1; |
| 4528 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4529 | spec->adc_nids = stac925x_adc_nids; |
| 4530 | spec->mux_nids = stac925x_mux_nids; |
| 4531 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4532 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4533 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4534 | switch (codec->vendor_id) { |
| 4535 | case 0x83847632: /* STAC9202 */ |
| 4536 | case 0x83847633: /* STAC9202D */ |
| 4537 | case 0x83847636: /* STAC9251 */ |
| 4538 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4539 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4540 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4541 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4542 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4543 | break; |
| 4544 | default: |
| 4545 | spec->num_dmics = 0; |
| 4546 | break; |
| 4547 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4548 | |
| 4549 | spec->init = stac925x_core_init; |
| 4550 | spec->mixer = stac925x_mixer; |
| 4551 | |
| 4552 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4553 | if (!err) { |
| 4554 | if (spec->board_config < 0) { |
| 4555 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4556 | "available, default to model=ref\n"); |
| 4557 | spec->board_config = STAC_925x_REF; |
| 4558 | goto again; |
| 4559 | } |
| 4560 | err = -EINVAL; |
| 4561 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4562 | if (err < 0) { |
| 4563 | stac92xx_free(codec); |
| 4564 | return err; |
| 4565 | } |
| 4566 | |
| 4567 | codec->patch_ops = stac92xx_patch_ops; |
| 4568 | |
| 4569 | return 0; |
| 4570 | } |
| 4571 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4572 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4573 | .num_items = 4, |
| 4574 | .items = { |
| 4575 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4576 | { "Digital Mic 1", 0x09 }, |
| 4577 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4578 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4579 | } |
| 4580 | }; |
| 4581 | |
| 4582 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4583 | { |
| 4584 | struct sigmatel_spec *spec; |
| 4585 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4586 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4587 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4588 | |
| 4589 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4590 | if (spec == NULL) |
| 4591 | return -ENOMEM; |
| 4592 | |
| 4593 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4594 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4595 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4596 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4597 | spec->board_config = snd_hda_check_board_config(codec, |
| 4598 | STAC_92HD73XX_MODELS, |
| 4599 | stac92hd73xx_models, |
| 4600 | stac92hd73xx_cfg_tbl); |
| 4601 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4602 | if (spec->board_config < 0) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4603 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4604 | " STAC92HD73XX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4605 | else |
| 4606 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4607 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4608 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4609 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4610 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4611 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4612 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4613 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4614 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4615 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4616 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4617 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4618 | case 0x3: /* 6 Channel */ |
| 4619 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4620 | spec->init = stac92hd73xx_6ch_core_init; |
| 4621 | break; |
| 4622 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4623 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4624 | spec->init = stac92hd73xx_8ch_core_init; |
| 4625 | break; |
| 4626 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4627 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4628 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4629 | } |
| 4630 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4631 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4632 | spec->aloopback_mask = 0x01; |
| 4633 | spec->aloopback_shift = 8; |
| 4634 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4635 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4636 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4637 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4638 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4639 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4640 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4641 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4642 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4643 | |
| 4644 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4645 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4646 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4647 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 4648 | sizeof(stac92hd73xx_dmux)); |
| 4649 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4650 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4651 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4652 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4653 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4654 | case STAC_DELL_M6_AMIC: |
| 4655 | case STAC_DELL_M6_DMIC: |
| 4656 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4657 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4658 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 4659 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4660 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4661 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4662 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4663 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4664 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4665 | switch (spec->board_config) { |
| 4666 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4667 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4668 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4669 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4670 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4671 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4672 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4673 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4674 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4675 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4676 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4677 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 4678 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4679 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4680 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4681 | break; |
| 4682 | } |
| 4683 | break; |
| 4684 | default: |
| 4685 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4686 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4687 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4688 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4689 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 4690 | /* GPIO0 High = Enable EAPD */ |
| 4691 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 4692 | spec->gpio_data = 0x01; |
| 4693 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4694 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4695 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4696 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 4697 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 4698 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4699 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4700 | |
| 4701 | if (!err) { |
| 4702 | if (spec->board_config < 0) { |
| 4703 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4704 | "available, default to model=ref\n"); |
| 4705 | spec->board_config = STAC_92HD73XX_REF; |
| 4706 | goto again; |
| 4707 | } |
| 4708 | err = -EINVAL; |
| 4709 | } |
| 4710 | |
| 4711 | if (err < 0) { |
| 4712 | stac92xx_free(codec); |
| 4713 | return err; |
| 4714 | } |
| 4715 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 4716 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 4717 | spec->hp_detect = 0; |
| 4718 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4719 | codec->patch_ops = stac92xx_patch_ops; |
| 4720 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4721 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 4722 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4723 | return 0; |
| 4724 | } |
| 4725 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4726 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 4727 | .num_items = 3, |
| 4728 | .items = { |
| 4729 | { "Analog Inputs", 0x03 }, |
| 4730 | { "Digital Mic 1", 0x04 }, |
| 4731 | { "Digital Mic 2", 0x05 }, |
| 4732 | } |
| 4733 | }; |
| 4734 | |
| 4735 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 4736 | { |
| 4737 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 4738 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4739 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 4740 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 4741 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4742 | |
| 4743 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4744 | if (spec == NULL) |
| 4745 | return -ENOMEM; |
| 4746 | |
| 4747 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4748 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4749 | spec->mono_nid = 0x19; |
| 4750 | spec->digbeep_nid = 0x21; |
| 4751 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 4752 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 4753 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 4754 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 4755 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4756 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 4757 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4758 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4759 | |
| 4760 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4761 | spec->mixer = stac92hd83xxx_mixer; |
| 4762 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 4763 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 4764 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 4765 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4766 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 4767 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 4768 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 4769 | spec->board_config = snd_hda_check_board_config(codec, |
| 4770 | STAC_92HD83XXX_MODELS, |
| 4771 | stac92hd83xxx_models, |
| 4772 | stac92hd83xxx_cfg_tbl); |
| 4773 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4774 | if (spec->board_config < 0) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4775 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4776 | " STAC92HD83XXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4777 | else |
| 4778 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4779 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4780 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 4781 | switch (codec->vendor_id) { |
| 4782 | case 0x111d7604: |
| 4783 | case 0x111d7605: |
| 4784 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 4785 | break; |
| 4786 | spec->num_pwrs = 0; |
| 4787 | break; |
| 4788 | } |
| 4789 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4790 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 4791 | if (!err) { |
| 4792 | if (spec->board_config < 0) { |
| 4793 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4794 | "available, default to model=ref\n"); |
| 4795 | spec->board_config = STAC_92HD83XXX_REF; |
| 4796 | goto again; |
| 4797 | } |
| 4798 | err = -EINVAL; |
| 4799 | } |
| 4800 | |
| 4801 | if (err < 0) { |
| 4802 | stac92xx_free(codec); |
| 4803 | return err; |
| 4804 | } |
| 4805 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 4806 | switch (spec->board_config) { |
| 4807 | case STAC_DELL_S14: |
| 4808 | nid = 0xf; |
| 4809 | break; |
| 4810 | default: |
| 4811 | nid = 0xe; |
| 4812 | break; |
| 4813 | } |
| 4814 | |
| 4815 | num_dacs = snd_hda_get_connections(codec, nid, |
| 4816 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
| 4817 | |
| 4818 | /* set port X to select the last DAC |
| 4819 | */ |
| 4820 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4821 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 4822 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4823 | codec->patch_ops = stac92xx_patch_ops; |
| 4824 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4825 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 4826 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4827 | return 0; |
| 4828 | } |
| 4829 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4830 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 4831 | .num_items = 3, |
| 4832 | .items = { |
| 4833 | { "Analog Inputs", 0x00 }, |
| 4834 | { "Digital Mic 1", 0x02 }, |
| 4835 | { "Digital Mic 2", 0x03 }, |
| 4836 | } |
| 4837 | }; |
| 4838 | |
| 4839 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4840 | .num_items = 4, |
| 4841 | .items = { |
| 4842 | { "Analog Inputs", 0x00 }, |
| 4843 | { "Mixer", 0x01 }, |
| 4844 | { "Digital Mic 1", 0x02 }, |
| 4845 | { "Digital Mic 2", 0x03 }, |
| 4846 | } |
| 4847 | }; |
| 4848 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4849 | /* get the pin connection (fixed, none, etc) */ |
| 4850 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 4851 | { |
| 4852 | struct sigmatel_spec *spec = codec->spec; |
| 4853 | unsigned int cfg; |
| 4854 | |
| 4855 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 4856 | return get_defcfg_connect(cfg); |
| 4857 | } |
| 4858 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4859 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 4860 | hda_nid_t *nids, int num_nids) |
| 4861 | { |
| 4862 | struct sigmatel_spec *spec = codec->spec; |
| 4863 | int idx, num; |
| 4864 | unsigned int def_conf; |
| 4865 | |
| 4866 | for (num = 0; num < num_nids; num++) { |
| 4867 | for (idx = 0; idx < spec->num_pins; idx++) |
| 4868 | if (spec->pin_nids[idx] == nids[num]) |
| 4869 | break; |
| 4870 | if (idx >= spec->num_pins) |
| 4871 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4872 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4873 | if (def_conf == AC_JACK_PORT_NONE) |
| 4874 | break; |
| 4875 | } |
| 4876 | return num; |
| 4877 | } |
| 4878 | |
| 4879 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 4880 | hda_nid_t dig0pin) |
| 4881 | { |
| 4882 | struct sigmatel_spec *spec = codec->spec; |
| 4883 | int idx; |
| 4884 | |
| 4885 | for (idx = 0; idx < spec->num_pins; idx++) |
| 4886 | if (spec->pin_nids[idx] == dig0pin) |
| 4887 | break; |
| 4888 | if ((idx + 2) >= spec->num_pins) |
| 4889 | return 0; |
| 4890 | |
| 4891 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4892 | 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] | 4893 | return 2; |
| 4894 | |
| 4895 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4896 | 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] | 4897 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4898 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4899 | return 1; |
| 4900 | else |
| 4901 | return 0; |
| 4902 | } |
| 4903 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4904 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 4905 | { |
| 4906 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 4907 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4908 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4909 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4910 | |
| 4911 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4912 | if (spec == NULL) |
| 4913 | return -ENOMEM; |
| 4914 | |
| 4915 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4916 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 4917 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 4918 | switch (codec->vendor_id) { |
| 4919 | case 0x111d76b6: |
| 4920 | case 0x111d76b7: |
| 4921 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 4922 | break; |
| 4923 | case 0x111d7603: |
| 4924 | case 0x111d7608: |
| 4925 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 4926 | spec->num_pins--; |
| 4927 | /* fallthrough */ |
| 4928 | default: |
| 4929 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 4930 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4931 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4932 | spec->board_config = snd_hda_check_board_config(codec, |
| 4933 | STAC_92HD71BXX_MODELS, |
| 4934 | stac92hd71bxx_models, |
| 4935 | stac92hd71bxx_cfg_tbl); |
| 4936 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4937 | if (spec->board_config < 0) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4938 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4939 | " STAC92HD71BXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4940 | else |
| 4941 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4942 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4943 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 4944 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 4945 | /* GPIO0 = EAPD */ |
| 4946 | spec->gpio_mask = 0x01; |
| 4947 | spec->gpio_dir = 0x01; |
| 4948 | spec->gpio_data = 0x01; |
| 4949 | } |
| 4950 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4951 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 4952 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 4953 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4954 | switch (codec->vendor_id) { |
| 4955 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 4956 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 4957 | unmute_init++; |
| 4958 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4959 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 4960 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4961 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 4962 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4963 | spec->mixer = stac92hd71bxx_mixer; |
| 4964 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4965 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4966 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 4967 | stac92hd71bxx_dmic_nids, |
| 4968 | STAC92HD71BXX_NUM_DMICS); |
| 4969 | if (spec->num_dmics) { |
| 4970 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 4971 | spec->dinput_mux = &spec->private_dimux; |
| 4972 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 4973 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4974 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4975 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 4976 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 4977 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 4978 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 4979 | switch (spec->board_config) { |
| 4980 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4981 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4982 | err = stac_add_event(spec, codec->afg, |
| 4983 | STAC_VREF_EVENT, 0x02); |
| 4984 | if (err < 0) |
| 4985 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 4986 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4987 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 4988 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4989 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4990 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4991 | spec->gpio_mask |= 0x02; |
| 4992 | break; |
| 4993 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4994 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4995 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4996 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4997 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4998 | /* no output amps */ |
| 4999 | spec->num_pwrs = 0; |
| 5000 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5001 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5002 | |
| 5003 | /* disable VSW */ |
| 5004 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5005 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5006 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5007 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5008 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5009 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5010 | stac92hd71bxx_dmic_nids, |
| 5011 | STAC92HD71BXX_NUM_DMICS - 1); |
| 5012 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5013 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5014 | break; |
| 5015 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5016 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5017 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5018 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5019 | /* no output amps */ |
| 5020 | spec->num_pwrs = 0; |
| 5021 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5022 | default: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5023 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5024 | sizeof(stac92hd71bxx_dmux_amixer)); |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5025 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5026 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 5027 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5028 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5029 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5030 | stac92hd71bxx_dmic_nids, |
| 5031 | STAC92HD71BXX_NUM_DMICS); |
| 5032 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5033 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5034 | } |
| 5035 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5036 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5037 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5038 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5039 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5040 | spec->aloopback_shift = 0; |
| 5041 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5042 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5043 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5044 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5045 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5046 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5047 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5048 | |
| 5049 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5050 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5051 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5052 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5053 | switch (spec->board_config) { |
| 5054 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5055 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5056 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5057 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5058 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5059 | /* fallthru */ |
| 5060 | case STAC_DELL_M4_2: |
| 5061 | spec->num_dmics = 0; |
| 5062 | spec->num_smuxes = 0; |
| 5063 | spec->num_dmuxes = 0; |
| 5064 | break; |
| 5065 | case STAC_DELL_M4_1: |
| 5066 | case STAC_DELL_M4_3: |
| 5067 | spec->num_dmics = 1; |
| 5068 | spec->num_smuxes = 0; |
| 5069 | spec->num_dmuxes = 0; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5070 | break; |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5071 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5072 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5073 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5074 | break; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5075 | }; |
| 5076 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5077 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5078 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5079 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5080 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5081 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5082 | if (!err) { |
| 5083 | if (spec->board_config < 0) { |
| 5084 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5085 | "available, default to model=ref\n"); |
| 5086 | spec->board_config = STAC_92HD71BXX_REF; |
| 5087 | goto again; |
| 5088 | } |
| 5089 | err = -EINVAL; |
| 5090 | } |
| 5091 | |
| 5092 | if (err < 0) { |
| 5093 | stac92xx_free(codec); |
| 5094 | return err; |
| 5095 | } |
| 5096 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5097 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5098 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5099 | return 0; |
| 5100 | }; |
| 5101 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5102 | static int patch_stac922x(struct hda_codec *codec) |
| 5103 | { |
| 5104 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5105 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5106 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5107 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5108 | if (spec == NULL) |
| 5109 | return -ENOMEM; |
| 5110 | |
| 5111 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5112 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5113 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5114 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5115 | stac922x_models, |
| 5116 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5117 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5118 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5119 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5120 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5121 | * codec SSID to distinguish the exact models |
| 5122 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5123 | 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] | 5124 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5125 | |
| 5126 | case 0x106b0800: |
| 5127 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5128 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5129 | case 0x106b0600: |
| 5130 | case 0x106b0700: |
| 5131 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5132 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5133 | case 0x106b0e00: |
| 5134 | case 0x106b0f00: |
| 5135 | case 0x106b1600: |
| 5136 | case 0x106b1700: |
| 5137 | case 0x106b0200: |
| 5138 | case 0x106b1e00: |
| 5139 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5140 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5141 | case 0x106b1a00: |
| 5142 | case 0x00000100: |
| 5143 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5144 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5145 | case 0x106b0a00: |
| 5146 | case 0x106b2200: |
| 5147 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5148 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5149 | default: |
| 5150 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5151 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5152 | } |
| 5153 | } |
| 5154 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5155 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5156 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5157 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 5158 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5159 | else |
| 5160 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5161 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5162 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5163 | spec->adc_nids = stac922x_adc_nids; |
| 5164 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5165 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5166 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5167 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5168 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5169 | |
| 5170 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5171 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5172 | |
| 5173 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5174 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5175 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5176 | if (!err) { |
| 5177 | if (spec->board_config < 0) { |
| 5178 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5179 | "available, default to model=ref\n"); |
| 5180 | spec->board_config = STAC_D945_REF; |
| 5181 | goto again; |
| 5182 | } |
| 5183 | err = -EINVAL; |
| 5184 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5185 | if (err < 0) { |
| 5186 | stac92xx_free(codec); |
| 5187 | return err; |
| 5188 | } |
| 5189 | |
| 5190 | codec->patch_ops = stac92xx_patch_ops; |
| 5191 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5192 | /* Fix Mux capture level; max to 2 */ |
| 5193 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5194 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5195 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5196 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5197 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5198 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5199 | return 0; |
| 5200 | } |
| 5201 | |
| 5202 | static int patch_stac927x(struct hda_codec *codec) |
| 5203 | { |
| 5204 | struct sigmatel_spec *spec; |
| 5205 | int err; |
| 5206 | |
| 5207 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5208 | if (spec == NULL) |
| 5209 | return -ENOMEM; |
| 5210 | |
| 5211 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5212 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5213 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5214 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5215 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5216 | stac927x_models, |
| 5217 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5218 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5219 | if (spec->board_config < 0) |
Herton Ronaldo Krzesinski | c98041f | 2009-02-11 20:33:15 -0200 | [diff] [blame] | 5220 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5221 | "STAC927x, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5222 | else |
| 5223 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5224 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5225 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5226 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5227 | spec->adc_nids = stac927x_adc_nids; |
| 5228 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5229 | spec->mux_nids = stac927x_mux_nids; |
| 5230 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5231 | spec->smux_nids = stac927x_smux_nids; |
| 5232 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5233 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5234 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5235 | spec->multiout.dac_nids = spec->dac_nids; |
| 5236 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5237 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5238 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5239 | case STAC_D965_5ST: |
| 5240 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5241 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5242 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5243 | spec->num_dmics = 0; |
| 5244 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5245 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5246 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5247 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5248 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5249 | switch (codec->subsystem_id) { |
| 5250 | case 0x10280209: |
| 5251 | case 0x1028022e: |
| 5252 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5253 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5254 | break; |
| 5255 | }; |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5256 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5257 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5258 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5259 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5260 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5261 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5262 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5263 | case STAC_DELL_3ST: |
| 5264 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5265 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5266 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5267 | spec->dmic_nids = stac927x_dmic_nids; |
| 5268 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5269 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5270 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5271 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5272 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5273 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5274 | break; |
| 5275 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5276 | if (spec->board_config > STAC_D965_REF) { |
| 5277 | /* GPIO0 High = Enable EAPD */ |
| 5278 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5279 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5280 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5281 | spec->num_dmics = 0; |
| 5282 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5283 | spec->init = stac927x_core_init; |
| 5284 | spec->mixer = stac927x_mixer; |
| 5285 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5286 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5287 | spec->num_pwrs = 0; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5288 | spec->aloopback_mask = 0x40; |
| 5289 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5290 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5291 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5292 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5293 | if (!err) { |
| 5294 | if (spec->board_config < 0) { |
| 5295 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5296 | "available, default to model=ref\n"); |
| 5297 | spec->board_config = STAC_D965_REF; |
| 5298 | goto again; |
| 5299 | } |
| 5300 | err = -EINVAL; |
| 5301 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5302 | if (err < 0) { |
| 5303 | stac92xx_free(codec); |
| 5304 | return err; |
| 5305 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5306 | |
| 5307 | codec->patch_ops = stac92xx_patch_ops; |
| 5308 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5309 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5310 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5311 | /* |
| 5312 | * !!FIXME!! |
| 5313 | * The STAC927x seem to require fairly long delays for certain |
| 5314 | * command sequences. With too short delays (even if the answer |
| 5315 | * is set to RIRB properly), it results in the silence output |
| 5316 | * on some hardwares like Dell. |
| 5317 | * |
| 5318 | * The below flag enables the longer delay (see get_response |
| 5319 | * in hda_intel.c). |
| 5320 | */ |
| 5321 | codec->bus->needs_damn_long_delay = 1; |
| 5322 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5323 | /* no jack detecion for ref-no-jd model */ |
| 5324 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5325 | spec->hp_detect = 0; |
| 5326 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5327 | return 0; |
| 5328 | } |
| 5329 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5330 | static int patch_stac9205(struct hda_codec *codec) |
| 5331 | { |
| 5332 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5333 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5334 | |
| 5335 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5336 | if (spec == NULL) |
| 5337 | return -ENOMEM; |
| 5338 | |
| 5339 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5340 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5341 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5342 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5343 | stac9205_models, |
| 5344 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5345 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5346 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5347 | 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] | 5348 | else |
| 5349 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5350 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5351 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5352 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5353 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5354 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5355 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5356 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5357 | spec->smux_nids = stac9205_smux_nids; |
| 5358 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5359 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5360 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5361 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5362 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5363 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5364 | |
| 5365 | spec->init = stac9205_core_init; |
| 5366 | spec->mixer = stac9205_mixer; |
| 5367 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5368 | spec->aloopback_mask = 0x40; |
| 5369 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5370 | /* Turn on/off EAPD per HP plugging */ |
| 5371 | if (spec->board_config != STAC_9205_EAPD) |
| 5372 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5373 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5374 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5375 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5376 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5377 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5378 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5379 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5380 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5381 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5382 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5383 | if (err < 0) |
| 5384 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5385 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5386 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5387 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5388 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5389 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5390 | |
| 5391 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5392 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5393 | spec->gpio_mask = 0x1b; |
| 5394 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5395 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5396 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5397 | */ |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5398 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5399 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5400 | case STAC_9205_REF: |
| 5401 | /* SPDIF-In enabled */ |
| 5402 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5403 | default: |
| 5404 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5405 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5406 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5407 | break; |
| 5408 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5409 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5410 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5411 | if (!err) { |
| 5412 | if (spec->board_config < 0) { |
| 5413 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5414 | "available, default to model=ref\n"); |
| 5415 | spec->board_config = STAC_9205_REF; |
| 5416 | goto again; |
| 5417 | } |
| 5418 | err = -EINVAL; |
| 5419 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5420 | if (err < 0) { |
| 5421 | stac92xx_free(codec); |
| 5422 | return err; |
| 5423 | } |
| 5424 | |
| 5425 | codec->patch_ops = stac92xx_patch_ops; |
| 5426 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5427 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5428 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5429 | return 0; |
| 5430 | } |
| 5431 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5432 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5433 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5434 | */ |
| 5435 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5436 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5437 | {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] | 5438 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5439 | {} |
| 5440 | }; |
| 5441 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5442 | static struct snd_kcontrol_new stac9872_mixer[] = { |
| 5443 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5444 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5445 | { } /* end */ |
| 5446 | }; |
| 5447 | |
| 5448 | static hda_nid_t stac9872_pin_nids[] = { |
| 5449 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 5450 | 0x11, 0x13, 0x14, |
| 5451 | }; |
| 5452 | |
| 5453 | static hda_nid_t stac9872_adc_nids[] = { |
| 5454 | 0x8 /*,0x6*/ |
| 5455 | }; |
| 5456 | |
| 5457 | static hda_nid_t stac9872_mux_nids[] = { |
| 5458 | 0x15 |
| 5459 | }; |
| 5460 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5461 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5462 | { |
| 5463 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5464 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5465 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5466 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5467 | if (spec == NULL) |
| 5468 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5469 | codec->spec = spec; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5470 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5471 | #if 0 /* no model right now */ |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5472 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5473 | stac9872_models, |
| 5474 | stac9872_cfg_tbl); |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5475 | #endif |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5476 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5477 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 5478 | spec->pin_nids = stac9872_pin_nids; |
| 5479 | spec->multiout.dac_nids = spec->dac_nids; |
| 5480 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 5481 | spec->adc_nids = stac9872_adc_nids; |
| 5482 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 5483 | spec->mux_nids = stac9872_mux_nids; |
| 5484 | spec->mixer = stac9872_mixer; |
| 5485 | spec->init = stac9872_core_init; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5486 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5487 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 5488 | if (err < 0) { |
| 5489 | stac92xx_free(codec); |
| 5490 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5491 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5492 | spec->input_mux = &spec->private_imux; |
| 5493 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5494 | return 0; |
| 5495 | } |
| 5496 | |
| 5497 | |
| 5498 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5499 | * patch entries |
| 5500 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5501 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5502 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5503 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5504 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5505 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5506 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5507 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5508 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5509 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5510 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5511 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5512 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5513 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5514 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5515 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5516 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5517 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5518 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5519 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5520 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5521 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5522 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5523 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5524 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5525 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5526 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5527 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5528 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5529 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5530 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5531 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5532 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5533 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5534 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5535 | * currently not fully supported. |
| 5536 | */ |
| 5537 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5538 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5539 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5540 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5541 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5542 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5543 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5544 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5545 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5546 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5547 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5548 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5549 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5550 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5551 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5552 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5553 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5554 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5555 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5556 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5557 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5558 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5559 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5560 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5561 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5562 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5563 | {} /* terminator */ |
| 5564 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5565 | |
| 5566 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 5567 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 5568 | |
| 5569 | MODULE_LICENSE("GPL"); |
| 5570 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 5571 | |
| 5572 | static struct hda_codec_preset_list sigmatel_list = { |
| 5573 | .preset = snd_hda_preset_sigmatel, |
| 5574 | .owner = THIS_MODULE, |
| 5575 | }; |
| 5576 | |
| 5577 | static int __init patch_sigmatel_init(void) |
| 5578 | { |
| 5579 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 5580 | } |
| 5581 | |
| 5582 | static void __exit patch_sigmatel_exit(void) |
| 5583 | { |
| 5584 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 5585 | } |
| 5586 | |
| 5587 | module_init(patch_sigmatel_init) |
| 5588 | module_exit(patch_sigmatel_exit) |