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, |
Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame^] | 79 | STAC_92HD73XX_INTEL, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 80 | STAC_DELL_M6_AMIC, |
| 81 | STAC_DELL_M6_DMIC, |
| 82 | STAC_DELL_M6_BOTH, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 83 | STAC_DELL_EQ, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 84 | STAC_92HD73XX_MODELS |
| 85 | }; |
| 86 | |
| 87 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 88 | STAC_92HD83XXX_AUTO, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 89 | STAC_92HD83XXX_REF, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 90 | STAC_92HD83XXX_PWR_REF, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 91 | STAC_DELL_S14, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 92 | STAC_92HD83XXX_MODELS |
| 93 | }; |
| 94 | |
| 95 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 96 | STAC_92HD71BXX_AUTO, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 97 | STAC_92HD71BXX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 98 | STAC_DELL_M4_1, |
| 99 | STAC_DELL_M4_2, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 100 | STAC_DELL_M4_3, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 101 | STAC_HP_M4, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 102 | STAC_HP_DV5, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 103 | STAC_HP_HDX, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 104 | STAC_HP_DV4_1222NR, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 105 | STAC_92HD71BXX_MODELS |
| 106 | }; |
| 107 | |
| 108 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 109 | STAC_925x_AUTO, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 110 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 111 | STAC_M1, |
| 112 | STAC_M1_2, |
| 113 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 114 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 115 | STAC_M3, |
| 116 | STAC_M5, |
| 117 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 118 | STAC_925x_MODELS |
| 119 | }; |
| 120 | |
| 121 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 122 | STAC_922X_AUTO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 123 | STAC_D945_REF, |
| 124 | STAC_D945GTP3, |
| 125 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 126 | STAC_INTEL_MAC_V1, |
| 127 | STAC_INTEL_MAC_V2, |
| 128 | STAC_INTEL_MAC_V3, |
| 129 | STAC_INTEL_MAC_V4, |
| 130 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 131 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 132 | * is given, one of the above models will be |
| 133 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 134 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 135 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 136 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 137 | STAC_MACBOOK_PRO_V1, |
| 138 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 139 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 140 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 141 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 142 | STAC_922X_DELL_D81, |
| 143 | STAC_922X_DELL_D82, |
| 144 | STAC_922X_DELL_M81, |
| 145 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 146 | STAC_922X_MODELS |
| 147 | }; |
| 148 | |
| 149 | enum { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 150 | STAC_927X_AUTO, |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 151 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 152 | STAC_D965_REF, |
| 153 | STAC_D965_3ST, |
| 154 | STAC_D965_5ST, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 155 | STAC_D965_5ST_NO_FP, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 156 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 157 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 158 | STAC_927X_MODELS |
| 159 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 160 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 161 | enum { |
| 162 | STAC_9872_AUTO, |
| 163 | STAC_9872_VAIO, |
| 164 | STAC_9872_MODELS |
| 165 | }; |
| 166 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 167 | struct sigmatel_event { |
| 168 | hda_nid_t nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 169 | unsigned char type; |
| 170 | unsigned char tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 171 | int data; |
| 172 | }; |
| 173 | |
| 174 | struct sigmatel_jack { |
| 175 | hda_nid_t nid; |
| 176 | int type; |
| 177 | struct snd_jack *jack; |
| 178 | }; |
| 179 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 180 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 181 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 182 | unsigned int num_mixers; |
| 183 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 184 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 185 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 186 | unsigned int surr_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 187 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 188 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 189 | unsigned int spdif_mute: 1; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 190 | unsigned int check_volume_offset:1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 191 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 192 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 193 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 194 | unsigned int gpio_mask; |
| 195 | unsigned int gpio_dir; |
| 196 | unsigned int gpio_data; |
| 197 | unsigned int gpio_mute; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 198 | unsigned int gpio_led; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 199 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 200 | /* stream */ |
| 201 | unsigned int stream_delay; |
| 202 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 203 | /* analog loopback */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 204 | struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 205 | unsigned char aloopback_mask; |
| 206 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 207 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 208 | /* power management */ |
| 209 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 210 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 211 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 212 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 213 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 214 | /* jack detection */ |
| 215 | struct snd_array jacks; |
| 216 | |
| 217 | /* events */ |
| 218 | struct snd_array events; |
| 219 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 220 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 221 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 222 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 223 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 224 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 225 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 226 | hda_nid_t hp_dacs[5]; |
| 227 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 228 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 229 | int volume_offset; |
| 230 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 231 | /* capture */ |
| 232 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 233 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 234 | hda_nid_t *mux_nids; |
| 235 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 236 | hda_nid_t *dmic_nids; |
| 237 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 238 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 239 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 240 | hda_nid_t *smux_nids; |
| 241 | unsigned int num_smuxes; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 242 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 243 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 244 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 245 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 246 | hda_nid_t anabeep_nid; |
| 247 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 248 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 249 | /* pin widgets */ |
| 250 | hda_nid_t *pin_nids; |
| 251 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 252 | |
| 253 | /* codec specific stuff */ |
| 254 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 255 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 256 | |
| 257 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 258 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 259 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 260 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 261 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 262 | struct hda_input_mux *sinput_mux; |
| 263 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 264 | unsigned int cur_amux; |
| 265 | hda_nid_t *amp_nids; |
| 266 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 267 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 268 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 269 | /* i/o switches */ |
| 270 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 271 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 272 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 273 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 274 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 275 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 276 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 277 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 278 | |
| 279 | /* dynamic controls and input_mux */ |
| 280 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 281 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 282 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 283 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 284 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 285 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 286 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | static hda_nid_t stac9200_adc_nids[1] = { |
| 290 | 0x03, |
| 291 | }; |
| 292 | |
| 293 | static hda_nid_t stac9200_mux_nids[1] = { |
| 294 | 0x0c, |
| 295 | }; |
| 296 | |
| 297 | static hda_nid_t stac9200_dac_nids[1] = { |
| 298 | 0x02, |
| 299 | }; |
| 300 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 301 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 302 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 303 | 0x0f, 0x10, 0x11 |
| 304 | }; |
| 305 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 306 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 307 | 0x26, 0, |
| 308 | }; |
| 309 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 310 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 311 | 0x1a, 0x1b |
| 312 | }; |
| 313 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 314 | #define DELL_M6_AMP 2 |
| 315 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 316 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 317 | }; |
| 318 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 319 | #define STAC92HD73XX_NUM_DMICS 2 |
| 320 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 321 | 0x13, 0x14, 0 |
| 322 | }; |
| 323 | |
| 324 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 325 | |
| 326 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 327 | 0x28, 0x29, 0x2a, 0x2b, |
| 328 | }; |
| 329 | |
| 330 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 331 | 0x20, 0x21, |
| 332 | }; |
| 333 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 334 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 335 | 0x22, 0x23, |
| 336 | }; |
| 337 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 338 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 339 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 340 | 0x11, 0x12, 0 |
| 341 | }; |
| 342 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 343 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 344 | |
| 345 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 346 | 0x17, 0x18, |
| 347 | }; |
| 348 | |
| 349 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 350 | 0x15, 0x16, |
| 351 | }; |
| 352 | |
| 353 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 354 | 0xa, 0xb, 0xd, 0xe, |
| 355 | }; |
| 356 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 357 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 358 | 0x1e, 0, |
| 359 | }; |
| 360 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 361 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 362 | 0x03, 0x0c, 0x20, 0x40, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 363 | }; |
| 364 | |
Takashi Iwai | 9248f26 | 2009-01-14 09:40:25 +0100 | [diff] [blame] | 365 | static hda_nid_t stac92hd83xxx_amp_nids[1] = { |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 366 | 0xc, |
| 367 | }; |
| 368 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 369 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 370 | 0x0a, 0x0d, 0x0f |
| 371 | }; |
| 372 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 373 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 374 | 0x12, 0x13, |
| 375 | }; |
| 376 | |
| 377 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 378 | 0x1a, 0x1b |
| 379 | }; |
| 380 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 381 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 382 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 383 | }; |
| 384 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 385 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 386 | 0x24, 0x25, |
| 387 | }; |
| 388 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 389 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 390 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 391 | 0x18, 0x19, 0 |
| 392 | }; |
| 393 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 394 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 395 | 0x22, 0 |
| 396 | }; |
| 397 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 398 | static hda_nid_t stac925x_adc_nids[1] = { |
| 399 | 0x03, |
| 400 | }; |
| 401 | |
| 402 | static hda_nid_t stac925x_mux_nids[1] = { |
| 403 | 0x0f, |
| 404 | }; |
| 405 | |
| 406 | static hda_nid_t stac925x_dac_nids[1] = { |
| 407 | 0x02, |
| 408 | }; |
| 409 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 410 | #define STAC925X_NUM_DMICS 1 |
| 411 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 412 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 413 | }; |
| 414 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 415 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 416 | 0x14, |
| 417 | }; |
| 418 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 419 | static hda_nid_t stac922x_adc_nids[2] = { |
| 420 | 0x06, 0x07, |
| 421 | }; |
| 422 | |
| 423 | static hda_nid_t stac922x_mux_nids[2] = { |
| 424 | 0x12, 0x13, |
| 425 | }; |
| 426 | |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 427 | static hda_nid_t stac927x_slave_dig_outs[2] = { |
| 428 | 0x1f, 0, |
| 429 | }; |
| 430 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 431 | static hda_nid_t stac927x_adc_nids[3] = { |
| 432 | 0x07, 0x08, 0x09 |
| 433 | }; |
| 434 | |
| 435 | static hda_nid_t stac927x_mux_nids[3] = { |
| 436 | 0x15, 0x16, 0x17 |
| 437 | }; |
| 438 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 439 | static hda_nid_t stac927x_smux_nids[1] = { |
| 440 | 0x21, |
| 441 | }; |
| 442 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 443 | static hda_nid_t stac927x_dac_nids[6] = { |
| 444 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 445 | }; |
| 446 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 447 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 448 | 0x1b, |
| 449 | }; |
| 450 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 451 | #define STAC927X_NUM_DMICS 2 |
| 452 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 453 | 0x13, 0x14, 0 |
| 454 | }; |
| 455 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 456 | static const char *stac927x_spdif_labels[5] = { |
| 457 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 458 | "Analog Mux 2", "Analog Mux 3" |
| 459 | }; |
| 460 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 461 | static hda_nid_t stac9205_adc_nids[2] = { |
| 462 | 0x12, 0x13 |
| 463 | }; |
| 464 | |
| 465 | static hda_nid_t stac9205_mux_nids[2] = { |
| 466 | 0x19, 0x1a |
| 467 | }; |
| 468 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 469 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 470 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 471 | }; |
| 472 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 473 | static hda_nid_t stac9205_smux_nids[1] = { |
| 474 | 0x21, |
| 475 | }; |
| 476 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 477 | #define STAC9205_NUM_DMICS 2 |
| 478 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 479 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 480 | }; |
| 481 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 482 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 483 | 0x08, 0x09, 0x0d, 0x0e, |
| 484 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 485 | }; |
| 486 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 487 | static hda_nid_t stac925x_pin_nids[8] = { |
| 488 | 0x07, 0x08, 0x0a, 0x0b, |
| 489 | 0x0c, 0x0d, 0x10, 0x11, |
| 490 | }; |
| 491 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 492 | static hda_nid_t stac922x_pin_nids[10] = { |
| 493 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 494 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 495 | }; |
| 496 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 497 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 498 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 499 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 500 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 501 | }; |
| 502 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 503 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 504 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 505 | 0x0f, 0x10, 0x11, 0x1f, 0x20, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 506 | }; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 507 | |
| 508 | #define STAC92HD71BXX_NUM_PINS 13 |
| 509 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
| 510 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 511 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 512 | 0x1f, 0x20, 0x27 |
| 513 | }; |
| 514 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 515 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 516 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 517 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 518 | }; |
| 519 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 520 | static hda_nid_t stac927x_pin_nids[14] = { |
| 521 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 522 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 523 | 0x14, 0x21, 0x22, 0x23, |
| 524 | }; |
| 525 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 526 | static hda_nid_t stac9205_pin_nids[12] = { |
| 527 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 528 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 529 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 530 | }; |
| 531 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 532 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 533 | |
| 534 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 535 | struct snd_ctl_elem_value *ucontrol) |
| 536 | { |
| 537 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 538 | struct sigmatel_spec *spec = codec->spec; |
| 539 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 540 | |
| 541 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 542 | kcontrol->private_value |= nid; |
| 543 | |
| 544 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 545 | } |
| 546 | |
| 547 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 548 | struct snd_ctl_elem_value *ucontrol) |
| 549 | { |
| 550 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 551 | struct sigmatel_spec *spec = codec->spec; |
| 552 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 553 | |
| 554 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 555 | kcontrol->private_value |= nid; |
| 556 | |
| 557 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 558 | } |
| 559 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 560 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 561 | struct snd_ctl_elem_info *uinfo) |
| 562 | { |
| 563 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 564 | struct sigmatel_spec *spec = codec->spec; |
| 565 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 566 | } |
| 567 | |
| 568 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 569 | struct snd_ctl_elem_value *ucontrol) |
| 570 | { |
| 571 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 572 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 573 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 574 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 575 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 576 | return 0; |
| 577 | } |
| 578 | |
| 579 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 580 | struct snd_ctl_elem_value *ucontrol) |
| 581 | { |
| 582 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 583 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 584 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 585 | |
| 586 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 587 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 588 | } |
| 589 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 590 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 591 | struct snd_ctl_elem_info *uinfo) |
| 592 | { |
| 593 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 594 | struct sigmatel_spec *spec = codec->spec; |
| 595 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 596 | } |
| 597 | |
| 598 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 599 | struct snd_ctl_elem_value *ucontrol) |
| 600 | { |
| 601 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 602 | struct sigmatel_spec *spec = codec->spec; |
| 603 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 604 | |
| 605 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 610 | struct snd_ctl_elem_value *ucontrol) |
| 611 | { |
| 612 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 613 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 614 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 615 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 616 | int err, val; |
| 617 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 618 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 619 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 620 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 621 | if (err < 0) |
| 622 | return err; |
| 623 | |
| 624 | if (spec->spdif_mute) { |
| 625 | if (smux_idx == 0) |
| 626 | nid = spec->multiout.dig_out_nid; |
| 627 | else |
| 628 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 629 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 630 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 631 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 632 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 633 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 634 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 635 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 636 | } |
| 637 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 638 | } |
| 639 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 640 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 641 | hda_nid_t nid, unsigned int new_vref) |
| 642 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 643 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 644 | unsigned int pincfg; |
| 645 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 646 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 647 | |
| 648 | pincfg &= 0xff; |
| 649 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 650 | pincfg |= new_vref; |
| 651 | |
| 652 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 653 | pincfg |= AC_PINCTL_OUT_EN; |
| 654 | else |
| 655 | pincfg |= AC_PINCTL_IN_EN; |
| 656 | |
| 657 | error = snd_hda_codec_write_cache(codec, nid, 0, |
| 658 | AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); |
| 659 | if (error < 0) |
| 660 | return error; |
| 661 | else |
| 662 | return 1; |
| 663 | } |
| 664 | |
| 665 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 666 | { |
| 667 | unsigned int vref; |
| 668 | vref = snd_hda_codec_read(codec, nid, 0, |
| 669 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 670 | vref &= AC_PINCTL_VREFEN; |
| 671 | return vref; |
| 672 | } |
| 673 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 674 | 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] | 675 | { |
| 676 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 677 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 678 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 679 | } |
| 680 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 681 | 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] | 682 | { |
| 683 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 684 | struct sigmatel_spec *spec = codec->spec; |
| 685 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 686 | |
| 687 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 688 | return 0; |
| 689 | } |
| 690 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 691 | 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] | 692 | { |
| 693 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 694 | struct sigmatel_spec *spec = codec->spec; |
| 695 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 696 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 697 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 698 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 699 | } |
| 700 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 701 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 702 | struct snd_ctl_elem_info *uinfo) |
| 703 | { |
| 704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 705 | struct sigmatel_spec *spec = codec->spec; |
| 706 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 707 | } |
| 708 | |
| 709 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 710 | struct snd_ctl_elem_value *ucontrol) |
| 711 | { |
| 712 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 713 | struct sigmatel_spec *spec = codec->spec; |
| 714 | |
| 715 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 716 | return 0; |
| 717 | } |
| 718 | |
| 719 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 720 | struct snd_ctl_elem_value *ucontrol) |
| 721 | { |
| 722 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 723 | struct sigmatel_spec *spec = codec->spec; |
| 724 | |
| 725 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 726 | spec->mono_nid, &spec->cur_mmux); |
| 727 | } |
| 728 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 729 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 730 | struct snd_ctl_elem_info *uinfo) |
| 731 | { |
| 732 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 733 | struct sigmatel_spec *spec = codec->spec; |
| 734 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 735 | } |
| 736 | |
| 737 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 738 | struct snd_ctl_elem_value *ucontrol) |
| 739 | { |
| 740 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 741 | struct sigmatel_spec *spec = codec->spec; |
| 742 | |
| 743 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 744 | return 0; |
| 745 | } |
| 746 | |
| 747 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 748 | struct snd_ctl_elem_value *ucontrol) |
| 749 | { |
| 750 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 751 | struct sigmatel_spec *spec = codec->spec; |
| 752 | struct snd_kcontrol *ctl = |
| 753 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 754 | if (!ctl) |
| 755 | return -EINVAL; |
| 756 | |
| 757 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 758 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 759 | |
| 760 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 761 | 0, &spec->cur_amux); |
| 762 | } |
| 763 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 764 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 765 | |
| 766 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 767 | struct snd_ctl_elem_value *ucontrol) |
| 768 | { |
| 769 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 770 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 771 | struct sigmatel_spec *spec = codec->spec; |
| 772 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 773 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 774 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 779 | struct snd_ctl_elem_value *ucontrol) |
| 780 | { |
| 781 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 782 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 783 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 784 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 785 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 786 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 787 | idx_val = spec->aloopback_mask << idx; |
| 788 | if (ucontrol->value.integer.value[0]) |
| 789 | val = spec->aloopback | idx_val; |
| 790 | else |
| 791 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 792 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 793 | return 0; |
| 794 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 795 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 796 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 797 | /* Only return the bits defined by the shift value of the |
| 798 | * first two bytes of the mask |
| 799 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 800 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 801 | kcontrol->private_value & 0xFFFF, 0x0); |
| 802 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 803 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 804 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 805 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 806 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 807 | } else { |
| 808 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 809 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 813 | kcontrol->private_value >> 16, dac_mode); |
| 814 | |
| 815 | return 1; |
| 816 | } |
| 817 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 818 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 819 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 820 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 821 | {} |
| 822 | }; |
| 823 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 824 | static struct hda_verb stac9200_eapd_init[] = { |
| 825 | /* set dac0mux for dac converter */ |
| 826 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 827 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 828 | {} |
| 829 | }; |
| 830 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 831 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 832 | /* set master volume and direct control */ |
| 833 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 834 | /* setup adcs to point to mixer */ |
| 835 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 836 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 837 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 838 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 839 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 840 | /* setup import muxs */ |
| 841 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 842 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 843 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 844 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 845 | {} |
| 846 | }; |
| 847 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 848 | static struct hda_verb dell_eq_core_init[] = { |
| 849 | /* set master volume to max value without distortion |
| 850 | * and direct control */ |
| 851 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +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}, |
| 855 | /* setup import muxs */ |
| 856 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 857 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 858 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 859 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 860 | {} |
| 861 | }; |
| 862 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 863 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 864 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 865 | /* setup adcs to point to mixer */ |
| 866 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 867 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 868 | /* setup import muxs */ |
| 869 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 870 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 871 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 872 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 873 | {} |
| 874 | }; |
| 875 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 876 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 877 | /* set master volume and direct control */ |
| 878 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 879 | /* setup adcs to point to mixer */ |
| 880 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 881 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 882 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 883 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 884 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 885 | /* setup import muxs */ |
| 886 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 887 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 888 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 889 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 890 | {} |
| 891 | }; |
| 892 | |
| 893 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 894 | /* set master volume and direct control */ |
| 895 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 896 | /* dac3 is connected to import3 mux */ |
| 897 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 898 | /* setup adcs to point to mixer */ |
| 899 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 900 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 901 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 902 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 903 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 904 | /* setup import muxs */ |
| 905 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 906 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 907 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 908 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 909 | {} |
| 910 | }; |
| 911 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 912 | static struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 913 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 914 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 915 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 916 | |
| 917 | /* power state controls amps */ |
| 918 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 919 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 920 | }; |
| 921 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 922 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 923 | /* set master volume and direct control */ |
| 924 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 925 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 926 | }; |
| 927 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 928 | #define HD_DISABLE_PORTF 1 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 929 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 930 | /* start of config #1 */ |
| 931 | |
| 932 | /* connect port 0f to audio mixer */ |
| 933 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 934 | /* start of config #2 */ |
| 935 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 936 | /* set master volume and direct control */ |
| 937 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 938 | {} |
| 939 | }; |
| 940 | |
| 941 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
| 942 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 943 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 944 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 945 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 946 | {} |
| 947 | }; |
| 948 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 949 | static struct hda_verb stac925x_core_init[] = { |
| 950 | /* set dac0mux for dac converter */ |
| 951 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 952 | /* mute the master volume */ |
| 953 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 954 | {} |
| 955 | }; |
| 956 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 957 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 958 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 959 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 960 | {} |
| 961 | }; |
| 962 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 963 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 964 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 965 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 966 | /* unmute node 0x1b */ |
| 967 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 968 | /* select node 0x03 as DAC */ |
| 969 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 970 | {} |
| 971 | }; |
| 972 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 973 | static struct hda_verb stac927x_core_init[] = { |
| 974 | /* set master volume and direct control */ |
| 975 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 976 | /* enable analog pc beep path */ |
| 977 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 978 | {} |
| 979 | }; |
| 980 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 981 | static struct hda_verb stac9205_core_init[] = { |
| 982 | /* set master volume and direct control */ |
| 983 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 984 | /* enable analog pc beep path */ |
| 985 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 986 | {} |
| 987 | }; |
| 988 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 989 | #define STAC_MONO_MUX \ |
| 990 | { \ |
| 991 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 992 | .name = "Mono Mux", \ |
| 993 | .count = 1, \ |
| 994 | .info = stac92xx_mono_mux_enum_info, \ |
| 995 | .get = stac92xx_mono_mux_enum_get, \ |
| 996 | .put = stac92xx_mono_mux_enum_put, \ |
| 997 | } |
| 998 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 999 | #define STAC_AMP_MUX \ |
| 1000 | { \ |
| 1001 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1002 | .name = "Amp Selector Capture Switch", \ |
| 1003 | .count = 1, \ |
| 1004 | .info = stac92xx_amp_mux_enum_info, \ |
| 1005 | .get = stac92xx_amp_mux_enum_get, \ |
| 1006 | .put = stac92xx_amp_mux_enum_put, \ |
| 1007 | } |
| 1008 | |
| 1009 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 1010 | { \ |
| 1011 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1012 | .name = xname, \ |
| 1013 | .index = 0, \ |
| 1014 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1015 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1016 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 1017 | .info = stac92xx_amp_volume_info, \ |
| 1018 | .get = stac92xx_amp_volume_get, \ |
| 1019 | .put = stac92xx_amp_volume_put, \ |
| 1020 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 1021 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 1022 | } |
| 1023 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1024 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1025 | { \ |
| 1026 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1027 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1028 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1029 | .info = stac92xx_aloopback_info, \ |
| 1030 | .get = stac92xx_aloopback_get, \ |
| 1031 | .put = stac92xx_aloopback_put, \ |
| 1032 | .private_value = verb_read | (verb_write << 16), \ |
| 1033 | } |
| 1034 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1035 | #define DC_BIAS(xname, idx, nid) \ |
| 1036 | { \ |
| 1037 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1038 | .name = xname, \ |
| 1039 | .index = idx, \ |
| 1040 | .info = stac92xx_dc_bias_info, \ |
| 1041 | .get = stac92xx_dc_bias_get, \ |
| 1042 | .put = stac92xx_dc_bias_put, \ |
| 1043 | .private_value = nid, \ |
| 1044 | } |
| 1045 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1046 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1047 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1048 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1049 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1050 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1051 | { } /* end */ |
| 1052 | }; |
| 1053 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1054 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1055 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1056 | /* start of config #1 */ |
| 1057 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1058 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1059 | |
| 1060 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1061 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1062 | |
| 1063 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1064 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1065 | |
| 1066 | /* start of config #2 */ |
| 1067 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1068 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1069 | |
| 1070 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1071 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1072 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1073 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1074 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1075 | |
| 1076 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1077 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1078 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1079 | { } /* end */ |
| 1080 | }; |
| 1081 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1082 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
| 1083 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1084 | {} |
| 1085 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1086 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1087 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
| 1088 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1089 | {} |
| 1090 | }; |
| 1091 | |
| 1092 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
| 1093 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1094 | {} |
| 1095 | }; |
| 1096 | |
| 1097 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1098 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1099 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1100 | |
| 1101 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1102 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1103 | |
| 1104 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1105 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1106 | |
| 1107 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1108 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1109 | |
| 1110 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1111 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1112 | |
| 1113 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1114 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1115 | |
| 1116 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1117 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1118 | { } /* end */ |
| 1119 | }; |
| 1120 | |
| 1121 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1122 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1123 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1124 | |
| 1125 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1126 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1127 | |
| 1128 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1129 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1130 | |
| 1131 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1132 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1133 | |
| 1134 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1135 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1136 | |
| 1137 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1138 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1139 | |
| 1140 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1141 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1142 | { } /* end */ |
| 1143 | }; |
| 1144 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1145 | |
| 1146 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1147 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1148 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1149 | |
| 1150 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1151 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1152 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1153 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1154 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1155 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1156 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1157 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1158 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1159 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
| 1160 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1161 | |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1162 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1163 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1164 | |
| 1165 | /* |
Matthew Ranostay | 74b7ff4 | 2008-12-20 17:47:24 -0500 | [diff] [blame] | 1166 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1167 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1168 | */ |
| 1169 | { } /* end */ |
| 1170 | }; |
| 1171 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1172 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1173 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1174 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1175 | |
| 1176 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1177 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1178 | /* analog pc-beep replaced with digital beep support */ |
| 1179 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1180 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1181 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1182 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1183 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1184 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1185 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1186 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1187 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1188 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1189 | |
| 1190 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1191 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1192 | |
| 1193 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1194 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1195 | { } /* end */ |
| 1196 | }; |
| 1197 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1198 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
| 1199 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1200 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1201 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1202 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1203 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1204 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1205 | |
| 1206 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1207 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1208 | { } /* end */ |
| 1209 | }; |
| 1210 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1211 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 1212 | HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), |
| 1213 | HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1214 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1215 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1216 | { } /* end */ |
| 1217 | }; |
| 1218 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1219 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1220 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1221 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1222 | |
| 1223 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1224 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1225 | { } /* end */ |
| 1226 | }; |
| 1227 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1228 | static struct snd_kcontrol_new stac9205_loopback[] = { |
| 1229 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1230 | {} |
| 1231 | }; |
| 1232 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1233 | /* This needs to be generated dynamically based on sequence */ |
| 1234 | static struct snd_kcontrol_new stac922x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1235 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1236 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1237 | |
| 1238 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1239 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1240 | { } /* end */ |
| 1241 | }; |
| 1242 | |
| 1243 | |
| 1244 | static struct snd_kcontrol_new stac927x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1245 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1246 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1247 | |
| 1248 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1249 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1250 | |
| 1251 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1252 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1253 | { } /* end */ |
| 1254 | }; |
| 1255 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1256 | static struct snd_kcontrol_new stac927x_loopback[] = { |
| 1257 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1258 | {} |
| 1259 | }; |
| 1260 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1261 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1262 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1263 | .name = "Digital Input Source", |
| 1264 | /* count set later */ |
| 1265 | .info = stac92xx_dmux_enum_info, |
| 1266 | .get = stac92xx_dmux_enum_get, |
| 1267 | .put = stac92xx_dmux_enum_put, |
| 1268 | }; |
| 1269 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1270 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1271 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1272 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1273 | /* count set later */ |
| 1274 | .info = stac92xx_smux_enum_info, |
| 1275 | .get = stac92xx_smux_enum_get, |
| 1276 | .put = stac92xx_smux_enum_put, |
| 1277 | }; |
| 1278 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1279 | static const char *slave_vols[] = { |
| 1280 | "Front Playback Volume", |
| 1281 | "Surround Playback Volume", |
| 1282 | "Center Playback Volume", |
| 1283 | "LFE Playback Volume", |
| 1284 | "Side Playback Volume", |
| 1285 | "Headphone Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1286 | "Speaker Playback Volume", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1287 | NULL |
| 1288 | }; |
| 1289 | |
| 1290 | static const char *slave_sws[] = { |
| 1291 | "Front Playback Switch", |
| 1292 | "Surround Playback Switch", |
| 1293 | "Center Playback Switch", |
| 1294 | "LFE Playback Switch", |
| 1295 | "Side Playback Switch", |
| 1296 | "Headphone Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1297 | "Speaker Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1298 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1299 | NULL |
| 1300 | }; |
| 1301 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1302 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1303 | 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] | 1304 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1305 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1306 | { |
| 1307 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1308 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1309 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1310 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1311 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1312 | |
| 1313 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1314 | if (err < 0) |
| 1315 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1316 | |
| 1317 | for (i = 0; i < spec->num_mixers; i++) { |
| 1318 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1319 | if (err < 0) |
| 1320 | return err; |
| 1321 | } |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1322 | if (spec->num_dmuxes > 0) { |
| 1323 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1324 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1325 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1326 | if (err < 0) |
| 1327 | return err; |
| 1328 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1329 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1330 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1331 | struct hda_input_mux *smux = &spec->private_smux; |
| 1332 | /* check for mute support on SPDIF out */ |
| 1333 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1334 | smux->items[smux->num_items].label = "Off"; |
| 1335 | smux->items[smux->num_items].index = 0; |
| 1336 | smux->num_items++; |
| 1337 | spec->spdif_mute = 1; |
| 1338 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1339 | stac_smux_mixer.count = spec->num_smuxes; |
Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1340 | err = snd_hda_ctl_add(codec, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1341 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1342 | if (err < 0) |
| 1343 | return err; |
| 1344 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1345 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1346 | if (spec->multiout.dig_out_nid) { |
| 1347 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1348 | if (err < 0) |
| 1349 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1350 | err = snd_hda_create_spdif_share_sw(codec, |
| 1351 | &spec->multiout); |
| 1352 | if (err < 0) |
| 1353 | return err; |
| 1354 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1355 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1356 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1357 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1358 | if (err < 0) |
| 1359 | return err; |
| 1360 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1361 | |
| 1362 | /* if we have no master control, let's create it */ |
| 1363 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1364 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1365 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1366 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1367 | /* correct volume offset */ |
| 1368 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1369 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1370 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1371 | if (err < 0) |
| 1372 | return err; |
| 1373 | } |
| 1374 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1375 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1376 | NULL, slave_sws); |
| 1377 | if (err < 0) |
| 1378 | return err; |
| 1379 | } |
| 1380 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1381 | if (spec->aloopback_ctl && |
| 1382 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1383 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1384 | if (err < 0) |
| 1385 | return err; |
| 1386 | } |
| 1387 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1388 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1389 | |
| 1390 | /* create jack input elements */ |
| 1391 | if (spec->hp_detect) { |
| 1392 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1393 | int type = SND_JACK_HEADPHONE; |
| 1394 | nid = cfg->hp_pins[i]; |
| 1395 | /* jack detection */ |
| 1396 | if (cfg->hp_outs == i) |
| 1397 | type |= SND_JACK_LINEOUT; |
| 1398 | err = stac92xx_add_jack(codec, nid, type); |
| 1399 | if (err < 0) |
| 1400 | return err; |
| 1401 | } |
| 1402 | } |
| 1403 | for (i = 0; i < cfg->line_outs; i++) { |
| 1404 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1405 | SND_JACK_LINEOUT); |
| 1406 | if (err < 0) |
| 1407 | return err; |
| 1408 | } |
| 1409 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1410 | nid = cfg->input_pins[i]; |
| 1411 | if (nid) { |
| 1412 | err = stac92xx_add_jack(codec, nid, |
| 1413 | SND_JACK_MICROPHONE); |
| 1414 | if (err < 0) |
| 1415 | return err; |
| 1416 | } |
| 1417 | } |
| 1418 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1419 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1420 | } |
| 1421 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1422 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1423 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1424 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1425 | }; |
| 1426 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1427 | static unsigned int gateway9200_m4_pin_configs[8] = { |
| 1428 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1429 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1430 | }; |
| 1431 | static unsigned int gateway9200_m4_2_pin_configs[8] = { |
| 1432 | 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, |
| 1433 | 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, |
| 1434 | }; |
| 1435 | |
| 1436 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1437 | STAC 9200 pin configs for |
| 1438 | 102801A8 |
| 1439 | 102801DE |
| 1440 | 102801E8 |
| 1441 | */ |
| 1442 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1443 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1444 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1445 | }; |
| 1446 | |
| 1447 | /* |
| 1448 | STAC 9200 pin configs for |
| 1449 | 102801C0 |
| 1450 | 102801C1 |
| 1451 | */ |
| 1452 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1453 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1454 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1455 | }; |
| 1456 | |
| 1457 | /* |
| 1458 | STAC 9200 pin configs for |
| 1459 | 102801C4 (Dell Dimension E310) |
| 1460 | 102801C5 |
| 1461 | 102801C7 |
| 1462 | 102801D9 |
| 1463 | 102801DA |
| 1464 | 102801E3 |
| 1465 | */ |
| 1466 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1467 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1468 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1469 | }; |
| 1470 | |
| 1471 | |
| 1472 | /* |
| 1473 | STAC 9200-32 pin configs for |
| 1474 | 102801B5 (Dell Inspiron 630m) |
| 1475 | 102801D8 (Dell Inspiron 640m) |
| 1476 | */ |
| 1477 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1478 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1479 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1480 | }; |
| 1481 | |
| 1482 | /* |
| 1483 | STAC 9200-32 pin configs for |
| 1484 | 102801C2 (Dell Latitude D620) |
| 1485 | 102801C8 |
| 1486 | 102801CC (Dell Latitude D820) |
| 1487 | 102801D4 |
| 1488 | 102801D6 |
| 1489 | */ |
| 1490 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1491 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1492 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1493 | }; |
| 1494 | |
| 1495 | /* |
| 1496 | STAC 9200-32 pin configs for |
| 1497 | 102801CE (Dell XPS M1710) |
| 1498 | 102801CF (Dell Precision M90) |
| 1499 | */ |
| 1500 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1501 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1502 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1503 | }; |
| 1504 | |
| 1505 | /* |
| 1506 | STAC 9200-32 pin configs for |
| 1507 | 102801C9 |
| 1508 | 102801CA |
| 1509 | 102801CB (Dell Latitude 120L) |
| 1510 | 102801D3 |
| 1511 | */ |
| 1512 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1513 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1514 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1515 | }; |
| 1516 | |
| 1517 | /* |
| 1518 | STAC 9200-32 pin configs for |
| 1519 | 102801BD (Dell Inspiron E1505n) |
| 1520 | 102801EE |
| 1521 | 102801EF |
| 1522 | */ |
| 1523 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1524 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1525 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1526 | }; |
| 1527 | |
| 1528 | /* |
| 1529 | STAC 9200-32 pin configs for |
| 1530 | 102801F5 (Dell Inspiron 1501) |
| 1531 | 102801F6 |
| 1532 | */ |
| 1533 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1534 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1535 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1536 | }; |
| 1537 | |
| 1538 | /* |
| 1539 | STAC 9200-32 |
| 1540 | 102801CD (Dell Inspiron E1705/9400) |
| 1541 | */ |
| 1542 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1543 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1544 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1545 | }; |
| 1546 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1547 | static unsigned int oqo9200_pin_configs[8] = { |
| 1548 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1549 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1550 | }; |
| 1551 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1552 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1553 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1554 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1555 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1556 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1557 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1558 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1559 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1560 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1561 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1562 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1563 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1564 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1565 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1566 | [STAC_9200_M4] = gateway9200_m4_pin_configs, |
| 1567 | [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1568 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1569 | }; |
| 1570 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1571 | static const char *stac9200_models[STAC_9200_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1572 | [STAC_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1573 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1574 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1575 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1576 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1577 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1578 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1579 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1580 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1581 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1582 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1583 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1584 | [STAC_9200_DELL_M27] = "dell-m27", |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1585 | [STAC_9200_M4] = "gateway-m4", |
| 1586 | [STAC_9200_M4_2] = "gateway-m4-2", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1587 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1588 | }; |
| 1589 | |
| 1590 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1591 | /* SigmaTel reference board */ |
| 1592 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1593 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1594 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1595 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1596 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1597 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1598 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1599 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1600 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1601 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1602 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1603 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1604 | "unknown Dell", STAC_9200_DELL_D22), |
| 1605 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1606 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1607 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1608 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1609 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1610 | "unknown Dell", STAC_9200_DELL_D23), |
| 1611 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1612 | "unknown Dell", STAC_9200_DELL_D23), |
| 1613 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1614 | "unknown Dell", STAC_9200_DELL_M22), |
| 1615 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1616 | "unknown Dell", STAC_9200_DELL_M24), |
| 1617 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1618 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1619 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1620 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1621 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1622 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1623 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1624 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1625 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1626 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1627 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1628 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1629 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1630 | "unknown Dell", STAC_9200_DELL_M22), |
| 1631 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1632 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1633 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1634 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1635 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1636 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1637 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1638 | "unknown Dell", STAC_9200_DELL_D23), |
| 1639 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1640 | "unknown Dell", STAC_9200_DELL_D23), |
| 1641 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1642 | "unknown Dell", STAC_9200_DELL_D21), |
| 1643 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1644 | "unknown Dell", STAC_9200_DELL_D23), |
| 1645 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1646 | "unknown Dell", STAC_9200_DELL_D21), |
| 1647 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1648 | "unknown Dell", STAC_9200_DELL_M25), |
| 1649 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1650 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1651 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1652 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1653 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1654 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1655 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1656 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1657 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1658 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1659 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1660 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1661 | /* OQO Mobile */ |
| 1662 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1663 | {} /* terminator */ |
| 1664 | }; |
| 1665 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1666 | static unsigned int ref925x_pin_configs[8] = { |
| 1667 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1668 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1669 | }; |
| 1670 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1671 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1672 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1673 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1674 | }; |
| 1675 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1676 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1677 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1678 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1679 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1680 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1681 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1682 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1683 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1684 | }; |
| 1685 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1686 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1687 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1688 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1689 | }; |
| 1690 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1691 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1692 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1693 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1694 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1695 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1696 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1697 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1698 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1699 | }; |
| 1700 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1701 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1702 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1703 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1704 | }; |
| 1705 | |
| 1706 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1707 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1708 | [STAC_M1] = stac925xM1_pin_configs, |
| 1709 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1710 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1711 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1712 | [STAC_M3] = stac925xM3_pin_configs, |
| 1713 | [STAC_M5] = stac925xM5_pin_configs, |
| 1714 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1715 | }; |
| 1716 | |
| 1717 | static const char *stac925x_models[STAC_925x_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1718 | [STAC_925x_AUTO] = "auto", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1719 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1720 | [STAC_M1] = "m1", |
| 1721 | [STAC_M1_2] = "m1-2", |
| 1722 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1723 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1724 | [STAC_M3] = "m3", |
| 1725 | [STAC_M5] = "m5", |
| 1726 | [STAC_M6] = "m6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1727 | }; |
| 1728 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1729 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1730 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1731 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1732 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1733 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1734 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1735 | /* Not sure about the brand name for those */ |
| 1736 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1737 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1738 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1739 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1740 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1741 | }; |
| 1742 | |
| 1743 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1744 | /* SigmaTel reference board */ |
| 1745 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1746 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1747 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1748 | |
| 1749 | /* Default table for unknown ID */ |
| 1750 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1751 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1752 | {} /* terminator */ |
| 1753 | }; |
| 1754 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1755 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1756 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1757 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1758 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1759 | 0x01452050, |
| 1760 | }; |
| 1761 | |
| 1762 | static unsigned int dell_m6_pin_configs[13] = { |
| 1763 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1764 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1765 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1766 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1767 | }; |
| 1768 | |
| 1769 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1770 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1771 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1772 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1773 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1774 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1775 | }; |
| 1776 | |
| 1777 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1778 | [STAC_92HD73XX_AUTO] = "auto", |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1779 | [STAC_92HD73XX_NO_JD] = "no-jd", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1780 | [STAC_92HD73XX_REF] = "ref", |
Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame^] | 1781 | [STAC_92HD73XX_INTEL] = "intel", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1782 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1783 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1784 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1785 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1786 | }; |
| 1787 | |
| 1788 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1789 | /* SigmaTel reference board */ |
| 1790 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1791 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1792 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1793 | "DFI LanParty", STAC_92HD73XX_REF), |
Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame^] | 1794 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, |
| 1795 | "Intel DG45ID", STAC_92HD73XX_INTEL), |
| 1796 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, |
| 1797 | "Intel DG45FC", STAC_92HD73XX_INTEL), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1798 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1799 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1800 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1801 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1802 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1803 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1804 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1805 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1806 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1807 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1808 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1809 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1810 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1811 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1812 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1813 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1814 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1815 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1816 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 1817 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Takashi Iwai | 626f5ce | 2009-07-28 00:54:39 +0200 | [diff] [blame] | 1818 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, |
| 1819 | "Dell Studio 1555", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1820 | {} /* terminator */ |
| 1821 | }; |
| 1822 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1823 | static unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1824 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1825 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1826 | 0x01451160, 0x98560170, |
| 1827 | }; |
| 1828 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1829 | static unsigned int dell_s14_pin_configs[10] = { |
| 1830 | 0x02214030, 0x02211010, 0x02a19020, 0x01014050, |
| 1831 | 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, |
| 1832 | 0x40f000f0, 0x40f000f0, |
| 1833 | }; |
| 1834 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1835 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1836 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1837 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1838 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1839 | }; |
| 1840 | |
| 1841 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1842 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1843 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1844 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1845 | [STAC_DELL_S14] = "dell-s14", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1846 | }; |
| 1847 | |
| 1848 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1849 | /* SigmaTel reference board */ |
| 1850 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1851 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1852 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1853 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1854 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 1855 | "unknown Dell", STAC_DELL_S14), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1856 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1857 | }; |
| 1858 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1859 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1860 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1861 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1862 | 0x90a000f0, 0x01452050, 0x01452050, 0x00000000, |
| 1863 | 0x00000000 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1864 | }; |
| 1865 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1866 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1867 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1868 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1869 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, |
| 1870 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1871 | }; |
| 1872 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1873 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1874 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1875 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1876 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1877 | 0x00000000 |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1878 | }; |
| 1879 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1880 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1881 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1882 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1883 | 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, |
| 1884 | 0x00000000 |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1885 | }; |
| 1886 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1887 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1888 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1889 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1890 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1891 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1892 | [STAC_HP_M4] = NULL, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1893 | [STAC_HP_DV5] = NULL, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1894 | [STAC_HP_HDX] = NULL, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1895 | [STAC_HP_DV4_1222NR] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1896 | }; |
| 1897 | |
| 1898 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1899 | [STAC_92HD71BXX_AUTO] = "auto", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1900 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1901 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1902 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1903 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1904 | [STAC_HP_M4] = "hp-m4", |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1905 | [STAC_HP_DV5] = "hp-dv5", |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1906 | [STAC_HP_HDX] = "hp-hdx", |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1907 | [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1908 | }; |
| 1909 | |
| 1910 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1911 | /* SigmaTel reference board */ |
| 1912 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1913 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1914 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1915 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1916 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 1917 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1918 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 1919 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1920 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
| 1921 | "HP dv4-7", STAC_HP_DV5), |
| 1922 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 1923 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1924 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 1925 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1926 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1927 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1928 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1929 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1930 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1931 | "unknown Dell", STAC_DELL_M4_1), |
| 1932 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1933 | "unknown Dell", STAC_DELL_M4_1), |
| 1934 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1935 | "unknown Dell", STAC_DELL_M4_1), |
| 1936 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1937 | "unknown Dell", STAC_DELL_M4_1), |
| 1938 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1939 | "unknown Dell", STAC_DELL_M4_1), |
| 1940 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1941 | "unknown Dell", STAC_DELL_M4_1), |
| 1942 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1943 | "unknown Dell", STAC_DELL_M4_1), |
| 1944 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1945 | "unknown Dell", STAC_DELL_M4_2), |
| 1946 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1947 | "unknown Dell", STAC_DELL_M4_2), |
| 1948 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1949 | "unknown Dell", STAC_DELL_M4_2), |
| 1950 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1951 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1952 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1953 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1954 | {} /* terminator */ |
| 1955 | }; |
| 1956 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1957 | static unsigned int ref922x_pin_configs[10] = { |
| 1958 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1959 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1960 | 0x40000100, 0x40000100, |
| 1961 | }; |
| 1962 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1963 | /* |
| 1964 | STAC 922X pin configs for |
| 1965 | 102801A7 |
| 1966 | 102801AB |
| 1967 | 102801A9 |
| 1968 | 102801D1 |
| 1969 | 102801D2 |
| 1970 | */ |
| 1971 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1972 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1973 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1974 | 0x01813122, 0x400001f2, |
| 1975 | }; |
| 1976 | |
| 1977 | /* |
| 1978 | STAC 922X pin configs for |
| 1979 | 102801AC |
| 1980 | 102801D0 |
| 1981 | */ |
| 1982 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1983 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1984 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1985 | 0x01813122, 0x400001f1, |
| 1986 | }; |
| 1987 | |
| 1988 | /* |
| 1989 | STAC 922X pin configs for |
| 1990 | 102801BF |
| 1991 | */ |
| 1992 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1993 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1994 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1995 | 0x40C003f1, 0x405003f0, |
| 1996 | }; |
| 1997 | |
| 1998 | /* |
| 1999 | STAC 9221 A1 pin configs for |
| 2000 | 102801D7 (Dell XPS M1210) |
| 2001 | */ |
| 2002 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 2003 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 2004 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2005 | 0x508003f3, 0x405003f4, |
| 2006 | }; |
| 2007 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2008 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 2009 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2010 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2011 | 0x02a19120, 0x40000100, |
| 2012 | }; |
| 2013 | |
| 2014 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 2015 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 2016 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2017 | 0x02a19320, 0x40000100, |
| 2018 | }; |
| 2019 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2020 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 2021 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 2022 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2023 | 0x400000fc, 0x400000fb, |
| 2024 | }; |
| 2025 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2026 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 2027 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2028 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2029 | 0x400000fc, 0x400000fb, |
| 2030 | }; |
| 2031 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2032 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 2033 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 2034 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 2035 | 0x400000fc, 0x400000fb, |
| 2036 | }; |
| 2037 | |
| 2038 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 2039 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2040 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2041 | 0x400000fc, 0x400000fb, |
| 2042 | }; |
| 2043 | |
| 2044 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 2045 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 2046 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 2047 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2048 | }; |
| 2049 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2050 | static unsigned int ecs202_pin_configs[10] = { |
| 2051 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 2052 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 2053 | 0x9037012e, 0x40e000f2, |
| 2054 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2055 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2056 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2057 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2058 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 2059 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2060 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 2061 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 2062 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 2063 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 2064 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2065 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2066 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2067 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 2068 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 2069 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 2070 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 2071 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 2072 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2073 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2074 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 2075 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 2076 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 2077 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2078 | }; |
| 2079 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2080 | static const char *stac922x_models[STAC_922X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2081 | [STAC_922X_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2082 | [STAC_D945_REF] = "ref", |
| 2083 | [STAC_D945GTP5] = "5stack", |
| 2084 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2085 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 2086 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 2087 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 2088 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 2089 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2090 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2091 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2092 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2093 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 2094 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 2095 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2096 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2097 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2098 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2099 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2100 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2101 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2102 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2103 | }; |
| 2104 | |
| 2105 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2106 | /* SigmaTel reference board */ |
| 2107 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2108 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2109 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2110 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2111 | /* Intel 945G based systems */ |
| 2112 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2113 | "Intel D945G", STAC_D945GTP3), |
| 2114 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2115 | "Intel D945G", STAC_D945GTP3), |
| 2116 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2117 | "Intel D945G", STAC_D945GTP3), |
| 2118 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2119 | "Intel D945G", STAC_D945GTP3), |
| 2120 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2121 | "Intel D945G", STAC_D945GTP3), |
| 2122 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2123 | "Intel D945G", STAC_D945GTP3), |
| 2124 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2125 | "Intel D945G", STAC_D945GTP3), |
| 2126 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2127 | "Intel D945G", STAC_D945GTP3), |
| 2128 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2129 | "Intel D945G", STAC_D945GTP3), |
| 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2131 | "Intel D945G", STAC_D945GTP3), |
| 2132 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2133 | "Intel D945G", STAC_D945GTP3), |
| 2134 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2135 | "Intel D945G", STAC_D945GTP3), |
| 2136 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2137 | "Intel D945G", STAC_D945GTP3), |
| 2138 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2139 | "Intel D945G", STAC_D945GTP3), |
| 2140 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2141 | "Intel D945G", STAC_D945GTP3), |
| 2142 | /* Intel D945G 5-stack systems */ |
| 2143 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2144 | "Intel D945G", STAC_D945GTP5), |
| 2145 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2146 | "Intel D945G", STAC_D945GTP5), |
| 2147 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2148 | "Intel D945G", STAC_D945GTP5), |
| 2149 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2150 | "Intel D945G", STAC_D945GTP5), |
| 2151 | /* Intel 945P based systems */ |
| 2152 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2153 | "Intel D945P", STAC_D945GTP3), |
| 2154 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2155 | "Intel D945P", STAC_D945GTP3), |
| 2156 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2157 | "Intel D945P", STAC_D945GTP3), |
| 2158 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2159 | "Intel D945P", STAC_D945GTP3), |
| 2160 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2161 | "Intel D945P", STAC_D945GTP3), |
| 2162 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2163 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2164 | /* other intel */ |
| 2165 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2166 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2167 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2168 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2169 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2170 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2171 | /* Dell systems */ |
| 2172 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2173 | "unknown Dell", STAC_922X_DELL_D81), |
| 2174 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2175 | "unknown Dell", STAC_922X_DELL_D81), |
| 2176 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2177 | "unknown Dell", STAC_922X_DELL_D81), |
| 2178 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2179 | "unknown Dell", STAC_922X_DELL_D82), |
| 2180 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2181 | "unknown Dell", STAC_922X_DELL_M81), |
| 2182 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2183 | "unknown Dell", STAC_922X_DELL_D82), |
| 2184 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2185 | "unknown Dell", STAC_922X_DELL_D81), |
| 2186 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2187 | "unknown Dell", STAC_922X_DELL_D81), |
| 2188 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2189 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2190 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2191 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2192 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2193 | {} /* terminator */ |
| 2194 | }; |
| 2195 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2196 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2197 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2198 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2199 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2200 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2201 | }; |
| 2202 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2203 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2204 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2205 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2206 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2207 | 0x40000100, 0x40000100 |
| 2208 | }; |
| 2209 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2210 | static unsigned int d965_5st_pin_configs[14] = { |
| 2211 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2212 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2213 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2214 | 0x40000100, 0x40000100 |
| 2215 | }; |
| 2216 | |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2217 | static unsigned int d965_5st_no_fp_pin_configs[14] = { |
| 2218 | 0x40000100, 0x40000100, 0x0181304e, 0x01014010, |
| 2219 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2220 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2221 | 0x40000100, 0x40000100 |
| 2222 | }; |
| 2223 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2224 | static unsigned int dell_3st_pin_configs[14] = { |
| 2225 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2226 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2227 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2228 | 0x40c003fc, 0x40000100 |
| 2229 | }; |
| 2230 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2231 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2232 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2233 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2234 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2235 | [STAC_D965_5ST] = d965_5st_pin_configs, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2236 | [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2237 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2238 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2239 | }; |
| 2240 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2241 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2242 | [STAC_927X_AUTO] = "auto", |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2243 | [STAC_D965_REF_NO_JD] = "ref-no-jd", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2244 | [STAC_D965_REF] = "ref", |
| 2245 | [STAC_D965_3ST] = "3stack", |
| 2246 | [STAC_D965_5ST] = "5stack", |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2247 | [STAC_D965_5ST_NO_FP] = "5stack-no-fp", |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2248 | [STAC_DELL_3ST] = "dell-3stack", |
| 2249 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2250 | }; |
| 2251 | |
| 2252 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2253 | /* SigmaTel reference board */ |
| 2254 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2255 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2256 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2257 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2258 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2259 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2260 | 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] | 2261 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2262 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 2263 | "Intel D965", STAC_D965_3ST), |
| 2264 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 2265 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2266 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2267 | 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] | 2268 | 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] | 2269 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2270 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2271 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2272 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2273 | 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] | 2274 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 2275 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2276 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2277 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2278 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2279 | 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] | 2280 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2281 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 2282 | "Intel D965", STAC_D965_5ST), |
| 2283 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 2284 | "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2285 | {} /* terminator */ |
| 2286 | }; |
| 2287 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2288 | static unsigned int ref9205_pin_configs[12] = { |
| 2289 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2290 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2291 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2292 | }; |
| 2293 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2294 | /* |
| 2295 | STAC 9205 pin configs for |
| 2296 | 102801F1 |
| 2297 | 102801F2 |
| 2298 | 102801FC |
| 2299 | 102801FD |
| 2300 | 10280204 |
| 2301 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2302 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2303 | */ |
| 2304 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2305 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2306 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2307 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2308 | }; |
| 2309 | |
| 2310 | /* |
| 2311 | STAC 9205 pin configs for |
| 2312 | 102801F9 |
| 2313 | 102801FA |
| 2314 | 102801FE |
| 2315 | 102801FF (Dell Precision M4300) |
| 2316 | 10280206 |
| 2317 | 10280200 |
| 2318 | 10280201 |
| 2319 | */ |
| 2320 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2321 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2322 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2323 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2324 | }; |
| 2325 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2326 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2327 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2328 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2329 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2330 | }; |
| 2331 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2332 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2333 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2334 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2335 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2336 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2337 | [STAC_9205_EAPD] = NULL, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2338 | }; |
| 2339 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2340 | static const char *stac9205_models[STAC_9205_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2341 | [STAC_9205_AUTO] = "auto", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2342 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2343 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2344 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2345 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2346 | [STAC_9205_EAPD] = "eapd", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2347 | }; |
| 2348 | |
| 2349 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2350 | /* SigmaTel reference board */ |
| 2351 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2352 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 2353 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 2354 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2355 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2356 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2357 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2358 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2359 | "unknown Dell", STAC_9205_DELL_M42), |
| 2360 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2361 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2362 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2363 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2364 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2365 | "Dell Precision", STAC_9205_DELL_M43), |
| 2366 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2367 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2368 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2369 | "unknown Dell", STAC_9205_DELL_M42), |
| 2370 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2371 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2372 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2373 | "Dell Precision", STAC_9205_DELL_M43), |
| 2374 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2375 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2376 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2377 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2378 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2379 | "Dell Precision", STAC_9205_DELL_M43), |
| 2380 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2381 | "Dell Precision", STAC_9205_DELL_M43), |
| 2382 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2383 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2384 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2385 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2386 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2387 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2388 | /* Gateway */ |
Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 2389 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2390 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2391 | {} /* terminator */ |
| 2392 | }; |
| 2393 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2394 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
| 2395 | unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2396 | { |
| 2397 | int i; |
| 2398 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2399 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2400 | if (!pincfgs) |
| 2401 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2402 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2403 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2404 | if (spec->pin_nids[i] && pincfgs[i]) |
| 2405 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 2406 | pincfgs[i]); |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2407 | } |
| 2408 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2409 | /* |
| 2410 | * Analog playback callbacks |
| 2411 | */ |
| 2412 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2413 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2414 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2415 | { |
| 2416 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2417 | if (spec->stream_delay) |
| 2418 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2419 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2420 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2421 | } |
| 2422 | |
| 2423 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2424 | struct hda_codec *codec, |
| 2425 | unsigned int stream_tag, |
| 2426 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2427 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2428 | { |
| 2429 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2430 | 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] | 2431 | } |
| 2432 | |
| 2433 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2434 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2435 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2436 | { |
| 2437 | struct sigmatel_spec *spec = codec->spec; |
| 2438 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2439 | } |
| 2440 | |
| 2441 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2442 | * Digital playback callbacks |
| 2443 | */ |
| 2444 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2445 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2446 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2447 | { |
| 2448 | struct sigmatel_spec *spec = codec->spec; |
| 2449 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2450 | } |
| 2451 | |
| 2452 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2453 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2454 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2455 | { |
| 2456 | struct sigmatel_spec *spec = codec->spec; |
| 2457 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2458 | } |
| 2459 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2460 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2461 | struct hda_codec *codec, |
| 2462 | unsigned int stream_tag, |
| 2463 | unsigned int format, |
| 2464 | struct snd_pcm_substream *substream) |
| 2465 | { |
| 2466 | struct sigmatel_spec *spec = codec->spec; |
| 2467 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2468 | stream_tag, format, substream); |
| 2469 | } |
| 2470 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2471 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2472 | struct hda_codec *codec, |
| 2473 | struct snd_pcm_substream *substream) |
| 2474 | { |
| 2475 | struct sigmatel_spec *spec = codec->spec; |
| 2476 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2477 | } |
| 2478 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2479 | |
| 2480 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2481 | * Analog capture callbacks |
| 2482 | */ |
| 2483 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2484 | struct hda_codec *codec, |
| 2485 | unsigned int stream_tag, |
| 2486 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2487 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2488 | { |
| 2489 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2490 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2491 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2492 | if (spec->powerdown_adcs) { |
| 2493 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2494 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2495 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2496 | } |
| 2497 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2498 | return 0; |
| 2499 | } |
| 2500 | |
| 2501 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2502 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2503 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2504 | { |
| 2505 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2506 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2507 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2508 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2509 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2510 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2511 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2512 | return 0; |
| 2513 | } |
| 2514 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2515 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2516 | .substreams = 1, |
| 2517 | .channels_min = 2, |
| 2518 | .channels_max = 2, |
| 2519 | /* NID is set in stac92xx_build_pcms */ |
| 2520 | .ops = { |
| 2521 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2522 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2523 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 2524 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2525 | }, |
| 2526 | }; |
| 2527 | |
| 2528 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2529 | .substreams = 1, |
| 2530 | .channels_min = 2, |
| 2531 | .channels_max = 2, |
| 2532 | /* NID is set in stac92xx_build_pcms */ |
| 2533 | }; |
| 2534 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2535 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2536 | .substreams = 1, |
| 2537 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2538 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2539 | .nid = 0x02, /* NID to query formats and rates */ |
| 2540 | .ops = { |
| 2541 | .open = stac92xx_playback_pcm_open, |
| 2542 | .prepare = stac92xx_playback_pcm_prepare, |
| 2543 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2544 | }, |
| 2545 | }; |
| 2546 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2547 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2548 | .substreams = 1, |
| 2549 | .channels_min = 2, |
| 2550 | .channels_max = 2, |
| 2551 | .nid = 0x06, /* NID to query formats and rates */ |
| 2552 | .ops = { |
| 2553 | .open = stac92xx_playback_pcm_open, |
| 2554 | .prepare = stac92xx_playback_pcm_prepare, |
| 2555 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2556 | }, |
| 2557 | }; |
| 2558 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2559 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2560 | .channels_min = 2, |
| 2561 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2562 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2563 | .ops = { |
| 2564 | .prepare = stac92xx_capture_pcm_prepare, |
| 2565 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2566 | }, |
| 2567 | }; |
| 2568 | |
| 2569 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2570 | { |
| 2571 | struct sigmatel_spec *spec = codec->spec; |
| 2572 | struct hda_pcm *info = spec->pcm_rec; |
| 2573 | |
| 2574 | codec->num_pcms = 1; |
| 2575 | codec->pcm_info = info; |
| 2576 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2577 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2578 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2579 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2580 | spec->multiout.dac_nids[0]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2581 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2582 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2583 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2584 | |
| 2585 | if (spec->alt_switch) { |
| 2586 | codec->num_pcms++; |
| 2587 | info++; |
| 2588 | info->name = "STAC92xx Analog Alt"; |
| 2589 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2590 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2591 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2592 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2593 | codec->num_pcms++; |
| 2594 | info++; |
| 2595 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2596 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2597 | if (spec->multiout.dig_out_nid) { |
| 2598 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2599 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2600 | } |
| 2601 | if (spec->dig_in_nid) { |
| 2602 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2603 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2604 | } |
| 2605 | } |
| 2606 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2607 | return 0; |
| 2608 | } |
| 2609 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2610 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, |
| 2611 | hda_nid_t nid) |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2612 | { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2613 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2614 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2615 | if (pincap & AC_PINCAP_VREF_100) |
| 2616 | return AC_PINCTL_VREF_100; |
| 2617 | if (pincap & AC_PINCAP_VREF_80) |
| 2618 | return AC_PINCTL_VREF_80; |
| 2619 | if (pincap & AC_PINCAP_VREF_50) |
| 2620 | return AC_PINCTL_VREF_50; |
| 2621 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2622 | return AC_PINCTL_VREF_GRD; |
| 2623 | return 0; |
| 2624 | } |
| 2625 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2626 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2627 | |
| 2628 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2629 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2630 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2631 | } |
| 2632 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2633 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2634 | |
| 2635 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2636 | struct snd_ctl_elem_value *ucontrol) |
| 2637 | { |
| 2638 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2639 | struct sigmatel_spec *spec = codec->spec; |
| 2640 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2641 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2642 | return 0; |
| 2643 | } |
| 2644 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2645 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 2646 | unsigned char type); |
| 2647 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2648 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2649 | struct snd_ctl_elem_value *ucontrol) |
| 2650 | { |
| 2651 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2652 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2653 | int nid = kcontrol->private_value; |
| 2654 | |
| 2655 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2656 | |
| 2657 | /* check to be sure that the ports are upto date with |
| 2658 | * switch changes |
| 2659 | */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2660 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2661 | |
| 2662 | return 1; |
| 2663 | } |
| 2664 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2665 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 2666 | struct snd_ctl_elem_info *uinfo) |
| 2667 | { |
| 2668 | int i; |
| 2669 | static char *texts[] = { |
| 2670 | "Mic In", "Line In", "Line Out" |
| 2671 | }; |
| 2672 | |
| 2673 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2674 | struct sigmatel_spec *spec = codec->spec; |
| 2675 | hda_nid_t nid = kcontrol->private_value; |
| 2676 | |
| 2677 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 2678 | i = 3; |
| 2679 | else |
| 2680 | i = 2; |
| 2681 | |
| 2682 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2683 | uinfo->value.enumerated.items = i; |
| 2684 | uinfo->count = 1; |
| 2685 | if (uinfo->value.enumerated.item >= i) |
| 2686 | uinfo->value.enumerated.item = i-1; |
| 2687 | strcpy(uinfo->value.enumerated.name, |
| 2688 | texts[uinfo->value.enumerated.item]); |
| 2689 | |
| 2690 | return 0; |
| 2691 | } |
| 2692 | |
| 2693 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 2694 | struct snd_ctl_elem_value *ucontrol) |
| 2695 | { |
| 2696 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2697 | hda_nid_t nid = kcontrol->private_value; |
| 2698 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 2699 | |
| 2700 | if (vref == stac92xx_get_default_vref(codec, nid)) |
| 2701 | ucontrol->value.enumerated.item[0] = 0; |
| 2702 | else if (vref == AC_PINCTL_VREF_GRD) |
| 2703 | ucontrol->value.enumerated.item[0] = 1; |
| 2704 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 2705 | ucontrol->value.enumerated.item[0] = 2; |
| 2706 | |
| 2707 | return 0; |
| 2708 | } |
| 2709 | |
| 2710 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 2711 | struct snd_ctl_elem_value *ucontrol) |
| 2712 | { |
| 2713 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2714 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 2715 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2716 | hda_nid_t nid = kcontrol->private_value; |
| 2717 | |
| 2718 | if (ucontrol->value.enumerated.item[0] == 0) |
| 2719 | new_vref = stac92xx_get_default_vref(codec, nid); |
| 2720 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 2721 | new_vref = AC_PINCTL_VREF_GRD; |
| 2722 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 2723 | new_vref = AC_PINCTL_VREF_HIZ; |
| 2724 | else |
| 2725 | return 0; |
| 2726 | |
| 2727 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 2728 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 2729 | return error; |
| 2730 | } |
| 2731 | |
| 2732 | return 0; |
| 2733 | } |
| 2734 | |
| 2735 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 2736 | struct snd_ctl_elem_info *uinfo) |
| 2737 | { |
| 2738 | static char *texts[2]; |
| 2739 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2740 | struct sigmatel_spec *spec = codec->spec; |
| 2741 | |
| 2742 | if (kcontrol->private_value == spec->line_switch) |
| 2743 | texts[0] = "Line In"; |
| 2744 | else |
| 2745 | texts[0] = "Mic In"; |
| 2746 | texts[1] = "Line Out"; |
| 2747 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 2748 | uinfo->value.enumerated.items = 2; |
| 2749 | uinfo->count = 1; |
| 2750 | |
| 2751 | if (uinfo->value.enumerated.item >= 2) |
| 2752 | uinfo->value.enumerated.item = 1; |
| 2753 | strcpy(uinfo->value.enumerated.name, |
| 2754 | texts[uinfo->value.enumerated.item]); |
| 2755 | |
| 2756 | return 0; |
| 2757 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2758 | |
| 2759 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2760 | { |
| 2761 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2762 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2763 | hda_nid_t nid = kcontrol->private_value; |
| 2764 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2765 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2766 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2767 | return 0; |
| 2768 | } |
| 2769 | |
| 2770 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2771 | { |
| 2772 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2773 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2774 | hda_nid_t nid = kcontrol->private_value; |
| 2775 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 2776 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2777 | |
| 2778 | spec->io_switch[io_idx] = val; |
| 2779 | |
| 2780 | if (val) |
| 2781 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2782 | else { |
| 2783 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2784 | if (io_idx) /* set VREF for mic */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2785 | pinctl |= stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2786 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2787 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2788 | |
| 2789 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2790 | * appropriately according to the pin direction |
| 2791 | */ |
| 2792 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2793 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2794 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2795 | return 1; |
| 2796 | } |
| 2797 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2798 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2799 | |
| 2800 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2801 | struct snd_ctl_elem_value *ucontrol) |
| 2802 | { |
| 2803 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2804 | struct sigmatel_spec *spec = codec->spec; |
| 2805 | |
| 2806 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2807 | return 0; |
| 2808 | } |
| 2809 | |
| 2810 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2811 | struct snd_ctl_elem_value *ucontrol) |
| 2812 | { |
| 2813 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2814 | struct sigmatel_spec *spec = codec->spec; |
| 2815 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2816 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2817 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2818 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2819 | return 0; |
| 2820 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2821 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2822 | |
| 2823 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2824 | spec->clfe_swap ? 0x4 : 0x0); |
| 2825 | |
| 2826 | return 1; |
| 2827 | } |
| 2828 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2829 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2830 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2831 | .name = xname, \ |
| 2832 | .index = 0, \ |
| 2833 | .info = stac92xx_hp_switch_info, \ |
| 2834 | .get = stac92xx_hp_switch_get, \ |
| 2835 | .put = stac92xx_hp_switch_put, \ |
| 2836 | } |
| 2837 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2838 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2839 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2840 | .name = xname, \ |
| 2841 | .index = 0, \ |
| 2842 | .info = stac92xx_io_switch_info, \ |
| 2843 | .get = stac92xx_io_switch_get, \ |
| 2844 | .put = stac92xx_io_switch_put, \ |
| 2845 | .private_value = xpval, \ |
| 2846 | } |
| 2847 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2848 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2849 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2850 | .name = xname, \ |
| 2851 | .index = 0, \ |
| 2852 | .info = stac92xx_clfe_switch_info, \ |
| 2853 | .get = stac92xx_clfe_switch_get, \ |
| 2854 | .put = stac92xx_clfe_switch_put, \ |
| 2855 | .private_value = xpval, \ |
| 2856 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2857 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2858 | enum { |
| 2859 | STAC_CTL_WIDGET_VOL, |
| 2860 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2861 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2862 | STAC_CTL_WIDGET_AMP_MUX, |
| 2863 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2864 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2865 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2866 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 2867 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2868 | }; |
| 2869 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2870 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2871 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2872 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2873 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2874 | STAC_AMP_MUX, |
| 2875 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2876 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2877 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2878 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2879 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2880 | }; |
| 2881 | |
| 2882 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2883 | static struct snd_kcontrol_new * |
| 2884 | stac_control_new(struct sigmatel_spec *spec, |
| 2885 | struct snd_kcontrol_new *ktemp, |
| 2886 | const char *name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2887 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2888 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2889 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2890 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2891 | knew = snd_array_new(&spec->kctls); |
| 2892 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2893 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2894 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2895 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2896 | if (!knew->name) { |
| 2897 | /* roolback */ |
| 2898 | memset(knew, 0, sizeof(*knew)); |
| 2899 | spec->kctls.alloced--; |
| 2900 | return NULL; |
| 2901 | } |
| 2902 | return knew; |
| 2903 | } |
| 2904 | |
| 2905 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2906 | struct snd_kcontrol_new *ktemp, |
| 2907 | int idx, const char *name, |
| 2908 | unsigned long val) |
| 2909 | { |
| 2910 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); |
| 2911 | if (!knew) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2912 | return -ENOMEM; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2913 | knew->index = idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2914 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2915 | return 0; |
| 2916 | } |
| 2917 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2918 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2919 | int type, int idx, const char *name, |
| 2920 | unsigned long val) |
| 2921 | { |
| 2922 | return stac92xx_add_control_temp(spec, |
| 2923 | &stac92xx_control_templates[type], |
| 2924 | idx, name, val); |
| 2925 | } |
| 2926 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2927 | |
| 2928 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2929 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2930 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2931 | { |
| 2932 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2933 | } |
| 2934 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2935 | static struct snd_kcontrol_new stac_input_src_temp = { |
| 2936 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2937 | .name = "Input Source", |
| 2938 | .info = stac92xx_mux_enum_info, |
| 2939 | .get = stac92xx_mux_enum_get, |
| 2940 | .put = stac92xx_mux_enum_put, |
| 2941 | }; |
| 2942 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2943 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 2944 | hda_nid_t nid, int idx) |
| 2945 | { |
| 2946 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 2947 | int control = 0; |
| 2948 | struct sigmatel_spec *spec = codec->spec; |
| 2949 | char name[22]; |
| 2950 | |
| 2951 | if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { |
| 2952 | if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
| 2953 | && nid == spec->line_switch) |
| 2954 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2955 | else if (snd_hda_query_pin_caps(codec, nid) |
| 2956 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 2957 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 2958 | else if (nid == spec->mic_switch) |
| 2959 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 2960 | } |
| 2961 | |
| 2962 | if (control) { |
| 2963 | strcpy(name, auto_pin_cfg_labels[idx]); |
| 2964 | return stac92xx_add_control(codec->spec, control, |
| 2965 | strcat(name, " Jack Mode"), nid); |
| 2966 | } |
| 2967 | |
| 2968 | return 0; |
| 2969 | } |
| 2970 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2971 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 2972 | { |
| 2973 | struct snd_kcontrol_new *knew; |
| 2974 | struct hda_input_mux *imux = &spec->private_imux; |
| 2975 | |
| 2976 | if (!spec->num_adcs || imux->num_items <= 1) |
| 2977 | return 0; /* no need for input source control */ |
| 2978 | knew = stac_control_new(spec, &stac_input_src_temp, |
| 2979 | stac_input_src_temp.name); |
| 2980 | if (!knew) |
| 2981 | return -ENOMEM; |
| 2982 | knew->count = spec->num_adcs; |
| 2983 | return 0; |
| 2984 | } |
| 2985 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2986 | /* check whether the line-input can be used as line-out */ |
| 2987 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2988 | { |
| 2989 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2990 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2991 | hda_nid_t nid; |
| 2992 | unsigned int pincap; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2993 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2994 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 2995 | return 0; |
| 2996 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2997 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2998 | if (pincap & AC_PINCAP_OUT) |
| 2999 | return nid; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3000 | return 0; |
| 3001 | } |
| 3002 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3003 | /* check whether the mic-input can be used as line-out */ |
| 3004 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) |
| 3005 | { |
| 3006 | struct sigmatel_spec *spec = codec->spec; |
| 3007 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3008 | unsigned int def_conf, pincap; |
| 3009 | unsigned int mic_pin; |
| 3010 | |
| 3011 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 3012 | return 0; |
| 3013 | mic_pin = AUTO_PIN_MIC; |
| 3014 | for (;;) { |
| 3015 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3016 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3017 | /* some laptops have an internal analog microphone |
| 3018 | * which can't be used as a output */ |
| 3019 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 3020 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3021 | if (pincap & AC_PINCAP_OUT) |
| 3022 | return nid; |
| 3023 | } |
| 3024 | if (mic_pin == AUTO_PIN_MIC) |
| 3025 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 3026 | else |
| 3027 | break; |
| 3028 | } |
| 3029 | return 0; |
| 3030 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3031 | |
| 3032 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3033 | { |
| 3034 | int i; |
| 3035 | |
| 3036 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 3037 | if (spec->multiout.dac_nids[i] == nid) |
| 3038 | return 1; |
| 3039 | } |
| 3040 | |
| 3041 | return 0; |
| 3042 | } |
| 3043 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3044 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3045 | { |
| 3046 | int i; |
| 3047 | if (is_in_dac_nids(spec, nid)) |
| 3048 | return 1; |
| 3049 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 3050 | if (spec->hp_dacs[i] == nid) |
| 3051 | return 1; |
| 3052 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 3053 | if (spec->speaker_dacs[i] == nid) |
| 3054 | return 1; |
| 3055 | return 0; |
| 3056 | } |
| 3057 | |
| 3058 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 3059 | { |
| 3060 | struct sigmatel_spec *spec = codec->spec; |
| 3061 | int j, conn_len; |
| 3062 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
| 3063 | unsigned int wcaps, wtype; |
| 3064 | |
| 3065 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 3066 | HDA_MAX_CONNECTIONS); |
| 3067 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 3068 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3069 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 3070 | /* we check only analog outputs */ |
| 3071 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 3072 | continue; |
| 3073 | /* if this route has a free DAC, assign it */ |
| 3074 | if (!check_all_dac_nids(spec, conn[j])) { |
| 3075 | if (conn_len > 1) { |
| 3076 | /* select this DAC in the pin's input mux */ |
| 3077 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3078 | AC_VERB_SET_CONNECT_SEL, j); |
| 3079 | } |
| 3080 | return conn[j]; |
| 3081 | } |
| 3082 | } |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 3083 | /* if all DACs are already assigned, connect to the primary DAC */ |
| 3084 | if (conn_len > 1) { |
| 3085 | for (j = 0; j < conn_len; j++) { |
| 3086 | if (conn[j] == spec->multiout.dac_nids[0]) { |
| 3087 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3088 | AC_VERB_SET_CONNECT_SEL, j); |
| 3089 | break; |
| 3090 | } |
| 3091 | } |
| 3092 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3093 | return 0; |
| 3094 | } |
| 3095 | |
| 3096 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3097 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 3098 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3099 | /* |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3100 | * Fill in the dac_nids table from the parsed pin configuration |
| 3101 | * This function only works when every pin in line_out_pins[] |
| 3102 | * contains atleast one DAC in its connection list. Some 92xx |
| 3103 | * codecs are not connected directly to a DAC, such as the 9200 |
| 3104 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3105 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3106 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3107 | { |
| 3108 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3109 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3110 | int i; |
| 3111 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3112 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3113 | for (i = 0; i < cfg->line_outs; i++) { |
| 3114 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3115 | dac = get_unassigned_dac(codec, nid); |
| 3116 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 3117 | if (spec->multiout.num_dacs > 0) { |
| 3118 | /* we have already working output pins, |
| 3119 | * so let's drop the broken ones again |
| 3120 | */ |
| 3121 | cfg->line_outs = spec->multiout.num_dacs; |
| 3122 | break; |
| 3123 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3124 | /* error out, no available DAC found */ |
| 3125 | snd_printk(KERN_ERR |
| 3126 | "%s: No available DAC for pin 0x%x\n", |
| 3127 | __func__, nid); |
| 3128 | return -ENODEV; |
| 3129 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3130 | add_spec_dacs(spec, dac); |
| 3131 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3132 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 3133 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3134 | nid = cfg->hp_pins[i]; |
| 3135 | dac = get_unassigned_dac(codec, nid); |
| 3136 | if (dac) { |
| 3137 | if (!spec->multiout.hp_nid) |
| 3138 | spec->multiout.hp_nid = dac; |
| 3139 | else |
| 3140 | add_spec_extra_dacs(spec, dac); |
| 3141 | } |
| 3142 | spec->hp_dacs[i] = dac; |
| 3143 | } |
| 3144 | |
| 3145 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 3146 | nid = cfg->speaker_pins[i]; |
| 3147 | dac = get_unassigned_dac(codec, nid); |
| 3148 | if (dac) |
| 3149 | add_spec_extra_dacs(spec, dac); |
| 3150 | spec->speaker_dacs[i] = dac; |
| 3151 | } |
| 3152 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3153 | /* add line-in as output */ |
| 3154 | nid = check_line_out_switch(codec); |
| 3155 | if (nid) { |
| 3156 | dac = get_unassigned_dac(codec, nid); |
| 3157 | if (dac) { |
| 3158 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 3159 | nid, cfg->line_outs); |
| 3160 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3161 | cfg->line_outs++; |
| 3162 | spec->line_switch = nid; |
| 3163 | add_spec_dacs(spec, dac); |
| 3164 | } |
| 3165 | } |
| 3166 | /* add mic as output */ |
| 3167 | nid = check_mic_out_switch(codec); |
| 3168 | if (nid) { |
| 3169 | dac = get_unassigned_dac(codec, nid); |
| 3170 | if (dac) { |
| 3171 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 3172 | nid, cfg->line_outs); |
| 3173 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 3174 | cfg->line_outs++; |
| 3175 | spec->mic_switch = nid; |
| 3176 | add_spec_dacs(spec, dac); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3177 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3178 | } |
| 3179 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3180 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3181 | spec->multiout.num_dacs, |
| 3182 | spec->multiout.dac_nids[0], |
| 3183 | spec->multiout.dac_nids[1], |
| 3184 | spec->multiout.dac_nids[2], |
| 3185 | spec->multiout.dac_nids[3], |
| 3186 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3187 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3188 | return 0; |
| 3189 | } |
| 3190 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3191 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3192 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 3193 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3194 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3195 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3196 | char name[32]; |
| 3197 | int err; |
| 3198 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3199 | if (!spec->check_volume_offset) { |
| 3200 | unsigned int caps, step, nums, db_scale; |
| 3201 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3202 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 3203 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 3204 | step = (step + 1) * 25; /* in .01dB unit */ |
| 3205 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 3206 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 3207 | db_scale = nums * step; |
| 3208 | /* if dB scale is over -64dB, and finer enough, |
| 3209 | * let's reduce it to half |
| 3210 | */ |
| 3211 | if (db_scale > 6400 && nums >= 0x1f) |
| 3212 | spec->volume_offset = nums / 2; |
| 3213 | spec->check_volume_offset = 1; |
| 3214 | } |
| 3215 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3216 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3217 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3218 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 3219 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3220 | if (err < 0) |
| 3221 | return err; |
| 3222 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3223 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3224 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 3225 | if (err < 0) |
| 3226 | return err; |
| 3227 | return 0; |
| 3228 | } |
| 3229 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3230 | #define create_controls(codec, pfx, nid, chs) \ |
| 3231 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 3232 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3233 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 3234 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3235 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3236 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 3237 | return 1; |
| 3238 | } else { |
| 3239 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 3240 | spec->multiout.num_dacs++; |
| 3241 | } |
| 3242 | return 0; |
| 3243 | } |
| 3244 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3245 | 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] | 3246 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3247 | int i; |
| 3248 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 3249 | if (!spec->multiout.extra_out_nid[i]) { |
| 3250 | spec->multiout.extra_out_nid[i] = nid; |
| 3251 | return 0; |
| 3252 | } |
| 3253 | } |
| 3254 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 3255 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3256 | } |
| 3257 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3258 | /* Create output controls |
| 3259 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 3260 | */ |
| 3261 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 3262 | const hda_nid_t *pins, |
| 3263 | const hda_nid_t *dac_nids, |
| 3264 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3265 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3266 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3267 | static const char *chname[4] = { |
| 3268 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 3269 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3270 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3271 | int i, err; |
| 3272 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3273 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3274 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 3275 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
| 3276 | wid_caps = get_wcaps(codec, pins[i]); |
| 3277 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3278 | spec->hp_detect = 1; |
| 3279 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3280 | nid = dac_nids[i]; |
| 3281 | if (!nid) |
| 3282 | continue; |
| 3283 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3284 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3285 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3286 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3287 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3288 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3289 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3290 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3291 | |
| 3292 | wid_caps = get_wcaps(codec, nid); |
| 3293 | |
| 3294 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3295 | err = stac92xx_add_control(spec, |
| 3296 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3297 | "Swap Center/LFE Playback Switch", nid); |
| 3298 | |
| 3299 | if (err < 0) |
| 3300 | return err; |
| 3301 | } |
| 3302 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3303 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3304 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3305 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3306 | switch (type) { |
| 3307 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3308 | name = "Headphone"; |
| 3309 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3310 | break; |
| 3311 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3312 | name = "Speaker"; |
| 3313 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3314 | break; |
| 3315 | default: |
| 3316 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3317 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3318 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3319 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3320 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3321 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3322 | return err; |
| 3323 | } |
| 3324 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3325 | return 0; |
| 3326 | } |
| 3327 | |
| 3328 | /* add playback controls from the parsed DAC table */ |
| 3329 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 3330 | const struct auto_pin_cfg *cfg) |
| 3331 | { |
| 3332 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3333 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3334 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3335 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3336 | |
| 3337 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 3338 | spec->multiout.dac_nids, |
| 3339 | cfg->line_out_type); |
| 3340 | if (err < 0) |
| 3341 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3342 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3343 | 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] | 3344 | err = stac92xx_add_control(spec, |
| 3345 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3346 | "Headphone as Line Out Switch", |
| 3347 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3348 | if (err < 0) |
| 3349 | return err; |
| 3350 | } |
| 3351 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3352 | for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { |
| 3353 | nid = cfg->input_pins[idx]; |
| 3354 | if (nid) { |
| 3355 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 3356 | if (err < 0) |
| 3357 | return err; |
| 3358 | } |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3359 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3360 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3361 | return 0; |
| 3362 | } |
| 3363 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3364 | /* add playback controls for Speaker and HP outputs */ |
| 3365 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3366 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3367 | { |
| 3368 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3369 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3370 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3371 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 3372 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 3373 | if (err < 0) |
| 3374 | return err; |
| 3375 | |
| 3376 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 3377 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 3378 | if (err < 0) |
| 3379 | return err; |
| 3380 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3381 | return 0; |
| 3382 | } |
| 3383 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3384 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3385 | static const char *stac92xx_mono_labels[4] = { |
| 3386 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3387 | }; |
| 3388 | |
| 3389 | /* create mono mux for mono out on capable codecs */ |
| 3390 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3391 | { |
| 3392 | struct sigmatel_spec *spec = codec->spec; |
| 3393 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3394 | int i, num_cons; |
| 3395 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3396 | |
| 3397 | num_cons = snd_hda_get_connections(codec, |
| 3398 | spec->mono_nid, |
| 3399 | con_lst, |
| 3400 | HDA_MAX_NUM_INPUTS); |
| 3401 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 3402 | return -EINVAL; |
| 3403 | |
| 3404 | for (i = 0; i < num_cons; i++) { |
| 3405 | mono_mux->items[mono_mux->num_items].label = |
| 3406 | stac92xx_mono_labels[i]; |
| 3407 | mono_mux->items[mono_mux->num_items].index = i; |
| 3408 | mono_mux->num_items++; |
| 3409 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3410 | |
| 3411 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3412 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3413 | } |
| 3414 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3415 | /* labels for amp mux outputs */ |
| 3416 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3417 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3418 | }; |
| 3419 | |
| 3420 | /* create amp out controls mux on capable codecs */ |
| 3421 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3422 | { |
| 3423 | struct sigmatel_spec *spec = codec->spec; |
| 3424 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3425 | int i, err; |
| 3426 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3427 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3428 | amp_mux->items[amp_mux->num_items].label = |
| 3429 | stac92xx_amp_labels[i]; |
| 3430 | amp_mux->items[amp_mux->num_items].index = i; |
| 3431 | amp_mux->num_items++; |
| 3432 | } |
| 3433 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3434 | if (spec->num_amps > 1) { |
| 3435 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3436 | "Amp Selector Capture Switch", 0); |
| 3437 | if (err < 0) |
| 3438 | return err; |
| 3439 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3440 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3441 | "Amp Capture Volume", |
| 3442 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3443 | } |
| 3444 | |
| 3445 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3446 | /* create PC beep volume controls */ |
| 3447 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3448 | hda_nid_t nid) |
| 3449 | { |
| 3450 | struct sigmatel_spec *spec = codec->spec; |
| 3451 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3452 | int err; |
| 3453 | |
| 3454 | /* check for mute support for the the amp */ |
| 3455 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3456 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3457 | "PC Beep Playback Switch", |
| 3458 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3459 | if (err < 0) |
| 3460 | return err; |
| 3461 | } |
| 3462 | |
| 3463 | /* check to see if there is volume support for the amp */ |
| 3464 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3465 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3466 | "PC Beep Playback Volume", |
| 3467 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3468 | if (err < 0) |
| 3469 | return err; |
| 3470 | } |
| 3471 | return 0; |
| 3472 | } |
| 3473 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3474 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3475 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3476 | |
| 3477 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3478 | struct snd_ctl_elem_value *ucontrol) |
| 3479 | { |
| 3480 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3481 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3482 | return 0; |
| 3483 | } |
| 3484 | |
| 3485 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3486 | struct snd_ctl_elem_value *ucontrol) |
| 3487 | { |
| 3488 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3489 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3490 | if (codec->beep->enabled != enabled) { |
| 3491 | codec->beep->enabled = enabled; |
| 3492 | return 1; |
| 3493 | } |
| 3494 | return 0; |
| 3495 | } |
| 3496 | |
| 3497 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3498 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3499 | .info = stac92xx_dig_beep_switch_info, |
| 3500 | .get = stac92xx_dig_beep_switch_get, |
| 3501 | .put = stac92xx_dig_beep_switch_put, |
| 3502 | }; |
| 3503 | |
| 3504 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3505 | { |
| 3506 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3507 | 0, "PC Beep Playback Switch", 0); |
| 3508 | } |
| 3509 | #endif |
| 3510 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3511 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3512 | { |
| 3513 | struct sigmatel_spec *spec = codec->spec; |
| 3514 | int wcaps, nid, i, err = 0; |
| 3515 | |
| 3516 | for (i = 0; i < spec->num_muxes; i++) { |
| 3517 | nid = spec->mux_nids[i]; |
| 3518 | wcaps = get_wcaps(codec, nid); |
| 3519 | |
| 3520 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3521 | err = stac92xx_add_control_idx(spec, |
| 3522 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3523 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3524 | if (err < 0) |
| 3525 | return err; |
| 3526 | } |
| 3527 | } |
| 3528 | return 0; |
| 3529 | }; |
| 3530 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3531 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3532 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3533 | }; |
| 3534 | |
| 3535 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3536 | { |
| 3537 | struct sigmatel_spec *spec = codec->spec; |
| 3538 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3539 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3540 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3541 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3542 | |
| 3543 | num_cons = snd_hda_get_connections(codec, |
| 3544 | spec->smux_nids[0], |
| 3545 | con_lst, |
| 3546 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3547 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3548 | return -EINVAL; |
| 3549 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3550 | if (!labels) |
| 3551 | labels = stac92xx_spdif_labels; |
| 3552 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3553 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3554 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3555 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3556 | spdif_mux->num_items++; |
| 3557 | } |
| 3558 | |
| 3559 | return 0; |
| 3560 | } |
| 3561 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3562 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3563 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3564 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3565 | "Digital Mic 3", "Digital Mic 4" |
| 3566 | }; |
| 3567 | |
| 3568 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3569 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3570 | const struct auto_pin_cfg *cfg) |
| 3571 | { |
| 3572 | struct sigmatel_spec *spec = codec->spec; |
| 3573 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3574 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3575 | int err, i, j; |
| 3576 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3577 | |
| 3578 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3579 | dimux->items[dimux->num_items].index = 0; |
| 3580 | dimux->num_items++; |
| 3581 | |
| 3582 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3583 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3584 | int index; |
| 3585 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3586 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3587 | unsigned int def_conf; |
| 3588 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3589 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3590 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3591 | continue; |
| 3592 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3593 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3594 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3595 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3596 | con_lst, |
| 3597 | HDA_MAX_NUM_INPUTS); |
| 3598 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3599 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3600 | index = j; |
| 3601 | goto found; |
| 3602 | } |
| 3603 | continue; |
| 3604 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3605 | wcaps = get_wcaps(codec, nid) & |
| 3606 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3607 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3608 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3609 | sprintf(name, "%s Capture Volume", |
| 3610 | stac92xx_dmic_labels[dimux->num_items]); |
| 3611 | |
| 3612 | err = stac92xx_add_control(spec, |
| 3613 | STAC_CTL_WIDGET_VOL, |
| 3614 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3615 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3616 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3617 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3618 | if (err < 0) |
| 3619 | return err; |
| 3620 | } |
| 3621 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3622 | dimux->items[dimux->num_items].label = |
| 3623 | stac92xx_dmic_labels[dimux->num_items]; |
| 3624 | dimux->items[dimux->num_items].index = index; |
| 3625 | dimux->num_items++; |
| 3626 | } |
| 3627 | |
| 3628 | return 0; |
| 3629 | } |
| 3630 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3631 | /* create playback/capture controls for input pins */ |
| 3632 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3633 | { |
| 3634 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3635 | struct hda_input_mux *imux = &spec->private_imux; |
| 3636 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3637 | int i, j, k; |
| 3638 | |
| 3639 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3640 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3641 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3642 | if (!cfg->input_pins[i]) |
| 3643 | continue; |
| 3644 | index = -1; |
| 3645 | for (j = 0; j < spec->num_muxes; j++) { |
| 3646 | int num_cons; |
| 3647 | num_cons = snd_hda_get_connections(codec, |
| 3648 | spec->mux_nids[j], |
| 3649 | con_lst, |
| 3650 | HDA_MAX_NUM_INPUTS); |
| 3651 | for (k = 0; k < num_cons; k++) |
| 3652 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3653 | index = k; |
| 3654 | goto found; |
| 3655 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3656 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3657 | continue; |
| 3658 | found: |
| 3659 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3660 | imux->items[imux->num_items].index = index; |
| 3661 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3662 | } |
| 3663 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3664 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3665 | /* |
| 3666 | * Set the current input for the muxes. |
| 3667 | * The STAC9221 has two input muxes with identical source |
| 3668 | * NID lists. Hopefully this won't get confused. |
| 3669 | */ |
| 3670 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3671 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3672 | AC_VERB_SET_CONNECT_SEL, |
| 3673 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3674 | } |
| 3675 | } |
| 3676 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3677 | return 0; |
| 3678 | } |
| 3679 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3680 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3681 | { |
| 3682 | struct sigmatel_spec *spec = codec->spec; |
| 3683 | int i; |
| 3684 | |
| 3685 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3686 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3687 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3688 | } |
| 3689 | } |
| 3690 | |
| 3691 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3692 | { |
| 3693 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3694 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3695 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3696 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3697 | hda_nid_t pin; |
| 3698 | pin = spec->autocfg.hp_pins[i]; |
| 3699 | if (pin) /* connect to front */ |
| 3700 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3701 | } |
| 3702 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3703 | hda_nid_t pin; |
| 3704 | pin = spec->autocfg.speaker_pins[i]; |
| 3705 | if (pin) /* connect to front */ |
| 3706 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3707 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3708 | } |
| 3709 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3710 | 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] | 3711 | { |
| 3712 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3713 | int hp_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3714 | int err; |
| 3715 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3716 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3717 | &spec->autocfg, |
| 3718 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3719 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3720 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3721 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3722 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3723 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3724 | * be set up as multi-channel outputs. |
| 3725 | */ |
| 3726 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3727 | spec->autocfg.hp_outs > 1) { |
| 3728 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3729 | * speaker_outs so that the following routines can handle |
| 3730 | * HP pins as primary outputs. |
| 3731 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3732 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3733 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3734 | sizeof(spec->autocfg.line_out_pins)); |
| 3735 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3736 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3737 | sizeof(spec->autocfg.hp_pins)); |
| 3738 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3739 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3740 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3741 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3742 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3743 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3744 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3745 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3746 | u32 caps = query_amp_caps(codec, |
| 3747 | spec->autocfg.mono_out_pin, dir); |
| 3748 | hda_nid_t conn_list[1]; |
| 3749 | |
| 3750 | /* get the mixer node and then the mono mux if it exists */ |
| 3751 | if (snd_hda_get_connections(codec, |
| 3752 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3753 | snd_hda_get_connections(codec, conn_list[0], |
| 3754 | conn_list, 1)) { |
| 3755 | |
| 3756 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3757 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3758 | >> AC_WCAP_TYPE_SHIFT; |
| 3759 | /* LR swap check, some stac925x have a mux that |
| 3760 | * changes the DACs output path instead of the |
| 3761 | * mono-mux path. |
| 3762 | */ |
| 3763 | if (wid_type == AC_WID_AUD_SEL && |
| 3764 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3765 | spec->mono_nid = conn_list[0]; |
| 3766 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3767 | if (dir) { |
| 3768 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3769 | |
| 3770 | /* most mono outs have a least a mute/unmute switch */ |
| 3771 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3772 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3773 | "Mono Playback Switch", |
| 3774 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3775 | if (err < 0) |
| 3776 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3777 | /* check for volume support for the amp */ |
| 3778 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3779 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3780 | err = stac92xx_add_control(spec, |
| 3781 | STAC_CTL_WIDGET_VOL, |
| 3782 | "Mono Playback Volume", |
| 3783 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3784 | if (err < 0) |
| 3785 | return err; |
| 3786 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3790 | AC_PINCTL_OUT_EN); |
| 3791 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3792 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3793 | if (!spec->multiout.num_dacs) { |
| 3794 | err = stac92xx_auto_fill_dac_nids(codec); |
| 3795 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3796 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3797 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 3798 | &spec->autocfg); |
| 3799 | if (err < 0) |
| 3800 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3801 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3802 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3803 | /* setup analog beep controls */ |
| 3804 | if (spec->anabeep_nid > 0) { |
| 3805 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3806 | spec->anabeep_nid); |
| 3807 | if (err < 0) |
| 3808 | return err; |
| 3809 | } |
| 3810 | |
| 3811 | /* setup digital beep controls and input device */ |
| 3812 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3813 | if (spec->digbeep_nid > 0) { |
| 3814 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3815 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3816 | |
| 3817 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3818 | if (err < 0) |
| 3819 | return err; |
| 3820 | err = snd_hda_attach_beep_device(codec, nid); |
| 3821 | if (err < 0) |
| 3822 | return err; |
Takashi Iwai | fa79796 | 2009-05-19 12:50:04 +0200 | [diff] [blame] | 3823 | /* IDT/STAC codecs have linear beep tone parameter */ |
| 3824 | codec->beep->linear_tone = 1; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3825 | /* if no beep switch is available, make its own one */ |
| 3826 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3827 | if (codec->beep && |
| 3828 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3829 | err = stac92xx_beep_switch_ctl(codec); |
| 3830 | if (err < 0) |
| 3831 | return err; |
| 3832 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3833 | } |
| 3834 | #endif |
| 3835 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3836 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3837 | if (err < 0) |
| 3838 | return err; |
| 3839 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3840 | /* All output parsing done, now restore the swapped hp pins */ |
| 3841 | if (hp_swap) { |
| 3842 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3843 | sizeof(spec->autocfg.hp_pins)); |
| 3844 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3845 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 3846 | spec->autocfg.line_outs = 0; |
| 3847 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3848 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3849 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3850 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3851 | return err; |
| 3852 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3853 | if (spec->mono_nid > 0) { |
| 3854 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3855 | if (err < 0) |
| 3856 | return err; |
| 3857 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3858 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3859 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3860 | if (err < 0) |
| 3861 | return err; |
| 3862 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3863 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3864 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3865 | &spec->autocfg)) < 0) |
| 3866 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3867 | if (spec->num_muxes > 0) { |
| 3868 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3869 | if (err < 0) |
| 3870 | return err; |
| 3871 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3872 | if (spec->num_smuxes > 0) { |
| 3873 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3874 | if (err < 0) |
| 3875 | return err; |
| 3876 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3877 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3878 | err = stac92xx_add_input_source(spec); |
| 3879 | if (err < 0) |
| 3880 | return err; |
| 3881 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3882 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3883 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3884 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3885 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3886 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3887 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3888 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3889 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3890 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3891 | if (spec->kctls.list) |
| 3892 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3893 | |
| 3894 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3895 | if (!spec->dinput_mux) |
| 3896 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3897 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3898 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3899 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3900 | return 1; |
| 3901 | } |
| 3902 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3903 | /* add playback controls for HP output */ |
| 3904 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3905 | struct auto_pin_cfg *cfg) |
| 3906 | { |
| 3907 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3908 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3909 | unsigned int wid_caps; |
| 3910 | |
| 3911 | if (! pin) |
| 3912 | return 0; |
| 3913 | |
| 3914 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3915 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3916 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3917 | |
| 3918 | return 0; |
| 3919 | } |
| 3920 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3921 | /* add playback controls for LFE output */ |
| 3922 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3923 | struct auto_pin_cfg *cfg) |
| 3924 | { |
| 3925 | struct sigmatel_spec *spec = codec->spec; |
| 3926 | int err; |
| 3927 | hda_nid_t lfe_pin = 0x0; |
| 3928 | int i; |
| 3929 | |
| 3930 | /* |
| 3931 | * search speaker outs and line outs for a mono speaker pin |
| 3932 | * with an amp. If one is found, add LFE controls |
| 3933 | * for it. |
| 3934 | */ |
| 3935 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3936 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3937 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3938 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3939 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3940 | /* found a mono speaker with an amp, must be lfe */ |
| 3941 | lfe_pin = pin; |
| 3942 | } |
| 3943 | |
| 3944 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3945 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3946 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3947 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3948 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3949 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3950 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3951 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3952 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3953 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3954 | /* found a mono speaker with an amp, |
| 3955 | must be lfe */ |
| 3956 | lfe_pin = pin; |
| 3957 | } |
| 3958 | } |
| 3959 | } |
| 3960 | |
| 3961 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3962 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3963 | if (err < 0) |
| 3964 | return err; |
| 3965 | } |
| 3966 | |
| 3967 | return 0; |
| 3968 | } |
| 3969 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3970 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3971 | { |
| 3972 | struct sigmatel_spec *spec = codec->spec; |
| 3973 | int err; |
| 3974 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3975 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3976 | return err; |
| 3977 | |
| 3978 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3979 | return err; |
| 3980 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3981 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3982 | return err; |
| 3983 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3984 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3985 | return err; |
| 3986 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3987 | if (spec->num_muxes > 0) { |
| 3988 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3989 | if (err < 0) |
| 3990 | return err; |
| 3991 | } |
| 3992 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3993 | err = stac92xx_add_input_source(spec); |
| 3994 | if (err < 0) |
| 3995 | return err; |
| 3996 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3997 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3998 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3999 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4000 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4001 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4002 | if (spec->kctls.list) |
| 4003 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4004 | |
| 4005 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4006 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4007 | |
| 4008 | return 1; |
| 4009 | } |
| 4010 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4011 | /* |
| 4012 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 4013 | * funky external mute control using GPIO pins. |
| 4014 | */ |
| 4015 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4016 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4017 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4018 | { |
| 4019 | unsigned int gpiostate, gpiomask, gpiodir; |
| 4020 | |
| 4021 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 4022 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4023 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4024 | |
| 4025 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 4026 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4027 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4028 | |
| 4029 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 4030 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4031 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4032 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4033 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4034 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 4035 | |
| 4036 | snd_hda_codec_write(codec, codec->afg, 0, |
| 4037 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4038 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4039 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4040 | |
| 4041 | msleep(1); |
| 4042 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 4043 | snd_hda_codec_read(codec, codec->afg, 0, |
| 4044 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4045 | } |
| 4046 | |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4047 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4048 | static void stac92xx_free_jack_priv(struct snd_jack *jack) |
| 4049 | { |
| 4050 | struct sigmatel_jack *jacks = jack->private_data; |
| 4051 | jacks->nid = 0; |
| 4052 | jacks->jack = NULL; |
| 4053 | } |
| 4054 | #endif |
| 4055 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4056 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 4057 | hda_nid_t nid, int type) |
| 4058 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4059 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4060 | struct sigmatel_spec *spec = codec->spec; |
| 4061 | struct sigmatel_jack *jack; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4062 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4063 | int connectivity = get_defcfg_connect(def_conf); |
| 4064 | char name[32]; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4065 | int err; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4066 | |
| 4067 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 4068 | return 0; |
| 4069 | |
| 4070 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 4071 | jack = snd_array_new(&spec->jacks); |
| 4072 | if (!jack) |
| 4073 | return -ENOMEM; |
| 4074 | jack->nid = nid; |
| 4075 | jack->type = type; |
| 4076 | |
Takashi Iwai | 86de741 | 2009-07-22 16:02:46 +0200 | [diff] [blame] | 4077 | snprintf(name, sizeof(name), "%s at %s %s Jack", |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4078 | snd_hda_get_jack_type(def_conf), |
| 4079 | snd_hda_get_jack_connectivity(def_conf), |
| 4080 | snd_hda_get_jack_location(def_conf)); |
| 4081 | |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4082 | err = snd_jack_new(codec->bus->card, name, type, &jack->jack); |
| 4083 | if (err < 0) { |
| 4084 | jack->nid = 0; |
| 4085 | return err; |
| 4086 | } |
| 4087 | jack->jack->private_data = jack; |
| 4088 | jack->jack->private_free = stac92xx_free_jack_priv; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4089 | #endif |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4090 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4091 | } |
| 4092 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4093 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 4094 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4095 | { |
| 4096 | struct sigmatel_event *event; |
| 4097 | |
| 4098 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 4099 | event = snd_array_new(&spec->events); |
| 4100 | if (!event) |
| 4101 | return -ENOMEM; |
| 4102 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4103 | event->type = type; |
| 4104 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4105 | event->data = data; |
| 4106 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4107 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4108 | } |
| 4109 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4110 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
| 4111 | hda_nid_t nid, unsigned char type) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4112 | { |
| 4113 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4114 | struct sigmatel_event *event = spec->events.list; |
| 4115 | int i; |
| 4116 | |
| 4117 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4118 | if (event->nid == nid && event->type == type) |
| 4119 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4120 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4121 | return NULL; |
| 4122 | } |
| 4123 | |
| 4124 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 4125 | unsigned char tag) |
| 4126 | { |
| 4127 | struct sigmatel_spec *spec = codec->spec; |
| 4128 | struct sigmatel_event *event = spec->events.list; |
| 4129 | int i; |
| 4130 | |
| 4131 | for (i = 0; i < spec->events.used; i++, event++) { |
| 4132 | if (event->tag == tag) |
| 4133 | return event; |
| 4134 | } |
| 4135 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4136 | } |
| 4137 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4138 | 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] | 4139 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4140 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4141 | struct sigmatel_event *event; |
| 4142 | int tag; |
| 4143 | |
| 4144 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
| 4145 | return; |
| 4146 | event = stac_get_event(codec, nid, type); |
| 4147 | if (event) |
| 4148 | tag = event->tag; |
| 4149 | else |
| 4150 | tag = stac_add_event(codec->spec, nid, type, 0); |
| 4151 | if (tag < 0) |
| 4152 | return; |
| 4153 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4154 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 4155 | AC_USRSP_EN | tag); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4156 | } |
| 4157 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4158 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 4159 | { |
| 4160 | int i; |
| 4161 | for (i = 0; i < cfg->hp_outs; i++) |
| 4162 | if (cfg->hp_pins[i] == nid) |
| 4163 | return 1; /* nid is a HP-Out */ |
| 4164 | |
| 4165 | return 0; /* nid is not a HP-Out */ |
| 4166 | }; |
| 4167 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4168 | static void stac92xx_power_down(struct hda_codec *codec) |
| 4169 | { |
| 4170 | struct sigmatel_spec *spec = codec->spec; |
| 4171 | |
| 4172 | /* power down inactive DACs */ |
| 4173 | hda_nid_t *dac; |
| 4174 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4175 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4176 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4177 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 4178 | } |
| 4179 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4180 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4181 | int enable); |
| 4182 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4183 | /* override some hints from the hwdep entry */ |
| 4184 | static void stac_store_hints(struct hda_codec *codec) |
| 4185 | { |
| 4186 | struct sigmatel_spec *spec = codec->spec; |
| 4187 | const char *p; |
| 4188 | int val; |
| 4189 | |
| 4190 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 4191 | if (val >= 0) |
| 4192 | spec->hp_detect = val; |
| 4193 | p = snd_hda_get_hint(codec, "gpio_mask"); |
| 4194 | if (p) { |
| 4195 | spec->gpio_mask = simple_strtoul(p, NULL, 0); |
| 4196 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 4197 | spec->gpio_mask; |
| 4198 | } |
| 4199 | p = snd_hda_get_hint(codec, "gpio_dir"); |
| 4200 | if (p) |
| 4201 | spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4202 | p = snd_hda_get_hint(codec, "gpio_data"); |
| 4203 | if (p) |
| 4204 | spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4205 | p = snd_hda_get_hint(codec, "eapd_mask"); |
| 4206 | if (p) |
| 4207 | spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; |
| 4208 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 4209 | if (val >= 0) |
| 4210 | spec->eapd_switch = val; |
| 4211 | } |
| 4212 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4213 | static int stac92xx_init(struct hda_codec *codec) |
| 4214 | { |
| 4215 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4216 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4217 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4218 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4219 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4220 | snd_hda_sequence_write(codec, spec->init); |
| 4221 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4222 | /* power down adcs initially */ |
| 4223 | if (spec->powerdown_adcs) |
| 4224 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4225 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4226 | spec->adc_nids[i], 0, |
| 4227 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4228 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4229 | /* override some hints */ |
| 4230 | stac_store_hints(codec); |
| 4231 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4232 | /* set up GPIO */ |
| 4233 | gpio = spec->gpio_data; |
| 4234 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 4235 | * otherwise, unsol event will turn it on/off dynamically |
| 4236 | */ |
| 4237 | if (!spec->eapd_switch) |
| 4238 | gpio |= spec->eapd_mask; |
| 4239 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 4240 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4241 | /* set up pins */ |
| 4242 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4243 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4244 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4245 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4246 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4247 | } |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4248 | /* force to enable the first line-out; the others are set up |
| 4249 | * in unsol_event |
| 4250 | */ |
| 4251 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4252 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4253 | /* fake event to set up pins */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4254 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4255 | STAC_HP_EVENT); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4256 | } else { |
| 4257 | stac92xx_auto_init_multi_out(codec); |
| 4258 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4259 | for (i = 0; i < cfg->hp_outs; i++) |
| 4260 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4261 | } |
| 4262 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4263 | hda_nid_t nid = cfg->input_pins[i]; |
| 4264 | if (nid) { |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4265 | unsigned int pinctl, conf; |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4266 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 4267 | /* for mic pins, force to initialize */ |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4268 | pinctl = stac92xx_get_default_vref(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4269 | pinctl |= AC_PINCTL_IN_EN; |
| 4270 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4271 | } else { |
| 4272 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4273 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4274 | /* if PINCTL already set then skip */ |
Takashi Iwai | 5dd17cb | 2009-05-07 16:22:53 +0200 | [diff] [blame] | 4275 | /* Also, if both INPUT and OUTPUT are set, |
| 4276 | * it must be a BIOS bug; need to override, too |
| 4277 | */ |
| 4278 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 4279 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 4280 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4281 | pinctl |= AC_PINCTL_IN_EN; |
| 4282 | stac92xx_auto_set_pinctl(codec, nid, |
| 4283 | pinctl); |
| 4284 | } |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4285 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4286 | conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4287 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 4288 | enable_pin_detect(codec, nid, |
| 4289 | STAC_INSERT_EVENT); |
| 4290 | stac_issue_unsol_event(codec, nid, |
| 4291 | STAC_INSERT_EVENT); |
| 4292 | } |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4293 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4294 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4295 | for (i = 0; i < spec->num_dmics; i++) |
| 4296 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4297 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4298 | if (cfg->dig_out_pins[0]) |
| 4299 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4300 | AC_PINCTL_OUT_EN); |
| 4301 | if (cfg->dig_in_pin) |
| 4302 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4303 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4304 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4305 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4306 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4307 | |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4308 | /* power on when no jack detection is available */ |
| 4309 | if (!spec->hp_detect) { |
| 4310 | stac_toggle_power_map(codec, nid, 1); |
| 4311 | continue; |
| 4312 | } |
| 4313 | |
| 4314 | if (is_nid_hp_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4315 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4316 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4317 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4318 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4319 | /* outputs are only ports capable of power management |
| 4320 | * any attempts on powering down a input port cause the |
| 4321 | * referenced VREF to act quirky. |
| 4322 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4323 | if (pinctl & AC_PINCTL_IN_EN) { |
| 4324 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4325 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4326 | } |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4327 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4328 | def_conf = get_defcfg_connect(def_conf); |
| 4329 | /* skip any ports that don't have jacks since presence |
| 4330 | * detection is useless */ |
| 4331 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4332 | if (def_conf != AC_JACK_PORT_NONE) |
| 4333 | stac_toggle_power_map(codec, nid, 1); |
| 4334 | continue; |
| 4335 | } |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4336 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
| 4337 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
| 4338 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); |
| 4339 | } |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4340 | } |
| 4341 | if (spec->dac_list) |
| 4342 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4343 | return 0; |
| 4344 | } |
| 4345 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4346 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4347 | { |
Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4348 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4349 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4350 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4351 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4352 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4353 | int i; |
Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4354 | for (i = 0; i < spec->jacks.used; i++, jacks++) { |
| 4355 | if (jacks->jack) |
| 4356 | snd_device_free(codec->bus->card, jacks->jack); |
| 4357 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4358 | } |
| 4359 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4360 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4361 | } |
| 4362 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4363 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4364 | { |
| 4365 | struct sigmatel_spec *spec = codec->spec; |
| 4366 | |
| 4367 | if (spec->kctls.list) { |
| 4368 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4369 | int i; |
| 4370 | for (i = 0; i < spec->kctls.used; i++) |
| 4371 | kfree(kctl[i].name); |
| 4372 | } |
| 4373 | snd_array_free(&spec->kctls); |
| 4374 | } |
| 4375 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4376 | static void stac92xx_free(struct hda_codec *codec) |
| 4377 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4378 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4379 | |
| 4380 | if (! spec) |
| 4381 | return; |
| 4382 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4383 | stac92xx_free_jacks(codec); |
| 4384 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4385 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4386 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4387 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4388 | } |
| 4389 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4390 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4391 | unsigned int flag) |
| 4392 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4393 | unsigned int old_ctl, pin_ctl; |
| 4394 | |
| 4395 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4396 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4397 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4398 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4399 | /* |
| 4400 | * we need to check the current set-up direction of |
| 4401 | * shared input pins since they can be switched via |
| 4402 | * "xxx as Output" mixer switch |
| 4403 | */ |
| 4404 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4405 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4406 | return; |
| 4407 | } |
| 4408 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4409 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4410 | /* if setting pin direction bits, clear the current |
| 4411 | direction bits first */ |
| 4412 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4413 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4414 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4415 | pin_ctl |= flag; |
| 4416 | if (old_ctl != pin_ctl) |
| 4417 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4418 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4419 | pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4420 | } |
| 4421 | |
| 4422 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4423 | unsigned int flag) |
| 4424 | { |
| 4425 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4426 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4427 | if (pin_ctl & flag) |
| 4428 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4429 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4430 | pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4431 | } |
| 4432 | |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4433 | 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] | 4434 | { |
| 4435 | if (!nid) |
| 4436 | return 0; |
| 4437 | 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] | 4438 | & (1 << 31)) |
| 4439 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4440 | return 0; |
| 4441 | } |
| 4442 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4443 | /* return non-zero if the hp-pin of the given array index isn't |
| 4444 | * a jack-detection target |
| 4445 | */ |
| 4446 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4447 | { |
| 4448 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4449 | |
| 4450 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4451 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4452 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4453 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4454 | return 1; |
| 4455 | /* ignore if the pin is set as line-out */ |
| 4456 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4457 | return 1; |
| 4458 | return 0; |
| 4459 | } |
| 4460 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4461 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4462 | { |
| 4463 | struct sigmatel_spec *spec = codec->spec; |
| 4464 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4465 | int i, presence; |
| 4466 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4467 | presence = 0; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4468 | if (spec->gpio_mute) |
| 4469 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4470 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4471 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4472 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4473 | if (presence) |
| 4474 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4475 | if (no_hp_sensing(spec, i)) |
| 4476 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4477 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 4478 | if (presence) { |
| 4479 | unsigned int pinctl; |
| 4480 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 4481 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4482 | if (pinctl & AC_PINCTL_IN_EN) |
| 4483 | presence = 0; /* mic- or line-input */ |
| 4484 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4485 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4486 | |
| 4487 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4488 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4489 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4490 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4491 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4492 | for (i = 0; i < cfg->line_outs; i++) |
| 4493 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4494 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4495 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4496 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4497 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4498 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4499 | stac_gpio_set(codec, spec->gpio_mask, |
| 4500 | spec->gpio_dir, spec->gpio_data & |
| 4501 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4502 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4503 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4504 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4505 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4506 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4507 | for (i = 0; i < cfg->line_outs; i++) |
| 4508 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4509 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4510 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4511 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4512 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4513 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4514 | stac_gpio_set(codec, spec->gpio_mask, |
| 4515 | spec->gpio_dir, spec->gpio_data | |
| 4516 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4517 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4518 | /* toggle hp outs */ |
| 4519 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4520 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4521 | if (no_hp_sensing(spec, i)) |
| 4522 | continue; |
| 4523 | if (presence) |
| 4524 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4525 | #if 0 /* FIXME */ |
| 4526 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 4527 | * on some devices since they use the HP pin actually for line/speaker |
| 4528 | * outs although the default pin config shows a different pin (that is |
| 4529 | * wrong and useless). |
| 4530 | * |
| 4531 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 4532 | * But, disabling the code below just works around it, and I'm too tired of |
| 4533 | * bug reports with such devices... |
| 4534 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4535 | else |
| 4536 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4537 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4538 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4539 | } |
| 4540 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4541 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4542 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4543 | { |
| 4544 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4545 | unsigned int idx, val; |
| 4546 | |
| 4547 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4548 | if (spec->pwr_nids[idx] == nid) |
| 4549 | break; |
| 4550 | } |
| 4551 | if (idx >= spec->num_pwrs) |
| 4552 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4553 | |
| 4554 | /* several codecs have two power down bits */ |
| 4555 | if (spec->pwr_mapping) |
| 4556 | idx = spec->pwr_mapping[idx]; |
| 4557 | else |
| 4558 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4559 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4560 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4561 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4562 | val &= ~idx; |
| 4563 | else |
| 4564 | val |= idx; |
| 4565 | |
| 4566 | /* power down unused output ports */ |
| 4567 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4568 | } |
| 4569 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4570 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4571 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4572 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4573 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4574 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4575 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4576 | { |
| 4577 | struct sigmatel_spec *spec = codec->spec; |
| 4578 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4579 | |
| 4580 | if (jacks) { |
| 4581 | int i; |
| 4582 | for (i = 0; i < spec->jacks.used; i++) { |
| 4583 | if (jacks->nid == nid) { |
| 4584 | unsigned int pin_ctl = |
| 4585 | snd_hda_codec_read(codec, nid, |
| 4586 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4587 | 0x00); |
| 4588 | int type = jacks->type; |
| 4589 | if (type == (SND_JACK_LINEOUT |
| 4590 | | SND_JACK_HEADPHONE)) |
| 4591 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4592 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4593 | snd_jack_report(jacks->jack, |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4594 | get_pin_presence(codec, nid) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4595 | ? type : 0); |
| 4596 | } |
| 4597 | jacks++; |
| 4598 | } |
| 4599 | } |
| 4600 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4601 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4602 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 4603 | unsigned char type) |
| 4604 | { |
| 4605 | struct sigmatel_event *event = stac_get_event(codec, nid, type); |
| 4606 | if (!event) |
| 4607 | return; |
| 4608 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4609 | } |
| 4610 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4611 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4612 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4613 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4614 | struct sigmatel_event *event; |
| 4615 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4616 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4617 | tag = (res >> 26) & 0x7f; |
| 4618 | event = stac_get_event_from_tag(codec, tag); |
| 4619 | if (!event) |
| 4620 | return; |
| 4621 | |
| 4622 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4623 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4624 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4625 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4626 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4627 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4628 | if (spec->num_pwrs > 0) |
| 4629 | stac92xx_pin_sense(codec, event->nid); |
| 4630 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 4631 | |
| 4632 | switch (codec->subsystem_id) { |
| 4633 | case 0x103c308f: |
| 4634 | if (event->nid == 0xb) { |
| 4635 | int pin = AC_PINCTL_IN_EN; |
| 4636 | |
| 4637 | if (get_pin_presence(codec, 0xa) |
| 4638 | && get_pin_presence(codec, 0xb)) |
| 4639 | pin |= AC_PINCTL_VREF_80; |
| 4640 | if (!get_pin_presence(codec, 0xb)) |
| 4641 | pin |= AC_PINCTL_VREF_80; |
| 4642 | |
| 4643 | /* toggle VREF state based on mic + hp pin |
| 4644 | * status |
| 4645 | */ |
| 4646 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 4647 | } |
| 4648 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4649 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4650 | case STAC_VREF_EVENT: |
| 4651 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4652 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4653 | /* toggle VREF state based on GPIOx status */ |
| 4654 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4655 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4656 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4657 | } |
| 4658 | } |
| 4659 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4660 | #ifdef CONFIG_PROC_FS |
| 4661 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 4662 | struct hda_codec *codec, hda_nid_t nid) |
| 4663 | { |
| 4664 | if (nid == codec->afg) |
| 4665 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
| 4666 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); |
| 4667 | } |
| 4668 | |
| 4669 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 4670 | struct hda_codec *codec, |
| 4671 | unsigned int verb) |
| 4672 | { |
| 4673 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 4674 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 4675 | } |
| 4676 | |
| 4677 | /* stac92hd71bxx, stac92hd73xx */ |
| 4678 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 4679 | struct hda_codec *codec, hda_nid_t nid) |
| 4680 | { |
| 4681 | stac92hd_proc_hook(buffer, codec, nid); |
| 4682 | if (nid == codec->afg) |
| 4683 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 4684 | } |
| 4685 | |
| 4686 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 4687 | struct hda_codec *codec, hda_nid_t nid) |
| 4688 | { |
| 4689 | if (nid == codec->afg) |
| 4690 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 4691 | } |
| 4692 | |
| 4693 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 4694 | struct hda_codec *codec, hda_nid_t nid) |
| 4695 | { |
| 4696 | if (nid == codec->afg) |
| 4697 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 4698 | } |
| 4699 | #else |
| 4700 | #define stac92hd_proc_hook NULL |
| 4701 | #define stac92hd7x_proc_hook NULL |
| 4702 | #define stac9205_proc_hook NULL |
| 4703 | #define stac927x_proc_hook NULL |
| 4704 | #endif |
| 4705 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4706 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4707 | static int stac92xx_resume(struct hda_codec *codec) |
| 4708 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4709 | struct sigmatel_spec *spec = codec->spec; |
| 4710 | |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4711 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4712 | snd_hda_codec_resume_amp(codec); |
| 4713 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4714 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4715 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4716 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4717 | STAC_HP_EVENT); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4718 | return 0; |
| 4719 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4720 | |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4721 | /* |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4722 | * using power check for controlling mute led of HP notebooks |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4723 | * check for mute state only on Speakers (nid = 0x10) |
| 4724 | * |
| 4725 | * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise |
| 4726 | * the LED is NOT working properly ! |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4727 | * |
| 4728 | * Changed name to reflect that it now works for any designated |
| 4729 | * model, not just HP HDX. |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4730 | */ |
| 4731 | |
| 4732 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4733 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4734 | hda_nid_t nid) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4735 | { |
| 4736 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4737 | |
| 4738 | if (nid == 0x10) { |
| 4739 | if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4740 | HDA_AMP_MUTE) |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 4741 | spec->gpio_data &= ~spec->gpio_led; /* orange */ |
Takashi Iwai | ba84bfc | 2009-05-30 08:59:03 +0200 | [diff] [blame] | 4742 | else |
| 4743 | spec->gpio_data |= spec->gpio_led; /* white */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4744 | |
| 4745 | stac_gpio_set(codec, spec->gpio_mask, |
| 4746 | spec->gpio_dir, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4747 | spec->gpio_data); |
| 4748 | } |
| 4749 | |
| 4750 | return 0; |
| 4751 | } |
| 4752 | #endif |
| 4753 | |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4754 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4755 | { |
| 4756 | struct sigmatel_spec *spec = codec->spec; |
| 4757 | if (spec->eapd_mask) |
| 4758 | stac_gpio_set(codec, spec->gpio_mask, |
| 4759 | spec->gpio_dir, spec->gpio_data & |
| 4760 | ~spec->eapd_mask); |
| 4761 | return 0; |
| 4762 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4763 | #endif |
| 4764 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4765 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4766 | .build_controls = stac92xx_build_controls, |
| 4767 | .build_pcms = stac92xx_build_pcms, |
| 4768 | .init = stac92xx_init, |
| 4769 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4770 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4771 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4772 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4773 | .resume = stac92xx_resume, |
| 4774 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4775 | }; |
| 4776 | |
| 4777 | static int patch_stac9200(struct hda_codec *codec) |
| 4778 | { |
| 4779 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4780 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4781 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4782 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4783 | if (spec == NULL) |
| 4784 | return -ENOMEM; |
| 4785 | |
| 4786 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4787 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4788 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4789 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4790 | stac9200_models, |
| 4791 | stac9200_cfg_tbl); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4792 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4793 | 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] | 4794 | else |
| 4795 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4796 | stac9200_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4797 | |
| 4798 | spec->multiout.max_channels = 2; |
| 4799 | spec->multiout.num_dacs = 1; |
| 4800 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4801 | spec->adc_nids = stac9200_adc_nids; |
| 4802 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4803 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4804 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4805 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4806 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4807 | |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4808 | if (spec->board_config == STAC_9200_M4 || |
| 4809 | spec->board_config == STAC_9200_M4_2 || |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4810 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4811 | spec->init = stac9200_eapd_init; |
| 4812 | else |
| 4813 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4814 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4815 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4816 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4817 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4818 | spec->gpio_data = 0x00; |
| 4819 | } |
| 4820 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4821 | err = stac9200_parse_auto_config(codec); |
| 4822 | if (err < 0) { |
| 4823 | stac92xx_free(codec); |
| 4824 | return err; |
| 4825 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4826 | |
Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4827 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 4828 | * do detection and HP/speaker toggle because the hardware does it. |
| 4829 | */ |
| 4830 | if (spec->board_config == STAC_9200_PANASONIC) |
| 4831 | spec->hp_detect = 0; |
| 4832 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4833 | codec->patch_ops = stac92xx_patch_ops; |
| 4834 | |
| 4835 | return 0; |
| 4836 | } |
| 4837 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4838 | static int patch_stac925x(struct hda_codec *codec) |
| 4839 | { |
| 4840 | struct sigmatel_spec *spec; |
| 4841 | int err; |
| 4842 | |
| 4843 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4844 | if (spec == NULL) |
| 4845 | return -ENOMEM; |
| 4846 | |
| 4847 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4848 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4849 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4850 | |
| 4851 | /* Check first for codec ID */ |
| 4852 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4853 | STAC_925x_MODELS, |
| 4854 | stac925x_models, |
| 4855 | stac925x_codec_id_cfg_tbl); |
| 4856 | |
| 4857 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4858 | if (spec->board_config < 0) |
| 4859 | spec->board_config = snd_hda_check_board_config(codec, |
| 4860 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4861 | stac925x_models, |
| 4862 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4863 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4864 | if (spec->board_config < 0) |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4865 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4866 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4867 | else |
| 4868 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4869 | stac925x_brd_tbl[spec->board_config]); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4870 | |
| 4871 | spec->multiout.max_channels = 2; |
| 4872 | spec->multiout.num_dacs = 1; |
| 4873 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4874 | spec->adc_nids = stac925x_adc_nids; |
| 4875 | spec->mux_nids = stac925x_mux_nids; |
| 4876 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4877 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4878 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4879 | switch (codec->vendor_id) { |
| 4880 | case 0x83847632: /* STAC9202 */ |
| 4881 | case 0x83847633: /* STAC9202D */ |
| 4882 | case 0x83847636: /* STAC9251 */ |
| 4883 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4884 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4885 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4886 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4887 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4888 | break; |
| 4889 | default: |
| 4890 | spec->num_dmics = 0; |
| 4891 | break; |
| 4892 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4893 | |
| 4894 | spec->init = stac925x_core_init; |
| 4895 | spec->mixer = stac925x_mixer; |
| 4896 | |
| 4897 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4898 | if (!err) { |
| 4899 | if (spec->board_config < 0) { |
| 4900 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4901 | "available, default to model=ref\n"); |
| 4902 | spec->board_config = STAC_925x_REF; |
| 4903 | goto again; |
| 4904 | } |
| 4905 | err = -EINVAL; |
| 4906 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4907 | if (err < 0) { |
| 4908 | stac92xx_free(codec); |
| 4909 | return err; |
| 4910 | } |
| 4911 | |
| 4912 | codec->patch_ops = stac92xx_patch_ops; |
| 4913 | |
| 4914 | return 0; |
| 4915 | } |
| 4916 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4917 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4918 | .num_items = 4, |
| 4919 | .items = { |
| 4920 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4921 | { "Digital Mic 1", 0x09 }, |
| 4922 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4923 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4924 | } |
| 4925 | }; |
| 4926 | |
| 4927 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4928 | { |
| 4929 | struct sigmatel_spec *spec; |
| 4930 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4931 | int err = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4932 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4933 | |
| 4934 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4935 | if (spec == NULL) |
| 4936 | return -ENOMEM; |
| 4937 | |
| 4938 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4939 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4940 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4941 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4942 | spec->board_config = snd_hda_check_board_config(codec, |
| 4943 | STAC_92HD73XX_MODELS, |
| 4944 | stac92hd73xx_models, |
| 4945 | stac92hd73xx_cfg_tbl); |
| 4946 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4947 | if (spec->board_config < 0) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4948 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4949 | " STAC92HD73XX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4950 | else |
| 4951 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4952 | stac92hd73xx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4953 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4954 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4955 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4956 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4957 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4958 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4959 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4960 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4961 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4962 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4963 | case 0x3: /* 6 Channel */ |
| 4964 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4965 | spec->init = stac92hd73xx_6ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4966 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4967 | break; |
| 4968 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4969 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4970 | spec->init = stac92hd73xx_8ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4971 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4972 | break; |
| 4973 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4974 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4975 | spec->init = stac92hd73xx_10ch_core_init; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4976 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 4977 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4978 | } |
| 4979 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4980 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4981 | spec->aloopback_mask = 0x01; |
| 4982 | spec->aloopback_shift = 8; |
| 4983 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4984 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4985 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4986 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4987 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4988 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4989 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4990 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4991 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4992 | |
| 4993 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4994 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4995 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4996 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 4997 | sizeof(stac92hd73xx_dmux)); |
| 4998 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4999 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5000 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 5001 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5002 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5003 | case STAC_DELL_M6_AMIC: |
| 5004 | case STAC_DELL_M6_DMIC: |
| 5005 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5006 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5007 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 5008 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5009 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5010 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5011 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5012 | if (spec->board_config != STAC_DELL_EQ) |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 5013 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5014 | switch (spec->board_config) { |
| 5015 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5016 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5017 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5018 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5019 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5020 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5021 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5022 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5023 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5024 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5025 | case STAC_DELL_M6_BOTH: /* Both */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5026 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 5027 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5028 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5029 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5030 | break; |
| 5031 | } |
| 5032 | break; |
| 5033 | default: |
| 5034 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5035 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5036 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5037 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5038 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 5039 | /* GPIO0 High = Enable EAPD */ |
| 5040 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 5041 | spec->gpio_data = 0x01; |
| 5042 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5043 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5044 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5045 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 5046 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 5047 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5048 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5049 | |
| 5050 | if (!err) { |
| 5051 | if (spec->board_config < 0) { |
| 5052 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5053 | "available, default to model=ref\n"); |
| 5054 | spec->board_config = STAC_92HD73XX_REF; |
| 5055 | goto again; |
| 5056 | } |
| 5057 | err = -EINVAL; |
| 5058 | } |
| 5059 | |
| 5060 | if (err < 0) { |
| 5061 | stac92xx_free(codec); |
| 5062 | return err; |
| 5063 | } |
| 5064 | |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 5065 | if (spec->board_config == STAC_92HD73XX_NO_JD) |
| 5066 | spec->hp_detect = 0; |
| 5067 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5068 | codec->patch_ops = stac92xx_patch_ops; |
| 5069 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5070 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5071 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5072 | return 0; |
| 5073 | } |
| 5074 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5075 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 5076 | .num_items = 3, |
| 5077 | .items = { |
| 5078 | { "Analog Inputs", 0x03 }, |
| 5079 | { "Digital Mic 1", 0x04 }, |
| 5080 | { "Digital Mic 2", 0x05 }, |
| 5081 | } |
| 5082 | }; |
| 5083 | |
| 5084 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 5085 | { |
| 5086 | struct sigmatel_spec *spec; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5087 | hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5088 | int err; |
Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5089 | int num_dacs; |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5090 | hda_nid_t nid; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5091 | |
| 5092 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5093 | if (spec == NULL) |
| 5094 | return -ENOMEM; |
| 5095 | |
| 5096 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5097 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5098 | spec->mono_nid = 0x19; |
| 5099 | spec->digbeep_nid = 0x21; |
| 5100 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 5101 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 5102 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 5103 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5104 | spec->amp_nids = stac92hd83xxx_amp_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5105 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 5106 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5107 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5108 | |
| 5109 | spec->init = stac92hd83xxx_core_init; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5110 | spec->mixer = stac92hd83xxx_mixer; |
| 5111 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 5112 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 5113 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
Matthew Ranostay | c15c506 | 2009-01-13 13:30:07 -0500 | [diff] [blame] | 5114 | spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5115 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 5116 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 5117 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 5118 | spec->board_config = snd_hda_check_board_config(codec, |
| 5119 | STAC_92HD83XXX_MODELS, |
| 5120 | stac92hd83xxx_models, |
| 5121 | stac92hd83xxx_cfg_tbl); |
| 5122 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5123 | if (spec->board_config < 0) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5124 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5125 | " STAC92HD83XXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5126 | else |
| 5127 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5128 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5129 | |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5130 | switch (codec->vendor_id) { |
| 5131 | case 0x111d7604: |
| 5132 | case 0x111d7605: |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5133 | case 0x111d76d5: |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5134 | if (spec->board_config == STAC_92HD83XXX_PWR_REF) |
| 5135 | break; |
| 5136 | spec->num_pwrs = 0; |
| 5137 | break; |
| 5138 | } |
| 5139 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5140 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 5141 | if (!err) { |
| 5142 | if (spec->board_config < 0) { |
| 5143 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5144 | "available, default to model=ref\n"); |
| 5145 | spec->board_config = STAC_92HD83XXX_REF; |
| 5146 | goto again; |
| 5147 | } |
| 5148 | err = -EINVAL; |
| 5149 | } |
| 5150 | |
| 5151 | if (err < 0) { |
| 5152 | stac92xx_free(codec); |
| 5153 | return err; |
| 5154 | } |
| 5155 | |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5156 | switch (spec->board_config) { |
| 5157 | case STAC_DELL_S14: |
| 5158 | nid = 0xf; |
| 5159 | break; |
| 5160 | default: |
| 5161 | nid = 0xe; |
| 5162 | break; |
| 5163 | } |
| 5164 | |
| 5165 | num_dacs = snd_hda_get_connections(codec, nid, |
| 5166 | conn, STAC92HD83_DAC_COUNT + 1) - 1; |
| 5167 | |
| 5168 | /* set port X to select the last DAC |
| 5169 | */ |
| 5170 | snd_hda_codec_write_cache(codec, nid, 0, |
| 5171 | AC_VERB_SET_CONNECT_SEL, num_dacs); |
| 5172 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5173 | codec->patch_ops = stac92xx_patch_ops; |
| 5174 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5175 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 5176 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5177 | return 0; |
| 5178 | } |
| 5179 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5180 | static struct hda_input_mux stac92hd71bxx_dmux_nomixer = { |
| 5181 | .num_items = 3, |
| 5182 | .items = { |
| 5183 | { "Analog Inputs", 0x00 }, |
| 5184 | { "Digital Mic 1", 0x02 }, |
| 5185 | { "Digital Mic 2", 0x03 }, |
| 5186 | } |
| 5187 | }; |
| 5188 | |
| 5189 | static struct hda_input_mux stac92hd71bxx_dmux_amixer = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5190 | .num_items = 4, |
| 5191 | .items = { |
| 5192 | { "Analog Inputs", 0x00 }, |
| 5193 | { "Mixer", 0x01 }, |
| 5194 | { "Digital Mic 1", 0x02 }, |
| 5195 | { "Digital Mic 2", 0x03 }, |
| 5196 | } |
| 5197 | }; |
| 5198 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5199 | /* get the pin connection (fixed, none, etc) */ |
| 5200 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 5201 | { |
| 5202 | struct sigmatel_spec *spec = codec->spec; |
| 5203 | unsigned int cfg; |
| 5204 | |
| 5205 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 5206 | return get_defcfg_connect(cfg); |
| 5207 | } |
| 5208 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5209 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
| 5210 | hda_nid_t *nids, int num_nids) |
| 5211 | { |
| 5212 | struct sigmatel_spec *spec = codec->spec; |
| 5213 | int idx, num; |
| 5214 | unsigned int def_conf; |
| 5215 | |
| 5216 | for (num = 0; num < num_nids; num++) { |
| 5217 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5218 | if (spec->pin_nids[idx] == nids[num]) |
| 5219 | break; |
| 5220 | if (idx >= spec->num_pins) |
| 5221 | break; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5222 | def_conf = stac_get_defcfg_connect(codec, idx); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5223 | if (def_conf == AC_JACK_PORT_NONE) |
| 5224 | break; |
| 5225 | } |
| 5226 | return num; |
| 5227 | } |
| 5228 | |
| 5229 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 5230 | hda_nid_t dig0pin) |
| 5231 | { |
| 5232 | struct sigmatel_spec *spec = codec->spec; |
| 5233 | int idx; |
| 5234 | |
| 5235 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5236 | if (spec->pin_nids[idx] == dig0pin) |
| 5237 | break; |
| 5238 | if ((idx + 2) >= spec->num_pins) |
| 5239 | return 0; |
| 5240 | |
| 5241 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5242 | 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] | 5243 | return 2; |
| 5244 | |
| 5245 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5246 | 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] | 5247 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5248 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5249 | return 1; |
| 5250 | else |
| 5251 | return 0; |
| 5252 | } |
| 5253 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5254 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 5255 | { |
| 5256 | struct sigmatel_spec *spec; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5257 | struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5258 | int err = 0; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5259 | unsigned int ndmic_nids = 0; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5260 | |
| 5261 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5262 | if (spec == NULL) |
| 5263 | return -ENOMEM; |
| 5264 | |
| 5265 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5266 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5267 | spec->num_pins = STAC92HD71BXX_NUM_PINS; |
| 5268 | switch (codec->vendor_id) { |
| 5269 | case 0x111d76b6: |
| 5270 | case 0x111d76b7: |
| 5271 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; |
| 5272 | break; |
| 5273 | case 0x111d7603: |
| 5274 | case 0x111d7608: |
| 5275 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 5276 | spec->num_pins--; |
| 5277 | /* fallthrough */ |
| 5278 | default: |
| 5279 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 5280 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5281 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5282 | spec->board_config = snd_hda_check_board_config(codec, |
| 5283 | STAC_92HD71BXX_MODELS, |
| 5284 | stac92hd71bxx_models, |
| 5285 | stac92hd71bxx_cfg_tbl); |
| 5286 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5287 | if (spec->board_config < 0) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5288 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5289 | " STAC92HD71BXX, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5290 | else |
| 5291 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5292 | stac92hd71bxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5293 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5294 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 5295 | /* GPIO0 = EAPD */ |
| 5296 | spec->gpio_mask = 0x01; |
| 5297 | spec->gpio_dir = 0x01; |
| 5298 | spec->gpio_data = 0x01; |
| 5299 | } |
| 5300 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5301 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 5302 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 5303 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5304 | switch (codec->vendor_id) { |
| 5305 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 5306 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5307 | unmute_init++; |
| 5308 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5309 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 5310 | case 0x111d76b5: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5311 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer, |
| 5312 | sizeof(stac92hd71bxx_dmux_nomixer)); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5313 | spec->mixer = stac92hd71bxx_mixer; |
| 5314 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5315 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5316 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5317 | stac92hd71bxx_dmic_nids, |
| 5318 | STAC92HD71BXX_NUM_DMICS); |
| 5319 | if (spec->num_dmics) { |
| 5320 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5321 | spec->dinput_mux = &spec->private_dimux; |
| 5322 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
| 5323 | } |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5324 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5325 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5326 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5327 | sizeof(stac92hd71bxx_dmux_amixer)); |
| 5328 | spec->private_dimux.num_items--; |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5329 | switch (spec->board_config) { |
| 5330 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5331 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5332 | err = stac_add_event(spec, codec->afg, |
| 5333 | STAC_VREF_EVENT, 0x02); |
| 5334 | if (err < 0) |
| 5335 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5336 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5337 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 5338 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5339 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5340 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5341 | spec->gpio_mask |= 0x02; |
| 5342 | break; |
| 5343 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5344 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5345 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5346 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5347 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5348 | /* no output amps */ |
| 5349 | spec->num_pwrs = 0; |
| 5350 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5351 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5352 | |
| 5353 | /* disable VSW */ |
| 5354 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5355 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5356 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 5357 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5358 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
| 5359 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5360 | stac92hd71bxx_dmic_nids, |
| 5361 | STAC92HD71BXX_NUM_DMICS - 1); |
| 5362 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5363 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5364 | break; |
| 5365 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5366 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5367 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5368 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5369 | /* no output amps */ |
| 5370 | spec->num_pwrs = 0; |
| 5371 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5372 | default: |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5373 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, |
| 5374 | sizeof(stac92hd71bxx_dmux_amixer)); |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5375 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5376 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 5377 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5378 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5379 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
| 5380 | stac92hd71bxx_dmic_nids, |
| 5381 | STAC92HD71BXX_NUM_DMICS); |
| 5382 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 5383 | ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5384 | } |
| 5385 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5386 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 5387 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 5388 | |
Takashi Iwai | b20f3b8 | 2009-06-02 01:20:22 +0200 | [diff] [blame] | 5389 | /* Some HP machines seem to have unstable codec communications |
| 5390 | * especially with ATI fglrx driver. For recovering from the |
| 5391 | * CORB/RIRB stall, allow the BUS reset and keep always sync |
| 5392 | */ |
| 5393 | if (spec->board_config == STAC_HP_DV5) { |
| 5394 | codec->bus->sync_write = 1; |
| 5395 | codec->bus->allow_bus_reset = 1; |
| 5396 | } |
| 5397 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5398 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5399 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5400 | spec->aloopback_shift = 0; |
| 5401 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5402 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5403 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5404 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 5405 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5406 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5407 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5408 | |
| 5409 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 5410 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5411 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5412 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5413 | switch (spec->board_config) { |
| 5414 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5415 | /* enable internal microphone */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5416 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5417 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 5418 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5419 | /* fallthru */ |
| 5420 | case STAC_DELL_M4_2: |
| 5421 | spec->num_dmics = 0; |
| 5422 | spec->num_smuxes = 0; |
| 5423 | spec->num_dmuxes = 0; |
| 5424 | break; |
| 5425 | case STAC_DELL_M4_1: |
| 5426 | case STAC_DELL_M4_3: |
| 5427 | spec->num_dmics = 1; |
| 5428 | spec->num_smuxes = 0; |
Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5429 | spec->num_dmuxes = 1; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5430 | break; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5431 | case STAC_HP_DV4_1222NR: |
| 5432 | spec->num_dmics = 1; |
| 5433 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 5434 | * bug reports to fix if needed |
| 5435 | */ |
| 5436 | spec->num_smuxes = 1; |
| 5437 | spec->num_dmuxes = 1; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5438 | spec->gpio_led = 0x01; |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5439 | /* fallthrough */ |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5440 | case STAC_HP_DV5: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5441 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5442 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 5443 | break; |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5444 | case STAC_HP_HDX: |
| 5445 | spec->num_dmics = 1; |
| 5446 | spec->num_dmuxes = 1; |
| 5447 | spec->num_smuxes = 1; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5448 | /* orange/white mute led on GPIO3, orange=0, white=1 */ |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5449 | spec->gpio_led = 0x08; |
| 5450 | break; |
| 5451 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5452 | |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5453 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 5454 | if (spec->gpio_led) { |
| 5455 | spec->gpio_mask |= spec->gpio_led; |
| 5456 | spec->gpio_dir |= spec->gpio_led; |
| 5457 | spec->gpio_data |= spec->gpio_led; |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5458 | /* register check_power_status callback. */ |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5459 | codec->patch_ops.check_power_status = |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5460 | stac92xx_hp_check_power_status; |
| 5461 | } |
Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5462 | #endif |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5463 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5464 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5465 | if (spec->dinput_mux) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5466 | spec->private_dimux.num_items += spec->num_dmics - ndmic_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5467 | |
Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5468 | err = stac92xx_parse_auto_config(codec, 0x21, 0); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5469 | if (!err) { |
| 5470 | if (spec->board_config < 0) { |
| 5471 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5472 | "available, default to model=ref\n"); |
| 5473 | spec->board_config = STAC_92HD71BXX_REF; |
| 5474 | goto again; |
| 5475 | } |
| 5476 | err = -EINVAL; |
| 5477 | } |
| 5478 | |
| 5479 | if (err < 0) { |
| 5480 | stac92xx_free(codec); |
| 5481 | return err; |
| 5482 | } |
| 5483 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5484 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 5485 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5486 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5487 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5488 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5489 | static int patch_stac922x(struct hda_codec *codec) |
| 5490 | { |
| 5491 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5492 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5493 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5494 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5495 | if (spec == NULL) |
| 5496 | return -ENOMEM; |
| 5497 | |
| 5498 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5499 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5500 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5501 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 5502 | stac922x_models, |
| 5503 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5504 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5505 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 5506 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5507 | /* Intel Macs have all same PCI SSID, so we need to check |
| 5508 | * codec SSID to distinguish the exact models |
| 5509 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5510 | 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] | 5511 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5512 | |
| 5513 | case 0x106b0800: |
| 5514 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5515 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5516 | case 0x106b0600: |
| 5517 | case 0x106b0700: |
| 5518 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5519 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5520 | case 0x106b0e00: |
| 5521 | case 0x106b0f00: |
| 5522 | case 0x106b1600: |
| 5523 | case 0x106b1700: |
| 5524 | case 0x106b0200: |
| 5525 | case 0x106b1e00: |
| 5526 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5527 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5528 | case 0x106b1a00: |
| 5529 | case 0x00000100: |
| 5530 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5531 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5532 | case 0x106b0a00: |
| 5533 | case 0x106b2200: |
| 5534 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5535 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5536 | default: |
| 5537 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5538 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5539 | } |
| 5540 | } |
| 5541 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5542 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5543 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5544 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 5545 | "using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5546 | else |
| 5547 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5548 | stac922x_brd_tbl[spec->board_config]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5549 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5550 | spec->adc_nids = stac922x_adc_nids; |
| 5551 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5552 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5553 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5554 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5555 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5556 | |
| 5557 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5558 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5559 | |
| 5560 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5561 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5562 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5563 | if (!err) { |
| 5564 | if (spec->board_config < 0) { |
| 5565 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5566 | "available, default to model=ref\n"); |
| 5567 | spec->board_config = STAC_D945_REF; |
| 5568 | goto again; |
| 5569 | } |
| 5570 | err = -EINVAL; |
| 5571 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5572 | if (err < 0) { |
| 5573 | stac92xx_free(codec); |
| 5574 | return err; |
| 5575 | } |
| 5576 | |
| 5577 | codec->patch_ops = stac92xx_patch_ops; |
| 5578 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5579 | /* Fix Mux capture level; max to 2 */ |
| 5580 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5581 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5582 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5583 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5584 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5585 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5586 | return 0; |
| 5587 | } |
| 5588 | |
| 5589 | static int patch_stac927x(struct hda_codec *codec) |
| 5590 | { |
| 5591 | struct sigmatel_spec *spec; |
| 5592 | int err; |
| 5593 | |
| 5594 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5595 | if (spec == NULL) |
| 5596 | return -ENOMEM; |
| 5597 | |
| 5598 | codec->spec = spec; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5599 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5600 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5601 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5602 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5603 | stac927x_models, |
| 5604 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5605 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5606 | if (spec->board_config < 0) |
Herton Ronaldo Krzesinski | c98041f | 2009-02-11 20:33:15 -0200 | [diff] [blame] | 5607 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5608 | "STAC927x, using BIOS defaults\n"); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5609 | else |
| 5610 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5611 | stac927x_brd_tbl[spec->board_config]); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5612 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5613 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5614 | spec->adc_nids = stac927x_adc_nids; |
| 5615 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5616 | spec->mux_nids = stac927x_mux_nids; |
| 5617 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5618 | spec->smux_nids = stac927x_smux_nids; |
| 5619 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5620 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5621 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5622 | spec->multiout.dac_nids = spec->dac_nids; |
| 5623 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5624 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5625 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5626 | case STAC_D965_5ST: |
| 5627 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5628 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5629 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5630 | spec->num_dmics = 0; |
| 5631 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5632 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5633 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5634 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5635 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5636 | switch (codec->subsystem_id) { |
| 5637 | case 0x10280209: |
| 5638 | case 0x1028022e: |
| 5639 | /* correct the device field to SPDIF out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5640 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5641 | break; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5642 | } |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5643 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5644 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5645 | /* correct the front output jack as a hp out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5646 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5647 | /* correct the front input jack as a mic */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5648 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5649 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5650 | case STAC_DELL_3ST: |
| 5651 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5652 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5653 | spec->gpio_data = 0x04; |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 5654 | switch (codec->subsystem_id) { |
| 5655 | case 0x1028022f: |
| 5656 | /* correct EAPD to be GPIO0 */ |
| 5657 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5658 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5659 | break; |
| 5660 | }; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5661 | spec->dmic_nids = stac927x_dmic_nids; |
| 5662 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5663 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5664 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5665 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5666 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5667 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5668 | break; |
| 5669 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5670 | if (spec->board_config > STAC_D965_REF) { |
| 5671 | /* GPIO0 High = Enable EAPD */ |
| 5672 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5673 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5674 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5675 | spec->num_dmics = 0; |
| 5676 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5677 | spec->init = stac927x_core_init; |
| 5678 | spec->mixer = stac927x_mixer; |
| 5679 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5680 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5681 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5682 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5683 | spec->aloopback_mask = 0x40; |
| 5684 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5685 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5686 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5687 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5688 | if (!err) { |
| 5689 | if (spec->board_config < 0) { |
| 5690 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5691 | "available, default to model=ref\n"); |
| 5692 | spec->board_config = STAC_D965_REF; |
| 5693 | goto again; |
| 5694 | } |
| 5695 | err = -EINVAL; |
| 5696 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5697 | if (err < 0) { |
| 5698 | stac92xx_free(codec); |
| 5699 | return err; |
| 5700 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5701 | |
| 5702 | codec->patch_ops = stac92xx_patch_ops; |
| 5703 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5704 | codec->proc_widget_hook = stac927x_proc_hook; |
| 5705 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5706 | /* |
| 5707 | * !!FIXME!! |
| 5708 | * The STAC927x seem to require fairly long delays for certain |
| 5709 | * command sequences. With too short delays (even if the answer |
| 5710 | * is set to RIRB properly), it results in the silence output |
| 5711 | * on some hardwares like Dell. |
| 5712 | * |
| 5713 | * The below flag enables the longer delay (see get_response |
| 5714 | * in hda_intel.c). |
| 5715 | */ |
| 5716 | codec->bus->needs_damn_long_delay = 1; |
| 5717 | |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5718 | /* no jack detecion for ref-no-jd model */ |
| 5719 | if (spec->board_config == STAC_D965_REF_NO_JD) |
| 5720 | spec->hp_detect = 0; |
| 5721 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5722 | return 0; |
| 5723 | } |
| 5724 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5725 | static int patch_stac9205(struct hda_codec *codec) |
| 5726 | { |
| 5727 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5728 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5729 | |
| 5730 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5731 | if (spec == NULL) |
| 5732 | return -ENOMEM; |
| 5733 | |
| 5734 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5735 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5736 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5737 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5738 | stac9205_models, |
| 5739 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5740 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5741 | if (spec->board_config < 0) |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5742 | 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] | 5743 | else |
| 5744 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5745 | stac9205_brd_tbl[spec->board_config]); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5746 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5747 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5748 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5749 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5750 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5751 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5752 | spec->smux_nids = stac9205_smux_nids; |
| 5753 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5754 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5755 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5756 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5757 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5758 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5759 | |
| 5760 | spec->init = stac9205_core_init; |
| 5761 | spec->mixer = stac9205_mixer; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5762 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5763 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5764 | spec->aloopback_mask = 0x40; |
| 5765 | spec->aloopback_shift = 0; |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5766 | /* Turn on/off EAPD per HP plugging */ |
| 5767 | if (spec->board_config != STAC_9205_EAPD) |
| 5768 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5769 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5770 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5771 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5772 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5773 | /* Enable SPDIF in/out */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5774 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
| 5775 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5776 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5777 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5778 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5779 | if (err < 0) |
| 5780 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5781 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5782 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5783 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5784 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5785 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5786 | |
| 5787 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5788 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5789 | spec->gpio_mask = 0x1b; |
| 5790 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5791 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5792 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5793 | */ |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5794 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5795 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5796 | case STAC_9205_REF: |
| 5797 | /* SPDIF-In enabled */ |
| 5798 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5799 | default: |
| 5800 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5801 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5802 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5803 | break; |
| 5804 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5805 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5806 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5807 | if (!err) { |
| 5808 | if (spec->board_config < 0) { |
| 5809 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5810 | "available, default to model=ref\n"); |
| 5811 | spec->board_config = STAC_9205_REF; |
| 5812 | goto again; |
| 5813 | } |
| 5814 | err = -EINVAL; |
| 5815 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5816 | if (err < 0) { |
| 5817 | stac92xx_free(codec); |
| 5818 | return err; |
| 5819 | } |
| 5820 | |
| 5821 | codec->patch_ops = stac92xx_patch_ops; |
| 5822 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5823 | codec->proc_widget_hook = stac9205_proc_hook; |
| 5824 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5825 | return 0; |
| 5826 | } |
| 5827 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5828 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5829 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5830 | */ |
| 5831 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5832 | static struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5833 | {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] | 5834 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5835 | {} |
| 5836 | }; |
| 5837 | |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5838 | static struct snd_kcontrol_new stac9872_mixer[] = { |
| 5839 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5840 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5841 | { } /* end */ |
| 5842 | }; |
| 5843 | |
| 5844 | static hda_nid_t stac9872_pin_nids[] = { |
| 5845 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 5846 | 0x11, 0x13, 0x14, |
| 5847 | }; |
| 5848 | |
| 5849 | static hda_nid_t stac9872_adc_nids[] = { |
| 5850 | 0x8 /*,0x6*/ |
| 5851 | }; |
| 5852 | |
| 5853 | static hda_nid_t stac9872_mux_nids[] = { |
| 5854 | 0x15 |
| 5855 | }; |
| 5856 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5857 | static unsigned int stac9872_vaio_pin_configs[9] = { |
| 5858 | 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, |
| 5859 | 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, |
| 5860 | 0x90a7013e |
| 5861 | }; |
| 5862 | |
| 5863 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 5864 | [STAC_9872_AUTO] = "auto", |
| 5865 | [STAC_9872_VAIO] = "vaio", |
| 5866 | }; |
| 5867 | |
| 5868 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { |
| 5869 | [STAC_9872_VAIO] = stac9872_vaio_pin_configs, |
| 5870 | }; |
| 5871 | |
| 5872 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 5873 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, |
| 5874 | "Sony VAIO F/S", STAC_9872_VAIO), |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5875 | {} /* terminator */ |
| 5876 | }; |
| 5877 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5878 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5879 | { |
| 5880 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5881 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5882 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5883 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5884 | if (spec == NULL) |
| 5885 | return -ENOMEM; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5886 | codec->spec = spec; |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 5887 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); |
| 5888 | spec->pin_nids = stac9872_pin_nids; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5889 | |
| 5890 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5891 | stac9872_models, |
| 5892 | stac9872_cfg_tbl); |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5893 | if (spec->board_config < 0) |
| 5894 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " |
| 5895 | "using BIOS defaults\n"); |
| 5896 | else |
| 5897 | stac92xx_set_config_regs(codec, |
| 5898 | stac9872_brd_tbl[spec->board_config]); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5899 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5900 | spec->multiout.dac_nids = spec->dac_nids; |
| 5901 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 5902 | spec->adc_nids = stac9872_adc_nids; |
| 5903 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 5904 | spec->mux_nids = stac9872_mux_nids; |
| 5905 | spec->mixer = stac9872_mixer; |
| 5906 | spec->init = stac9872_core_init; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5907 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5908 | err = stac92xx_parse_auto_config(codec, 0x10, 0x12); |
| 5909 | if (err < 0) { |
| 5910 | stac92xx_free(codec); |
| 5911 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5912 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5913 | spec->input_mux = &spec->private_imux; |
| 5914 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5915 | return 0; |
| 5916 | } |
| 5917 | |
| 5918 | |
| 5919 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5920 | * patch entries |
| 5921 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5922 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5923 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5924 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5925 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5926 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5927 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5928 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5929 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5930 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5931 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5932 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5933 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5934 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5935 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5936 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5937 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5938 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5939 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5940 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5941 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5942 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5943 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5944 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5945 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5946 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5947 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5948 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5949 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5950 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5951 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5952 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5953 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5954 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5955 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5956 | * currently not fully supported. |
| 5957 | */ |
| 5958 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5959 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5960 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 5961 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5962 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5963 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5964 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5965 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5966 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5967 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5968 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5969 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5970 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5971 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5972 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5973 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5974 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5975 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5976 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5977 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5978 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5979 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5980 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5981 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5982 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5983 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5984 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5985 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5986 | {} /* terminator */ |
| 5987 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5988 | |
| 5989 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 5990 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 5991 | |
| 5992 | MODULE_LICENSE("GPL"); |
| 5993 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 5994 | |
| 5995 | static struct hda_codec_preset_list sigmatel_list = { |
| 5996 | .preset = snd_hda_preset_sigmatel, |
| 5997 | .owner = THIS_MODULE, |
| 5998 | }; |
| 5999 | |
| 6000 | static int __init patch_sigmatel_init(void) |
| 6001 | { |
| 6002 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 6003 | } |
| 6004 | |
| 6005 | static void __exit patch_sigmatel_exit(void) |
| 6006 | { |
| 6007 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 6008 | } |
| 6009 | |
| 6010 | module_init(patch_sigmatel_init) |
| 6011 | module_exit(patch_sigmatel_exit) |