| 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, | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 43 | 	STAC_LO_EVENT, | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 44 | 	STAC_MIC_EVENT, | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 45 | }; | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 46 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 47 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 48 | 	STAC_AUTO, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 49 | 	STAC_REF, | 
| Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 50 | 	STAC_9200_OQO, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 51 | 	STAC_9200_DELL_D21, | 
 | 52 | 	STAC_9200_DELL_D22, | 
 | 53 | 	STAC_9200_DELL_D23, | 
 | 54 | 	STAC_9200_DELL_M21, | 
 | 55 | 	STAC_9200_DELL_M22, | 
 | 56 | 	STAC_9200_DELL_M23, | 
 | 57 | 	STAC_9200_DELL_M24, | 
 | 58 | 	STAC_9200_DELL_M25, | 
 | 59 | 	STAC_9200_DELL_M26, | 
 | 60 | 	STAC_9200_DELL_M27, | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 61 | 	STAC_9200_M4, | 
 | 62 | 	STAC_9200_M4_2, | 
| Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 63 | 	STAC_9200_PANASONIC, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 64 | 	STAC_9200_MODELS | 
 | 65 | }; | 
 | 66 |  | 
 | 67 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 68 | 	STAC_9205_AUTO, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 69 | 	STAC_9205_REF, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 70 | 	STAC_9205_DELL_M42, | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 71 | 	STAC_9205_DELL_M43, | 
 | 72 | 	STAC_9205_DELL_M44, | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 73 | 	STAC_9205_EAPD, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 74 | 	STAC_9205_MODELS | 
 | 75 | }; | 
 | 76 |  | 
 | 77 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 78 | 	STAC_92HD73XX_AUTO, | 
| Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 79 | 	STAC_92HD73XX_NO_JD, /* no jack-detection */ | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 80 | 	STAC_92HD73XX_REF, | 
| Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame] | 81 | 	STAC_92HD73XX_INTEL, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 82 | 	STAC_DELL_M6_AMIC, | 
 | 83 | 	STAC_DELL_M6_DMIC, | 
 | 84 | 	STAC_DELL_M6_BOTH, | 
| Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 85 | 	STAC_DELL_EQ, | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 86 | 	STAC_ALIENWARE_M17X, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 87 | 	STAC_92HD73XX_MODELS | 
 | 88 | }; | 
 | 89 |  | 
 | 90 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 91 | 	STAC_92HD83XXX_AUTO, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 92 | 	STAC_92HD83XXX_REF, | 
| Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 93 | 	STAC_92HD83XXX_PWR_REF, | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 94 | 	STAC_DELL_S14, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 95 | 	STAC_92HD83XXX_MODELS | 
 | 96 | }; | 
 | 97 |  | 
 | 98 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 99 | 	STAC_92HD71BXX_AUTO, | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 100 | 	STAC_92HD71BXX_REF, | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 101 | 	STAC_DELL_M4_1, | 
 | 102 | 	STAC_DELL_M4_2, | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 103 | 	STAC_DELL_M4_3, | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 104 | 	STAC_HP_M4, | 
| Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 105 | 	STAC_HP_DV5, | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 106 | 	STAC_HP_HDX, | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 107 | 	STAC_HP_DV4_1222NR, | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 108 | 	STAC_92HD71BXX_MODELS | 
 | 109 | }; | 
 | 110 |  | 
 | 111 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 112 | 	STAC_925x_AUTO, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 113 | 	STAC_925x_REF, | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 114 | 	STAC_M1, | 
 | 115 | 	STAC_M1_2, | 
 | 116 | 	STAC_M2, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 117 | 	STAC_M2_2, | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 118 | 	STAC_M3, | 
 | 119 | 	STAC_M5, | 
 | 120 | 	STAC_M6, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 121 | 	STAC_925x_MODELS | 
 | 122 | }; | 
 | 123 |  | 
 | 124 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 125 | 	STAC_922X_AUTO, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 126 | 	STAC_D945_REF, | 
 | 127 | 	STAC_D945GTP3, | 
 | 128 | 	STAC_D945GTP5, | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 129 | 	STAC_INTEL_MAC_V1, | 
 | 130 | 	STAC_INTEL_MAC_V2, | 
 | 131 | 	STAC_INTEL_MAC_V3, | 
 | 132 | 	STAC_INTEL_MAC_V4, | 
 | 133 | 	STAC_INTEL_MAC_V5, | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 134 | 	STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter | 
 | 135 | 			      * is given, one of the above models will be | 
 | 136 | 			      * chosen according to the subsystem id. */ | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 137 | 	/* for backward compatibility */ | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 138 | 	STAC_MACMINI, | 
| Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 139 | 	STAC_MACBOOK, | 
| Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 140 | 	STAC_MACBOOK_PRO_V1, | 
 | 141 | 	STAC_MACBOOK_PRO_V2, | 
| Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 142 | 	STAC_IMAC_INTEL, | 
| Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 143 | 	STAC_IMAC_INTEL_20, | 
| Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 144 | 	STAC_ECS_202, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 145 | 	STAC_922X_DELL_D81, | 
 | 146 | 	STAC_922X_DELL_D82, | 
 | 147 | 	STAC_922X_DELL_M81, | 
 | 148 | 	STAC_922X_DELL_M82, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 149 | 	STAC_922X_MODELS | 
 | 150 | }; | 
 | 151 |  | 
 | 152 | enum { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 153 | 	STAC_927X_AUTO, | 
| Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 154 | 	STAC_D965_REF_NO_JD, /* no jack-detection */ | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 155 | 	STAC_D965_REF, | 
 | 156 | 	STAC_D965_3ST, | 
 | 157 | 	STAC_D965_5ST, | 
| Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 158 | 	STAC_D965_5ST_NO_FP, | 
| Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 159 | 	STAC_DELL_3ST, | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 160 | 	STAC_DELL_BIOS, | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 161 | 	STAC_927X_MODELS | 
 | 162 | }; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 163 |  | 
| Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 164 | enum { | 
 | 165 | 	STAC_9872_AUTO, | 
 | 166 | 	STAC_9872_VAIO, | 
 | 167 | 	STAC_9872_MODELS | 
 | 168 | }; | 
 | 169 |  | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 170 | struct sigmatel_event { | 
 | 171 | 	hda_nid_t nid; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 172 | 	unsigned char type; | 
 | 173 | 	unsigned char tag; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 174 | 	int data; | 
 | 175 | }; | 
 | 176 |  | 
 | 177 | struct sigmatel_jack { | 
 | 178 | 	hda_nid_t nid; | 
 | 179 | 	int type; | 
 | 180 | 	struct snd_jack *jack; | 
 | 181 | }; | 
 | 182 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 183 | struct sigmatel_mic_route { | 
 | 184 | 	hda_nid_t pin; | 
 | 185 | 	unsigned char mux_idx; | 
 | 186 | 	unsigned char dmux_idx; | 
 | 187 | }; | 
 | 188 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 189 | struct sigmatel_spec { | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 190 | 	struct snd_kcontrol_new *mixers[4]; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 191 | 	unsigned int num_mixers; | 
 | 192 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 193 | 	int board_config; | 
| Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 194 | 	unsigned int eapd_switch: 1; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 195 | 	unsigned int surr_switch: 1; | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 196 | 	unsigned int alt_switch: 1; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 197 | 	unsigned int hp_detect: 1; | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 198 | 	unsigned int spdif_mute: 1; | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 199 | 	unsigned int check_volume_offset:1; | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 200 | 	unsigned int auto_mic:1; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 201 |  | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 202 | 	/* gpio lines */ | 
| Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 203 | 	unsigned int eapd_mask; | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 204 | 	unsigned int gpio_mask; | 
 | 205 | 	unsigned int gpio_dir; | 
 | 206 | 	unsigned int gpio_data; | 
 | 207 | 	unsigned int gpio_mute; | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 208 | 	unsigned int gpio_led; | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 209 |  | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 210 | 	/* stream */ | 
 | 211 | 	unsigned int stream_delay; | 
 | 212 |  | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 213 | 	/* analog loopback */ | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 214 | 	struct snd_kcontrol_new *aloopback_ctl; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 215 | 	unsigned char aloopback_mask; | 
 | 216 | 	unsigned char aloopback_shift; | 
| Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 217 |  | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 218 | 	/* power management */ | 
 | 219 | 	unsigned int num_pwrs; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 220 | 	unsigned int *pwr_mapping; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 221 | 	hda_nid_t *pwr_nids; | 
| Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 222 | 	hda_nid_t *dac_list; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 223 |  | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 224 | 	/* jack detection */ | 
 | 225 | 	struct snd_array jacks; | 
 | 226 |  | 
 | 227 | 	/* events */ | 
 | 228 | 	struct snd_array events; | 
 | 229 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 230 | 	/* playback */ | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 231 | 	struct hda_input_mux *mono_mux; | 
 | 232 | 	unsigned int cur_mmux; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 233 | 	struct hda_multi_out multiout; | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 234 | 	hda_nid_t dac_nids[5]; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 235 | 	hda_nid_t hp_dacs[5]; | 
 | 236 | 	hda_nid_t speaker_dacs[5]; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 237 |  | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 238 | 	int volume_offset; | 
 | 239 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 240 | 	/* capture */ | 
 | 241 | 	hda_nid_t *adc_nids; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 242 | 	unsigned int num_adcs; | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 243 | 	hda_nid_t *mux_nids; | 
 | 244 | 	unsigned int num_muxes; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 245 | 	hda_nid_t *dmic_nids; | 
 | 246 | 	unsigned int num_dmics; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 247 | 	hda_nid_t *dmux_nids; | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 248 | 	unsigned int num_dmuxes; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 249 | 	hda_nid_t *smux_nids; | 
 | 250 | 	unsigned int num_smuxes; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 251 | 	unsigned int num_analog_muxes; | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 252 |  | 
 | 253 | 	unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ | 
 | 254 | 	unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ | 
 | 255 | 	unsigned int num_caps; /* number of capture volume/switch elements */ | 
 | 256 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 257 | 	struct sigmatel_mic_route ext_mic; | 
 | 258 | 	struct sigmatel_mic_route int_mic; | 
 | 259 |  | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 260 | 	const char **spdif_labels; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 261 |  | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 262 | 	hda_nid_t dig_in_nid; | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 263 | 	hda_nid_t mono_nid; | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 264 | 	hda_nid_t anabeep_nid; | 
 | 265 | 	hda_nid_t digbeep_nid; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 266 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 267 | 	/* pin widgets */ | 
 | 268 | 	hda_nid_t *pin_nids; | 
 | 269 | 	unsigned int num_pins; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 270 |  | 
 | 271 | 	/* codec specific stuff */ | 
 | 272 | 	struct hda_verb *init; | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 273 | 	struct snd_kcontrol_new *mixer; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 274 |  | 
 | 275 | 	/* capture source */ | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 276 | 	struct hda_input_mux *dinput_mux; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 277 | 	unsigned int cur_dmux[2]; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 278 | 	struct hda_input_mux *input_mux; | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 279 | 	unsigned int cur_mux[3]; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 280 | 	struct hda_input_mux *sinput_mux; | 
 | 281 | 	unsigned int cur_smux[2]; | 
| Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 282 | 	unsigned int cur_amux; | 
 | 283 | 	hda_nid_t *amp_nids; | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 284 | 	unsigned int powerdown_adcs; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 285 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 286 | 	/* i/o switches */ | 
 | 287 | 	unsigned int io_switch[2]; | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 288 | 	unsigned int clfe_swap; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 289 | 	hda_nid_t line_switch;	/* shared line-in for input and output */ | 
 | 290 | 	hda_nid_t mic_switch;	/* shared mic-in for input and output */ | 
 | 291 | 	hda_nid_t hp_switch; /* NID of HP as line-out */ | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 292 | 	unsigned int aloopback; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 293 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 294 | 	struct hda_pcm pcm_rec[2];	/* PCM information */ | 
 | 295 |  | 
 | 296 | 	/* dynamic controls and input_mux */ | 
 | 297 | 	struct auto_pin_cfg autocfg; | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 298 | 	struct snd_array kctls; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 299 | 	struct hda_input_mux private_dimux; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 300 | 	struct hda_input_mux private_imux; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 301 | 	struct hda_input_mux private_smux; | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 302 | 	struct hda_input_mux private_mono_mux; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 303 | }; | 
 | 304 |  | 
 | 305 | static hda_nid_t stac9200_adc_nids[1] = { | 
 | 306 |         0x03, | 
 | 307 | }; | 
 | 308 |  | 
 | 309 | static hda_nid_t stac9200_mux_nids[1] = { | 
 | 310 |         0x0c, | 
 | 311 | }; | 
 | 312 |  | 
 | 313 | static hda_nid_t stac9200_dac_nids[1] = { | 
 | 314 |         0x02, | 
 | 315 | }; | 
 | 316 |  | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 317 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { | 
 | 318 | 	0x0a, 0x0b, 0x0c, 0xd, 0x0e, | 
 | 319 | 	0x0f, 0x10, 0x11 | 
 | 320 | }; | 
 | 321 |  | 
| Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 322 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { | 
 | 323 | 	0x26, 0, | 
 | 324 | }; | 
 | 325 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 326 | static hda_nid_t stac92hd73xx_adc_nids[2] = { | 
 | 327 | 	0x1a, 0x1b | 
 | 328 | }; | 
 | 329 |  | 
 | 330 | #define STAC92HD73XX_NUM_DMICS	2 | 
 | 331 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | 
 | 332 | 	0x13, 0x14, 0 | 
 | 333 | }; | 
 | 334 |  | 
 | 335 | #define STAC92HD73_DAC_COUNT 5 | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 336 |  | 
| Takashi Iwai | e2aec17 | 2009-09-02 01:00:05 +0200 | [diff] [blame] | 337 | static hda_nid_t stac92hd73xx_mux_nids[2] = { | 
 | 338 | 	0x20, 0x21, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 339 | }; | 
 | 340 |  | 
 | 341 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { | 
 | 342 | 	0x20, 0x21, | 
 | 343 | }; | 
 | 344 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 345 | static hda_nid_t stac92hd73xx_smux_nids[2] = { | 
 | 346 | 	0x22, 0x23, | 
 | 347 | }; | 
 | 348 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 349 | #define STAC92HD73XX_NUM_CAPS	2 | 
 | 350 | static unsigned long stac92hd73xx_capvols[] = { | 
 | 351 | 	HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), | 
 | 352 | 	HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), | 
 | 353 | }; | 
 | 354 | #define stac92hd73xx_capsws	stac92hd73xx_capvols | 
 | 355 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 356 | #define STAC92HD83_DAC_COUNT 3 | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 357 |  | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 358 | static hda_nid_t stac92hd83xxx_mux_nids[2] = { | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 359 | 	0x17, 0x18, | 
 | 360 | }; | 
 | 361 |  | 
 | 362 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { | 
 | 363 | 	0x15, 0x16, | 
 | 364 | }; | 
 | 365 |  | 
 | 366 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { | 
 | 367 | 	0xa, 0xb, 0xd, 0xe, | 
 | 368 | }; | 
 | 369 |  | 
| Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 370 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { | 
 | 371 | 	0x1e, 0, | 
 | 372 | }; | 
 | 373 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 374 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { | 
| Matthew Ranostay | 87e88a7 | 2009-01-22 20:38:42 -0500 | [diff] [blame] | 375 | 	0x03, 0x0c, 0x20, 0x40, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 376 | }; | 
 | 377 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 378 | #define STAC92HD83XXX_NUM_CAPS	2 | 
 | 379 | static unsigned long stac92hd83xxx_capvols[] = { | 
 | 380 | 	HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), | 
 | 381 | 	HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT), | 
 | 382 | }; | 
 | 383 | #define stac92hd83xxx_capsws	stac92hd83xxx_capvols | 
 | 384 |  | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 385 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { | 
 | 386 | 	0x0a, 0x0d, 0x0f | 
 | 387 | }; | 
 | 388 |  | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 389 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { | 
 | 390 | 	0x12, 0x13, | 
 | 391 | }; | 
 | 392 |  | 
 | 393 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { | 
 | 394 | 	0x1a, 0x1b | 
 | 395 | }; | 
 | 396 |  | 
| Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 397 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { | 
 | 398 | 	0x1c, 0x1d, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 399 | }; | 
 | 400 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 401 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { | 
 | 402 | 	0x24, 0x25, | 
 | 403 | }; | 
 | 404 |  | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 405 | #define STAC92HD71BXX_NUM_DMICS	2 | 
 | 406 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { | 
 | 407 | 	0x18, 0x19, 0 | 
 | 408 | }; | 
 | 409 |  | 
| Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 410 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { | 
 | 411 | 	0x22, 0 | 
 | 412 | }; | 
 | 413 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 414 | #define STAC92HD71BXX_NUM_CAPS		2 | 
 | 415 | static unsigned long stac92hd71bxx_capvols[] = { | 
 | 416 | 	HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), | 
 | 417 | 	HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | 
 | 418 | }; | 
 | 419 | #define stac92hd71bxx_capsws	stac92hd71bxx_capvols | 
 | 420 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 421 | static hda_nid_t stac925x_adc_nids[1] = { | 
 | 422 |         0x03, | 
 | 423 | }; | 
 | 424 |  | 
 | 425 | static hda_nid_t stac925x_mux_nids[1] = { | 
 | 426 |         0x0f, | 
 | 427 | }; | 
 | 428 |  | 
 | 429 | static hda_nid_t stac925x_dac_nids[1] = { | 
 | 430 |         0x02, | 
 | 431 | }; | 
 | 432 |  | 
| Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 433 | #define STAC925X_NUM_DMICS	1 | 
 | 434 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { | 
 | 435 | 	0x15, 0 | 
| Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 436 | }; | 
 | 437 |  | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 438 | static hda_nid_t stac925x_dmux_nids[1] = { | 
 | 439 | 	0x14, | 
 | 440 | }; | 
 | 441 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 442 | static unsigned long stac925x_capvols[] = { | 
 | 443 | 	HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), | 
 | 444 | }; | 
 | 445 | static unsigned long stac925x_capsws[] = { | 
 | 446 | 	HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), | 
 | 447 | }; | 
 | 448 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 449 | static hda_nid_t stac922x_adc_nids[2] = { | 
 | 450 |         0x06, 0x07, | 
 | 451 | }; | 
 | 452 |  | 
 | 453 | static hda_nid_t stac922x_mux_nids[2] = { | 
 | 454 |         0x12, 0x13, | 
 | 455 | }; | 
 | 456 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 457 | #define STAC922X_NUM_CAPS	2 | 
 | 458 | static unsigned long stac922x_capvols[] = { | 
 | 459 | 	HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), | 
 | 460 | 	HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), | 
 | 461 | }; | 
 | 462 | #define stac922x_capsws		stac922x_capvols | 
 | 463 |  | 
| Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 464 | static hda_nid_t stac927x_slave_dig_outs[2] = { | 
 | 465 | 	0x1f, 0, | 
 | 466 | }; | 
 | 467 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 468 | static hda_nid_t stac927x_adc_nids[3] = { | 
 | 469 |         0x07, 0x08, 0x09 | 
 | 470 | }; | 
 | 471 |  | 
 | 472 | static hda_nid_t stac927x_mux_nids[3] = { | 
 | 473 |         0x15, 0x16, 0x17 | 
 | 474 | }; | 
 | 475 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 476 | static hda_nid_t stac927x_smux_nids[1] = { | 
 | 477 | 	0x21, | 
 | 478 | }; | 
 | 479 |  | 
| Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 480 | static hda_nid_t stac927x_dac_nids[6] = { | 
 | 481 | 	0x02, 0x03, 0x04, 0x05, 0x06, 0 | 
 | 482 | }; | 
 | 483 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 484 | static hda_nid_t stac927x_dmux_nids[1] = { | 
 | 485 | 	0x1b, | 
 | 486 | }; | 
 | 487 |  | 
| Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 488 | #define STAC927X_NUM_DMICS 2 | 
 | 489 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { | 
 | 490 | 	0x13, 0x14, 0 | 
 | 491 | }; | 
 | 492 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 493 | #define STAC927X_NUM_CAPS	3 | 
 | 494 | static unsigned long stac927x_capvols[] = { | 
 | 495 | 	HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), | 
 | 496 | 	HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), | 
 | 497 | 	HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), | 
 | 498 | }; | 
 | 499 | static unsigned long stac927x_capsws[] = { | 
 | 500 | 	HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), | 
 | 501 | 	HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), | 
 | 502 | 	HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | 
 | 503 | }; | 
 | 504 |  | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 505 | static const char *stac927x_spdif_labels[5] = { | 
 | 506 | 	"Digital Playback", "ADAT", "Analog Mux 1", | 
 | 507 | 	"Analog Mux 2", "Analog Mux 3" | 
 | 508 | }; | 
 | 509 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 510 | static hda_nid_t stac9205_adc_nids[2] = { | 
 | 511 |         0x12, 0x13 | 
 | 512 | }; | 
 | 513 |  | 
 | 514 | static hda_nid_t stac9205_mux_nids[2] = { | 
 | 515 |         0x19, 0x1a | 
 | 516 | }; | 
 | 517 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 518 | static hda_nid_t stac9205_dmux_nids[1] = { | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 519 | 	0x1d, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 520 | }; | 
 | 521 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 522 | static hda_nid_t stac9205_smux_nids[1] = { | 
 | 523 | 	0x21, | 
 | 524 | }; | 
 | 525 |  | 
| Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 526 | #define STAC9205_NUM_DMICS	2 | 
 | 527 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { | 
 | 528 |         0x17, 0x18, 0 | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 529 | }; | 
 | 530 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 531 | #define STAC9205_NUM_CAPS	2 | 
 | 532 | static unsigned long stac9205_capvols[] = { | 
 | 533 | 	HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), | 
 | 534 | 	HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), | 
 | 535 | }; | 
 | 536 | static unsigned long stac9205_capsws[] = { | 
 | 537 | 	HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), | 
 | 538 | 	HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), | 
 | 539 | }; | 
 | 540 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 541 | static hda_nid_t stac9200_pin_nids[8] = { | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 542 | 	0x08, 0x09, 0x0d, 0x0e,  | 
 | 543 | 	0x0f, 0x10, 0x11, 0x12, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 544 | }; | 
 | 545 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 546 | static hda_nid_t stac925x_pin_nids[8] = { | 
 | 547 | 	0x07, 0x08, 0x0a, 0x0b,  | 
 | 548 | 	0x0c, 0x0d, 0x10, 0x11, | 
 | 549 | }; | 
 | 550 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 551 | static hda_nid_t stac922x_pin_nids[10] = { | 
 | 552 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 
 | 553 | 	0x0f, 0x10, 0x11, 0x15, 0x1b, | 
 | 554 | }; | 
 | 555 |  | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 556 | static hda_nid_t stac92hd73xx_pin_nids[13] = { | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 557 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 
 | 558 | 	0x0f, 0x10, 0x11, 0x12, 0x13, | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 559 | 	0x14, 0x22, 0x23 | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 560 | }; | 
 | 561 |  | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 562 | static hda_nid_t stac92hd83xxx_pin_nids[10] = { | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 563 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 564 | 	0x0f, 0x10, 0x11, 0x1f, 0x20, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 565 | }; | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 566 |  | 
 | 567 | #define STAC92HD71BXX_NUM_PINS 13 | 
 | 568 | static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { | 
 | 569 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x00, | 
 | 570 | 	0x00, 0x14, 0x18, 0x19, 0x1e, | 
 | 571 | 	0x1f, 0x20, 0x27 | 
 | 572 | }; | 
 | 573 | static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 574 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 
 | 575 | 	0x0f, 0x14, 0x18, 0x19, 0x1e, | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 576 | 	0x1f, 0x20, 0x27 | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 577 | }; | 
 | 578 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 579 | static hda_nid_t stac927x_pin_nids[14] = { | 
 | 580 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 
 | 581 | 	0x0f, 0x10, 0x11, 0x12, 0x13, | 
 | 582 | 	0x14, 0x21, 0x22, 0x23, | 
 | 583 | }; | 
 | 584 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 585 | static hda_nid_t stac9205_pin_nids[12] = { | 
 | 586 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, | 
 | 587 | 	0x0f, 0x14, 0x16, 0x17, 0x18, | 
 | 588 | 	0x21, 0x22, | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 589 | }; | 
 | 590 |  | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 591 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, | 
 | 592 | 				   struct snd_ctl_elem_info *uinfo) | 
 | 593 | { | 
 | 594 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 595 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 596 | 	return snd_hda_input_mux_info(spec->dinput_mux, uinfo); | 
 | 597 | } | 
 | 598 |  | 
 | 599 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, | 
 | 600 | 				  struct snd_ctl_elem_value *ucontrol) | 
 | 601 | { | 
 | 602 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 603 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 604 | 	unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 605 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 606 | 	ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 607 | 	return 0; | 
 | 608 | } | 
 | 609 |  | 
 | 610 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, | 
 | 611 | 				  struct snd_ctl_elem_value *ucontrol) | 
 | 612 | { | 
 | 613 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 614 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 615 | 	unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 616 |  | 
 | 617 | 	return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 618 | 			spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 619 | } | 
 | 620 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 621 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, | 
 | 622 | 				   struct snd_ctl_elem_info *uinfo) | 
 | 623 | { | 
 | 624 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 625 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 626 | 	return snd_hda_input_mux_info(spec->sinput_mux, uinfo); | 
 | 627 | } | 
 | 628 |  | 
 | 629 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, | 
 | 630 | 				  struct snd_ctl_elem_value *ucontrol) | 
 | 631 | { | 
 | 632 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 633 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 634 | 	unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
 | 635 |  | 
 | 636 | 	ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; | 
 | 637 | 	return 0; | 
 | 638 | } | 
 | 639 |  | 
 | 640 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, | 
 | 641 | 				  struct snd_ctl_elem_value *ucontrol) | 
 | 642 | { | 
 | 643 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 644 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 645 | 	struct hda_input_mux *smux = &spec->private_smux; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 646 | 	unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 647 | 	int err, val; | 
 | 648 | 	hda_nid_t nid; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 649 |  | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 650 | 	err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 651 | 			spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 652 | 	if (err < 0) | 
 | 653 | 		return err; | 
 | 654 |  | 
 | 655 | 	if (spec->spdif_mute) { | 
 | 656 | 		if (smux_idx == 0) | 
 | 657 | 			nid = spec->multiout.dig_out_nid; | 
 | 658 | 		else | 
 | 659 | 			nid = codec->slave_dig_outs[smux_idx - 1]; | 
 | 660 | 		if (spec->cur_smux[smux_idx] == smux->num_items - 1) | 
| Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 661 | 			val = HDA_AMP_MUTE; | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 662 | 		else | 
| Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 663 | 			val = 0; | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 664 | 		/* un/mute SPDIF out */ | 
| Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 665 | 		snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, | 
 | 666 | 					 HDA_AMP_MUTE, val); | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 667 | 	} | 
 | 668 | 	return 0; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 669 | } | 
 | 670 |  | 
| Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 671 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, | 
 | 672 | 					hda_nid_t nid, unsigned int new_vref) | 
 | 673 | { | 
| Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 674 | 	int error; | 
| Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 675 | 	unsigned int pincfg; | 
 | 676 | 	pincfg = snd_hda_codec_read(codec, nid, 0, | 
 | 677 | 				AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 
 | 678 |  | 
 | 679 | 	pincfg &= 0xff; | 
 | 680 | 	pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | 
 | 681 | 	pincfg |= new_vref; | 
 | 682 |  | 
 | 683 | 	if (new_vref == AC_PINCTL_VREF_HIZ) | 
 | 684 | 		pincfg |= AC_PINCTL_OUT_EN; | 
 | 685 | 	else | 
 | 686 | 		pincfg |= AC_PINCTL_IN_EN; | 
 | 687 |  | 
 | 688 | 	error = snd_hda_codec_write_cache(codec, nid, 0, | 
 | 689 | 					AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg); | 
 | 690 | 	if (error < 0) | 
 | 691 | 		return error; | 
 | 692 | 	else | 
 | 693 | 		return 1; | 
 | 694 | } | 
 | 695 |  | 
 | 696 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) | 
 | 697 | { | 
 | 698 | 	unsigned int vref; | 
 | 699 | 	vref = snd_hda_codec_read(codec, nid, 0, | 
 | 700 | 				AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 
 | 701 | 	vref &= AC_PINCTL_VREFEN; | 
 | 702 | 	return vref; | 
 | 703 | } | 
 | 704 |  | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 705 | 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] | 706 | { | 
 | 707 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 708 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 709 | 	return snd_hda_input_mux_info(spec->input_mux, uinfo); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 710 | } | 
 | 711 |  | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 712 | 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] | 713 | { | 
 | 714 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 715 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 716 | 	unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
 | 717 |  | 
 | 718 | 	ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; | 
 | 719 | 	return 0; | 
 | 720 | } | 
 | 721 |  | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 722 | 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] | 723 | { | 
 | 724 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 725 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 726 | 	unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 727 | 	const struct hda_input_mux *imux = spec->input_mux; | 
 | 728 | 	unsigned int idx, prev_idx; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 729 |  | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 730 | 	idx = ucontrol->value.enumerated.item[0]; | 
 | 731 | 	if (idx >= imux->num_items) | 
 | 732 | 		idx = imux->num_items - 1; | 
 | 733 | 	prev_idx = spec->cur_mux[adc_idx]; | 
 | 734 | 	if (prev_idx == idx) | 
 | 735 | 		return 0; | 
 | 736 | 	if (idx < spec->num_analog_muxes) { | 
 | 737 | 		snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, | 
 | 738 | 					  AC_VERB_SET_CONNECT_SEL, | 
 | 739 | 					  imux->items[idx].index); | 
 | 740 | 		if (prev_idx >= spec->num_analog_muxes) { | 
 | 741 | 			imux = spec->dinput_mux; | 
 | 742 | 			/* 0 = analog */ | 
 | 743 | 			snd_hda_codec_write_cache(codec, | 
 | 744 | 						  spec->dmux_nids[adc_idx], 0, | 
 | 745 | 						  AC_VERB_SET_CONNECT_SEL, | 
 | 746 | 						  imux->items[0].index); | 
 | 747 | 		} | 
 | 748 | 	} else { | 
 | 749 | 		imux = spec->dinput_mux; | 
 | 750 | 		snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, | 
 | 751 | 					  AC_VERB_SET_CONNECT_SEL, | 
 | 752 | 					  imux->items[idx - 1].index); | 
 | 753 | 	} | 
 | 754 | 	spec->cur_mux[adc_idx] = idx; | 
 | 755 | 	return 1; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 756 | } | 
 | 757 |  | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 758 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, | 
 | 759 | 	struct snd_ctl_elem_info *uinfo) | 
 | 760 | { | 
 | 761 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 762 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 763 | 	return snd_hda_input_mux_info(spec->mono_mux, uinfo); | 
 | 764 | } | 
 | 765 |  | 
 | 766 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, | 
 | 767 | 	struct snd_ctl_elem_value *ucontrol) | 
 | 768 | { | 
 | 769 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 770 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 771 |  | 
 | 772 | 	ucontrol->value.enumerated.item[0] = spec->cur_mmux; | 
 | 773 | 	return 0; | 
 | 774 | } | 
 | 775 |  | 
 | 776 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, | 
 | 777 | 	struct snd_ctl_elem_value *ucontrol) | 
 | 778 | { | 
 | 779 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 780 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 781 |  | 
 | 782 | 	return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, | 
 | 783 | 				     spec->mono_nid, &spec->cur_mmux); | 
 | 784 | } | 
 | 785 |  | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 786 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info | 
 | 787 |  | 
 | 788 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, | 
 | 789 | 	struct snd_ctl_elem_value *ucontrol) | 
 | 790 | { | 
 | 791 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 792 | 	unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 793 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 794 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 795 | 	ucontrol->value.integer.value[0] = !!(spec->aloopback & | 
 | 796 | 					      (spec->aloopback_mask << idx)); | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 797 | 	return 0; | 
 | 798 | } | 
 | 799 |  | 
 | 800 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, | 
 | 801 | 		struct snd_ctl_elem_value *ucontrol) | 
 | 802 | { | 
 | 803 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 804 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 805 | 	unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 806 | 	unsigned int dac_mode; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 807 | 	unsigned int val, idx_val; | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 808 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 809 | 	idx_val = spec->aloopback_mask << idx; | 
 | 810 | 	if (ucontrol->value.integer.value[0]) | 
 | 811 | 		val = spec->aloopback | idx_val; | 
 | 812 | 	else | 
 | 813 | 		val = spec->aloopback & ~idx_val; | 
| Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 814 | 	if (spec->aloopback == val) | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 815 | 		return 0; | 
 | 816 |  | 
| Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 817 | 	spec->aloopback = val; | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 818 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 819 | 	/* Only return the bits defined by the shift value of the | 
 | 820 | 	 * first two bytes of the mask | 
 | 821 | 	 */ | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 822 | 	dac_mode = snd_hda_codec_read(codec, codec->afg, 0, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 823 | 				      kcontrol->private_value & 0xFFFF, 0x0); | 
 | 824 | 	dac_mode >>= spec->aloopback_shift; | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 825 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 826 | 	if (spec->aloopback & idx_val) { | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 827 | 		snd_hda_power_up(codec); | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 828 | 		dac_mode |= idx_val; | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 829 | 	} else { | 
 | 830 | 		snd_hda_power_down(codec); | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 831 | 		dac_mode &= ~idx_val; | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 832 | 	} | 
 | 833 |  | 
 | 834 | 	snd_hda_codec_write_cache(codec, codec->afg, 0, | 
 | 835 | 		kcontrol->private_value >> 16, dac_mode); | 
 | 836 |  | 
 | 837 | 	return 1; | 
 | 838 | } | 
 | 839 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 840 | static struct hda_verb stac9200_core_init[] = { | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 841 | 	/* set dac0mux for dac converter */ | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 842 | 	{ 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 843 | 	{} | 
 | 844 | }; | 
 | 845 |  | 
| Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 846 | static struct hda_verb stac9200_eapd_init[] = { | 
 | 847 | 	/* set dac0mux for dac converter */ | 
 | 848 | 	{0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, | 
 | 849 | 	{0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | 
 | 850 | 	{} | 
 | 851 | }; | 
 | 852 |  | 
| Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 853 | static struct hda_verb dell_eq_core_init[] = { | 
 | 854 | 	/* set master volume to max value without distortion | 
 | 855 | 	 * and direct control */ | 
 | 856 | 	{ 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, | 
| Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 857 | 	{} | 
 | 858 | }; | 
 | 859 |  | 
| Takashi Iwai | e2aec17 | 2009-09-02 01:00:05 +0200 | [diff] [blame] | 860 | static struct hda_verb stac92hd73xx_core_init[] = { | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 861 | 	/* set master volume and direct control */ | 
 | 862 | 	{ 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 863 | 	{} | 
 | 864 | }; | 
 | 865 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 866 | static struct hda_verb stac92hd83xxx_core_init[] = { | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 867 | 	/* power state controls amps */ | 
 | 868 | 	{ 0x01, AC_VERB_SET_EAPD, 1 << 2}, | 
| Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 869 | 	{} | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 870 | }; | 
 | 871 |  | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 872 | static struct hda_verb stac92hd71bxx_core_init[] = { | 
 | 873 | 	/* set master volume and direct control */ | 
 | 874 | 	{ 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 
| Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 875 | 	{} | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 876 | }; | 
 | 877 |  | 
| Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 878 | static struct hda_verb stac92hd71bxx_unmute_core_init[] = { | 
 | 879 | 	/* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ | 
 | 880 | 	{ 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 881 | 	{ 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 
 | 882 | 	{ 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 883 | 	{} | 
 | 884 | }; | 
 | 885 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 886 | static struct hda_verb stac925x_core_init[] = { | 
 | 887 | 	/* set dac0mux for dac converter */ | 
 | 888 | 	{ 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, | 
| Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 889 | 	/* mute the master volume */ | 
 | 890 | 	{ 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 891 | 	{} | 
 | 892 | }; | 
 | 893 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 894 | static struct hda_verb stac922x_core_init[] = { | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 895 | 	/* set master volume and direct control */	 | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 896 | 	{ 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 897 | 	{} | 
 | 898 | }; | 
 | 899 |  | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 900 | static struct hda_verb d965_core_init[] = { | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 901 | 	/* set master volume and direct control */	 | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 902 | 	{ 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 903 | 	/* unmute node 0x1b */ | 
 | 904 | 	{ 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, | 
 | 905 | 	/* select node 0x03 as DAC */	 | 
 | 906 | 	{ 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, | 
 | 907 | 	{} | 
 | 908 | }; | 
 | 909 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 910 | static struct hda_verb stac927x_core_init[] = { | 
 | 911 | 	/* set master volume and direct control */	 | 
 | 912 | 	{ 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 913 | 	/* enable analog pc beep path */ | 
 | 914 | 	{ 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 915 | 	{} | 
 | 916 | }; | 
 | 917 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 918 | static struct hda_verb stac9205_core_init[] = { | 
 | 919 | 	/* set master volume and direct control */	 | 
 | 920 | 	{ 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 921 | 	/* enable analog pc beep path */ | 
 | 922 | 	{ 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 923 | 	{} | 
 | 924 | }; | 
 | 925 |  | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 926 | #define STAC_MONO_MUX \ | 
 | 927 | 	{ \ | 
 | 928 | 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 
 | 929 | 		.name = "Mono Mux", \ | 
 | 930 | 		.count = 1, \ | 
 | 931 | 		.info = stac92xx_mono_mux_enum_info, \ | 
 | 932 | 		.get = stac92xx_mono_mux_enum_get, \ | 
 | 933 | 		.put = stac92xx_mono_mux_enum_put, \ | 
 | 934 | 	} | 
 | 935 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 936 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 937 | 	{ \ | 
 | 938 | 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 
 | 939 | 		.name  = "Analog Loopback", \ | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 940 | 		.count = cnt, \ | 
| Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 941 | 		.info  = stac92xx_aloopback_info, \ | 
 | 942 | 		.get   = stac92xx_aloopback_get, \ | 
 | 943 | 		.put   = stac92xx_aloopback_put, \ | 
 | 944 | 		.private_value = verb_read | (verb_write << 16), \ | 
 | 945 | 	} | 
 | 946 |  | 
| Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 947 | #define DC_BIAS(xname, idx, nid) \ | 
 | 948 | 	{ \ | 
 | 949 | 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 
 | 950 | 		.name = xname, \ | 
 | 951 | 		.index = idx, \ | 
 | 952 | 		.info = stac92xx_dc_bias_info, \ | 
 | 953 | 		.get = stac92xx_dc_bias_get, \ | 
 | 954 | 		.put = stac92xx_dc_bias_put, \ | 
 | 955 | 		.private_value = nid, \ | 
 | 956 | 	} | 
 | 957 |  | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 958 | static struct snd_kcontrol_new stac9200_mixer[] = { | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 959 | 	HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), | 
 | 960 | 	HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 961 | 	HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), | 
 | 962 | 	HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 963 | 	{ } /* end */ | 
 | 964 | }; | 
 | 965 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 966 | static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { | 
 | 967 | 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), | 
 | 968 | 	{} | 
 | 969 | }; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 970 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 971 | static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { | 
 | 972 | 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), | 
 | 973 | 	{} | 
 | 974 | }; | 
 | 975 |  | 
 | 976 | static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { | 
 | 977 | 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), | 
 | 978 | 	{} | 
 | 979 | }; | 
 | 980 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 981 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 982 | static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { | 
 | 983 | 	STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) | 
 | 984 | }; | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 985 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 986 | static struct snd_kcontrol_new stac925x_mixer[] = { | 
| Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 987 | 	HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), | 
 | 988 | 	HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 989 | 	{ } /* end */ | 
 | 990 | }; | 
 | 991 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 992 | static struct snd_kcontrol_new stac9205_loopback[] = { | 
 | 993 | 	STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), | 
 | 994 | 	{} | 
 | 995 | }; | 
 | 996 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 997 | static struct snd_kcontrol_new stac927x_loopback[] = { | 
 | 998 | 	STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), | 
 | 999 | 	{} | 
 | 1000 | }; | 
 | 1001 |  | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1002 | static struct snd_kcontrol_new stac_dmux_mixer = { | 
 | 1003 | 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 
 | 1004 | 	.name = "Digital Input Source", | 
 | 1005 | 	/* count set later */ | 
 | 1006 | 	.info = stac92xx_dmux_enum_info, | 
 | 1007 | 	.get = stac92xx_dmux_enum_get, | 
 | 1008 | 	.put = stac92xx_dmux_enum_put, | 
 | 1009 | }; | 
 | 1010 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1011 | static struct snd_kcontrol_new stac_smux_mixer = { | 
 | 1012 | 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 
| Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1013 | 	.name = "IEC958 Playback Source", | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1014 | 	/* count set later */ | 
 | 1015 | 	.info = stac92xx_smux_enum_info, | 
 | 1016 | 	.get = stac92xx_smux_enum_get, | 
 | 1017 | 	.put = stac92xx_smux_enum_put, | 
 | 1018 | }; | 
 | 1019 |  | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1020 | static const char *slave_vols[] = { | 
 | 1021 | 	"Front Playback Volume", | 
 | 1022 | 	"Surround Playback Volume", | 
 | 1023 | 	"Center Playback Volume", | 
 | 1024 | 	"LFE Playback Volume", | 
 | 1025 | 	"Side Playback Volume", | 
 | 1026 | 	"Headphone Playback Volume", | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1027 | 	"Speaker Playback Volume", | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1028 | 	NULL | 
 | 1029 | }; | 
 | 1030 |  | 
 | 1031 | static const char *slave_sws[] = { | 
 | 1032 | 	"Front Playback Switch", | 
 | 1033 | 	"Surround Playback Switch", | 
 | 1034 | 	"Center Playback Switch", | 
 | 1035 | 	"LFE Playback Switch", | 
 | 1036 | 	"Side Playback Switch", | 
 | 1037 | 	"Headphone Playback Switch", | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1038 | 	"Speaker Playback Switch", | 
| Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1039 | 	"IEC958 Playback Switch", | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1040 | 	NULL | 
 | 1041 | }; | 
 | 1042 |  | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1043 | static void stac92xx_free_kctls(struct hda_codec *codec); | 
| Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1044 | 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] | 1045 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1046 | static int stac92xx_build_controls(struct hda_codec *codec) | 
 | 1047 | { | 
 | 1048 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1049 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 1050 | 	hda_nid_t nid; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1051 | 	int err; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1052 | 	int i; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1053 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 1054 | 	if (spec->mixer) { | 
 | 1055 | 		err = snd_hda_add_new_ctls(codec, spec->mixer); | 
 | 1056 | 		if (err < 0) | 
 | 1057 | 			return err; | 
 | 1058 | 	} | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1059 |  | 
 | 1060 | 	for (i = 0; i < spec->num_mixers; i++) { | 
 | 1061 | 		err = snd_hda_add_new_ctls(codec, spec->mixers[i]); | 
 | 1062 | 		if (err < 0) | 
 | 1063 | 			return err; | 
 | 1064 | 	} | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 1065 | 	if (!spec->auto_mic && spec->num_dmuxes > 0 && | 
 | 1066 | 	    snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1067 | 		stac_dmux_mixer.count = spec->num_dmuxes; | 
| Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1068 | 		err = snd_hda_ctl_add(codec, | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1069 | 				  snd_ctl_new1(&stac_dmux_mixer, codec)); | 
 | 1070 | 		if (err < 0) | 
 | 1071 | 			return err; | 
 | 1072 | 	} | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1073 | 	if (spec->num_smuxes > 0) { | 
| Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1074 | 		int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); | 
 | 1075 | 		struct hda_input_mux *smux = &spec->private_smux; | 
 | 1076 | 		/* check for mute support on SPDIF out */ | 
 | 1077 | 		if (wcaps & AC_WCAP_OUT_AMP) { | 
 | 1078 | 			smux->items[smux->num_items].label = "Off"; | 
 | 1079 | 			smux->items[smux->num_items].index = 0; | 
 | 1080 | 			smux->num_items++; | 
 | 1081 | 			spec->spdif_mute = 1; | 
 | 1082 | 		} | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1083 | 		stac_smux_mixer.count = spec->num_smuxes; | 
| Takashi Iwai | 4f2d23e | 2008-12-19 10:14:13 +0100 | [diff] [blame] | 1084 | 		err = snd_hda_ctl_add(codec, | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1085 | 				  snd_ctl_new1(&stac_smux_mixer, codec)); | 
 | 1086 | 		if (err < 0) | 
 | 1087 | 			return err; | 
 | 1088 | 	} | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1089 |  | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1090 | 	if (spec->multiout.dig_out_nid) { | 
 | 1091 | 		err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); | 
 | 1092 | 		if (err < 0) | 
 | 1093 | 			return err; | 
| Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1094 | 		err = snd_hda_create_spdif_share_sw(codec, | 
 | 1095 | 						    &spec->multiout); | 
 | 1096 | 		if (err < 0) | 
 | 1097 | 			return err; | 
 | 1098 | 		spec->multiout.share_spdif = 1; | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1099 | 	} | 
| Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1100 | 	if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1101 | 		err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); | 
 | 1102 | 		if (err < 0) | 
 | 1103 | 			return err; | 
 | 1104 | 	} | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1105 |  | 
 | 1106 | 	/* if we have no master control, let's create it */ | 
 | 1107 | 	if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { | 
| Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1108 | 		unsigned int vmaster_tlv[4]; | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1109 | 		snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], | 
| Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1110 | 					HDA_OUTPUT, vmaster_tlv); | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 1111 | 		/* correct volume offset */ | 
 | 1112 | 		vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1113 | 		err = snd_hda_add_vmaster(codec, "Master Playback Volume", | 
| Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1114 | 					  vmaster_tlv, slave_vols); | 
| Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1115 | 		if (err < 0) | 
 | 1116 | 			return err; | 
 | 1117 | 	} | 
 | 1118 | 	if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { | 
 | 1119 | 		err = snd_hda_add_vmaster(codec, "Master Playback Switch", | 
 | 1120 | 					  NULL, slave_sws); | 
 | 1121 | 		if (err < 0) | 
 | 1122 | 			return err; | 
 | 1123 | 	} | 
 | 1124 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1125 | 	if (spec->aloopback_ctl && | 
 | 1126 | 	    snd_hda_get_bool_hint(codec, "loopback") == 1) { | 
 | 1127 | 		err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); | 
 | 1128 | 		if (err < 0) | 
 | 1129 | 			return err; | 
 | 1130 | 	} | 
 | 1131 |  | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1132 | 	stac92xx_free_kctls(codec); /* no longer needed */ | 
| Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1133 |  | 
 | 1134 | 	/* create jack input elements */ | 
 | 1135 | 	if (spec->hp_detect) { | 
 | 1136 | 		for (i = 0; i < cfg->hp_outs; i++) { | 
 | 1137 | 			int type = SND_JACK_HEADPHONE; | 
 | 1138 | 			nid = cfg->hp_pins[i]; | 
 | 1139 | 			/* jack detection */ | 
 | 1140 | 			if (cfg->hp_outs == i) | 
 | 1141 | 				type |= SND_JACK_LINEOUT; | 
 | 1142 | 			err = stac92xx_add_jack(codec, nid, type); | 
 | 1143 | 			if (err < 0) | 
 | 1144 | 				return err; | 
 | 1145 | 		} | 
 | 1146 | 	} | 
 | 1147 | 	for (i = 0; i < cfg->line_outs; i++) { | 
 | 1148 | 		err = stac92xx_add_jack(codec, cfg->line_out_pins[i], | 
 | 1149 | 					SND_JACK_LINEOUT); | 
 | 1150 | 		if (err < 0) | 
 | 1151 | 			return err; | 
 | 1152 | 	} | 
 | 1153 | 	for (i = 0; i < AUTO_PIN_LAST; i++) { | 
 | 1154 | 		nid = cfg->input_pins[i]; | 
 | 1155 | 		if (nid) { | 
 | 1156 | 			err = stac92xx_add_jack(codec, nid, | 
 | 1157 | 						SND_JACK_MICROPHONE); | 
 | 1158 | 			if (err < 0) | 
 | 1159 | 				return err; | 
 | 1160 | 		} | 
 | 1161 | 	} | 
 | 1162 |  | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1163 | 	return 0;	 | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1164 | } | 
 | 1165 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1166 | static unsigned int ref9200_pin_configs[8] = { | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1167 | 	0x01c47010, 0x01447010, 0x0221401f, 0x01114010, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1168 | 	0x02a19020, 0x01a19021, 0x90100140, 0x01813122, | 
 | 1169 | }; | 
 | 1170 |  | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1171 | static unsigned int gateway9200_m4_pin_configs[8] = { | 
 | 1172 | 	0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, | 
 | 1173 | 	0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, | 
 | 1174 | }; | 
 | 1175 | static unsigned int gateway9200_m4_2_pin_configs[8] = { | 
 | 1176 | 	0x400000fe, 0x404500f4, 0x400100f0, 0x90110010, | 
 | 1177 | 	0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3, | 
 | 1178 | }; | 
 | 1179 |  | 
 | 1180 | /* | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1181 |     STAC 9200 pin configs for | 
 | 1182 |     102801A8 | 
 | 1183 |     102801DE | 
 | 1184 |     102801E8 | 
 | 1185 | */ | 
 | 1186 | static unsigned int dell9200_d21_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1187 | 	0x400001f0, 0x400001f1, 0x02214030, 0x01014010,  | 
 | 1188 | 	0x02a19020, 0x01a19021, 0x90100140, 0x01813122, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1189 | }; | 
 | 1190 |  | 
 | 1191 | /*  | 
 | 1192 |     STAC 9200 pin configs for | 
 | 1193 |     102801C0 | 
 | 1194 |     102801C1 | 
 | 1195 | */ | 
 | 1196 | static unsigned int dell9200_d22_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1197 | 	0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,  | 
 | 1198 | 	0x01813020, 0x02a19021, 0x90100140, 0x400001f2, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1199 | }; | 
 | 1200 |  | 
 | 1201 | /*  | 
 | 1202 |     STAC 9200 pin configs for | 
 | 1203 |     102801C4 (Dell Dimension E310) | 
 | 1204 |     102801C5 | 
 | 1205 |     102801C7 | 
 | 1206 |     102801D9 | 
 | 1207 |     102801DA | 
 | 1208 |     102801E3 | 
 | 1209 | */ | 
 | 1210 | static unsigned int dell9200_d23_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1211 | 	0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,  | 
 | 1212 | 	0x01813020, 0x01a19021, 0x90100140, 0x400001f2,  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1213 | }; | 
 | 1214 |  | 
 | 1215 |  | 
 | 1216 | /*  | 
 | 1217 |     STAC 9200-32 pin configs for | 
 | 1218 |     102801B5 (Dell Inspiron 630m) | 
 | 1219 |     102801D8 (Dell Inspiron 640m) | 
 | 1220 | */ | 
 | 1221 | static unsigned int dell9200_m21_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1222 | 	0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, | 
 | 1223 | 	0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1224 | }; | 
 | 1225 |  | 
 | 1226 | /*  | 
 | 1227 |     STAC 9200-32 pin configs for | 
 | 1228 |     102801C2 (Dell Latitude D620) | 
 | 1229 |     102801C8  | 
 | 1230 |     102801CC (Dell Latitude D820) | 
 | 1231 |     102801D4  | 
 | 1232 |     102801D6  | 
 | 1233 | */ | 
 | 1234 | static unsigned int dell9200_m22_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1235 | 	0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,  | 
 | 1236 | 	0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1237 | }; | 
 | 1238 |  | 
 | 1239 | /*  | 
 | 1240 |     STAC 9200-32 pin configs for | 
 | 1241 |     102801CE (Dell XPS M1710) | 
 | 1242 |     102801CF (Dell Precision M90) | 
 | 1243 | */ | 
 | 1244 | static unsigned int dell9200_m23_pin_configs[8] = { | 
 | 1245 | 	0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, | 
 | 1246 | 	0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, | 
 | 1247 | }; | 
 | 1248 |  | 
 | 1249 | /* | 
 | 1250 |     STAC 9200-32 pin configs for  | 
 | 1251 |     102801C9 | 
 | 1252 |     102801CA | 
 | 1253 |     102801CB (Dell Latitude 120L) | 
 | 1254 |     102801D3 | 
 | 1255 | */ | 
 | 1256 | static unsigned int dell9200_m24_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1257 | 	0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,  | 
 | 1258 | 	0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1259 | }; | 
 | 1260 |  | 
 | 1261 | /* | 
 | 1262 |     STAC 9200-32 pin configs for | 
 | 1263 |     102801BD (Dell Inspiron E1505n) | 
 | 1264 |     102801EE | 
 | 1265 |     102801EF | 
 | 1266 | */ | 
 | 1267 | static unsigned int dell9200_m25_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1268 | 	0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,  | 
 | 1269 | 	0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1270 | }; | 
 | 1271 |  | 
 | 1272 | /* | 
 | 1273 |     STAC 9200-32 pin configs for | 
 | 1274 |     102801F5 (Dell Inspiron 1501) | 
 | 1275 |     102801F6 | 
 | 1276 | */ | 
 | 1277 | static unsigned int dell9200_m26_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1278 | 	0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,  | 
 | 1279 | 	0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1280 | }; | 
 | 1281 |  | 
 | 1282 | /* | 
 | 1283 |     STAC 9200-32 | 
 | 1284 |     102801CD (Dell Inspiron E1705/9400) | 
 | 1285 | */ | 
 | 1286 | static unsigned int dell9200_m27_pin_configs[8] = { | 
| Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1287 | 	0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, | 
 | 1288 | 	0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1289 | }; | 
 | 1290 |  | 
| Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1291 | static unsigned int oqo9200_pin_configs[8] = { | 
 | 1292 | 	0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, | 
 | 1293 | 	0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, | 
 | 1294 | }; | 
 | 1295 |  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1296 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1297 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { | 
 | 1298 | 	[STAC_REF] = ref9200_pin_configs, | 
| Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1299 | 	[STAC_9200_OQO] = oqo9200_pin_configs, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1300 | 	[STAC_9200_DELL_D21] = dell9200_d21_pin_configs, | 
 | 1301 | 	[STAC_9200_DELL_D22] = dell9200_d22_pin_configs, | 
 | 1302 | 	[STAC_9200_DELL_D23] = dell9200_d23_pin_configs, | 
 | 1303 | 	[STAC_9200_DELL_M21] = dell9200_m21_pin_configs, | 
 | 1304 | 	[STAC_9200_DELL_M22] = dell9200_m22_pin_configs, | 
 | 1305 | 	[STAC_9200_DELL_M23] = dell9200_m23_pin_configs, | 
 | 1306 | 	[STAC_9200_DELL_M24] = dell9200_m24_pin_configs, | 
 | 1307 | 	[STAC_9200_DELL_M25] = dell9200_m25_pin_configs, | 
 | 1308 | 	[STAC_9200_DELL_M26] = dell9200_m26_pin_configs, | 
 | 1309 | 	[STAC_9200_DELL_M27] = dell9200_m27_pin_configs, | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1310 | 	[STAC_9200_M4] = gateway9200_m4_pin_configs, | 
 | 1311 | 	[STAC_9200_M4_2] = gateway9200_m4_2_pin_configs, | 
| Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1312 | 	[STAC_9200_PANASONIC] = ref9200_pin_configs, | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1313 | }; | 
 | 1314 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1315 | static const char *stac9200_models[STAC_9200_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1316 | 	[STAC_AUTO] = "auto", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1317 | 	[STAC_REF] = "ref", | 
| Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1318 | 	[STAC_9200_OQO] = "oqo", | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1319 | 	[STAC_9200_DELL_D21] = "dell-d21", | 
 | 1320 | 	[STAC_9200_DELL_D22] = "dell-d22", | 
 | 1321 | 	[STAC_9200_DELL_D23] = "dell-d23", | 
 | 1322 | 	[STAC_9200_DELL_M21] = "dell-m21", | 
 | 1323 | 	[STAC_9200_DELL_M22] = "dell-m22", | 
 | 1324 | 	[STAC_9200_DELL_M23] = "dell-m23", | 
 | 1325 | 	[STAC_9200_DELL_M24] = "dell-m24", | 
 | 1326 | 	[STAC_9200_DELL_M25] = "dell-m25", | 
 | 1327 | 	[STAC_9200_DELL_M26] = "dell-m26", | 
 | 1328 | 	[STAC_9200_DELL_M27] = "dell-m27", | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1329 | 	[STAC_9200_M4] = "gateway-m4", | 
 | 1330 | 	[STAC_9200_M4_2] = "gateway-m4-2", | 
| Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1331 | 	[STAC_9200_PANASONIC] = "panasonic", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1332 | }; | 
 | 1333 |  | 
 | 1334 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { | 
 | 1335 | 	/* SigmaTel reference board */ | 
 | 1336 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
 | 1337 | 		      "DFI LanParty", STAC_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1338 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 1339 | 		      "DFI LanParty", STAC_REF), | 
| Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1340 | 	/* Dell laptops have BIOS problem */ | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1341 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, | 
 | 1342 | 		      "unknown Dell", STAC_9200_DELL_D21), | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1343 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1344 | 		      "Dell Inspiron 630m", STAC_9200_DELL_M21), | 
 | 1345 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, | 
 | 1346 | 		      "Dell Inspiron E1505n", STAC_9200_DELL_M25), | 
 | 1347 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, | 
 | 1348 | 		      "unknown Dell", STAC_9200_DELL_D22), | 
 | 1349 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, | 
 | 1350 | 		      "unknown Dell", STAC_9200_DELL_D22), | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1351 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1352 | 		      "Dell Latitude D620", STAC_9200_DELL_M22), | 
 | 1353 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, | 
 | 1354 | 		      "unknown Dell", STAC_9200_DELL_D23), | 
 | 1355 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, | 
 | 1356 | 		      "unknown Dell", STAC_9200_DELL_D23), | 
 | 1357 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, | 
 | 1358 | 		      "unknown Dell", STAC_9200_DELL_M22), | 
 | 1359 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, | 
 | 1360 | 		      "unknown Dell", STAC_9200_DELL_M24), | 
 | 1361 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, | 
 | 1362 | 		      "unknown Dell", STAC_9200_DELL_M24), | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1363 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1364 | 		      "Dell Latitude 120L", STAC_9200_DELL_M24), | 
| Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1365 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1366 | 		      "Dell Latitude D820", STAC_9200_DELL_M22), | 
| Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1367 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1368 | 		      "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), | 
| Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1369 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1370 | 		      "Dell XPS M1710", STAC_9200_DELL_M23), | 
| Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1371 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1372 | 		      "Dell Precision M90", STAC_9200_DELL_M23), | 
 | 1373 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, | 
 | 1374 | 		      "unknown Dell", STAC_9200_DELL_M22), | 
 | 1375 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, | 
 | 1376 | 		      "unknown Dell", STAC_9200_DELL_M22), | 
| Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1377 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1378 | 		      "unknown Dell", STAC_9200_DELL_M22), | 
| Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1379 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1380 | 		      "Dell Inspiron 640m", STAC_9200_DELL_M21), | 
 | 1381 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, | 
 | 1382 | 		      "unknown Dell", STAC_9200_DELL_D23), | 
 | 1383 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, | 
 | 1384 | 		      "unknown Dell", STAC_9200_DELL_D23), | 
 | 1385 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, | 
 | 1386 | 		      "unknown Dell", STAC_9200_DELL_D21), | 
 | 1387 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, | 
 | 1388 | 		      "unknown Dell", STAC_9200_DELL_D23), | 
 | 1389 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, | 
 | 1390 | 		      "unknown Dell", STAC_9200_DELL_D21), | 
 | 1391 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, | 
 | 1392 | 		      "unknown Dell", STAC_9200_DELL_M25), | 
 | 1393 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, | 
 | 1394 | 		      "unknown Dell", STAC_9200_DELL_M25), | 
| Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1395 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1396 | 		      "Dell Inspiron 1501", STAC_9200_DELL_M26), | 
 | 1397 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, | 
 | 1398 | 		      "unknown Dell", STAC_9200_DELL_M26), | 
| Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1399 | 	/* Panasonic */ | 
| Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1400 | 	SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), | 
| Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1401 | 	/* Gateway machines needs EAPD to be set on resume */ | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1402 | 	SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), | 
 | 1403 | 	SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), | 
 | 1404 | 	SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), | 
| Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1405 | 	/* OQO Mobile */ | 
 | 1406 | 	SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1407 | 	{} /* terminator */ | 
 | 1408 | }; | 
 | 1409 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1410 | static unsigned int ref925x_pin_configs[8] = { | 
 | 1411 | 	0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1412 | 	0x90a70320, 0x02214210, 0x01019020, 0x9033032e, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1413 | }; | 
 | 1414 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1415 | static unsigned int stac925xM1_pin_configs[8] = { | 
 | 1416 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1417 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1418 | }; | 
 | 1419 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1420 | static unsigned int stac925xM1_2_pin_configs[8] = { | 
 | 1421 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1422 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | 
 | 1423 | }; | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1424 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1425 | static unsigned int stac925xM2_pin_configs[8] = { | 
 | 1426 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1427 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | 
| Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1428 | }; | 
 | 1429 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1430 | static unsigned int stac925xM2_2_pin_configs[8] = { | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1431 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1432 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | 
 | 1433 | }; | 
 | 1434 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1435 | static unsigned int stac925xM3_pin_configs[8] = { | 
 | 1436 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1437 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, | 
 | 1438 | }; | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1439 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1440 | static unsigned int stac925xM5_pin_configs[8] = { | 
 | 1441 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1442 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, | 
 | 1443 | }; | 
 | 1444 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1445 | static unsigned int stac925xM6_pin_configs[8] = { | 
 | 1446 | 	0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, | 
 | 1447 | 	0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1448 | }; | 
 | 1449 |  | 
 | 1450 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { | 
 | 1451 | 	[STAC_REF] = ref925x_pin_configs, | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1452 | 	[STAC_M1] = stac925xM1_pin_configs, | 
 | 1453 | 	[STAC_M1_2] = stac925xM1_2_pin_configs, | 
 | 1454 | 	[STAC_M2] = stac925xM2_pin_configs, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1455 | 	[STAC_M2_2] = stac925xM2_2_pin_configs, | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1456 | 	[STAC_M3] = stac925xM3_pin_configs, | 
 | 1457 | 	[STAC_M5] = stac925xM5_pin_configs, | 
 | 1458 | 	[STAC_M6] = stac925xM6_pin_configs, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1459 | }; | 
 | 1460 |  | 
 | 1461 | static const char *stac925x_models[STAC_925x_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1462 | 	[STAC_925x_AUTO] = "auto", | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1463 | 	[STAC_REF] = "ref", | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1464 | 	[STAC_M1] = "m1", | 
 | 1465 | 	[STAC_M1_2] = "m1-2", | 
 | 1466 | 	[STAC_M2] = "m2", | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1467 | 	[STAC_M2_2] = "m2-2", | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1468 | 	[STAC_M3] = "m3", | 
 | 1469 | 	[STAC_M5] = "m5", | 
 | 1470 | 	[STAC_M6] = "m6", | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1471 | }; | 
 | 1472 |  | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1473 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1474 | 	SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), | 
 | 1475 | 	SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), | 
 | 1476 | 	SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), | 
 | 1477 | 	SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1478 | 	SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1479 | 	/* Not sure about the brand name for those */ | 
 | 1480 | 	SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), | 
 | 1481 | 	SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), | 
 | 1482 | 	SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), | 
 | 1483 | 	SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1484 | 	{} /* terminator */ | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1485 | }; | 
 | 1486 |  | 
 | 1487 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { | 
 | 1488 | 	/* SigmaTel reference board */ | 
 | 1489 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1490 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), | 
| Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1491 | 	SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1492 |  | 
 | 1493 | 	/* Default table for unknown ID */ | 
 | 1494 | 	SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), | 
 | 1495 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1496 | 	{} /* terminator */ | 
 | 1497 | }; | 
 | 1498 |  | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1499 | static unsigned int ref92hd73xx_pin_configs[13] = { | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1500 | 	0x02214030, 0x02a19040, 0x01a19020, 0x02214030, | 
 | 1501 | 	0x0181302e, 0x01014010, 0x01014020, 0x01014030, | 
 | 1502 | 	0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1503 | 	0x01452050, | 
 | 1504 | }; | 
 | 1505 |  | 
 | 1506 | static unsigned int dell_m6_pin_configs[13] = { | 
 | 1507 | 	0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1508 | 	0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1509 | 	0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, | 
 | 1510 | 	0x4f0000f0, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1511 | }; | 
 | 1512 |  | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 1513 | static unsigned int alienware_m17x_pin_configs[13] = { | 
 | 1514 | 	0x0321101f, 0x0321101f, 0x03a11020, 0x03014020, | 
 | 1515 | 	0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0, | 
 | 1516 | 	0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, | 
 | 1517 | 	0x904601b0, | 
 | 1518 | }; | 
 | 1519 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1520 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1521 | 	[STAC_92HD73XX_REF]	= ref92hd73xx_pin_configs, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1522 | 	[STAC_DELL_M6_AMIC]	= dell_m6_pin_configs, | 
 | 1523 | 	[STAC_DELL_M6_DMIC]	= dell_m6_pin_configs, | 
 | 1524 | 	[STAC_DELL_M6_BOTH]	= dell_m6_pin_configs, | 
| Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1525 | 	[STAC_DELL_EQ]	= dell_m6_pin_configs, | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 1526 | 	[STAC_ALIENWARE_M17X]	= alienware_m17x_pin_configs, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1527 | }; | 
 | 1528 |  | 
 | 1529 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1530 | 	[STAC_92HD73XX_AUTO] = "auto", | 
| Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 1531 | 	[STAC_92HD73XX_NO_JD] = "no-jd", | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1532 | 	[STAC_92HD73XX_REF] = "ref", | 
| Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame] | 1533 | 	[STAC_92HD73XX_INTEL] = "intel", | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1534 | 	[STAC_DELL_M6_AMIC] = "dell-m6-amic", | 
 | 1535 | 	[STAC_DELL_M6_DMIC] = "dell-m6-dmic", | 
 | 1536 | 	[STAC_DELL_M6_BOTH] = "dell-m6", | 
| Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1537 | 	[STAC_DELL_EQ] = "dell-eq", | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 1538 | 	[STAC_ALIENWARE_M17X] = "alienware", | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1539 | }; | 
 | 1540 |  | 
 | 1541 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | 
 | 1542 | 	/* SigmaTel reference board */ | 
 | 1543 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1544 | 				"DFI LanParty", STAC_92HD73XX_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1545 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 1546 | 				"DFI LanParty", STAC_92HD73XX_REF), | 
| Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame] | 1547 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, | 
 | 1548 | 				"Intel DG45ID", STAC_92HD73XX_INTEL), | 
 | 1549 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, | 
 | 1550 | 				"Intel DG45FC", STAC_92HD73XX_INTEL), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1551 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1552 | 				"Dell Studio 1535", STAC_DELL_M6_DMIC), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1553 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1554 | 				"unknown Dell", STAC_DELL_M6_DMIC), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1555 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1556 | 				"unknown Dell", STAC_DELL_M6_BOTH), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1557 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1558 | 				"unknown Dell", STAC_DELL_M6_BOTH), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1559 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1560 | 				"unknown Dell", STAC_DELL_M6_AMIC), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1561 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1562 | 				"unknown Dell", STAC_DELL_M6_AMIC), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1563 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1564 | 				"unknown Dell", STAC_DELL_M6_DMIC), | 
 | 1565 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, | 
 | 1566 | 				"unknown Dell", STAC_DELL_M6_DMIC), | 
| Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1567 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1568 | 				"Dell Studio 1537", STAC_DELL_M6_DMIC), | 
| Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 1569 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, | 
 | 1570 | 				"Dell Studio 17", STAC_DELL_M6_DMIC), | 
| Takashi Iwai | 626f5ce | 2009-07-28 00:54:39 +0200 | [diff] [blame] | 1571 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, | 
 | 1572 | 				"Dell Studio 1555", STAC_DELL_M6_DMIC), | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1573 | 	{} /* terminator */ | 
 | 1574 | }; | 
 | 1575 |  | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 1576 | static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = { | 
 | 1577 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1, | 
 | 1578 | 		      "Alienware M17x", STAC_ALIENWARE_M17X), | 
 | 1579 | 	{} /* terminator */ | 
 | 1580 | }; | 
 | 1581 |  | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1582 | static unsigned int ref92hd83xxx_pin_configs[10] = { | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1583 | 	0x02214030, 0x02211010, 0x02a19020, 0x02170130, | 
 | 1584 | 	0x01014050, 0x01819040, 0x01014020, 0x90a3014e, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1585 | 	0x01451160, 0x98560170, | 
 | 1586 | }; | 
 | 1587 |  | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1588 | static unsigned int dell_s14_pin_configs[10] = { | 
| Takashi Iwai | 69b5655 | 2009-09-15 12:37:42 +0200 | [diff] [blame] | 1589 | 	0x0221403f, 0x0221101f, 0x02a19020, 0x90170110, | 
 | 1590 | 	0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160, | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1591 | 	0x40f000f0, 0x40f000f0, | 
 | 1592 | }; | 
 | 1593 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1594 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { | 
 | 1595 | 	[STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, | 
| Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1596 | 	[STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1597 | 	[STAC_DELL_S14] = dell_s14_pin_configs, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1598 | }; | 
 | 1599 |  | 
 | 1600 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1601 | 	[STAC_92HD83XXX_AUTO] = "auto", | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1602 | 	[STAC_92HD83XXX_REF] = "ref", | 
| Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 1603 | 	[STAC_92HD83XXX_PWR_REF] = "mic-ref", | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1604 | 	[STAC_DELL_S14] = "dell-s14", | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1605 | }; | 
 | 1606 |  | 
 | 1607 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { | 
 | 1608 | 	/* SigmaTel reference board */ | 
 | 1609 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
| Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 1610 | 		      "DFI LanParty", STAC_92HD83XXX_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1611 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 1612 | 		      "DFI LanParty", STAC_92HD83XXX_REF), | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 1613 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, | 
 | 1614 | 		      "unknown Dell", STAC_DELL_S14), | 
| Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 1615 | 	{} /* terminator */ | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1616 | }; | 
 | 1617 |  | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1618 | static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = { | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1619 | 	0x02214030, 0x02a19040, 0x01a19020, 0x01014010, | 
| Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1620 | 	0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1621 | 	0x90a000f0, 0x01452050, 0x01452050, 0x00000000, | 
 | 1622 | 	0x00000000 | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1623 | }; | 
 | 1624 |  | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1625 | static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = { | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1626 | 	0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, | 
| Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1627 | 	0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1628 | 	0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000, | 
 | 1629 | 	0x00000000 | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1630 | }; | 
 | 1631 |  | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1632 | static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = { | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1633 | 	0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, | 
 | 1634 | 	0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1635 | 	0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, | 
 | 1636 | 	0x00000000 | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1637 | }; | 
 | 1638 |  | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1639 | static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = { | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1640 | 	0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, | 
 | 1641 | 	0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 1642 | 	0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000, | 
 | 1643 | 	0x00000000 | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1644 | }; | 
 | 1645 |  | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1646 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { | 
 | 1647 | 	[STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1648 | 	[STAC_DELL_M4_1]	= dell_m4_1_pin_configs, | 
 | 1649 | 	[STAC_DELL_M4_2]	= dell_m4_2_pin_configs, | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1650 | 	[STAC_DELL_M4_3]	= dell_m4_3_pin_configs, | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1651 | 	[STAC_HP_M4]		= NULL, | 
| Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1652 | 	[STAC_HP_DV5]		= NULL, | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1653 | 	[STAC_HP_HDX]           = NULL, | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1654 | 	[STAC_HP_DV4_1222NR]	= NULL, | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1655 | }; | 
 | 1656 |  | 
 | 1657 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1658 | 	[STAC_92HD71BXX_AUTO] = "auto", | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1659 | 	[STAC_92HD71BXX_REF] = "ref", | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1660 | 	[STAC_DELL_M4_1] = "dell-m4-1", | 
 | 1661 | 	[STAC_DELL_M4_2] = "dell-m4-2", | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1662 | 	[STAC_DELL_M4_3] = "dell-m4-3", | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1663 | 	[STAC_HP_M4] = "hp-m4", | 
| Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 1664 | 	[STAC_HP_DV5] = "hp-dv5", | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1665 | 	[STAC_HP_HDX] = "hp-hdx", | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1666 | 	[STAC_HP_DV4_1222NR] = "hp-dv4-1222nr", | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1667 | }; | 
 | 1668 |  | 
 | 1669 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | 
 | 1670 | 	/* SigmaTel reference board */ | 
 | 1671 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
 | 1672 | 		      "DFI LanParty", STAC_92HD71BXX_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1673 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 1674 | 		      "DFI LanParty", STAC_92HD71BXX_REF), | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 1675 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, | 
 | 1676 | 		      "HP dv4-1222nr", STAC_HP_DV4_1222NR), | 
| Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 1677 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, | 
 | 1678 | 		      "HP", STAC_HP_DV5), | 
| Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1679 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, | 
 | 1680 | 		      "HP dv4-7", STAC_HP_DV5), | 
 | 1681 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, | 
 | 1682 | 		      "HP dv4-7", STAC_HP_DV5), | 
| Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1683 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, | 
 | 1684 | 		      "HP HDX", STAC_HP_HDX),  /* HDX18 */ | 
| Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1685 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, | 
| Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 1686 | 		      "HP mini 1000", STAC_HP_M4), | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 1687 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, | 
| Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 1688 | 		      "HP HDX", STAC_HP_HDX),  /* HDX16 */ | 
| Takashi Iwai | 6e34c03 | 2009-09-14 15:42:18 +0200 | [diff] [blame] | 1689 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620, | 
 | 1690 | 		      "HP dv6", STAC_HP_DV5), | 
| Takashi Iwai | 1972d02 | 2009-08-06 08:44:43 +0200 | [diff] [blame] | 1691 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, | 
 | 1692 | 		      "HP", STAC_HP_DV5), | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1693 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, | 
 | 1694 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1695 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, | 
 | 1696 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1697 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, | 
 | 1698 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1699 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, | 
 | 1700 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1701 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, | 
 | 1702 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1703 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, | 
 | 1704 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1705 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, | 
 | 1706 | 				"unknown Dell", STAC_DELL_M4_1), | 
 | 1707 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, | 
 | 1708 | 				"unknown Dell", STAC_DELL_M4_2), | 
 | 1709 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, | 
 | 1710 | 				"unknown Dell", STAC_DELL_M4_2), | 
 | 1711 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, | 
 | 1712 | 				"unknown Dell", STAC_DELL_M4_2), | 
 | 1713 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, | 
 | 1714 | 				"unknown Dell", STAC_DELL_M4_2), | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1715 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, | 
 | 1716 | 				"unknown Dell", STAC_DELL_M4_3), | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1717 | 	{} /* terminator */ | 
 | 1718 | }; | 
 | 1719 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1720 | static unsigned int ref922x_pin_configs[10] = { | 
 | 1721 | 	0x01014010, 0x01016011, 0x01012012, 0x0221401f, | 
 | 1722 | 	0x01813122, 0x01011014, 0x01441030, 0x01c41030, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1723 | 	0x40000100, 0x40000100, | 
 | 1724 | }; | 
 | 1725 |  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1726 | /* | 
 | 1727 |     STAC 922X pin configs for | 
 | 1728 |     102801A7 | 
 | 1729 |     102801AB | 
 | 1730 |     102801A9 | 
 | 1731 |     102801D1 | 
 | 1732 |     102801D2 | 
 | 1733 | */ | 
 | 1734 | static unsigned int dell_922x_d81_pin_configs[10] = { | 
 | 1735 | 	0x02214030, 0x01a19021, 0x01111012, 0x01114010, | 
 | 1736 | 	0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, | 
 | 1737 | 	0x01813122, 0x400001f2, | 
 | 1738 | }; | 
 | 1739 |  | 
 | 1740 | /* | 
 | 1741 |     STAC 922X pin configs for | 
 | 1742 |     102801AC | 
 | 1743 |     102801D0 | 
 | 1744 | */ | 
 | 1745 | static unsigned int dell_922x_d82_pin_configs[10] = { | 
 | 1746 | 	0x02214030, 0x01a19021, 0x01111012, 0x01114010, | 
 | 1747 | 	0x02a19020, 0x01117011, 0x01451140, 0x400001f0, | 
 | 1748 | 	0x01813122, 0x400001f1, | 
 | 1749 | }; | 
 | 1750 |  | 
 | 1751 | /* | 
 | 1752 |     STAC 922X pin configs for | 
 | 1753 |     102801BF | 
 | 1754 | */ | 
 | 1755 | static unsigned int dell_922x_m81_pin_configs[10] = { | 
 | 1756 | 	0x0321101f, 0x01112024, 0x01111222, 0x91174220, | 
 | 1757 | 	0x03a11050, 0x01116221, 0x90a70330, 0x01452340,  | 
 | 1758 | 	0x40C003f1, 0x405003f0, | 
 | 1759 | }; | 
 | 1760 |  | 
 | 1761 | /* | 
 | 1762 |     STAC 9221 A1 pin configs for | 
 | 1763 |     102801D7 (Dell XPS M1210) | 
 | 1764 | */ | 
 | 1765 | static unsigned int dell_922x_m82_pin_configs[10] = { | 
| Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1766 | 	0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,  | 
 | 1767 | 	0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1768 | 	0x508003f3, 0x405003f4,  | 
 | 1769 | }; | 
 | 1770 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1771 | static unsigned int d945gtp3_pin_configs[10] = { | 
| Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1772 | 	0x0221401f, 0x01a19022, 0x01813021, 0x01014010, | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1773 | 	0x40000100, 0x40000100, 0x40000100, 0x40000100, | 
 | 1774 | 	0x02a19120, 0x40000100, | 
 | 1775 | }; | 
 | 1776 |  | 
 | 1777 | static unsigned int d945gtp5_pin_configs[10] = { | 
| Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1778 | 	0x0221401f, 0x01011012, 0x01813024, 0x01014010, | 
 | 1779 | 	0x01a19021, 0x01016011, 0x01452130, 0x40000100, | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1780 | 	0x02a19320, 0x40000100, | 
 | 1781 | }; | 
 | 1782 |  | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1783 | static unsigned int intel_mac_v1_pin_configs[10] = { | 
 | 1784 | 	0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, | 
 | 1785 | 	0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, | 
| Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1786 | 	0x400000fc, 0x400000fb, | 
 | 1787 | }; | 
 | 1788 |  | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1789 | static unsigned int intel_mac_v2_pin_configs[10] = { | 
 | 1790 | 	0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, | 
 | 1791 | 	0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, | 
| Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1792 | 	0x400000fc, 0x400000fb, | 
 | 1793 | }; | 
 | 1794 |  | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1795 | static unsigned int intel_mac_v3_pin_configs[10] = { | 
 | 1796 | 	0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, | 
 | 1797 | 	0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, | 
 | 1798 | 	0x400000fc, 0x400000fb, | 
 | 1799 | }; | 
 | 1800 |  | 
 | 1801 | static unsigned int intel_mac_v4_pin_configs[10] = { | 
 | 1802 | 	0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, | 
 | 1803 | 	0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, | 
 | 1804 | 	0x400000fc, 0x400000fb, | 
 | 1805 | }; | 
 | 1806 |  | 
 | 1807 | static unsigned int intel_mac_v5_pin_configs[10] = { | 
 | 1808 | 	0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, | 
 | 1809 | 	0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, | 
 | 1810 | 	0x400000fc, 0x400000fb, | 
| Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1811 | }; | 
 | 1812 |  | 
| Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1813 | static unsigned int ecs202_pin_configs[10] = { | 
 | 1814 | 	0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, | 
 | 1815 | 	0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, | 
 | 1816 | 	0x9037012e, 0x40e000f2, | 
 | 1817 | }; | 
| Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1818 |  | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1819 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1820 | 	[STAC_D945_REF] = ref922x_pin_configs, | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1821 | 	[STAC_D945GTP3] = d945gtp3_pin_configs, | 
 | 1822 | 	[STAC_D945GTP5] = d945gtp5_pin_configs, | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1823 | 	[STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, | 
 | 1824 | 	[STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, | 
 | 1825 | 	[STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, | 
 | 1826 | 	[STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, | 
 | 1827 | 	[STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1828 | 	[STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1829 | 	/* for backward compatibility */ | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1830 | 	[STAC_MACMINI] = intel_mac_v3_pin_configs, | 
 | 1831 | 	[STAC_MACBOOK] = intel_mac_v5_pin_configs, | 
 | 1832 | 	[STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, | 
 | 1833 | 	[STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, | 
 | 1834 | 	[STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, | 
 | 1835 | 	[STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, | 
| Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1836 | 	[STAC_ECS_202] = ecs202_pin_configs, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1837 | 	[STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, | 
 | 1838 | 	[STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,	 | 
 | 1839 | 	[STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, | 
 | 1840 | 	[STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,	 | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1841 | }; | 
 | 1842 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1843 | static const char *stac922x_models[STAC_922X_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 1844 | 	[STAC_922X_AUTO] = "auto", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1845 | 	[STAC_D945_REF]	= "ref", | 
 | 1846 | 	[STAC_D945GTP5]	= "5stack", | 
 | 1847 | 	[STAC_D945GTP3]	= "3stack", | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1848 | 	[STAC_INTEL_MAC_V1] = "intel-mac-v1", | 
 | 1849 | 	[STAC_INTEL_MAC_V2] = "intel-mac-v2", | 
 | 1850 | 	[STAC_INTEL_MAC_V3] = "intel-mac-v3", | 
 | 1851 | 	[STAC_INTEL_MAC_V4] = "intel-mac-v4", | 
 | 1852 | 	[STAC_INTEL_MAC_V5] = "intel-mac-v5", | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1853 | 	[STAC_INTEL_MAC_AUTO] = "intel-mac-auto", | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1854 | 	/* for backward compatibility */ | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1855 | 	[STAC_MACMINI]	= "macmini", | 
| Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1856 | 	[STAC_MACBOOK]	= "macbook", | 
| Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 1857 | 	[STAC_MACBOOK_PRO_V1]	= "macbook-pro-v1", | 
 | 1858 | 	[STAC_MACBOOK_PRO_V2]	= "macbook-pro", | 
| Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1859 | 	[STAC_IMAC_INTEL] = "imac-intel", | 
| Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1860 | 	[STAC_IMAC_INTEL_20] = "imac-intel-20", | 
| Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1861 | 	[STAC_ECS_202] = "ecs202", | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1862 | 	[STAC_922X_DELL_D81] = "dell-d81", | 
 | 1863 | 	[STAC_922X_DELL_D82] = "dell-d82", | 
 | 1864 | 	[STAC_922X_DELL_M81] = "dell-m81", | 
 | 1865 | 	[STAC_922X_DELL_M82] = "dell-m82", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1866 | }; | 
 | 1867 |  | 
 | 1868 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { | 
 | 1869 | 	/* SigmaTel reference board */ | 
 | 1870 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
 | 1871 | 		      "DFI LanParty", STAC_D945_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1872 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 1873 | 		      "DFI LanParty", STAC_D945_REF), | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1874 | 	/* Intel 945G based systems */ | 
 | 1875 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, | 
 | 1876 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1877 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, | 
 | 1878 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1879 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, | 
 | 1880 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1881 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, | 
 | 1882 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1883 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, | 
 | 1884 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1885 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, | 
 | 1886 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1887 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, | 
 | 1888 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1889 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, | 
 | 1890 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1891 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, | 
 | 1892 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1893 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, | 
 | 1894 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1895 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, | 
 | 1896 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1897 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, | 
 | 1898 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1899 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, | 
 | 1900 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1901 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, | 
 | 1902 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1903 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, | 
 | 1904 | 		      "Intel D945G", STAC_D945GTP3), | 
 | 1905 | 	/* Intel D945G 5-stack systems */ | 
 | 1906 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, | 
 | 1907 | 		      "Intel D945G", STAC_D945GTP5), | 
 | 1908 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, | 
 | 1909 | 		      "Intel D945G", STAC_D945GTP5), | 
 | 1910 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, | 
 | 1911 | 		      "Intel D945G", STAC_D945GTP5), | 
 | 1912 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, | 
 | 1913 | 		      "Intel D945G", STAC_D945GTP5), | 
 | 1914 | 	/* Intel 945P based systems */ | 
 | 1915 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, | 
 | 1916 | 		      "Intel D945P", STAC_D945GTP3), | 
 | 1917 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, | 
 | 1918 | 		      "Intel D945P", STAC_D945GTP3), | 
 | 1919 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, | 
 | 1920 | 		      "Intel D945P", STAC_D945GTP3), | 
 | 1921 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, | 
 | 1922 | 		      "Intel D945P", STAC_D945GTP3), | 
 | 1923 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, | 
 | 1924 | 		      "Intel D945P", STAC_D945GTP3), | 
 | 1925 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, | 
 | 1926 | 		      "Intel D945P", STAC_D945GTP5), | 
| Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 1927 | 	/* other intel */ | 
 | 1928 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, | 
 | 1929 | 		      "Intel D945", STAC_D945_REF), | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1930 | 	/* other systems  */ | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1931 | 	/* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1932 | 	SND_PCI_QUIRK(0x8384, 0x7680, | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1933 | 		      "Mac", STAC_INTEL_MAC_AUTO), | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1934 | 	/* Dell systems  */ | 
 | 1935 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, | 
 | 1936 | 		      "unknown Dell", STAC_922X_DELL_D81), | 
 | 1937 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, | 
 | 1938 | 		      "unknown Dell", STAC_922X_DELL_D81), | 
 | 1939 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, | 
 | 1940 | 		      "unknown Dell", STAC_922X_DELL_D81), | 
 | 1941 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, | 
 | 1942 | 		      "unknown Dell", STAC_922X_DELL_D82), | 
 | 1943 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, | 
 | 1944 | 		      "unknown Dell", STAC_922X_DELL_M81), | 
 | 1945 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, | 
 | 1946 | 		      "unknown Dell", STAC_922X_DELL_D82), | 
 | 1947 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, | 
 | 1948 | 		      "unknown Dell", STAC_922X_DELL_D81), | 
 | 1949 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, | 
 | 1950 | 		      "unknown Dell", STAC_922X_DELL_D81), | 
 | 1951 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, | 
 | 1952 | 		      "Dell XPS M1210", STAC_922X_DELL_M82), | 
| Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1953 | 	/* ECS/PC Chips boards */ | 
| Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 1954 | 	SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, | 
| Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 1955 | 		      "ECS/PC chips", STAC_ECS_202), | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1956 | 	{} /* terminator */ | 
 | 1957 | }; | 
 | 1958 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1959 | static unsigned int ref927x_pin_configs[14] = { | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1960 | 	0x02214020, 0x02a19080, 0x0181304e, 0x01014010, | 
 | 1961 | 	0x01a19040, 0x01011012, 0x01016011, 0x0101201f,  | 
 | 1962 | 	0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, | 
 | 1963 | 	0x01c42190, 0x40000100, | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 1964 | }; | 
 | 1965 |  | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1966 | static unsigned int d965_3st_pin_configs[14] = { | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 1967 | 	0x0221401f, 0x02a19120, 0x40000100, 0x01014011, | 
 | 1968 | 	0x01a19021, 0x01813024, 0x40000100, 0x40000100, | 
 | 1969 | 	0x40000100, 0x40000100, 0x40000100, 0x40000100, | 
 | 1970 | 	0x40000100, 0x40000100 | 
 | 1971 | }; | 
 | 1972 |  | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1973 | static unsigned int d965_5st_pin_configs[14] = { | 
 | 1974 | 	0x02214020, 0x02a19080, 0x0181304e, 0x01014010, | 
 | 1975 | 	0x01a19040, 0x01011012, 0x01016011, 0x40000100, | 
 | 1976 | 	0x40000100, 0x40000100, 0x40000100, 0x01442070, | 
 | 1977 | 	0x40000100, 0x40000100 | 
 | 1978 | }; | 
 | 1979 |  | 
| Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 1980 | static unsigned int d965_5st_no_fp_pin_configs[14] = { | 
 | 1981 | 	0x40000100, 0x40000100, 0x0181304e, 0x01014010, | 
 | 1982 | 	0x01a19040, 0x01011012, 0x01016011, 0x40000100, | 
 | 1983 | 	0x40000100, 0x40000100, 0x40000100, 0x01442070, | 
 | 1984 | 	0x40000100, 0x40000100 | 
 | 1985 | }; | 
 | 1986 |  | 
| Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1987 | static unsigned int dell_3st_pin_configs[14] = { | 
 | 1988 | 	0x02211230, 0x02a11220, 0x01a19040, 0x01114210, | 
 | 1989 | 	0x01111212, 0x01116211, 0x01813050, 0x01112214, | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 1990 | 	0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, | 
| Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 1991 | 	0x40c003fc, 0x40000100 | 
 | 1992 | }; | 
 | 1993 |  | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 1994 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { | 
| Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 1995 | 	[STAC_D965_REF_NO_JD] = ref927x_pin_configs, | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 1996 | 	[STAC_D965_REF]  = ref927x_pin_configs, | 
 | 1997 | 	[STAC_D965_3ST]  = d965_3st_pin_configs, | 
 | 1998 | 	[STAC_D965_5ST]  = d965_5st_pin_configs, | 
| Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 1999 | 	[STAC_D965_5ST_NO_FP]  = d965_5st_no_fp_pin_configs, | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2000 | 	[STAC_DELL_3ST]  = dell_3st_pin_configs, | 
 | 2001 | 	[STAC_DELL_BIOS] = NULL, | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2002 | }; | 
 | 2003 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2004 | static const char *stac927x_models[STAC_927X_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2005 | 	[STAC_927X_AUTO]	= "auto", | 
| Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 2006 | 	[STAC_D965_REF_NO_JD]	= "ref-no-jd", | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2007 | 	[STAC_D965_REF]		= "ref", | 
 | 2008 | 	[STAC_D965_3ST]		= "3stack", | 
 | 2009 | 	[STAC_D965_5ST]		= "5stack", | 
| Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 2010 | 	[STAC_D965_5ST_NO_FP]	= "5stack-no-fp", | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2011 | 	[STAC_DELL_3ST]		= "dell-3stack", | 
 | 2012 | 	[STAC_DELL_BIOS]	= "dell-bios", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2013 | }; | 
 | 2014 |  | 
 | 2015 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { | 
 | 2016 | 	/* SigmaTel reference board */ | 
 | 2017 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
 | 2018 | 		      "DFI LanParty", STAC_D965_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2019 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 2020 | 		      "DFI LanParty", STAC_D965_REF), | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2021 | 	 /* Intel 946 based systems */ | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2022 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), | 
 | 2023 | 	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] | 2024 | 	/* 965 based 3 stack systems */ | 
| Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2025 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, | 
 | 2026 | 			   "Intel D965", STAC_D965_3ST), | 
 | 2027 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, | 
 | 2028 | 			   "Intel D965", STAC_D965_3ST), | 
| Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2029 | 	/* Dell 3 stack systems */ | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2030 | 	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] | 2031 | 	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] | 2032 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01ed, "Dell     ", STAC_DELL_3ST), | 
 | 2033 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f4, "Dell     ", STAC_DELL_3ST), | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2034 | 	/* Dell 3 stack systems with verb table in BIOS */ | 
| Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2035 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), | 
 | 2036 | 	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] | 2037 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022e, "Dell     ", STAC_DELL_BIOS), | 
| Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 2038 | 	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] | 2039 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0242, "Dell     ", STAC_DELL_BIOS), | 
 | 2040 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0243, "Dell     ", STAC_DELL_BIOS), | 
 | 2041 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x02ff, "Dell     ", STAC_DELL_BIOS), | 
 | 2042 | 	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] | 2043 | 	/* 965 based 5 stack systems */ | 
| Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2044 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, | 
 | 2045 | 			   "Intel D965", STAC_D965_5ST), | 
 | 2046 | 	SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, | 
 | 2047 | 			   "Intel D965", STAC_D965_5ST), | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2048 | 	{} /* terminator */ | 
 | 2049 | }; | 
 | 2050 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2051 | static unsigned int ref9205_pin_configs[12] = { | 
 | 2052 | 	0x40000100, 0x40000100, 0x01016011, 0x01014010, | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2053 | 	0x01813122, 0x01a19021, 0x01019020, 0x40000100, | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2054 | 	0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2055 | }; | 
 | 2056 |  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2057 | /* | 
 | 2058 |     STAC 9205 pin configs for | 
 | 2059 |     102801F1 | 
 | 2060 |     102801F2 | 
 | 2061 |     102801FC | 
 | 2062 |     102801FD | 
 | 2063 |     10280204 | 
 | 2064 |     1028021F | 
| Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2065 |     10280228 (Dell Vostro 1500) | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2066 | */ | 
 | 2067 | static unsigned int dell_9205_m42_pin_configs[12] = { | 
 | 2068 | 	0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, | 
 | 2069 | 	0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, | 
 | 2070 | 	0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, | 
 | 2071 | }; | 
 | 2072 |  | 
 | 2073 | /* | 
 | 2074 |     STAC 9205 pin configs for | 
 | 2075 |     102801F9 | 
 | 2076 |     102801FA | 
 | 2077 |     102801FE | 
 | 2078 |     102801FF (Dell Precision M4300) | 
 | 2079 |     10280206 | 
 | 2080 |     10280200 | 
 | 2081 |     10280201 | 
 | 2082 | */ | 
 | 2083 | static unsigned int dell_9205_m43_pin_configs[12] = { | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2084 | 	0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, | 
 | 2085 | 	0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, | 
 | 2086 | 	0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, | 
 | 2087 | }; | 
 | 2088 |  | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2089 | static unsigned int dell_9205_m44_pin_configs[12] = { | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2090 | 	0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, | 
 | 2091 | 	0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, | 
 | 2092 | 	0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, | 
 | 2093 | }; | 
 | 2094 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2095 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2096 | 	[STAC_9205_REF] = ref9205_pin_configs, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2097 | 	[STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, | 
 | 2098 | 	[STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, | 
 | 2099 | 	[STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2100 | 	[STAC_9205_EAPD] = NULL, | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2101 | }; | 
 | 2102 |  | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2103 | static const char *stac9205_models[STAC_9205_MODELS] = { | 
| Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2104 | 	[STAC_9205_AUTO] = "auto", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2105 | 	[STAC_9205_REF] = "ref", | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2106 | 	[STAC_9205_DELL_M42] = "dell-m42", | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2107 | 	[STAC_9205_DELL_M43] = "dell-m43", | 
 | 2108 | 	[STAC_9205_DELL_M44] = "dell-m44", | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2109 | 	[STAC_9205_EAPD] = "eapd", | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2110 | }; | 
 | 2111 |  | 
 | 2112 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { | 
 | 2113 | 	/* SigmaTel reference board */ | 
 | 2114 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 
 | 2115 | 		      "DFI LanParty", STAC_9205_REF), | 
| Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 2116 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, | 
 | 2117 | 		      "SigmaTel", STAC_9205_REF), | 
| Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2118 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, | 
 | 2119 | 		      "DFI LanParty", STAC_9205_REF), | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2120 | 	/* Dell */ | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2121 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, | 
 | 2122 | 		      "unknown Dell", STAC_9205_DELL_M42), | 
 | 2123 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, | 
 | 2124 | 		      "unknown Dell", STAC_9205_DELL_M42), | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2125 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, | 
| Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2126 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2127 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, | 
 | 2128 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
 | 2129 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, | 
 | 2130 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2131 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, | 
 | 2132 | 		      "unknown Dell", STAC_9205_DELL_M42), | 
 | 2133 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, | 
 | 2134 | 		      "unknown Dell", STAC_9205_DELL_M42), | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2135 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, | 
 | 2136 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
 | 2137 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2138 | 		      "Dell Precision M4300", STAC_9205_DELL_M43), | 
| Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2139 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, | 
 | 2140 | 		      "unknown Dell", STAC_9205_DELL_M42), | 
| Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2141 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, | 
 | 2142 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
 | 2143 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, | 
 | 2144 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
 | 2145 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, | 
 | 2146 | 		      "Dell Precision", STAC_9205_DELL_M43), | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2147 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, | 
 | 2148 | 		      "Dell Inspiron", STAC_9205_DELL_M44), | 
| Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2149 | 	SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, | 
 | 2150 | 		      "Dell Vostro 1500", STAC_9205_DELL_M42), | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2151 | 	/* Gateway */ | 
| Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 2152 | 	SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 2153 | 	SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2154 | 	{} /* terminator */ | 
 | 2155 | }; | 
 | 2156 |  | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2157 | static void stac92xx_set_config_regs(struct hda_codec *codec, | 
 | 2158 | 				     unsigned int *pincfgs) | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2159 | { | 
 | 2160 | 	int i; | 
 | 2161 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2162 |  | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2163 | 	if (!pincfgs) | 
 | 2164 | 		return; | 
| Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2165 |  | 
| Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2166 | 	for (i = 0; i < spec->num_pins; i++) | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2167 | 		if (spec->pin_nids[i] && pincfgs[i]) | 
 | 2168 | 			snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], | 
 | 2169 | 						 pincfgs[i]); | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2170 | } | 
 | 2171 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2172 | /* | 
 | 2173 |  * Analog playback callbacks | 
 | 2174 |  */ | 
 | 2175 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, | 
 | 2176 | 				      struct hda_codec *codec, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2177 | 				      struct snd_pcm_substream *substream) | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2178 | { | 
 | 2179 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2180 | 	if (spec->stream_delay) | 
 | 2181 | 		msleep(spec->stream_delay); | 
| Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2182 | 	return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, | 
 | 2183 | 					     hinfo); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2184 | } | 
 | 2185 |  | 
 | 2186 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 
 | 2187 | 					 struct hda_codec *codec, | 
 | 2188 | 					 unsigned int stream_tag, | 
 | 2189 | 					 unsigned int format, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2190 | 					 struct snd_pcm_substream *substream) | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2191 | { | 
 | 2192 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2193 | 	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] | 2194 | } | 
 | 2195 |  | 
 | 2196 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | 
 | 2197 | 					struct hda_codec *codec, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2198 | 					struct snd_pcm_substream *substream) | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2199 | { | 
 | 2200 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2201 | 	return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); | 
 | 2202 | } | 
 | 2203 |  | 
 | 2204 | /* | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2205 |  * Digital playback callbacks | 
 | 2206 |  */ | 
 | 2207 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, | 
 | 2208 | 					  struct hda_codec *codec, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2209 | 					  struct snd_pcm_substream *substream) | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2210 | { | 
 | 2211 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2212 | 	return snd_hda_multi_out_dig_open(codec, &spec->multiout); | 
 | 2213 | } | 
 | 2214 |  | 
 | 2215 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, | 
 | 2216 | 					   struct hda_codec *codec, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2217 | 					   struct snd_pcm_substream *substream) | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2218 | { | 
 | 2219 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2220 | 	return snd_hda_multi_out_dig_close(codec, &spec->multiout); | 
 | 2221 | } | 
 | 2222 |  | 
| Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2223 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, | 
 | 2224 | 					 struct hda_codec *codec, | 
 | 2225 | 					 unsigned int stream_tag, | 
 | 2226 | 					 unsigned int format, | 
 | 2227 | 					 struct snd_pcm_substream *substream) | 
 | 2228 | { | 
 | 2229 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2230 | 	return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, | 
 | 2231 | 					     stream_tag, format, substream); | 
 | 2232 | } | 
 | 2233 |  | 
| Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2234 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, | 
 | 2235 | 					struct hda_codec *codec, | 
 | 2236 | 					struct snd_pcm_substream *substream) | 
 | 2237 | { | 
 | 2238 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2239 | 	return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); | 
 | 2240 | } | 
 | 2241 |  | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2242 |  | 
 | 2243 | /* | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2244 |  * Analog capture callbacks | 
 | 2245 |  */ | 
 | 2246 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | 
 | 2247 | 					struct hda_codec *codec, | 
 | 2248 | 					unsigned int stream_tag, | 
 | 2249 | 					unsigned int format, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2250 | 					struct snd_pcm_substream *substream) | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2251 | { | 
 | 2252 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2253 | 	hda_nid_t nid = spec->adc_nids[substream->number]; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2254 |  | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2255 | 	if (spec->powerdown_adcs) { | 
 | 2256 | 		msleep(40); | 
| Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2257 | 		snd_hda_codec_write(codec, nid, 0, | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2258 | 			AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | 
 | 2259 | 	} | 
 | 2260 | 	snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2261 | 	return 0; | 
 | 2262 | } | 
 | 2263 |  | 
 | 2264 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | 
 | 2265 | 					struct hda_codec *codec, | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2266 | 					struct snd_pcm_substream *substream) | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2267 | { | 
 | 2268 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2269 | 	hda_nid_t nid = spec->adc_nids[substream->number]; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2270 |  | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2271 | 	snd_hda_codec_cleanup_stream(codec, nid); | 
 | 2272 | 	if (spec->powerdown_adcs) | 
| Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 2273 | 		snd_hda_codec_write(codec, nid, 0, | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2274 | 			AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2275 | 	return 0; | 
 | 2276 | } | 
 | 2277 |  | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2278 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { | 
 | 2279 | 	.substreams = 1, | 
 | 2280 | 	.channels_min = 2, | 
 | 2281 | 	.channels_max = 2, | 
 | 2282 | 	/* NID is set in stac92xx_build_pcms */ | 
 | 2283 | 	.ops = { | 
 | 2284 | 		.open = stac92xx_dig_playback_pcm_open, | 
| Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2285 | 		.close = stac92xx_dig_playback_pcm_close, | 
| Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 2286 | 		.prepare = stac92xx_dig_playback_pcm_prepare, | 
 | 2287 | 		.cleanup = stac92xx_dig_playback_pcm_cleanup | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2288 | 	}, | 
 | 2289 | }; | 
 | 2290 |  | 
 | 2291 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { | 
 | 2292 | 	.substreams = 1, | 
 | 2293 | 	.channels_min = 2, | 
 | 2294 | 	.channels_max = 2, | 
 | 2295 | 	/* NID is set in stac92xx_build_pcms */ | 
 | 2296 | }; | 
 | 2297 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2298 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { | 
 | 2299 | 	.substreams = 1, | 
 | 2300 | 	.channels_min = 2, | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2301 | 	.channels_max = 8, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2302 | 	.nid = 0x02, /* NID to query formats and rates */ | 
 | 2303 | 	.ops = { | 
 | 2304 | 		.open = stac92xx_playback_pcm_open, | 
 | 2305 | 		.prepare = stac92xx_playback_pcm_prepare, | 
 | 2306 | 		.cleanup = stac92xx_playback_pcm_cleanup | 
 | 2307 | 	}, | 
 | 2308 | }; | 
 | 2309 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2310 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { | 
 | 2311 | 	.substreams = 1, | 
 | 2312 | 	.channels_min = 2, | 
 | 2313 | 	.channels_max = 2, | 
 | 2314 | 	.nid = 0x06, /* NID to query formats and rates */ | 
 | 2315 | 	.ops = { | 
 | 2316 | 		.open = stac92xx_playback_pcm_open, | 
 | 2317 | 		.prepare = stac92xx_playback_pcm_prepare, | 
 | 2318 | 		.cleanup = stac92xx_playback_pcm_cleanup | 
 | 2319 | 	}, | 
 | 2320 | }; | 
 | 2321 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2322 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2323 | 	.channels_min = 2, | 
 | 2324 | 	.channels_max = 2, | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2325 | 	/* NID + .substreams is set in stac92xx_build_pcms */ | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2326 | 	.ops = { | 
 | 2327 | 		.prepare = stac92xx_capture_pcm_prepare, | 
 | 2328 | 		.cleanup = stac92xx_capture_pcm_cleanup | 
 | 2329 | 	}, | 
 | 2330 | }; | 
 | 2331 |  | 
 | 2332 | static int stac92xx_build_pcms(struct hda_codec *codec) | 
 | 2333 | { | 
 | 2334 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2335 | 	struct hda_pcm *info = spec->pcm_rec; | 
 | 2336 |  | 
 | 2337 | 	codec->num_pcms = 1; | 
 | 2338 | 	codec->pcm_info = info; | 
 | 2339 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2340 | 	info->name = "STAC92xx Analog"; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2341 | 	info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; | 
| Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 2342 | 	info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = | 
 | 2343 | 		spec->multiout.dac_nids[0]; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2344 | 	info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2345 | 	info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2346 | 	info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2347 |  | 
 | 2348 | 	if (spec->alt_switch) { | 
 | 2349 | 		codec->num_pcms++; | 
 | 2350 | 		info++; | 
 | 2351 | 		info->name = "STAC92xx Analog Alt"; | 
 | 2352 | 		info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; | 
 | 2353 | 	} | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2354 |  | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2355 | 	if (spec->multiout.dig_out_nid || spec->dig_in_nid) { | 
 | 2356 | 		codec->num_pcms++; | 
 | 2357 | 		info++; | 
 | 2358 | 		info->name = "STAC92xx Digital"; | 
| Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 2359 | 		info->pcm_type = spec->autocfg.dig_out_type[0]; | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2360 | 		if (spec->multiout.dig_out_nid) { | 
 | 2361 | 			info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; | 
 | 2362 | 			info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; | 
 | 2363 | 		} | 
 | 2364 | 		if (spec->dig_in_nid) { | 
 | 2365 | 			info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; | 
 | 2366 | 			info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; | 
 | 2367 | 		} | 
 | 2368 | 	} | 
 | 2369 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2370 | 	return 0; | 
 | 2371 | } | 
 | 2372 |  | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2373 | static unsigned int stac92xx_get_default_vref(struct hda_codec *codec, | 
 | 2374 | 					hda_nid_t nid) | 
| Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2375 | { | 
| Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2376 | 	unsigned int pincap = snd_hda_query_pin_caps(codec, nid); | 
| Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2377 | 	pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; | 
 | 2378 | 	if (pincap & AC_PINCAP_VREF_100) | 
 | 2379 | 		return AC_PINCTL_VREF_100; | 
 | 2380 | 	if (pincap & AC_PINCAP_VREF_80) | 
 | 2381 | 		return AC_PINCTL_VREF_80; | 
 | 2382 | 	if (pincap & AC_PINCAP_VREF_50) | 
 | 2383 | 		return AC_PINCTL_VREF_50; | 
 | 2384 | 	if (pincap & AC_PINCAP_VREF_GRD) | 
 | 2385 | 		return AC_PINCTL_VREF_GRD; | 
 | 2386 | 	return 0; | 
 | 2387 | } | 
 | 2388 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2389 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) | 
 | 2390 |  | 
 | 2391 | { | 
| Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2392 | 	snd_hda_codec_write_cache(codec, nid, 0, | 
 | 2393 | 				  AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2394 | } | 
 | 2395 |  | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2396 | #define stac92xx_hp_switch_info		snd_ctl_boolean_mono_info | 
 | 2397 |  | 
 | 2398 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, | 
 | 2399 | 			struct snd_ctl_elem_value *ucontrol) | 
 | 2400 | { | 
 | 2401 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2402 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2403 |  | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2404 | 	ucontrol->value.integer.value[0] = !!spec->hp_switch; | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2405 | 	return 0; | 
 | 2406 | } | 
 | 2407 |  | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2408 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid); | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2409 |  | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2410 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, | 
 | 2411 | 			struct snd_ctl_elem_value *ucontrol) | 
 | 2412 | { | 
 | 2413 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2414 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2415 | 	int nid = kcontrol->private_value; | 
 | 2416 |   | 
 | 2417 | 	spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2418 |  | 
 | 2419 | 	/* check to be sure that the ports are upto date with | 
 | 2420 | 	 * switch changes | 
 | 2421 | 	 */ | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2422 | 	stac_issue_unsol_event(codec, nid); | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2423 |  | 
 | 2424 | 	return 1; | 
 | 2425 | } | 
 | 2426 |  | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2427 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, | 
 | 2428 | 				struct snd_ctl_elem_info *uinfo) | 
 | 2429 | { | 
 | 2430 | 	int i; | 
 | 2431 | 	static char *texts[] = { | 
 | 2432 | 		"Mic In", "Line In", "Line Out" | 
 | 2433 | 	}; | 
 | 2434 |  | 
 | 2435 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2436 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2437 | 	hda_nid_t nid = kcontrol->private_value; | 
 | 2438 |  | 
 | 2439 | 	if (nid == spec->mic_switch || nid == spec->line_switch) | 
 | 2440 | 		i = 3; | 
 | 2441 | 	else | 
 | 2442 | 		i = 2; | 
 | 2443 |  | 
 | 2444 | 	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 
 | 2445 | 	uinfo->value.enumerated.items = i; | 
 | 2446 | 	uinfo->count = 1; | 
 | 2447 | 	if (uinfo->value.enumerated.item >= i) | 
 | 2448 | 		uinfo->value.enumerated.item = i-1; | 
 | 2449 | 	strcpy(uinfo->value.enumerated.name, | 
 | 2450 | 		texts[uinfo->value.enumerated.item]); | 
 | 2451 |  | 
 | 2452 | 	return 0; | 
 | 2453 | } | 
 | 2454 |  | 
 | 2455 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, | 
 | 2456 | 				struct snd_ctl_elem_value *ucontrol) | 
 | 2457 | { | 
 | 2458 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2459 | 	hda_nid_t nid = kcontrol->private_value; | 
 | 2460 | 	unsigned int vref = stac92xx_vref_get(codec, nid); | 
 | 2461 |  | 
 | 2462 | 	if (vref == stac92xx_get_default_vref(codec, nid)) | 
 | 2463 | 		ucontrol->value.enumerated.item[0] = 0; | 
 | 2464 | 	else if (vref == AC_PINCTL_VREF_GRD) | 
 | 2465 | 		ucontrol->value.enumerated.item[0] = 1; | 
 | 2466 | 	else if (vref == AC_PINCTL_VREF_HIZ) | 
 | 2467 | 		ucontrol->value.enumerated.item[0] = 2; | 
 | 2468 |  | 
 | 2469 | 	return 0; | 
 | 2470 | } | 
 | 2471 |  | 
 | 2472 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, | 
 | 2473 | 				struct snd_ctl_elem_value *ucontrol) | 
 | 2474 | { | 
 | 2475 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2476 | 	unsigned int new_vref = 0; | 
| Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 2477 | 	int error; | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2478 | 	hda_nid_t nid = kcontrol->private_value; | 
 | 2479 |  | 
 | 2480 | 	if (ucontrol->value.enumerated.item[0] == 0) | 
 | 2481 | 		new_vref = stac92xx_get_default_vref(codec, nid); | 
 | 2482 | 	else if (ucontrol->value.enumerated.item[0] == 1) | 
 | 2483 | 		new_vref = AC_PINCTL_VREF_GRD; | 
 | 2484 | 	else if (ucontrol->value.enumerated.item[0] == 2) | 
 | 2485 | 		new_vref = AC_PINCTL_VREF_HIZ; | 
 | 2486 | 	else | 
 | 2487 | 		return 0; | 
 | 2488 |  | 
 | 2489 | 	if (new_vref != stac92xx_vref_get(codec, nid)) { | 
 | 2490 | 		error = stac92xx_vref_set(codec, nid, new_vref); | 
 | 2491 | 		return error; | 
 | 2492 | 	} | 
 | 2493 |  | 
 | 2494 | 	return 0; | 
 | 2495 | } | 
 | 2496 |  | 
 | 2497 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, | 
 | 2498 | 				struct snd_ctl_elem_info *uinfo) | 
 | 2499 | { | 
 | 2500 | 	static char *texts[2]; | 
 | 2501 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2502 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2503 |  | 
 | 2504 | 	if (kcontrol->private_value == spec->line_switch) | 
 | 2505 | 		texts[0] = "Line In"; | 
 | 2506 | 	else | 
 | 2507 | 		texts[0] = "Mic In"; | 
 | 2508 | 	texts[1] = "Line Out"; | 
 | 2509 | 	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 
 | 2510 | 	uinfo->value.enumerated.items = 2; | 
 | 2511 | 	uinfo->count = 1; | 
 | 2512 |  | 
 | 2513 | 	if (uinfo->value.enumerated.item >= 2) | 
 | 2514 | 		uinfo->value.enumerated.item = 1; | 
 | 2515 | 	strcpy(uinfo->value.enumerated.name, | 
 | 2516 | 		texts[uinfo->value.enumerated.item]); | 
 | 2517 |  | 
 | 2518 | 	return 0; | 
 | 2519 | } | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2520 |  | 
 | 2521 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 
 | 2522 | { | 
 | 2523 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2524 | 	struct sigmatel_spec *spec = codec->spec; | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2525 | 	hda_nid_t nid = kcontrol->private_value; | 
 | 2526 | 	int io_idx = (nid == spec->mic_switch) ? 1 : 0; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2527 |  | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2528 | 	ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2529 | 	return 0; | 
 | 2530 | } | 
 | 2531 |  | 
 | 2532 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 
 | 2533 | { | 
 | 2534 |         struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2535 | 	struct sigmatel_spec *spec = codec->spec; | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2536 | 	hda_nid_t nid = kcontrol->private_value; | 
 | 2537 | 	int io_idx = (nid == spec->mic_switch) ? 1 : 0; | 
 | 2538 | 	unsigned short val = !!ucontrol->value.enumerated.item[0]; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2539 |  | 
 | 2540 | 	spec->io_switch[io_idx] = val; | 
 | 2541 |  | 
 | 2542 | 	if (val) | 
 | 2543 | 		stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | 
| Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2544 | 	else { | 
 | 2545 | 		unsigned int pinctl = AC_PINCTL_IN_EN; | 
 | 2546 | 		if (io_idx) /* set VREF for mic */ | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2547 | 			pinctl |= stac92xx_get_default_vref(codec, nid); | 
| Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2548 | 		stac92xx_auto_set_pinctl(codec, nid, pinctl); | 
 | 2549 | 	} | 
| Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2550 |  | 
 | 2551 | 	/* check the auto-mute again: we need to mute/unmute the speaker | 
 | 2552 | 	 * appropriately according to the pin direction | 
 | 2553 | 	 */ | 
 | 2554 | 	if (spec->hp_detect) | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 2555 | 		stac_issue_unsol_event(codec, nid); | 
| Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2556 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2557 |         return 1; | 
 | 2558 | } | 
 | 2559 |  | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2560 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info | 
 | 2561 |  | 
 | 2562 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, | 
 | 2563 | 		struct snd_ctl_elem_value *ucontrol) | 
 | 2564 | { | 
 | 2565 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2566 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2567 |  | 
 | 2568 | 	ucontrol->value.integer.value[0] = spec->clfe_swap; | 
 | 2569 | 	return 0; | 
 | 2570 | } | 
 | 2571 |  | 
 | 2572 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, | 
 | 2573 | 		struct snd_ctl_elem_value *ucontrol) | 
 | 2574 | { | 
 | 2575 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 2576 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2577 | 	hda_nid_t nid = kcontrol->private_value & 0xff; | 
| Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2578 | 	unsigned int val = !!ucontrol->value.integer.value[0]; | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2579 |  | 
| Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2580 | 	if (spec->clfe_swap == val) | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2581 | 		return 0; | 
 | 2582 |  | 
| Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2583 | 	spec->clfe_swap = val; | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2584 |  | 
 | 2585 | 	snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, | 
 | 2586 | 		spec->clfe_swap ? 0x4 : 0x0); | 
 | 2587 |  | 
 | 2588 | 	return 1; | 
 | 2589 | } | 
 | 2590 |  | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2591 | #define STAC_CODEC_HP_SWITCH(xname) \ | 
 | 2592 | 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 
 | 2593 | 	  .name = xname, \ | 
 | 2594 | 	  .index = 0, \ | 
 | 2595 | 	  .info = stac92xx_hp_switch_info, \ | 
 | 2596 | 	  .get = stac92xx_hp_switch_get, \ | 
 | 2597 | 	  .put = stac92xx_hp_switch_put, \ | 
 | 2598 | 	} | 
 | 2599 |  | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2600 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ | 
 | 2601 | 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 
 | 2602 | 	  .name = xname, \ | 
 | 2603 | 	  .index = 0, \ | 
 | 2604 |           .info = stac92xx_io_switch_info, \ | 
 | 2605 |           .get = stac92xx_io_switch_get, \ | 
 | 2606 |           .put = stac92xx_io_switch_put, \ | 
 | 2607 |           .private_value = xpval, \ | 
 | 2608 | 	} | 
 | 2609 |  | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2610 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ | 
 | 2611 | 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 
 | 2612 | 	  .name = xname, \ | 
 | 2613 | 	  .index = 0, \ | 
 | 2614 | 	  .info = stac92xx_clfe_switch_info, \ | 
 | 2615 | 	  .get = stac92xx_clfe_switch_get, \ | 
 | 2616 | 	  .put = stac92xx_clfe_switch_put, \ | 
 | 2617 | 	  .private_value = xpval, \ | 
 | 2618 | 	} | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2619 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2620 | enum { | 
 | 2621 | 	STAC_CTL_WIDGET_VOL, | 
 | 2622 | 	STAC_CTL_WIDGET_MUTE, | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2623 | 	STAC_CTL_WIDGET_MONO_MUX, | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2624 | 	STAC_CTL_WIDGET_HP_SWITCH, | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2625 | 	STAC_CTL_WIDGET_IO_SWITCH, | 
| Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2626 | 	STAC_CTL_WIDGET_CLFE_SWITCH, | 
 | 2627 | 	STAC_CTL_WIDGET_DC_BIAS | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2628 | }; | 
 | 2629 |  | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2630 | static struct snd_kcontrol_new stac92xx_control_templates[] = { | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2631 | 	HDA_CODEC_VOLUME(NULL, 0, 0, 0), | 
 | 2632 | 	HDA_CODEC_MUTE(NULL, 0, 0, 0), | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2633 | 	STAC_MONO_MUX, | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2634 | 	STAC_CODEC_HP_SWITCH(NULL), | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2635 | 	STAC_CODEC_IO_SWITCH(NULL, 0), | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2636 | 	STAC_CODEC_CLFE_SWITCH(NULL, 0), | 
| Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 2637 | 	DC_BIAS(NULL, 0, 0), | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2638 | }; | 
 | 2639 |  | 
 | 2640 | /* add dynamic controls */ | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2641 | static struct snd_kcontrol_new * | 
 | 2642 | stac_control_new(struct sigmatel_spec *spec, | 
 | 2643 | 		 struct snd_kcontrol_new *ktemp, | 
 | 2644 | 		 const char *name) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2645 | { | 
| Takashi Iwai | c8b6bf9b | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2646 | 	struct snd_kcontrol_new *knew; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2647 |  | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2648 | 	snd_array_init(&spec->kctls, sizeof(*knew), 32); | 
 | 2649 | 	knew = snd_array_new(&spec->kctls); | 
 | 2650 | 	if (!knew) | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2651 | 		return NULL; | 
| Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2652 | 	*knew = *ktemp; | 
| Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2653 | 	knew->name = kstrdup(name, GFP_KERNEL); | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2654 | 	if (!knew->name) { | 
 | 2655 | 		/* roolback */ | 
 | 2656 | 		memset(knew, 0, sizeof(*knew)); | 
 | 2657 | 		spec->kctls.alloced--; | 
 | 2658 | 		return NULL; | 
 | 2659 | 	} | 
 | 2660 | 	return knew; | 
 | 2661 | } | 
 | 2662 |  | 
 | 2663 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, | 
 | 2664 | 				     struct snd_kcontrol_new *ktemp, | 
 | 2665 | 				     int idx, const char *name, | 
 | 2666 | 				     unsigned long val) | 
 | 2667 | { | 
 | 2668 | 	struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name); | 
 | 2669 | 	if (!knew) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2670 | 		return -ENOMEM; | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2671 | 	knew->index = idx; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2672 | 	knew->private_value = val; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2673 | 	return 0; | 
 | 2674 | } | 
 | 2675 |  | 
| Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2676 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, | 
 | 2677 | 					   int type, int idx, const char *name, | 
 | 2678 | 					   unsigned long val) | 
 | 2679 | { | 
 | 2680 | 	return stac92xx_add_control_temp(spec, | 
 | 2681 | 					 &stac92xx_control_templates[type], | 
 | 2682 | 					 idx, name, val); | 
 | 2683 | } | 
 | 2684 |  | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2685 |  | 
 | 2686 | /* add dynamic controls */ | 
| Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2687 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, | 
 | 2688 | 				       const char *name, unsigned long val) | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2689 | { | 
 | 2690 | 	return stac92xx_add_control_idx(spec, type, 0, name, val); | 
 | 2691 | } | 
 | 2692 |  | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2693 | static struct snd_kcontrol_new stac_input_src_temp = { | 
 | 2694 | 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 
 | 2695 | 	.name = "Input Source", | 
 | 2696 | 	.info = stac92xx_mux_enum_info, | 
 | 2697 | 	.get = stac92xx_mux_enum_get, | 
 | 2698 | 	.put = stac92xx_mux_enum_put, | 
 | 2699 | }; | 
 | 2700 |  | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 2701 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, | 
 | 2702 | 						hda_nid_t nid, int idx) | 
 | 2703 | { | 
 | 2704 | 	int def_conf = snd_hda_codec_get_pincfg(codec, nid); | 
 | 2705 | 	int control = 0; | 
 | 2706 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2707 | 	char name[22]; | 
 | 2708 |  | 
 | 2709 | 	if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { | 
 | 2710 | 		if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD | 
 | 2711 | 			&& nid == spec->line_switch) | 
 | 2712 | 			control = STAC_CTL_WIDGET_IO_SWITCH; | 
 | 2713 | 		else if (snd_hda_query_pin_caps(codec, nid) | 
 | 2714 | 			& (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) | 
 | 2715 | 			control = STAC_CTL_WIDGET_DC_BIAS; | 
 | 2716 | 		else if (nid == spec->mic_switch) | 
 | 2717 | 			control = STAC_CTL_WIDGET_IO_SWITCH; | 
 | 2718 | 	} | 
 | 2719 |  | 
 | 2720 | 	if (control) { | 
 | 2721 | 		strcpy(name, auto_pin_cfg_labels[idx]); | 
 | 2722 | 		return stac92xx_add_control(codec->spec, control, | 
 | 2723 | 					strcat(name, " Jack Mode"), nid); | 
 | 2724 | 	} | 
 | 2725 |  | 
 | 2726 | 	return 0; | 
 | 2727 | } | 
 | 2728 |  | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2729 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) | 
 | 2730 | { | 
 | 2731 | 	struct snd_kcontrol_new *knew; | 
 | 2732 | 	struct hda_input_mux *imux = &spec->private_imux; | 
 | 2733 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 2734 | 	if (spec->auto_mic) | 
 | 2735 | 		return 0; /* no need for input source */ | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 2736 | 	if (!spec->num_adcs || imux->num_items <= 1) | 
 | 2737 | 		return 0; /* no need for input source control */ | 
 | 2738 | 	knew = stac_control_new(spec, &stac_input_src_temp, | 
 | 2739 | 				stac_input_src_temp.name); | 
 | 2740 | 	if (!knew) | 
 | 2741 | 		return -ENOMEM; | 
 | 2742 | 	knew->count = spec->num_adcs; | 
 | 2743 | 	return 0; | 
 | 2744 | } | 
 | 2745 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2746 | /* check whether the line-input can be used as line-out */ | 
 | 2747 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2748 | { | 
 | 2749 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2750 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 2751 | 	hda_nid_t nid; | 
 | 2752 | 	unsigned int pincap; | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2753 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2754 | 	if (cfg->line_out_type != AUTO_PIN_LINE_OUT) | 
 | 2755 | 		return 0; | 
 | 2756 | 	nid = cfg->input_pins[AUTO_PIN_LINE]; | 
| Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2757 | 	pincap = snd_hda_query_pin_caps(codec, nid); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2758 | 	if (pincap & AC_PINCAP_OUT) | 
 | 2759 | 		return nid; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2760 | 	return 0; | 
 | 2761 | } | 
 | 2762 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2763 | /* check whether the mic-input can be used as line-out */ | 
 | 2764 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) | 
 | 2765 | { | 
 | 2766 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2767 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 2768 | 	unsigned int def_conf, pincap; | 
 | 2769 | 	unsigned int mic_pin; | 
 | 2770 |  | 
 | 2771 | 	if (cfg->line_out_type != AUTO_PIN_LINE_OUT) | 
 | 2772 | 		return 0; | 
 | 2773 | 	mic_pin = AUTO_PIN_MIC; | 
 | 2774 | 	for (;;) { | 
 | 2775 | 		hda_nid_t nid = cfg->input_pins[mic_pin]; | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 2776 | 		def_conf = snd_hda_codec_get_pincfg(codec, nid); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2777 | 		/* some laptops have an internal analog microphone | 
 | 2778 | 		 * which can't be used as a output */ | 
 | 2779 | 		if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { | 
| Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 2780 | 			pincap = snd_hda_query_pin_caps(codec, nid); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2781 | 			if (pincap & AC_PINCAP_OUT) | 
 | 2782 | 				return nid; | 
 | 2783 | 		} | 
 | 2784 | 		if (mic_pin == AUTO_PIN_MIC) | 
 | 2785 | 			mic_pin = AUTO_PIN_FRONT_MIC; | 
 | 2786 | 		else | 
 | 2787 | 			break; | 
 | 2788 | 	} | 
 | 2789 | 	return 0; | 
 | 2790 | } | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2791 |  | 
 | 2792 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | 
 | 2793 | { | 
 | 2794 | 	int i; | 
 | 2795 | 	 | 
 | 2796 | 	for (i = 0; i < spec->multiout.num_dacs; i++) { | 
 | 2797 | 		if (spec->multiout.dac_nids[i] == nid) | 
 | 2798 | 			return 1; | 
 | 2799 | 	} | 
 | 2800 |  | 
 | 2801 | 	return 0; | 
 | 2802 | } | 
 | 2803 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2804 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | 
 | 2805 | { | 
 | 2806 | 	int i; | 
 | 2807 | 	if (is_in_dac_nids(spec, nid)) | 
 | 2808 | 		return 1; | 
 | 2809 | 	for (i = 0; i < spec->autocfg.hp_outs; i++) | 
 | 2810 | 		if (spec->hp_dacs[i] == nid) | 
 | 2811 | 			return 1; | 
 | 2812 | 	for (i = 0; i < spec->autocfg.speaker_outs; i++) | 
 | 2813 | 		if (spec->speaker_dacs[i] == nid) | 
 | 2814 | 			return 1; | 
 | 2815 | 	return 0; | 
 | 2816 | } | 
 | 2817 |  | 
 | 2818 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | 
 | 2819 | { | 
 | 2820 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 2821 | 	int j, conn_len; | 
 | 2822 | 	hda_nid_t conn[HDA_MAX_CONNECTIONS]; | 
 | 2823 | 	unsigned int wcaps, wtype; | 
 | 2824 |  | 
 | 2825 | 	conn_len = snd_hda_get_connections(codec, nid, conn, | 
 | 2826 | 					   HDA_MAX_CONNECTIONS); | 
 | 2827 | 	for (j = 0; j < conn_len; j++) { | 
| Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 2828 | 		wcaps = get_wcaps(codec, conn[j]); | 
| Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 2829 | 		wtype = get_wcaps_type(wcaps); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2830 | 		/* we check only analog outputs */ | 
 | 2831 | 		if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) | 
 | 2832 | 			continue; | 
 | 2833 | 		/* if this route has a free DAC, assign it */ | 
 | 2834 | 		if (!check_all_dac_nids(spec, conn[j])) { | 
 | 2835 | 			if (conn_len > 1) { | 
 | 2836 | 				/* select this DAC in the pin's input mux */ | 
 | 2837 | 				snd_hda_codec_write_cache(codec, nid, 0, | 
 | 2838 | 						  AC_VERB_SET_CONNECT_SEL, j); | 
 | 2839 | 			} | 
 | 2840 | 			return conn[j]; | 
 | 2841 | 		} | 
 | 2842 | 	} | 
| Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 2843 | 	/* if all DACs are already assigned, connect to the primary DAC */ | 
 | 2844 | 	if (conn_len > 1) { | 
 | 2845 | 		for (j = 0; j < conn_len; j++) { | 
 | 2846 | 			if (conn[j] == spec->multiout.dac_nids[0]) { | 
 | 2847 | 				snd_hda_codec_write_cache(codec, nid, 0, | 
 | 2848 | 						  AC_VERB_SET_CONNECT_SEL, j); | 
 | 2849 | 				break; | 
 | 2850 | 			} | 
 | 2851 | 		} | 
 | 2852 | 	} | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2853 | 	return 0; | 
 | 2854 | } | 
 | 2855 |  | 
 | 2856 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | 
 | 2857 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | 
 | 2858 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2859 | /* | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2860 |  * Fill in the dac_nids table from the parsed pin configuration | 
 | 2861 |  * This function only works when every pin in line_out_pins[] | 
 | 2862 |  * contains atleast one DAC in its connection list. Some 92xx | 
 | 2863 |  * codecs are not connected directly to a DAC, such as the 9200 | 
 | 2864 |  * and 9202/925x. For those, dac_nids[] must be hard-coded. | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2865 |  */ | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2866 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2867 | { | 
 | 2868 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2869 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 2870 | 	int i; | 
 | 2871 | 	hda_nid_t nid, dac; | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2872 | 	 | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2873 | 	for (i = 0; i < cfg->line_outs; i++) { | 
 | 2874 | 		nid = cfg->line_out_pins[i]; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2875 | 		dac = get_unassigned_dac(codec, nid); | 
 | 2876 | 		if (!dac) { | 
| Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2877 | 			if (spec->multiout.num_dacs > 0) { | 
 | 2878 | 				/* we have already working output pins, | 
 | 2879 | 				 * so let's drop the broken ones again | 
 | 2880 | 				 */ | 
 | 2881 | 				cfg->line_outs = spec->multiout.num_dacs; | 
 | 2882 | 				break; | 
 | 2883 | 			} | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2884 | 			/* error out, no available DAC found */ | 
 | 2885 | 			snd_printk(KERN_ERR | 
 | 2886 | 				   "%s: No available DAC for pin 0x%x\n", | 
 | 2887 | 				   __func__, nid); | 
 | 2888 | 			return -ENODEV; | 
 | 2889 | 		} | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2890 | 		add_spec_dacs(spec, dac); | 
 | 2891 | 	} | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2892 |  | 
| Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 2893 | 	for (i = 0; i < cfg->hp_outs; i++) { | 
 | 2894 | 		nid = cfg->hp_pins[i]; | 
 | 2895 | 		dac = get_unassigned_dac(codec, nid); | 
 | 2896 | 		if (dac) { | 
 | 2897 | 			if (!spec->multiout.hp_nid) | 
 | 2898 | 				spec->multiout.hp_nid = dac; | 
 | 2899 | 			else | 
 | 2900 | 				add_spec_extra_dacs(spec, dac); | 
 | 2901 | 		} | 
 | 2902 | 		spec->hp_dacs[i] = dac; | 
 | 2903 | 	} | 
 | 2904 |  | 
 | 2905 | 	for (i = 0; i < cfg->speaker_outs; i++) { | 
 | 2906 | 		nid = cfg->speaker_pins[i]; | 
 | 2907 | 		dac = get_unassigned_dac(codec, nid); | 
 | 2908 | 		if (dac) | 
 | 2909 | 			add_spec_extra_dacs(spec, dac); | 
 | 2910 | 		spec->speaker_dacs[i] = dac; | 
 | 2911 | 	} | 
 | 2912 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2913 | 	/* add line-in as output */ | 
 | 2914 | 	nid = check_line_out_switch(codec); | 
 | 2915 | 	if (nid) { | 
 | 2916 | 		dac = get_unassigned_dac(codec, nid); | 
 | 2917 | 		if (dac) { | 
 | 2918 | 			snd_printdd("STAC: Add line-in 0x%x as output %d\n", | 
 | 2919 | 				    nid, cfg->line_outs); | 
 | 2920 | 			cfg->line_out_pins[cfg->line_outs] = nid; | 
 | 2921 | 			cfg->line_outs++; | 
 | 2922 | 			spec->line_switch = nid; | 
 | 2923 | 			add_spec_dacs(spec, dac); | 
 | 2924 | 		} | 
 | 2925 | 	} | 
 | 2926 | 	/* add mic as output */ | 
 | 2927 | 	nid = check_mic_out_switch(codec); | 
 | 2928 | 	if (nid) { | 
 | 2929 | 		dac = get_unassigned_dac(codec, nid); | 
 | 2930 | 		if (dac) { | 
 | 2931 | 			snd_printdd("STAC: Add mic-in 0x%x as output %d\n", | 
 | 2932 | 				    nid, cfg->line_outs); | 
 | 2933 | 			cfg->line_out_pins[cfg->line_outs] = nid; | 
 | 2934 | 			cfg->line_outs++; | 
 | 2935 | 			spec->mic_switch = nid; | 
 | 2936 | 			add_spec_dacs(spec, dac); | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2937 | 		} | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2938 | 	} | 
 | 2939 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2940 | 	snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2941 | 		   spec->multiout.num_dacs, | 
 | 2942 | 		   spec->multiout.dac_nids[0], | 
 | 2943 | 		   spec->multiout.dac_nids[1], | 
 | 2944 | 		   spec->multiout.dac_nids[2], | 
 | 2945 | 		   spec->multiout.dac_nids[3], | 
 | 2946 | 		   spec->multiout.dac_nids[4]); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2947 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2948 | 	return 0; | 
 | 2949 | } | 
 | 2950 |  | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2951 | /* create volume control/switch for the given prefx type */ | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 2952 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, | 
 | 2953 | 			       int idx, hda_nid_t nid, int chs) | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2954 | { | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2955 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2956 | 	char name[32]; | 
 | 2957 | 	int err; | 
 | 2958 |  | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2959 | 	if (!spec->check_volume_offset) { | 
 | 2960 | 		unsigned int caps, step, nums, db_scale; | 
 | 2961 | 		caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 
 | 2962 | 		step = (caps & AC_AMPCAP_STEP_SIZE) >> | 
 | 2963 | 			AC_AMPCAP_STEP_SIZE_SHIFT; | 
 | 2964 | 		step = (step + 1) * 25; /* in .01dB unit */ | 
 | 2965 | 		nums = (caps & AC_AMPCAP_NUM_STEPS) >> | 
 | 2966 | 			AC_AMPCAP_NUM_STEPS_SHIFT; | 
 | 2967 | 		db_scale = nums * step; | 
 | 2968 | 		/* if dB scale is over -64dB, and finer enough, | 
 | 2969 | 		 * let's reduce it to half | 
 | 2970 | 		 */ | 
 | 2971 | 		if (db_scale > 6400 && nums >= 0x1f) | 
 | 2972 | 			spec->volume_offset = nums / 2; | 
 | 2973 | 		spec->check_volume_offset = 1; | 
 | 2974 | 	} | 
 | 2975 |  | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2976 | 	sprintf(name, "%s Playback Volume", pfx); | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 2977 | 	err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 2978 | 		HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, | 
 | 2979 | 					spec->volume_offset)); | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2980 | 	if (err < 0) | 
 | 2981 | 		return err; | 
 | 2982 | 	sprintf(name, "%s Playback Switch", pfx); | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 2983 | 	err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2984 | 				   HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); | 
 | 2985 | 	if (err < 0) | 
 | 2986 | 		return err; | 
 | 2987 | 	return 0; | 
 | 2988 | } | 
 | 2989 |  | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 2990 | #define create_controls(codec, pfx, nid, chs) \ | 
 | 2991 | 	create_controls_idx(codec, pfx, 0, nid, chs) | 
 | 2992 |  | 
| Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2993 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) | 
 | 2994 | { | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 2995 | 	if (spec->multiout.num_dacs > 4) { | 
| Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2996 | 		printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); | 
 | 2997 | 		return 1; | 
 | 2998 | 	} else { | 
 | 2999 | 		spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; | 
 | 3000 | 		spec->multiout.num_dacs++; | 
 | 3001 | 	} | 
 | 3002 | 	return 0; | 
 | 3003 | } | 
 | 3004 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3005 | 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] | 3006 | { | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3007 | 	int i; | 
 | 3008 | 	for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { | 
 | 3009 | 		if (!spec->multiout.extra_out_nid[i]) { | 
 | 3010 | 			spec->multiout.extra_out_nid[i] = nid; | 
 | 3011 | 			return 0; | 
 | 3012 | 		} | 
 | 3013 | 	} | 
 | 3014 | 	printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); | 
 | 3015 | 	return 1; | 
| Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3016 | } | 
 | 3017 |  | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3018 | /* Create output controls | 
 | 3019 |  * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) | 
 | 3020 |  */ | 
 | 3021 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, | 
 | 3022 | 				 const hda_nid_t *pins, | 
 | 3023 | 				 const hda_nid_t *dac_nids, | 
 | 3024 | 				 int type) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3025 | { | 
| Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3026 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3027 | 	static const char *chname[4] = { | 
 | 3028 | 		"Front", "Surround", NULL /*CLFE*/, "Side" | 
 | 3029 | 	}; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3030 | 	hda_nid_t nid; | 
| Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 3031 | 	int i, err; | 
 | 3032 | 	unsigned int wid_caps; | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3033 |  | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3034 | 	for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { | 
| Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 3035 | 		if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { | 
 | 3036 | 			wid_caps = get_wcaps(codec, pins[i]); | 
 | 3037 | 			if (wid_caps & AC_WCAP_UNSOL_CAP) | 
 | 3038 | 				spec->hp_detect = 1; | 
 | 3039 | 		} | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3040 | 		nid = dac_nids[i]; | 
 | 3041 | 		if (!nid) | 
 | 3042 | 			continue; | 
 | 3043 | 		if (type != AUTO_PIN_HP_OUT && i == 2) { | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3044 | 			/* Center/LFE */ | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3045 | 			err = create_controls(codec, "Center", nid, 1); | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3046 | 			if (err < 0) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3047 | 				return err; | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3048 | 			err = create_controls(codec, "LFE", nid, 2); | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3049 | 			if (err < 0) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3050 | 				return err; | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3051 |  | 
 | 3052 | 			wid_caps = get_wcaps(codec, nid); | 
 | 3053 |  | 
 | 3054 | 			if (wid_caps & AC_WCAP_LR_SWAP) { | 
 | 3055 | 				err = stac92xx_add_control(spec, | 
 | 3056 | 					STAC_CTL_WIDGET_CLFE_SWITCH, | 
 | 3057 | 					"Swap Center/LFE Playback Switch", nid); | 
 | 3058 |  | 
 | 3059 | 				if (err < 0) | 
 | 3060 | 					return err; | 
 | 3061 | 			} | 
 | 3062 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3063 | 		} else { | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3064 | 			const char *name; | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3065 | 			int idx; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3066 | 			switch (type) { | 
 | 3067 | 			case AUTO_PIN_HP_OUT: | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3068 | 				name = "Headphone"; | 
 | 3069 | 				idx = i; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3070 | 				break; | 
 | 3071 | 			case AUTO_PIN_SPEAKER_OUT: | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3072 | 				name = "Speaker"; | 
 | 3073 | 				idx = i; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3074 | 				break; | 
 | 3075 | 			default: | 
 | 3076 | 				name = chname[i]; | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3077 | 				idx = 0; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3078 | 				break; | 
| Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 3079 | 			} | 
| Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 3080 | 			err = create_controls_idx(codec, name, idx, nid, 3); | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3081 | 			if (err < 0) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3082 | 				return err; | 
 | 3083 | 		} | 
 | 3084 | 	} | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3085 | 	return 0; | 
 | 3086 | } | 
 | 3087 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3088 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, | 
 | 3089 | 				    unsigned long sw, int idx) | 
 | 3090 | { | 
 | 3091 | 	int err; | 
 | 3092 | 	err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, | 
| Takashi Iwai | bf677bd | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 3093 | 				       "Capture Volume", vol); | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3094 | 	if (err < 0) | 
 | 3095 | 		return err; | 
 | 3096 | 	err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx, | 
| Takashi Iwai | bf677bd | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 3097 | 				       "Capture Switch", sw); | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3098 | 	if (err < 0) | 
 | 3099 | 		return err; | 
 | 3100 | 	return 0; | 
 | 3101 | } | 
 | 3102 |  | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3103 | /* add playback controls from the parsed DAC table */ | 
 | 3104 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | 
 | 3105 | 					       const struct auto_pin_cfg *cfg) | 
 | 3106 | { | 
 | 3107 | 	struct sigmatel_spec *spec = codec->spec; | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3108 | 	hda_nid_t nid; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3109 | 	int err; | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3110 | 	int idx; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3111 |  | 
 | 3112 | 	err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, | 
 | 3113 | 				    spec->multiout.dac_nids, | 
 | 3114 | 				    cfg->line_out_type); | 
 | 3115 | 	if (err < 0) | 
 | 3116 | 		return err; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3117 |  | 
| Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3118 | 	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] | 3119 | 		err = stac92xx_add_control(spec, | 
 | 3120 | 			STAC_CTL_WIDGET_HP_SWITCH, | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3121 | 			"Headphone as Line Out Switch", | 
 | 3122 | 			cfg->hp_pins[cfg->hp_outs - 1]); | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3123 | 		if (err < 0) | 
 | 3124 | 			return err; | 
 | 3125 | 	} | 
 | 3126 |  | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3127 | 	for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { | 
 | 3128 | 		nid = cfg->input_pins[idx]; | 
 | 3129 | 		if (nid) { | 
 | 3130 | 			err = stac92xx_add_jack_mode_control(codec, nid, idx); | 
 | 3131 | 			if (err < 0) | 
 | 3132 | 				return err; | 
 | 3133 | 		} | 
| Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3134 | 	} | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3135 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3136 | 	return 0; | 
 | 3137 | } | 
 | 3138 |  | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3139 | /* add playback controls for Speaker and HP outputs */ | 
 | 3140 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, | 
 | 3141 | 					struct auto_pin_cfg *cfg) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3142 | { | 
 | 3143 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3144 | 	int err; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3145 |  | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3146 | 	err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, | 
 | 3147 | 				    spec->hp_dacs, AUTO_PIN_HP_OUT); | 
 | 3148 | 	if (err < 0) | 
 | 3149 | 		return err; | 
 | 3150 |  | 
 | 3151 | 	err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, | 
 | 3152 | 				    spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); | 
 | 3153 | 	if (err < 0) | 
 | 3154 | 		return err; | 
 | 3155 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3156 | 	return 0; | 
 | 3157 | } | 
 | 3158 |  | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3159 | /* labels for mono mux outputs */ | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3160 | static const char *stac92xx_mono_labels[4] = { | 
 | 3161 | 	"DAC0", "DAC1", "Mixer", "DAC2" | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3162 | }; | 
 | 3163 |  | 
 | 3164 | /* create mono mux for mono out on capable codecs */ | 
 | 3165 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) | 
 | 3166 | { | 
 | 3167 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3168 | 	struct hda_input_mux *mono_mux = &spec->private_mono_mux; | 
 | 3169 | 	int i, num_cons; | 
 | 3170 | 	hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; | 
 | 3171 |  | 
 | 3172 | 	num_cons = snd_hda_get_connections(codec, | 
 | 3173 | 				spec->mono_nid, | 
 | 3174 | 				con_lst, | 
 | 3175 | 				HDA_MAX_NUM_INPUTS); | 
| Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3176 | 	if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3177 | 		return -EINVAL; | 
 | 3178 |  | 
 | 3179 | 	for (i = 0; i < num_cons; i++) { | 
 | 3180 | 		mono_mux->items[mono_mux->num_items].label = | 
 | 3181 | 					stac92xx_mono_labels[i]; | 
 | 3182 | 		mono_mux->items[mono_mux->num_items].index = i; | 
 | 3183 | 		mono_mux->num_items++; | 
 | 3184 | 	} | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3185 |  | 
 | 3186 | 	return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, | 
 | 3187 | 				"Mono Mux", spec->mono_nid); | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3188 | } | 
 | 3189 |  | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3190 | /* create PC beep volume controls */ | 
 | 3191 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, | 
 | 3192 | 						hda_nid_t nid) | 
 | 3193 | { | 
 | 3194 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3195 | 	u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 
 | 3196 | 	int err; | 
 | 3197 |  | 
 | 3198 | 	/* check for mute support for the the amp */ | 
 | 3199 | 	if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { | 
 | 3200 | 		err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, | 
 | 3201 | 			"PC Beep Playback Switch", | 
 | 3202 | 			HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | 
 | 3203 | 			if (err < 0) | 
 | 3204 | 				return err; | 
 | 3205 | 	} | 
 | 3206 |  | 
 | 3207 | 	/* check to see if there is volume support for the amp */ | 
 | 3208 | 	if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { | 
 | 3209 | 		err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, | 
 | 3210 | 			"PC Beep Playback Volume", | 
 | 3211 | 			HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); | 
 | 3212 | 			if (err < 0) | 
 | 3213 | 				return err; | 
 | 3214 | 	} | 
 | 3215 | 	return 0; | 
 | 3216 | } | 
 | 3217 |  | 
| Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3218 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 
 | 3219 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info | 
 | 3220 |  | 
 | 3221 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, | 
 | 3222 | 					struct snd_ctl_elem_value *ucontrol) | 
 | 3223 | { | 
 | 3224 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 3225 | 	ucontrol->value.integer.value[0] = codec->beep->enabled; | 
 | 3226 | 	return 0; | 
 | 3227 | } | 
 | 3228 |  | 
 | 3229 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, | 
 | 3230 | 					struct snd_ctl_elem_value *ucontrol) | 
 | 3231 | { | 
 | 3232 | 	struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 
 | 3233 | 	int enabled = !!ucontrol->value.integer.value[0]; | 
 | 3234 | 	if (codec->beep->enabled != enabled) { | 
 | 3235 | 		codec->beep->enabled = enabled; | 
 | 3236 | 		return 1; | 
 | 3237 | 	} | 
 | 3238 | 	return 0; | 
 | 3239 | } | 
 | 3240 |  | 
 | 3241 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { | 
 | 3242 | 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 
 | 3243 | 	.info = stac92xx_dig_beep_switch_info, | 
 | 3244 | 	.get = stac92xx_dig_beep_switch_get, | 
 | 3245 | 	.put = stac92xx_dig_beep_switch_put, | 
 | 3246 | }; | 
 | 3247 |  | 
 | 3248 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) | 
 | 3249 | { | 
 | 3250 | 	return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, | 
 | 3251 | 					 0, "PC Beep Playback Switch", 0); | 
 | 3252 | } | 
 | 3253 | #endif | 
 | 3254 |  | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3255 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) | 
 | 3256 | { | 
 | 3257 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3258 | 	int i, j, err = 0; | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3259 |  | 
 | 3260 | 	for (i = 0; i < spec->num_muxes; i++) { | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3261 | 		hda_nid_t nid; | 
 | 3262 | 		unsigned int wcaps; | 
 | 3263 | 		unsigned long val; | 
 | 3264 |  | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3265 | 		nid = spec->mux_nids[i]; | 
 | 3266 | 		wcaps = get_wcaps(codec, nid); | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3267 | 		if (!(wcaps & AC_WCAP_OUT_AMP)) | 
 | 3268 | 			continue; | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3269 |  | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3270 | 		/* check whether already the same control was created as | 
 | 3271 | 		 * normal Capture Volume. | 
 | 3272 | 		 */ | 
 | 3273 | 		val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); | 
 | 3274 | 		for (j = 0; j < spec->num_caps; j++) { | 
 | 3275 | 			if (spec->capvols[j] == val) | 
 | 3276 | 				break; | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3277 | 		} | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3278 | 		if (j < spec->num_caps) | 
 | 3279 | 			continue; | 
 | 3280 |  | 
 | 3281 | 		err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i, | 
 | 3282 | 					       "Mux Capture Volume", val); | 
 | 3283 | 		if (err < 0) | 
 | 3284 | 			return err; | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3285 | 	} | 
 | 3286 | 	return 0; | 
 | 3287 | }; | 
 | 3288 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3289 | static const char *stac92xx_spdif_labels[3] = { | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3290 | 	"Digital Playback", "Analog Mux 1", "Analog Mux 2", | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3291 | }; | 
 | 3292 |  | 
 | 3293 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) | 
 | 3294 | { | 
 | 3295 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3296 | 	struct hda_input_mux *spdif_mux = &spec->private_smux; | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3297 | 	const char **labels = spec->spdif_labels; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3298 | 	int i, num_cons; | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3299 | 	hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3300 |  | 
 | 3301 | 	num_cons = snd_hda_get_connections(codec, | 
 | 3302 | 				spec->smux_nids[0], | 
 | 3303 | 				con_lst, | 
 | 3304 | 				HDA_MAX_NUM_INPUTS); | 
| Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3305 | 	if (num_cons <= 0) | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3306 | 		return -EINVAL; | 
 | 3307 |  | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3308 | 	if (!labels) | 
 | 3309 | 		labels = stac92xx_spdif_labels; | 
 | 3310 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3311 | 	for (i = 0; i < num_cons; i++) { | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3312 | 		spdif_mux->items[spdif_mux->num_items].label = labels[i]; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3313 | 		spdif_mux->items[spdif_mux->num_items].index = i; | 
 | 3314 | 		spdif_mux->num_items++; | 
 | 3315 | 	} | 
 | 3316 |  | 
 | 3317 | 	return 0; | 
 | 3318 | } | 
 | 3319 |  | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3320 | /* labels for dmic mux inputs */ | 
| Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3321 | static const char *stac92xx_dmic_labels[5] = { | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3322 | 	"Analog Inputs", "Digital Mic 1", "Digital Mic 2", | 
 | 3323 | 	"Digital Mic 3", "Digital Mic 4" | 
 | 3324 | }; | 
 | 3325 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3326 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, | 
 | 3327 | 				hda_nid_t nid) | 
 | 3328 | { | 
 | 3329 | 	hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | 
 | 3330 | 	int i, nums; | 
 | 3331 |  | 
 | 3332 | 	nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | 
 | 3333 | 	for (i = 0; i < nums; i++) | 
 | 3334 | 		if (conn[i] == nid) | 
 | 3335 | 			return i; | 
 | 3336 | 	return -1; | 
 | 3337 | } | 
 | 3338 |  | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3339 | /* create a volume assigned to the given pin (only if supported) */ | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3340 | /* return 1 if the volume control is created */ | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3341 | static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3342 | 				   const char *label, int direction) | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3343 | { | 
 | 3344 | 	unsigned int caps, nums; | 
 | 3345 | 	char name[32]; | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3346 | 	int err; | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3347 |  | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3348 | 	if (direction == HDA_OUTPUT) | 
 | 3349 | 		caps = AC_WCAP_OUT_AMP; | 
 | 3350 | 	else | 
 | 3351 | 		caps = AC_WCAP_IN_AMP; | 
 | 3352 | 	if (!(get_wcaps(codec, nid) & caps)) | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3353 | 		return 0; | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3354 | 	caps = query_amp_caps(codec, nid, direction); | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3355 | 	nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; | 
 | 3356 | 	if (!nums) | 
 | 3357 | 		return 0; | 
 | 3358 | 	snprintf(name, sizeof(name), "%s Capture Volume", label); | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3359 | 	err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, | 
 | 3360 | 				    HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); | 
 | 3361 | 	if (err < 0) | 
 | 3362 | 		return err; | 
 | 3363 | 	return 1; | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3364 | } | 
 | 3365 |  | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3366 | /* create playback/capture controls for input pins on dmic capable codecs */ | 
 | 3367 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, | 
 | 3368 | 						const struct auto_pin_cfg *cfg) | 
 | 3369 | { | 
 | 3370 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3371 | 	struct hda_input_mux *imux = &spec->private_imux; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3372 | 	struct hda_input_mux *dimux = &spec->private_dimux; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3373 | 	int err, i, active_mics; | 
 | 3374 | 	unsigned int def_conf; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3375 |  | 
 | 3376 | 	dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; | 
 | 3377 | 	dimux->items[dimux->num_items].index = 0; | 
 | 3378 | 	dimux->num_items++; | 
 | 3379 |  | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3380 | 	active_mics = 0; | 
 | 3381 | 	for (i = 0; i < spec->num_dmics; i++) { | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3382 | 		/* check the validity: sometimes it's a dead vendor-spec node */ | 
 | 3383 | 		if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i])) | 
 | 3384 | 		    != AC_WID_PIN) | 
 | 3385 | 			continue; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3386 | 		def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); | 
 | 3387 | 		if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) | 
 | 3388 | 			active_mics++; | 
 | 3389 | 	} | 
 | 3390 |  | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3391 | 	for (i = 0; i < spec->num_dmics; i++) { | 
| Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3392 | 		hda_nid_t nid; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3393 | 		int index; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3394 | 		const char *label; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3395 |  | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3396 | 		nid = spec->dmic_nids[i]; | 
 | 3397 | 		if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) | 
 | 3398 | 			continue; | 
 | 3399 | 		def_conf = snd_hda_codec_get_pincfg(codec, nid); | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3400 | 		if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | 
 | 3401 | 			continue; | 
 | 3402 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3403 | 		index = get_connection_index(codec, spec->dmux_nids[0], nid); | 
 | 3404 | 		if (index < 0) | 
 | 3405 | 			continue; | 
 | 3406 |  | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3407 | 		if (active_mics == 1) | 
 | 3408 | 			label = "Digital Mic"; | 
 | 3409 | 		else | 
 | 3410 | 			label = stac92xx_dmic_labels[dimux->num_items]; | 
 | 3411 |  | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3412 | 		err = create_elem_capture_vol(codec, nid, label, HDA_INPUT); | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3413 | 		if (err < 0) | 
 | 3414 | 			return err; | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3415 | 		if (!err) { | 
 | 3416 | 			err = create_elem_capture_vol(codec, nid, label, | 
 | 3417 | 						      HDA_OUTPUT); | 
 | 3418 | 			if (err < 0) | 
 | 3419 | 				return err; | 
 | 3420 | 		} | 
| Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3421 |  | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3422 | 		dimux->items[dimux->num_items].label = label; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3423 | 		dimux->items[dimux->num_items].index = index; | 
 | 3424 | 		dimux->num_items++; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3425 | 		if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { | 
 | 3426 | 			imux->items[imux->num_items].label = label; | 
 | 3427 | 			imux->items[imux->num_items].index = index; | 
 | 3428 | 			imux->num_items++; | 
 | 3429 | 		} | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3430 | 	} | 
 | 3431 |  | 
 | 3432 | 	return 0; | 
 | 3433 | } | 
 | 3434 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3435 | static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, | 
 | 3436 | 			 hda_nid_t *fixed, hda_nid_t *ext) | 
 | 3437 | { | 
 | 3438 | 	unsigned int cfg; | 
 | 3439 |  | 
 | 3440 | 	if (!nid) | 
 | 3441 | 		return 0; | 
 | 3442 | 	cfg = snd_hda_codec_get_pincfg(codec, nid); | 
 | 3443 | 	switch (get_defcfg_connect(cfg)) { | 
 | 3444 | 	case AC_JACK_PORT_FIXED: | 
 | 3445 | 		if (*fixed) | 
 | 3446 | 			return 1; /* already occupied */ | 
 | 3447 | 		*fixed = nid; | 
 | 3448 | 		break; | 
 | 3449 | 	case AC_JACK_PORT_COMPLEX: | 
 | 3450 | 		if (*ext) | 
 | 3451 | 			return 1; /* already occupied */ | 
 | 3452 | 		*ext = nid; | 
 | 3453 | 		break; | 
 | 3454 | 	} | 
 | 3455 | 	return 0; | 
 | 3456 | } | 
 | 3457 |  | 
 | 3458 | static int set_mic_route(struct hda_codec *codec, | 
 | 3459 | 			 struct sigmatel_mic_route *mic, | 
 | 3460 | 			 hda_nid_t pin) | 
 | 3461 | { | 
 | 3462 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3463 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 3464 | 	int i; | 
 | 3465 |  | 
 | 3466 | 	mic->pin = pin; | 
 | 3467 | 	for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) | 
 | 3468 | 		if (pin == cfg->input_pins[i]) | 
 | 3469 | 			break; | 
 | 3470 | 	if (i <= AUTO_PIN_FRONT_MIC) { | 
 | 3471 | 		/* analog pin */ | 
 | 3472 | 		mic->dmux_idx = 0; | 
 | 3473 | 		i = get_connection_index(codec, spec->mux_nids[0], pin); | 
 | 3474 | 		if (i < 0) | 
 | 3475 | 			return -1; | 
 | 3476 | 		mic->mux_idx = i; | 
| Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 3477 | 	}  else if (spec->dmux_nids) { | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3478 | 		/* digital pin */ | 
 | 3479 | 		mic->mux_idx = 0; | 
 | 3480 | 		i = get_connection_index(codec, spec->dmux_nids[0], pin); | 
 | 3481 | 		if (i < 0) | 
 | 3482 | 			return -1; | 
 | 3483 | 		mic->dmux_idx = i; | 
 | 3484 | 	} | 
 | 3485 | 	return 0; | 
 | 3486 | } | 
 | 3487 |  | 
 | 3488 | /* return non-zero if the device is for automatic mic switch */ | 
 | 3489 | static int stac_check_auto_mic(struct hda_codec *codec) | 
 | 3490 | { | 
 | 3491 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3492 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 3493 | 	hda_nid_t fixed, ext; | 
 | 3494 | 	int i; | 
 | 3495 |  | 
 | 3496 | 	for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { | 
 | 3497 | 		if (cfg->input_pins[i]) | 
 | 3498 | 			return 0; /* must be exclusively mics */ | 
 | 3499 | 	} | 
 | 3500 | 	fixed = ext = 0; | 
 | 3501 | 	for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) | 
 | 3502 | 		if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) | 
 | 3503 | 			return 0; | 
 | 3504 | 	for (i = 0; i < spec->num_dmics; i++) | 
 | 3505 | 		if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) | 
 | 3506 | 			return 0; | 
 | 3507 | 	if (!fixed || !ext) | 
 | 3508 | 		return 0; | 
 | 3509 | 	if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) | 
 | 3510 | 		return 0; /* no unsol support */ | 
 | 3511 | 	if (set_mic_route(codec, &spec->ext_mic, ext) || | 
 | 3512 | 	    set_mic_route(codec, &spec->int_mic, fixed)) | 
 | 3513 | 		return 0; /* something is wrong */ | 
 | 3514 | 	return 1; | 
 | 3515 | } | 
 | 3516 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3517 | /* create playback/capture controls for input pins */ | 
 | 3518 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) | 
 | 3519 | { | 
 | 3520 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3521 | 	struct hda_input_mux *imux = &spec->private_imux; | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3522 | 	int i, j; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3523 |  | 
 | 3524 | 	for (i = 0; i < AUTO_PIN_LAST; i++) { | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3525 | 		hda_nid_t nid = cfg->input_pins[i]; | 
 | 3526 | 		int index, err; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3527 |  | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3528 | 		if (!nid) | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3529 | 			continue; | 
 | 3530 | 		index = -1; | 
 | 3531 | 		for (j = 0; j < spec->num_muxes; j++) { | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3532 | 			index = get_connection_index(codec, spec->mux_nids[j], | 
 | 3533 | 						     nid); | 
 | 3534 | 			if (index >= 0) | 
 | 3535 | 				break; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3536 | 		} | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3537 | 		if (index < 0) | 
 | 3538 | 			continue; | 
 | 3539 |  | 
 | 3540 | 		err = create_elem_capture_vol(codec, nid, | 
| Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 3541 | 					      auto_pin_cfg_labels[i], | 
 | 3542 | 					      HDA_INPUT); | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 3543 | 		if (err < 0) | 
 | 3544 | 			return err; | 
 | 3545 |  | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3546 | 		imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; | 
 | 3547 | 		imux->items[imux->num_items].index = index; | 
 | 3548 | 		imux->num_items++; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3549 | 	} | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 3550 | 	spec->num_analog_muxes = imux->num_items; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3551 |  | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3552 | 	if (imux->num_items) { | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3553 | 		/* | 
 | 3554 | 		 * Set the current input for the muxes. | 
 | 3555 | 		 * The STAC9221 has two input muxes with identical source | 
 | 3556 | 		 * NID lists.  Hopefully this won't get confused. | 
 | 3557 | 		 */ | 
 | 3558 | 		for (i = 0; i < spec->num_muxes; i++) { | 
| Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3559 | 			snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, | 
 | 3560 | 						  AC_VERB_SET_CONNECT_SEL, | 
 | 3561 | 						  imux->items[0].index); | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3562 | 		} | 
 | 3563 | 	} | 
 | 3564 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3565 | 	return 0; | 
 | 3566 | } | 
 | 3567 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3568 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) | 
 | 3569 | { | 
 | 3570 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3571 | 	int i; | 
 | 3572 |  | 
 | 3573 | 	for (i = 0; i < spec->autocfg.line_outs; i++) { | 
 | 3574 | 		hda_nid_t nid = spec->autocfg.line_out_pins[i]; | 
 | 3575 | 		stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); | 
 | 3576 | 	} | 
 | 3577 | } | 
 | 3578 |  | 
 | 3579 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) | 
 | 3580 | { | 
 | 3581 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3582 | 	int i; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3583 |  | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3584 | 	for (i = 0; i < spec->autocfg.hp_outs; i++) { | 
 | 3585 | 		hda_nid_t pin; | 
 | 3586 | 		pin = spec->autocfg.hp_pins[i]; | 
 | 3587 | 		if (pin) /* connect to front */ | 
 | 3588 | 			stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); | 
 | 3589 | 	} | 
 | 3590 | 	for (i = 0; i < spec->autocfg.speaker_outs; i++) { | 
 | 3591 | 		hda_nid_t pin; | 
 | 3592 | 		pin = spec->autocfg.speaker_pins[i]; | 
 | 3593 | 		if (pin) /* connect to front */ | 
 | 3594 | 			stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); | 
 | 3595 | 	} | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3596 | } | 
 | 3597 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3598 | 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] | 3599 | { | 
 | 3600 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3601 | 	int hp_swap = 0; | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3602 | 	int i, err; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3603 |  | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3604 | 	if ((err = snd_hda_parse_pin_def_config(codec, | 
 | 3605 | 						&spec->autocfg, | 
 | 3606 | 						spec->dmic_nids)) < 0) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3607 | 		return err; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3608 | 	if (! spec->autocfg.line_outs) | 
| Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3609 | 		return 0; /* can't find valid pin config */ | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3610 |  | 
| Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3611 | 	/* If we have no real line-out pin and multiple hp-outs, HPs should | 
 | 3612 | 	 * be set up as multi-channel outputs. | 
 | 3613 | 	 */ | 
 | 3614 | 	if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && | 
 | 3615 | 	    spec->autocfg.hp_outs > 1) { | 
 | 3616 | 		/* Copy hp_outs to line_outs, backup line_outs in | 
 | 3617 | 		 * speaker_outs so that the following routines can handle | 
 | 3618 | 		 * HP pins as primary outputs. | 
 | 3619 | 		 */ | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3620 | 		snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); | 
| Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3621 | 		memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, | 
 | 3622 | 		       sizeof(spec->autocfg.line_out_pins)); | 
 | 3623 | 		spec->autocfg.speaker_outs = spec->autocfg.line_outs; | 
 | 3624 | 		memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, | 
 | 3625 | 		       sizeof(spec->autocfg.hp_pins)); | 
 | 3626 | 		spec->autocfg.line_outs = spec->autocfg.hp_outs; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3627 | 		spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; | 
 | 3628 | 		spec->autocfg.hp_outs = 0; | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3629 | 		hp_swap = 1; | 
| Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3630 | 	} | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3631 | 	if (spec->autocfg.mono_out_pin) { | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3632 | 		int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & | 
 | 3633 | 			(AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3634 | 		u32 caps = query_amp_caps(codec, | 
 | 3635 | 				spec->autocfg.mono_out_pin, dir); | 
 | 3636 | 		hda_nid_t conn_list[1]; | 
 | 3637 |  | 
 | 3638 | 		/* get the mixer node and then the mono mux if it exists */ | 
 | 3639 | 		if (snd_hda_get_connections(codec, | 
 | 3640 | 				spec->autocfg.mono_out_pin, conn_list, 1) && | 
 | 3641 | 				snd_hda_get_connections(codec, conn_list[0], | 
| Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 3642 | 				conn_list, 1) > 0) { | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3643 |  | 
 | 3644 | 				int wcaps = get_wcaps(codec, conn_list[0]); | 
| Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 3645 | 				int wid_type = get_wcaps_type(wcaps); | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3646 | 				/* LR swap check, some stac925x have a mux that | 
 | 3647 |  				 * changes the DACs output path instead of the | 
 | 3648 |  				 * mono-mux path. | 
 | 3649 |  				 */ | 
 | 3650 | 				if (wid_type == AC_WID_AUD_SEL && | 
 | 3651 | 						!(wcaps & AC_WCAP_LR_SWAP)) | 
 | 3652 | 					spec->mono_nid = conn_list[0]; | 
 | 3653 | 		} | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3654 | 		if (dir) { | 
 | 3655 | 			hda_nid_t nid = spec->autocfg.mono_out_pin; | 
 | 3656 |  | 
 | 3657 | 			/* most mono outs have a least a mute/unmute switch */ | 
 | 3658 | 			dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; | 
 | 3659 | 			err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, | 
 | 3660 | 				"Mono Playback Switch", | 
 | 3661 | 				HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3662 | 			if (err < 0) | 
 | 3663 | 				return err; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3664 | 			/* check for volume support for the amp */ | 
 | 3665 | 			if ((caps & AC_AMPCAP_NUM_STEPS) | 
 | 3666 | 					>> AC_AMPCAP_NUM_STEPS_SHIFT) { | 
 | 3667 | 				err = stac92xx_add_control(spec, | 
 | 3668 | 					STAC_CTL_WIDGET_VOL, | 
 | 3669 | 					"Mono Playback Volume", | 
 | 3670 | 				HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); | 
 | 3671 | 				if (err < 0) | 
 | 3672 | 					return err; | 
 | 3673 | 			} | 
| Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3674 | 		} | 
 | 3675 |  | 
 | 3676 | 		stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, | 
 | 3677 | 					 AC_PINCTL_OUT_EN); | 
 | 3678 | 	} | 
| Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3679 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3680 | 	if (!spec->multiout.num_dacs) { | 
 | 3681 | 		err = stac92xx_auto_fill_dac_nids(codec); | 
 | 3682 | 		if (err < 0) | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3683 | 			return err; | 
| Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 3684 | 		err = stac92xx_auto_create_multi_out_ctls(codec, | 
 | 3685 | 							  &spec->autocfg); | 
 | 3686 | 		if (err < 0) | 
 | 3687 | 			return err; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 3688 | 	} | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3689 |  | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3690 | 	/* setup analog beep controls */ | 
 | 3691 | 	if (spec->anabeep_nid > 0) { | 
 | 3692 | 		err = stac92xx_auto_create_beep_ctls(codec, | 
 | 3693 | 			spec->anabeep_nid); | 
 | 3694 | 		if (err < 0) | 
 | 3695 | 			return err; | 
 | 3696 | 	} | 
 | 3697 |  | 
 | 3698 | 	/* setup digital beep controls and input device */ | 
 | 3699 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 
 | 3700 | 	if (spec->digbeep_nid > 0) { | 
 | 3701 | 		hda_nid_t nid = spec->digbeep_nid; | 
| Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3702 | 		unsigned int caps; | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3703 |  | 
 | 3704 | 		err = stac92xx_auto_create_beep_ctls(codec, nid); | 
 | 3705 | 		if (err < 0) | 
 | 3706 | 			return err; | 
 | 3707 | 		err = snd_hda_attach_beep_device(codec, nid); | 
 | 3708 | 		if (err < 0) | 
 | 3709 | 			return err; | 
| Takashi Iwai | fa79796 | 2009-05-19 12:50:04 +0200 | [diff] [blame] | 3710 | 		/* IDT/STAC codecs have linear beep tone parameter */ | 
 | 3711 | 		codec->beep->linear_tone = 1; | 
| Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3712 | 		/* if no beep switch is available, make its own one */ | 
 | 3713 | 		caps = query_amp_caps(codec, nid, HDA_OUTPUT); | 
 | 3714 | 		if (codec->beep && | 
 | 3715 | 		    !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { | 
 | 3716 | 			err = stac92xx_beep_switch_ctl(codec); | 
 | 3717 | 			if (err < 0) | 
 | 3718 | 				return err; | 
 | 3719 | 		} | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3720 | 	} | 
 | 3721 | #endif | 
 | 3722 |  | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3723 | 	err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3724 | 	if (err < 0) | 
 | 3725 | 		return err; | 
 | 3726 |  | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3727 | 	/* All output parsing done, now restore the swapped hp pins */ | 
 | 3728 | 	if (hp_swap) { | 
 | 3729 | 		memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, | 
 | 3730 | 		       sizeof(spec->autocfg.hp_pins)); | 
 | 3731 | 		spec->autocfg.hp_outs = spec->autocfg.line_outs; | 
 | 3732 | 		spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; | 
 | 3733 | 		spec->autocfg.line_outs = 0; | 
 | 3734 | 	} | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3735 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 3736 | 	if (stac_check_auto_mic(codec)) { | 
 | 3737 | 		spec->auto_mic = 1; | 
 | 3738 | 		/* only one capture for auto-mic */ | 
 | 3739 | 		spec->num_adcs = 1; | 
 | 3740 | 		spec->num_caps = 1; | 
 | 3741 | 		spec->num_muxes = 1; | 
 | 3742 | 	} | 
 | 3743 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 3744 | 	for (i = 0; i < spec->num_caps; i++) { | 
 | 3745 | 		err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], | 
 | 3746 | 					       spec->capsws[i], i); | 
 | 3747 | 		if (err < 0) | 
 | 3748 | 			return err; | 
 | 3749 | 	} | 
 | 3750 |  | 
| Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 3751 | 	err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); | 
| Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3752 | 	if (err < 0) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3753 | 		return err; | 
 | 3754 |  | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3755 | 	if (spec->mono_nid > 0) { | 
 | 3756 | 		err = stac92xx_auto_create_mono_output_ctls(codec); | 
 | 3757 | 		if (err < 0) | 
 | 3758 | 			return err; | 
 | 3759 | 	} | 
| Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3760 | 	if (spec->num_dmics > 0 && !spec->dinput_mux) | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3761 | 		if ((err = stac92xx_auto_create_dmic_input_ctls(codec, | 
 | 3762 | 						&spec->autocfg)) < 0) | 
 | 3763 | 			return err; | 
| Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3764 | 	if (spec->num_muxes > 0) { | 
 | 3765 | 		err = stac92xx_auto_create_mux_input_ctls(codec); | 
 | 3766 | 		if (err < 0) | 
 | 3767 | 			return err; | 
 | 3768 | 	} | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3769 | 	if (spec->num_smuxes > 0) { | 
 | 3770 | 		err = stac92xx_auto_create_spdif_mux_ctls(codec); | 
 | 3771 | 		if (err < 0) | 
 | 3772 | 			return err; | 
 | 3773 | 	} | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3774 |  | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3775 | 	err = stac92xx_add_input_source(spec); | 
 | 3776 | 	if (err < 0) | 
 | 3777 | 		return err; | 
 | 3778 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3779 | 	spec->multiout.max_channels = spec->multiout.num_dacs * 2; | 
| Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3780 | 	if (spec->multiout.max_channels > 2) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3781 | 		spec->surr_switch = 1; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3782 |  | 
| Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3783 | 	if (spec->autocfg.dig_outs) | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3784 | 		spec->multiout.dig_out_nid = dig_out; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3785 | 	if (dig_in && spec->autocfg.dig_in_pin) | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3786 | 		spec->dig_in_nid = dig_in; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3787 |  | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3788 | 	if (spec->kctls.list) | 
 | 3789 | 		spec->mixers[spec->num_mixers++] = spec->kctls.list; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3790 |  | 
 | 3791 | 	spec->input_mux = &spec->private_imux; | 
| Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 3792 | 	if (!spec->dinput_mux) | 
 | 3793 | 		spec->dinput_mux = &spec->private_dimux; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3794 | 	spec->sinput_mux = &spec->private_smux; | 
| Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3795 | 	spec->mono_mux = &spec->private_mono_mux; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3796 | 	return 1; | 
 | 3797 | } | 
 | 3798 |  | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3799 | /* add playback controls for HP output */ | 
 | 3800 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, | 
 | 3801 | 					struct auto_pin_cfg *cfg) | 
 | 3802 | { | 
 | 3803 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3804 | 	hda_nid_t pin = cfg->hp_pins[0]; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3805 | 	unsigned int wid_caps; | 
 | 3806 |  | 
 | 3807 | 	if (! pin) | 
 | 3808 | 		return 0; | 
 | 3809 |  | 
 | 3810 | 	wid_caps = get_wcaps(codec, pin); | 
| Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3811 | 	if (wid_caps & AC_WCAP_UNSOL_CAP) | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3812 | 		spec->hp_detect = 1; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3813 |  | 
 | 3814 | 	return 0; | 
 | 3815 | } | 
 | 3816 |  | 
| Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3817 | /* add playback controls for LFE output */ | 
 | 3818 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, | 
 | 3819 | 					struct auto_pin_cfg *cfg) | 
 | 3820 | { | 
 | 3821 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3822 | 	int err; | 
 | 3823 | 	hda_nid_t lfe_pin = 0x0; | 
 | 3824 | 	int i; | 
 | 3825 |  | 
 | 3826 | 	/* | 
 | 3827 | 	 * search speaker outs and line outs for a mono speaker pin | 
 | 3828 | 	 * with an amp.  If one is found, add LFE controls | 
 | 3829 | 	 * for it. | 
 | 3830 | 	 */ | 
 | 3831 | 	for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { | 
 | 3832 | 		hda_nid_t pin = spec->autocfg.speaker_pins[i]; | 
| Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3833 | 		unsigned int wcaps = get_wcaps(codec, pin); | 
| Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3834 | 		wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); | 
 | 3835 | 		if (wcaps == AC_WCAP_OUT_AMP) | 
 | 3836 | 			/* found a mono speaker with an amp, must be lfe */ | 
 | 3837 | 			lfe_pin = pin; | 
 | 3838 | 	} | 
 | 3839 |  | 
 | 3840 | 	/* if speaker_outs is 0, then speakers may be in line_outs */ | 
 | 3841 | 	if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { | 
 | 3842 | 		for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { | 
 | 3843 | 			hda_nid_t pin = spec->autocfg.line_out_pins[i]; | 
| Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3844 | 			unsigned int defcfg; | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3845 | 			defcfg = snd_hda_codec_get_pincfg(codec, pin); | 
| Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3846 | 			if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { | 
| Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3847 | 				unsigned int wcaps = get_wcaps(codec, pin); | 
| Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3848 | 				wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); | 
 | 3849 | 				if (wcaps == AC_WCAP_OUT_AMP) | 
 | 3850 | 					/* found a mono speaker with an amp, | 
 | 3851 | 					   must be lfe */ | 
 | 3852 | 					lfe_pin = pin; | 
 | 3853 | 			} | 
 | 3854 | 		} | 
 | 3855 | 	} | 
 | 3856 |  | 
 | 3857 | 	if (lfe_pin) { | 
| Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 3858 | 		err = create_controls(codec, "LFE", lfe_pin, 1); | 
| Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3859 | 		if (err < 0) | 
 | 3860 | 			return err; | 
 | 3861 | 	} | 
 | 3862 |  | 
 | 3863 | 	return 0; | 
 | 3864 | } | 
 | 3865 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3866 | static int stac9200_parse_auto_config(struct hda_codec *codec) | 
 | 3867 | { | 
 | 3868 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3869 | 	int err; | 
 | 3870 |  | 
| Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3871 | 	if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3872 | 		return err; | 
 | 3873 |  | 
 | 3874 | 	if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) | 
 | 3875 | 		return err; | 
 | 3876 |  | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3877 | 	if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) | 
 | 3878 | 		return err; | 
 | 3879 |  | 
| Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3880 | 	if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) | 
 | 3881 | 		return err; | 
 | 3882 |  | 
| Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3883 | 	if (spec->num_muxes > 0) { | 
 | 3884 | 		err = stac92xx_auto_create_mux_input_ctls(codec); | 
 | 3885 | 		if (err < 0) | 
 | 3886 | 			return err; | 
 | 3887 | 	} | 
 | 3888 |  | 
| Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3889 | 	err = stac92xx_add_input_source(spec); | 
 | 3890 | 	if (err < 0) | 
 | 3891 | 		return err; | 
 | 3892 |  | 
| Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3893 | 	if (spec->autocfg.dig_outs) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3894 | 		spec->multiout.dig_out_nid = 0x05; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3895 | 	if (spec->autocfg.dig_in_pin) | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3896 | 		spec->dig_in_nid = 0x04; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3897 |  | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3898 | 	if (spec->kctls.list) | 
 | 3899 | 		spec->mixers[spec->num_mixers++] = spec->kctls.list; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3900 |  | 
 | 3901 | 	spec->input_mux = &spec->private_imux; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3902 | 	spec->dinput_mux = &spec->private_dimux; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3903 |  | 
 | 3904 | 	return 1; | 
 | 3905 | } | 
 | 3906 |  | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3907 | /* | 
 | 3908 |  * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a | 
 | 3909 |  * funky external mute control using GPIO pins. | 
 | 3910 |  */ | 
 | 3911 |  | 
| Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3912 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3913 | 			  unsigned int dir_mask, unsigned int data) | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3914 | { | 
 | 3915 | 	unsigned int gpiostate, gpiomask, gpiodir; | 
 | 3916 |  | 
 | 3917 | 	gpiostate = snd_hda_codec_read(codec, codec->afg, 0, | 
 | 3918 | 				       AC_VERB_GET_GPIO_DATA, 0); | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3919 | 	gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3920 |  | 
 | 3921 | 	gpiomask = snd_hda_codec_read(codec, codec->afg, 0, | 
 | 3922 | 				      AC_VERB_GET_GPIO_MASK, 0); | 
| Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3923 | 	gpiomask |= mask; | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3924 |  | 
 | 3925 | 	gpiodir = snd_hda_codec_read(codec, codec->afg, 0, | 
 | 3926 | 				     AC_VERB_GET_GPIO_DIRECTION, 0); | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3927 | 	gpiodir |= dir_mask; | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3928 |  | 
| Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3929 | 	/* Configure GPIOx as CMOS */ | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3930 | 	snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); | 
 | 3931 |  | 
 | 3932 | 	snd_hda_codec_write(codec, codec->afg, 0, | 
 | 3933 | 			    AC_VERB_SET_GPIO_MASK, gpiomask); | 
| Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3934 | 	snd_hda_codec_read(codec, codec->afg, 0, | 
 | 3935 | 			   AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3936 |  | 
 | 3937 | 	msleep(1); | 
 | 3938 |  | 
| Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3939 | 	snd_hda_codec_read(codec, codec->afg, 0, | 
 | 3940 | 			   AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3941 | } | 
 | 3942 |  | 
| Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 3943 | #ifdef CONFIG_SND_HDA_INPUT_JACK | 
| Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 3944 | static void stac92xx_free_jack_priv(struct snd_jack *jack) | 
 | 3945 | { | 
 | 3946 | 	struct sigmatel_jack *jacks = jack->private_data; | 
 | 3947 | 	jacks->nid = 0; | 
 | 3948 | 	jacks->jack = NULL; | 
 | 3949 | } | 
 | 3950 | #endif | 
 | 3951 |  | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3952 | static int stac92xx_add_jack(struct hda_codec *codec, | 
 | 3953 | 		hda_nid_t nid, int type) | 
 | 3954 | { | 
| Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 3955 | #ifdef CONFIG_SND_HDA_INPUT_JACK | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3956 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 3957 | 	struct sigmatel_jack *jack; | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3958 | 	int def_conf = snd_hda_codec_get_pincfg(codec, nid); | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3959 | 	int connectivity = get_defcfg_connect(def_conf); | 
 | 3960 | 	char name[32]; | 
| Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 3961 | 	int err; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3962 |  | 
 | 3963 | 	if (connectivity && connectivity != AC_JACK_PORT_FIXED) | 
 | 3964 | 		return 0; | 
 | 3965 |  | 
 | 3966 | 	snd_array_init(&spec->jacks, sizeof(*jack), 32); | 
 | 3967 | 	jack = snd_array_new(&spec->jacks); | 
 | 3968 | 	if (!jack) | 
 | 3969 | 		return -ENOMEM; | 
 | 3970 | 	jack->nid = nid; | 
 | 3971 | 	jack->type = type; | 
 | 3972 |  | 
| Takashi Iwai | 86de741 | 2009-07-22 16:02:46 +0200 | [diff] [blame] | 3973 | 	snprintf(name, sizeof(name), "%s at %s %s Jack", | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3974 | 		snd_hda_get_jack_type(def_conf), | 
 | 3975 | 		snd_hda_get_jack_connectivity(def_conf), | 
 | 3976 | 		snd_hda_get_jack_location(def_conf)); | 
 | 3977 |  | 
| Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 3978 | 	err = snd_jack_new(codec->bus->card, name, type, &jack->jack); | 
 | 3979 | 	if (err < 0) { | 
 | 3980 | 		jack->nid = 0; | 
 | 3981 | 		return err; | 
 | 3982 | 	} | 
 | 3983 | 	jack->jack->private_data = jack; | 
 | 3984 | 	jack->jack->private_free = stac92xx_free_jack_priv; | 
| Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3985 | #endif | 
| Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 3986 | 	return 0; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3987 | } | 
 | 3988 |  | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3989 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, | 
 | 3990 | 			  unsigned char type, int data) | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3991 | { | 
 | 3992 | 	struct sigmatel_event *event; | 
 | 3993 |  | 
 | 3994 | 	snd_array_init(&spec->events, sizeof(*event), 32); | 
 | 3995 | 	event = snd_array_new(&spec->events); | 
 | 3996 | 	if (!event) | 
 | 3997 | 		return -ENOMEM; | 
 | 3998 | 	event->nid = nid; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3999 | 	event->type = type; | 
 | 4000 | 	event->tag = spec->events.used; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4001 | 	event->data = data; | 
 | 4002 |  | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4003 | 	return event->tag; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4004 | } | 
 | 4005 |  | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4006 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4007 | 					     hda_nid_t nid) | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4008 | { | 
 | 4009 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4010 | 	struct sigmatel_event *event = spec->events.list; | 
 | 4011 | 	int i; | 
 | 4012 |  | 
 | 4013 | 	for (i = 0; i < spec->events.used; i++, event++) { | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4014 | 		if (event->nid == nid) | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4015 | 			return event; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4016 | 	} | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4017 | 	return NULL; | 
 | 4018 | } | 
 | 4019 |  | 
 | 4020 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, | 
 | 4021 | 						      unsigned char tag) | 
 | 4022 | { | 
 | 4023 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4024 | 	struct sigmatel_event *event = spec->events.list; | 
 | 4025 | 	int i; | 
 | 4026 |  | 
 | 4027 | 	for (i = 0; i < spec->events.used; i++, event++) { | 
 | 4028 | 		if (event->tag == tag) | 
 | 4029 | 			return event; | 
 | 4030 | 	} | 
 | 4031 | 	return NULL; | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4032 | } | 
 | 4033 |  | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4034 | /* check if given nid is a valid pin and no other events are assigned | 
 | 4035 |  * to it.  If OK, assign the event, set the unsol flag, and returns 1. | 
 | 4036 |  * Otherwise, returns zero. | 
 | 4037 |  */ | 
 | 4038 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | 
 | 4039 | 			     unsigned int type) | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4040 | { | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4041 | 	struct sigmatel_event *event; | 
 | 4042 | 	int tag; | 
 | 4043 |  | 
 | 4044 | 	if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4045 | 		return 0; | 
 | 4046 | 	event = stac_get_event(codec, nid); | 
 | 4047 | 	if (event) { | 
 | 4048 | 		if (event->type != type) | 
 | 4049 | 			return 0; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4050 | 		tag = event->tag; | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4051 | 	} else { | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4052 | 		tag = stac_add_event(codec->spec, nid, type, 0); | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4053 | 		if (tag < 0) | 
 | 4054 | 			return 0; | 
 | 4055 | 	} | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4056 | 	snd_hda_codec_write_cache(codec, nid, 0, | 
 | 4057 | 				  AC_VERB_SET_UNSOLICITED_ENABLE, | 
 | 4058 | 				  AC_USRSP_EN | tag); | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4059 | 	return 1; | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4060 | } | 
 | 4061 |  | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4062 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) | 
 | 4063 | { | 
 | 4064 | 	int i; | 
 | 4065 | 	for (i = 0; i < cfg->hp_outs; i++) | 
 | 4066 | 		if (cfg->hp_pins[i] == nid) | 
 | 4067 | 			return 1; /* nid is a HP-Out */ | 
 | 4068 |  | 
 | 4069 | 	return 0; /* nid is not a HP-Out */ | 
 | 4070 | }; | 
 | 4071 |  | 
| Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4072 | static void stac92xx_power_down(struct hda_codec *codec) | 
 | 4073 | { | 
 | 4074 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4075 |  | 
 | 4076 | 	/* power down inactive DACs */ | 
 | 4077 | 	hda_nid_t *dac; | 
 | 4078 | 	for (dac = spec->dac_list; *dac; dac++) | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4079 | 		if (!check_all_dac_nids(spec, *dac)) | 
| Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4080 | 			snd_hda_codec_write(codec, *dac, 0, | 
| Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 4081 | 					AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 
 | 4082 | } | 
 | 4083 |  | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4084 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, | 
 | 4085 | 				  int enable); | 
 | 4086 |  | 
| Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4087 | /* override some hints from the hwdep entry */ | 
 | 4088 | static void stac_store_hints(struct hda_codec *codec) | 
 | 4089 | { | 
 | 4090 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4091 | 	const char *p; | 
 | 4092 | 	int val; | 
 | 4093 |  | 
 | 4094 | 	val = snd_hda_get_bool_hint(codec, "hp_detect"); | 
 | 4095 | 	if (val >= 0) | 
 | 4096 | 		spec->hp_detect = val; | 
 | 4097 | 	p = snd_hda_get_hint(codec, "gpio_mask"); | 
 | 4098 | 	if (p) { | 
 | 4099 | 		spec->gpio_mask = simple_strtoul(p, NULL, 0); | 
 | 4100 | 		spec->eapd_mask = spec->gpio_dir = spec->gpio_data = | 
 | 4101 | 			spec->gpio_mask; | 
 | 4102 | 	} | 
 | 4103 | 	p = snd_hda_get_hint(codec, "gpio_dir"); | 
 | 4104 | 	if (p) | 
 | 4105 | 		spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask; | 
 | 4106 | 	p = snd_hda_get_hint(codec, "gpio_data"); | 
 | 4107 | 	if (p) | 
 | 4108 | 		spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask; | 
 | 4109 | 	p = snd_hda_get_hint(codec, "eapd_mask"); | 
 | 4110 | 	if (p) | 
 | 4111 | 		spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask; | 
 | 4112 | 	val = snd_hda_get_bool_hint(codec, "eapd_switch"); | 
 | 4113 | 	if (val >= 0) | 
 | 4114 | 		spec->eapd_switch = val; | 
 | 4115 | } | 
 | 4116 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4117 | static int stac92xx_init(struct hda_codec *codec) | 
 | 4118 | { | 
 | 4119 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4120 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4121 | 	unsigned int gpio; | 
| Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4122 | 	int i; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4123 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4124 | 	snd_hda_sequence_write(codec, spec->init); | 
 | 4125 |  | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4126 | 	/* power down adcs initially */ | 
 | 4127 | 	if (spec->powerdown_adcs) | 
 | 4128 | 		for (i = 0; i < spec->num_adcs; i++) | 
| Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 4129 | 			snd_hda_codec_write(codec, | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4130 | 				spec->adc_nids[i], 0, | 
 | 4131 | 				AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4132 |  | 
| Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 4133 | 	/* override some hints */ | 
 | 4134 | 	stac_store_hints(codec); | 
 | 4135 |  | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4136 | 	/* set up GPIO */ | 
 | 4137 | 	gpio = spec->gpio_data; | 
 | 4138 | 	/* turn on EAPD statically when spec->eapd_switch isn't set. | 
 | 4139 | 	 * otherwise, unsol event will turn it on/off dynamically | 
 | 4140 | 	 */ | 
 | 4141 | 	if (!spec->eapd_switch) | 
 | 4142 | 		gpio |= spec->eapd_mask; | 
 | 4143 | 	stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); | 
 | 4144 |  | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4145 | 	/* set up pins */ | 
 | 4146 | 	if (spec->hp_detect) { | 
| Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 4147 | 		/* Enable unsolicited responses on the HP widget */ | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4148 | 		for (i = 0; i < cfg->hp_outs; i++) { | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4149 | 			hda_nid_t nid = cfg->hp_pins[i]; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4150 | 			enable_pin_detect(codec, nid, STAC_HP_EVENT); | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4151 | 		} | 
| Takashi Iwai | 1c4bdf9 | 2009-08-13 08:23:24 +0200 | [diff] [blame] | 4152 | 		if (cfg->line_out_type == AUTO_PIN_LINE_OUT && | 
 | 4153 | 		    cfg->speaker_outs > 0) { | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4154 | 			/* enable pin-detect for line-outs as well */ | 
| Takashi Iwai | 15cfa2b | 2009-08-03 14:23:33 +0200 | [diff] [blame] | 4155 | 			for (i = 0; i < cfg->line_outs; i++) { | 
 | 4156 | 				hda_nid_t nid = cfg->line_out_pins[i]; | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4157 | 				enable_pin_detect(codec, nid, STAC_LO_EVENT); | 
 | 4158 | 			} | 
 | 4159 | 		} | 
 | 4160 |  | 
| Takashi Iwai | 0a07aca | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 4161 | 		/* force to enable the first line-out; the others are set up | 
 | 4162 | 		 * in unsol_event | 
 | 4163 | 		 */ | 
 | 4164 | 		stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4165 | 				AC_PINCTL_OUT_EN); | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4166 | 		/* fake event to set up pins */ | 
| Takashi Iwai | 5f380eb | 2009-09-14 15:36:14 +0200 | [diff] [blame] | 4167 | 		if (cfg->hp_pins[0]) | 
 | 4168 | 			stac_issue_unsol_event(codec, cfg->hp_pins[0]); | 
 | 4169 | 		else if (cfg->line_out_pins[0]) | 
 | 4170 | 			stac_issue_unsol_event(codec, cfg->line_out_pins[0]); | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4171 | 	} else { | 
 | 4172 | 		stac92xx_auto_init_multi_out(codec); | 
 | 4173 | 		stac92xx_auto_init_hp_out(codec); | 
| Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4174 | 		for (i = 0; i < cfg->hp_outs; i++) | 
 | 4175 | 			stac_toggle_power_map(codec, cfg->hp_pins[i], 1); | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4176 | 	} | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4177 | 	if (spec->auto_mic) { | 
| Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 4178 | 		/* initialize connection to analog input */ | 
| Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 4179 | 		if (spec->dmux_nids) | 
 | 4180 | 			snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, | 
| Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 4181 | 					  AC_VERB_SET_CONNECT_SEL, 0); | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4182 | 		if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) | 
 | 4183 | 			stac_issue_unsol_event(codec, spec->ext_mic.pin); | 
 | 4184 | 	} | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4185 | 	for (i = 0; i < AUTO_PIN_LAST; i++) { | 
| Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4186 | 		hda_nid_t nid = cfg->input_pins[i]; | 
 | 4187 | 		if (nid) { | 
| Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4188 | 			unsigned int pinctl, conf; | 
| Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4189 | 			if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { | 
 | 4190 | 				/* for mic pins, force to initialize */ | 
| Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4191 | 				pinctl = stac92xx_get_default_vref(codec, nid); | 
| Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4192 | 				pinctl |= AC_PINCTL_IN_EN; | 
 | 4193 | 				stac92xx_auto_set_pinctl(codec, nid, pinctl); | 
| Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4194 | 			} else { | 
 | 4195 | 				pinctl = snd_hda_codec_read(codec, nid, 0, | 
 | 4196 | 					AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 
 | 4197 | 				/* if PINCTL already set then skip */ | 
| Takashi Iwai | 5dd17cb | 2009-05-07 16:22:53 +0200 | [diff] [blame] | 4198 | 				/* Also, if both INPUT and OUTPUT are set, | 
 | 4199 | 				 * it must be a BIOS bug; need to override, too | 
 | 4200 | 				 */ | 
 | 4201 | 				if (!(pinctl & AC_PINCTL_IN_EN) || | 
 | 4202 | 				    (pinctl & AC_PINCTL_OUT_EN)) { | 
 | 4203 | 					pinctl &= ~AC_PINCTL_OUT_EN; | 
| Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4204 | 					pinctl |= AC_PINCTL_IN_EN; | 
 | 4205 | 					stac92xx_auto_set_pinctl(codec, nid, | 
 | 4206 | 								 pinctl); | 
 | 4207 | 				} | 
| Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 4208 | 			} | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4209 | 			conf = snd_hda_codec_get_pincfg(codec, nid); | 
| Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4210 | 			if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4211 | 				if (enable_pin_detect(codec, nid, | 
 | 4212 | 						      STAC_INSERT_EVENT)) | 
 | 4213 | 					stac_issue_unsol_event(codec, nid); | 
| Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 4214 | 			} | 
| Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 4215 | 		} | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4216 | 	} | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4217 | 	for (i = 0; i < spec->num_dmics; i++) | 
 | 4218 | 		stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], | 
 | 4219 | 					AC_PINCTL_IN_EN); | 
| Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 4220 | 	if (cfg->dig_out_pins[0]) | 
 | 4221 | 		stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4222 | 					 AC_PINCTL_OUT_EN); | 
 | 4223 | 	if (cfg->dig_in_pin) | 
 | 4224 | 		stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, | 
 | 4225 | 					 AC_PINCTL_IN_EN); | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4226 | 	for (i = 0; i < spec->num_pwrs; i++)  { | 
 | 4227 | 		hda_nid_t nid = spec->pwr_nids[i]; | 
 | 4228 | 		int pinctl, def_conf; | 
| Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4229 |  | 
| Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4230 | 		/* power on when no jack detection is available */ | 
 | 4231 | 		if (!spec->hp_detect) { | 
 | 4232 | 			stac_toggle_power_map(codec, nid, 1); | 
 | 4233 | 			continue; | 
 | 4234 | 		} | 
 | 4235 |  | 
 | 4236 | 		if (is_nid_hp_pin(cfg, nid)) | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4237 | 			continue; /* already has an unsol event */ | 
| Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4238 |  | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4239 | 		pinctl = snd_hda_codec_read(codec, nid, 0, | 
 | 4240 | 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 
 | 4241 | 		/* outputs are only ports capable of power management | 
 | 4242 | 		 * any attempts on powering down a input port cause the | 
 | 4243 | 		 * referenced VREF to act quirky. | 
 | 4244 | 		 */ | 
| Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4245 | 		if (pinctl & AC_PINCTL_IN_EN) { | 
 | 4246 | 			stac_toggle_power_map(codec, nid, 1); | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4247 | 			continue; | 
| Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 4248 | 		} | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4249 | 		def_conf = snd_hda_codec_get_pincfg(codec, nid); | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4250 | 		def_conf = get_defcfg_connect(def_conf); | 
 | 4251 | 		/* skip any ports that don't have jacks since presence | 
 | 4252 |  		 * detection is useless */ | 
 | 4253 | 		if (def_conf != AC_JACK_PORT_COMPLEX) { | 
 | 4254 | 			if (def_conf != AC_JACK_PORT_NONE) | 
 | 4255 | 				stac_toggle_power_map(codec, nid, 1); | 
 | 4256 | 			continue; | 
 | 4257 | 		} | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4258 | 		if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) | 
 | 4259 | 			stac_issue_unsol_event(codec, nid); | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4260 | 	} | 
 | 4261 | 	if (spec->dac_list) | 
 | 4262 | 		stac92xx_power_down(codec); | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4263 | 	return 0; | 
 | 4264 | } | 
 | 4265 |  | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4266 | static void stac92xx_free_jacks(struct hda_codec *codec) | 
 | 4267 | { | 
| Takashi Iwai | 8c8145b | 2009-06-22 17:00:38 +0200 | [diff] [blame] | 4268 | #ifdef CONFIG_SND_HDA_INPUT_JACK | 
| Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4269 | 	/* free jack instances manually when clearing/reconfiguring */ | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4270 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | b94d353 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4271 | 	if (!codec->bus->shutdown && spec->jacks.list) { | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4272 | 		struct sigmatel_jack *jacks = spec->jacks.list; | 
 | 4273 | 		int i; | 
| Takashi Iwai | 95c0909 | 2009-04-14 16:15:29 +0200 | [diff] [blame] | 4274 | 		for (i = 0; i < spec->jacks.used; i++, jacks++) { | 
 | 4275 | 			if (jacks->jack) | 
 | 4276 | 				snd_device_free(codec->bus->card, jacks->jack); | 
 | 4277 | 		} | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4278 | 	} | 
 | 4279 | 	snd_array_free(&spec->jacks); | 
| Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4280 | #endif | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4281 | } | 
 | 4282 |  | 
| Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4283 | static void stac92xx_free_kctls(struct hda_codec *codec) | 
 | 4284 | { | 
 | 4285 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4286 |  | 
 | 4287 | 	if (spec->kctls.list) { | 
 | 4288 | 		struct snd_kcontrol_new *kctl = spec->kctls.list; | 
 | 4289 | 		int i; | 
 | 4290 | 		for (i = 0; i < spec->kctls.used; i++) | 
 | 4291 | 			kfree(kctl[i].name); | 
 | 4292 | 	} | 
 | 4293 | 	snd_array_free(&spec->kctls); | 
 | 4294 | } | 
 | 4295 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4296 | static void stac92xx_free(struct hda_codec *codec) | 
 | 4297 | { | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4298 | 	struct sigmatel_spec *spec = codec->spec; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4299 |  | 
 | 4300 | 	if (! spec) | 
 | 4301 | 		return; | 
 | 4302 |  | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4303 | 	stac92xx_free_jacks(codec); | 
 | 4304 | 	snd_array_free(&spec->events); | 
| Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4305 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4306 | 	kfree(spec); | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4307 | 	snd_hda_detach_beep_device(codec); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4308 | } | 
 | 4309 |  | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4310 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | 
 | 4311 | 				unsigned int flag) | 
 | 4312 | { | 
| Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4313 | 	unsigned int old_ctl, pin_ctl; | 
 | 4314 |  | 
 | 4315 | 	pin_ctl = snd_hda_codec_read(codec, nid, | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4316 | 			0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4317 |  | 
| Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4318 | 	if (pin_ctl & AC_PINCTL_IN_EN) { | 
 | 4319 | 		/* | 
 | 4320 | 		 * we need to check the current set-up direction of | 
 | 4321 | 		 * shared input pins since they can be switched via | 
 | 4322 | 		 * "xxx as Output" mixer switch | 
 | 4323 | 		 */ | 
 | 4324 | 		struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4325 | 		if (nid == spec->line_switch || nid == spec->mic_switch) | 
| Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4326 | 			return; | 
 | 4327 | 	} | 
 | 4328 |  | 
| Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4329 | 	old_ctl = pin_ctl; | 
| Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4330 | 	/* if setting pin direction bits, clear the current | 
 | 4331 | 	   direction bits first */ | 
 | 4332 | 	if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) | 
 | 4333 | 		pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | 
 | 4334 | 	 | 
| Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4335 | 	pin_ctl |= flag; | 
 | 4336 | 	if (old_ctl != pin_ctl) | 
 | 4337 | 		snd_hda_codec_write_cache(codec, nid, 0, | 
 | 4338 | 					  AC_VERB_SET_PIN_WIDGET_CONTROL, | 
 | 4339 | 					  pin_ctl); | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4340 | } | 
 | 4341 |  | 
 | 4342 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | 
 | 4343 | 				  unsigned int flag) | 
 | 4344 | { | 
 | 4345 | 	unsigned int pin_ctl = snd_hda_codec_read(codec, nid, | 
 | 4346 | 			0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); | 
| Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 4347 | 	if (pin_ctl & flag) | 
 | 4348 | 		snd_hda_codec_write_cache(codec, nid, 0, | 
 | 4349 | 					  AC_VERB_SET_PIN_WIDGET_CONTROL, | 
 | 4350 | 					  pin_ctl & ~flag); | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4351 | } | 
 | 4352 |  | 
| Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4353 | 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] | 4354 | { | 
 | 4355 | 	if (!nid) | 
 | 4356 | 		return 0; | 
 | 4357 | 	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] | 4358 | 	    & (1 << 31)) | 
 | 4359 | 		return 1; | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4360 | 	return 0; | 
 | 4361 | } | 
 | 4362 |  | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4363 | static void stac92xx_line_out_detect(struct hda_codec *codec, | 
 | 4364 | 				     int presence) | 
 | 4365 | { | 
 | 4366 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4367 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 4368 | 	int i; | 
 | 4369 |  | 
 | 4370 | 	for (i = 0; i < cfg->line_outs; i++) { | 
 | 4371 | 		if (presence) | 
 | 4372 | 			break; | 
 | 4373 | 		presence = get_pin_presence(codec, cfg->line_out_pins[i]); | 
 | 4374 | 		if (presence) { | 
 | 4375 | 			unsigned int pinctl; | 
 | 4376 | 			pinctl = snd_hda_codec_read(codec, | 
 | 4377 | 						    cfg->line_out_pins[i], 0, | 
 | 4378 | 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 
 | 4379 | 			if (pinctl & AC_PINCTL_IN_EN) | 
 | 4380 | 				presence = 0; /* mic- or line-input */ | 
 | 4381 | 		} | 
 | 4382 | 	} | 
 | 4383 |  | 
 | 4384 | 	if (presence) { | 
 | 4385 | 		/* disable speakers */ | 
 | 4386 | 		for (i = 0; i < cfg->speaker_outs; i++) | 
 | 4387 | 			stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], | 
 | 4388 | 						AC_PINCTL_OUT_EN); | 
 | 4389 | 		if (spec->eapd_mask && spec->eapd_switch) | 
 | 4390 | 			stac_gpio_set(codec, spec->gpio_mask, | 
 | 4391 | 				spec->gpio_dir, spec->gpio_data & | 
 | 4392 | 				~spec->eapd_mask); | 
 | 4393 | 	} else { | 
 | 4394 | 		/* enable speakers */ | 
 | 4395 | 		for (i = 0; i < cfg->speaker_outs; i++) | 
 | 4396 | 			stac92xx_set_pinctl(codec, cfg->speaker_pins[i], | 
 | 4397 | 						AC_PINCTL_OUT_EN); | 
 | 4398 | 		if (spec->eapd_mask && spec->eapd_switch) | 
 | 4399 | 			stac_gpio_set(codec, spec->gpio_mask, | 
 | 4400 | 				spec->gpio_dir, spec->gpio_data | | 
 | 4401 | 				spec->eapd_mask); | 
 | 4402 | 	} | 
 | 4403 | }  | 
 | 4404 |  | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4405 | /* return non-zero if the hp-pin of the given array index isn't | 
 | 4406 |  * a jack-detection target | 
 | 4407 |  */ | 
 | 4408 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) | 
 | 4409 | { | 
 | 4410 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 4411 |  | 
 | 4412 | 	/* ignore sensing of shared line and mic jacks */ | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4413 | 	if (cfg->hp_pins[i] == spec->line_switch) | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4414 | 		return 1; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4415 | 	if (cfg->hp_pins[i] == spec->mic_switch) | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4416 | 		return 1; | 
 | 4417 | 	/* ignore if the pin is set as line-out */ | 
 | 4418 | 	if (cfg->hp_pins[i] == spec->hp_switch) | 
 | 4419 | 		return 1; | 
 | 4420 | 	return 0; | 
 | 4421 | } | 
 | 4422 |  | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4423 | static void stac92xx_hp_detect(struct hda_codec *codec) | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4424 | { | 
 | 4425 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4426 | 	struct auto_pin_cfg *cfg = &spec->autocfg; | 
 | 4427 | 	int i, presence; | 
 | 4428 |  | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4429 | 	presence = 0; | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4430 | 	if (spec->gpio_mute) | 
 | 4431 | 		presence = !(snd_hda_codec_read(codec, codec->afg, 0, | 
 | 4432 | 			AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); | 
 | 4433 |  | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4434 | 	for (i = 0; i < cfg->hp_outs; i++) { | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4435 | 		if (presence) | 
 | 4436 | 			break; | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4437 | 		if (no_hp_sensing(spec, i)) | 
 | 4438 | 			continue; | 
| Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4439 | 		presence = get_pin_presence(codec, cfg->hp_pins[i]); | 
 | 4440 | 		if (presence) { | 
 | 4441 | 			unsigned int pinctl; | 
 | 4442 | 			pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, | 
 | 4443 | 					    AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 
 | 4444 | 			if (pinctl & AC_PINCTL_IN_EN) | 
 | 4445 | 				presence = 0; /* mic- or line-input */ | 
 | 4446 | 		} | 
| Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4447 | 	} | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4448 |  | 
 | 4449 | 	if (presence) { | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4450 | 		/* disable lineouts */ | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4451 | 		if (spec->hp_switch) | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4452 | 			stac92xx_reset_pinctl(codec, spec->hp_switch, | 
 | 4453 | 					      AC_PINCTL_OUT_EN); | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4454 | 		for (i = 0; i < cfg->line_outs; i++) | 
 | 4455 | 			stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], | 
 | 4456 | 						AC_PINCTL_OUT_EN); | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4457 | 	} else { | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4458 | 		/* enable lineouts */ | 
| Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4459 | 		if (spec->hp_switch) | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4460 | 			stac92xx_set_pinctl(codec, spec->hp_switch, | 
 | 4461 | 					    AC_PINCTL_OUT_EN); | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4462 | 		for (i = 0; i < cfg->line_outs; i++) | 
 | 4463 | 			stac92xx_set_pinctl(codec, cfg->line_out_pins[i], | 
 | 4464 | 						AC_PINCTL_OUT_EN); | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4465 | 	} | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4466 | 	stac92xx_line_out_detect(codec, presence); | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4467 | 	/* toggle hp outs */ | 
 | 4468 | 	for (i = 0; i < cfg->hp_outs; i++) { | 
 | 4469 | 		unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; | 
 | 4470 | 		if (no_hp_sensing(spec, i)) | 
 | 4471 | 			continue; | 
 | 4472 | 		if (presence) | 
 | 4473 | 			stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); | 
| Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4474 | #if 0 /* FIXME */ | 
 | 4475 | /* Resetting the pinctl like below may lead to (a sort of) regressions | 
 | 4476 |  * on some devices since they use the HP pin actually for line/speaker | 
 | 4477 |  * outs although the default pin config shows a different pin (that is | 
 | 4478 |  * wrong and useless). | 
 | 4479 |  * | 
 | 4480 |  * So, it's basically a problem of default pin configs, likely a BIOS issue. | 
 | 4481 |  * But, disabling the code below just works around it, and I'm too tired of | 
 | 4482 |  * bug reports with such devices...  | 
 | 4483 |  */ | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4484 | 		else | 
 | 4485 | 			stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); | 
| Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 4486 | #endif /* FIXME */ | 
| Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4487 | 	} | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4488 | }  | 
 | 4489 |  | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4490 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, | 
 | 4491 | 				  int enable) | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4492 | { | 
 | 4493 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4494 | 	unsigned int idx, val; | 
 | 4495 |  | 
 | 4496 | 	for (idx = 0; idx < spec->num_pwrs; idx++) { | 
 | 4497 | 		if (spec->pwr_nids[idx] == nid) | 
 | 4498 | 			break; | 
 | 4499 | 	} | 
 | 4500 | 	if (idx >= spec->num_pwrs) | 
 | 4501 | 		return; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4502 |  | 
 | 4503 | 	/* several codecs have two power down bits */ | 
 | 4504 | 	if (spec->pwr_mapping) | 
 | 4505 | 		idx = spec->pwr_mapping[idx]; | 
 | 4506 | 	else | 
 | 4507 | 		idx = 1 << idx; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4508 |  | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4509 | 	val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; | 
 | 4510 | 	if (enable) | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4511 | 		val &= ~idx; | 
 | 4512 | 	else | 
 | 4513 | 		val |= idx; | 
 | 4514 |  | 
 | 4515 | 	/* power down unused output ports */ | 
 | 4516 | 	snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4517 | } | 
 | 4518 |  | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4519 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) | 
 | 4520 | { | 
| Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4521 | 	stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); | 
| Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4522 | } | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4523 |  | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4524 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) | 
 | 4525 | { | 
 | 4526 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4527 | 	struct sigmatel_jack *jacks = spec->jacks.list; | 
 | 4528 |  | 
 | 4529 | 	if (jacks) { | 
 | 4530 | 		int i; | 
 | 4531 | 		for (i = 0; i < spec->jacks.used; i++) { | 
 | 4532 | 			if (jacks->nid == nid) { | 
 | 4533 | 				unsigned int pin_ctl = | 
 | 4534 | 					snd_hda_codec_read(codec, nid, | 
 | 4535 | 					0, AC_VERB_GET_PIN_WIDGET_CONTROL, | 
 | 4536 | 					 0x00); | 
 | 4537 | 				int type = jacks->type; | 
 | 4538 | 				if (type == (SND_JACK_LINEOUT | 
 | 4539 | 						| SND_JACK_HEADPHONE)) | 
 | 4540 | 					type = (pin_ctl & AC_PINCTL_HP_EN) | 
 | 4541 | 					? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; | 
 | 4542 | 				snd_jack_report(jacks->jack, | 
| Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 4543 | 					get_pin_presence(codec, nid) | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4544 | 					? type : 0); | 
 | 4545 | 			} | 
 | 4546 | 			jacks++; | 
 | 4547 | 		} | 
 | 4548 | 	} | 
 | 4549 | } | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4550 |  | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4551 | static void stac92xx_mic_detect(struct hda_codec *codec) | 
 | 4552 | { | 
 | 4553 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4554 | 	struct sigmatel_mic_route *mic; | 
 | 4555 |  | 
 | 4556 | 	if (get_pin_presence(codec, spec->ext_mic.pin)) | 
 | 4557 | 		mic = &spec->ext_mic; | 
 | 4558 | 	else | 
 | 4559 | 		mic = &spec->int_mic; | 
 | 4560 | 	if (mic->dmux_idx) | 
 | 4561 | 		snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, | 
 | 4562 | 					  AC_VERB_SET_CONNECT_SEL, | 
 | 4563 | 					  mic->dmux_idx); | 
 | 4564 | 	else | 
 | 4565 | 		snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, | 
 | 4566 | 					  AC_VERB_SET_CONNECT_SEL, | 
 | 4567 | 					  mic->mux_idx); | 
 | 4568 | } | 
 | 4569 |  | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4570 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4571 | { | 
| Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 4572 | 	struct sigmatel_event *event = stac_get_event(codec, nid); | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4573 | 	if (!event) | 
 | 4574 | 		return; | 
 | 4575 | 	codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); | 
 | 4576 | } | 
 | 4577 |  | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4578 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | 
 | 4579 | { | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4580 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4581 | 	struct sigmatel_event *event; | 
 | 4582 | 	int tag, data; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4583 |  | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4584 | 	tag = (res >> 26) & 0x7f; | 
 | 4585 | 	event = stac_get_event_from_tag(codec, tag); | 
 | 4586 | 	if (!event) | 
 | 4587 | 		return; | 
 | 4588 |  | 
 | 4589 | 	switch (event->type) { | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4590 | 	case STAC_HP_EVENT: | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4591 | 	case STAC_LO_EVENT: | 
| Takashi Iwai | 16ffe32 | 2009-08-04 13:40:54 +0200 | [diff] [blame] | 4592 | 		stac92xx_hp_detect(codec); | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4593 | 		break; | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4594 | 	case STAC_MIC_EVENT: | 
 | 4595 | 		stac92xx_mic_detect(codec); | 
 | 4596 | 		break; | 
 | 4597 | 	} | 
 | 4598 |  | 
 | 4599 | 	switch (event->type) { | 
 | 4600 | 	case STAC_HP_EVENT: | 
| Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 4601 | 	case STAC_LO_EVENT: | 
| Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4602 | 	case STAC_MIC_EVENT: | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4603 | 	case STAC_INSERT_EVENT: | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4604 | 	case STAC_PWR_EVENT: | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4605 | 		if (spec->num_pwrs > 0) | 
 | 4606 | 			stac92xx_pin_sense(codec, event->nid); | 
 | 4607 | 		stac92xx_report_jack(codec, event->nid); | 
| Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 4608 |  | 
 | 4609 | 		switch (codec->subsystem_id) { | 
 | 4610 | 		case 0x103c308f: | 
 | 4611 | 			if (event->nid == 0xb) { | 
 | 4612 | 				int pin = AC_PINCTL_IN_EN; | 
 | 4613 |  | 
 | 4614 | 				if (get_pin_presence(codec, 0xa) | 
 | 4615 | 						&& get_pin_presence(codec, 0xb)) | 
 | 4616 | 					pin |= AC_PINCTL_VREF_80; | 
 | 4617 | 				if (!get_pin_presence(codec, 0xb)) | 
 | 4618 | 					pin |= AC_PINCTL_VREF_80; | 
 | 4619 |  | 
 | 4620 | 				/* toggle VREF state based on mic + hp pin | 
 | 4621 | 				 * status | 
 | 4622 | 				 */ | 
 | 4623 | 				stac92xx_auto_set_pinctl(codec, 0x0a, pin); | 
 | 4624 | 			} | 
 | 4625 | 		} | 
| Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4626 | 		break; | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4627 | 	case STAC_VREF_EVENT: | 
 | 4628 | 		data = snd_hda_codec_read(codec, codec->afg, 0, | 
 | 4629 | 					  AC_VERB_GET_GPIO_DATA, 0); | 
| Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4630 | 		/* toggle VREF state based on GPIOx status */ | 
 | 4631 | 		snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4632 | 				    !!(data & (1 << event->data))); | 
| Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4633 | 		break; | 
| Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4634 | 	} | 
 | 4635 | } | 
 | 4636 |  | 
| Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 4637 | #ifdef CONFIG_PROC_FS | 
 | 4638 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, | 
 | 4639 | 			       struct hda_codec *codec, hda_nid_t nid) | 
 | 4640 | { | 
 | 4641 | 	if (nid == codec->afg) | 
 | 4642 | 		snd_iprintf(buffer, "Power-Map: 0x%02x\n",  | 
 | 4643 | 			    snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); | 
 | 4644 | } | 
 | 4645 |  | 
 | 4646 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, | 
 | 4647 | 				  struct hda_codec *codec, | 
 | 4648 | 				  unsigned int verb) | 
 | 4649 | { | 
 | 4650 | 	snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", | 
 | 4651 | 		    snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); | 
 | 4652 | } | 
 | 4653 |  | 
 | 4654 | /* stac92hd71bxx, stac92hd73xx */ | 
 | 4655 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, | 
 | 4656 | 				 struct hda_codec *codec, hda_nid_t nid) | 
 | 4657 | { | 
 | 4658 | 	stac92hd_proc_hook(buffer, codec, nid); | 
 | 4659 | 	if (nid == codec->afg) | 
 | 4660 | 		analog_loop_proc_hook(buffer, codec, 0xfa0); | 
 | 4661 | } | 
 | 4662 |  | 
 | 4663 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, | 
 | 4664 | 			       struct hda_codec *codec, hda_nid_t nid) | 
 | 4665 | { | 
 | 4666 | 	if (nid == codec->afg) | 
 | 4667 | 		analog_loop_proc_hook(buffer, codec, 0xfe0); | 
 | 4668 | } | 
 | 4669 |  | 
 | 4670 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, | 
 | 4671 | 			       struct hda_codec *codec, hda_nid_t nid) | 
 | 4672 | { | 
 | 4673 | 	if (nid == codec->afg) | 
 | 4674 | 		analog_loop_proc_hook(buffer, codec, 0xfeb); | 
 | 4675 | } | 
 | 4676 | #else | 
 | 4677 | #define stac92hd_proc_hook	NULL | 
 | 4678 | #define stac92hd7x_proc_hook	NULL | 
 | 4679 | #define stac9205_proc_hook	NULL | 
 | 4680 | #define stac927x_proc_hook	NULL | 
 | 4681 | #endif | 
 | 4682 |  | 
| Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4683 | #ifdef SND_HDA_NEEDS_RESUME | 
| Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4684 | static int stac92xx_resume(struct hda_codec *codec) | 
 | 4685 | { | 
| Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4686 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 4687 |  | 
| Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4688 | 	stac92xx_init(codec); | 
| Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4689 | 	snd_hda_codec_resume_amp(codec); | 
 | 4690 | 	snd_hda_codec_resume_cache(codec); | 
| Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4691 | 	/* fake event to set up pins again to override cached values */ | 
| Takashi Iwai | 5f380eb | 2009-09-14 15:36:14 +0200 | [diff] [blame] | 4692 | 	if (spec->hp_detect) { | 
 | 4693 | 		if (spec->autocfg.hp_pins[0]) | 
 | 4694 | 			stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]); | 
 | 4695 | 		else if (spec->autocfg.line_out_pins[0]) | 
 | 4696 | 			stac_issue_unsol_event(codec, | 
 | 4697 | 					       spec->autocfg.line_out_pins[0]); | 
 | 4698 | 	} | 
| Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4699 | 	return 0; | 
 | 4700 | } | 
| Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4701 |  | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4702 | /* | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4703 |  * using power check for controlling mute led of HP notebooks | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4704 |  * check for mute state only on Speakers (nid = 0x10) | 
 | 4705 |  * | 
 | 4706 |  * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise | 
 | 4707 |  * the LED is NOT working properly ! | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4708 |  * | 
 | 4709 |  * Changed name to reflect that it now works for any designated | 
 | 4710 |  * model, not just HP HDX. | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4711 |  */ | 
 | 4712 |  | 
 | 4713 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 4714 | static int stac92xx_hp_check_power_status(struct hda_codec *codec, | 
| Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4715 | 					      hda_nid_t nid) | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4716 | { | 
 | 4717 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4718 |  | 
 | 4719 | 	if (nid == 0x10) { | 
 | 4720 | 		if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) & | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4721 | 		    HDA_AMP_MUTE) | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 4722 | 			spec->gpio_data &= ~spec->gpio_led; /* orange */ | 
| Takashi Iwai | ba84bfc | 2009-05-30 08:59:03 +0200 | [diff] [blame] | 4723 | 		else | 
 | 4724 | 			spec->gpio_data |= spec->gpio_led; /* white */ | 
| Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 4725 |  | 
 | 4726 | 		stac_gpio_set(codec, spec->gpio_mask, | 
 | 4727 | 			      spec->gpio_dir, | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 4728 | 			      spec->gpio_data); | 
 | 4729 | 	} | 
 | 4730 |  | 
 | 4731 | 	return 0; | 
 | 4732 | } | 
 | 4733 | #endif | 
 | 4734 |  | 
| Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4735 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) | 
 | 4736 | { | 
 | 4737 | 	struct sigmatel_spec *spec = codec->spec; | 
| Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4738 | 	int i; | 
 | 4739 | 	hda_nid_t nid; | 
 | 4740 |  | 
 | 4741 | 	/* reset each pin before powering down DAC/ADC to avoid click noise */ | 
 | 4742 | 	nid = codec->start_nid; | 
 | 4743 | 	for (i = 0; i < codec->num_nodes; i++, nid++) { | 
 | 4744 | 		unsigned int wcaps = get_wcaps(codec, nid); | 
| Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 4745 | 		unsigned int wid_type = get_wcaps_type(wcaps); | 
| Takashi Iwai | 05ff7e1 | 2009-07-22 12:39:24 +0200 | [diff] [blame] | 4746 | 		if (wid_type == AC_WID_PIN) | 
 | 4747 | 			snd_hda_codec_read(codec, nid, 0, | 
 | 4748 | 				AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | 
 | 4749 | 	} | 
 | 4750 |  | 
| Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4751 | 	if (spec->eapd_mask) | 
 | 4752 | 		stac_gpio_set(codec, spec->gpio_mask, | 
 | 4753 | 				spec->gpio_dir, spec->gpio_data & | 
 | 4754 | 				~spec->eapd_mask); | 
 | 4755 | 	return 0; | 
 | 4756 | } | 
| Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4757 | #endif | 
 | 4758 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4759 | static struct hda_codec_ops stac92xx_patch_ops = { | 
 | 4760 | 	.build_controls = stac92xx_build_controls, | 
 | 4761 | 	.build_pcms = stac92xx_build_pcms, | 
 | 4762 | 	.init = stac92xx_init, | 
 | 4763 | 	.free = stac92xx_free, | 
| Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4764 | 	.unsol_event = stac92xx_unsol_event, | 
| Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4765 | #ifdef SND_HDA_NEEDS_RESUME | 
| Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4766 | 	.suspend = stac92xx_suspend, | 
| Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4767 | 	.resume = stac92xx_resume, | 
 | 4768 | #endif | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4769 | }; | 
 | 4770 |  | 
 | 4771 | static int patch_stac9200(struct hda_codec *codec) | 
 | 4772 | { | 
 | 4773 | 	struct sigmatel_spec *spec; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4774 | 	int err; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4775 |  | 
| Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4776 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4777 | 	if (spec == NULL) | 
 | 4778 | 		return -ENOMEM; | 
 | 4779 |  | 
 | 4780 | 	codec->spec = spec; | 
| Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4781 | 	spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); | 
| Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4782 | 	spec->pin_nids = stac9200_pin_nids; | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4783 | 	spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, | 
 | 4784 | 							stac9200_models, | 
 | 4785 | 							stac9200_cfg_tbl); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4786 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4787 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 4788 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4789 | 	else | 
 | 4790 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4791 | 					 stac9200_brd_tbl[spec->board_config]); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4792 |  | 
 | 4793 | 	spec->multiout.max_channels = 2; | 
 | 4794 | 	spec->multiout.num_dacs = 1; | 
 | 4795 | 	spec->multiout.dac_nids = stac9200_dac_nids; | 
 | 4796 | 	spec->adc_nids = stac9200_adc_nids; | 
 | 4797 | 	spec->mux_nids = stac9200_mux_nids; | 
| Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4798 | 	spec->num_muxes = 1; | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4799 | 	spec->num_dmics = 0; | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4800 | 	spec->num_adcs = 1; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4801 | 	spec->num_pwrs = 0; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4802 |  | 
| Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4803 | 	if (spec->board_config == STAC_9200_M4 || | 
 | 4804 | 	    spec->board_config == STAC_9200_M4_2 || | 
| Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4805 | 	    spec->board_config == STAC_9200_OQO) | 
| Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4806 | 		spec->init = stac9200_eapd_init; | 
 | 4807 | 	else | 
 | 4808 | 		spec->init = stac9200_core_init; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4809 | 	spec->mixer = stac9200_mixer; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4810 |  | 
| Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4811 | 	if (spec->board_config == STAC_9200_PANASONIC) { | 
 | 4812 | 		spec->gpio_mask = spec->gpio_dir = 0x09; | 
 | 4813 | 		spec->gpio_data = 0x00; | 
 | 4814 | 	} | 
 | 4815 |  | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4816 | 	err = stac9200_parse_auto_config(codec); | 
 | 4817 | 	if (err < 0) { | 
 | 4818 | 		stac92xx_free(codec); | 
 | 4819 | 		return err; | 
 | 4820 | 	} | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4821 |  | 
| Takashi Iwai | 2acc9dc | 2009-01-09 16:57:14 +0100 | [diff] [blame] | 4822 | 	/* CF-74 has no headphone detection, and the driver should *NOT* | 
 | 4823 | 	 * do detection and HP/speaker toggle because the hardware does it. | 
 | 4824 | 	 */ | 
 | 4825 | 	if (spec->board_config == STAC_9200_PANASONIC) | 
 | 4826 | 		spec->hp_detect = 0; | 
 | 4827 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4828 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 4829 |  | 
 | 4830 | 	return 0; | 
 | 4831 | } | 
 | 4832 |  | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4833 | static int patch_stac925x(struct hda_codec *codec) | 
 | 4834 | { | 
 | 4835 | 	struct sigmatel_spec *spec; | 
 | 4836 | 	int err; | 
 | 4837 |  | 
 | 4838 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 4839 | 	if (spec == NULL) | 
 | 4840 | 		return -ENOMEM; | 
 | 4841 |  | 
 | 4842 | 	codec->spec = spec; | 
| Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4843 | 	spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4844 | 	spec->pin_nids = stac925x_pin_nids; | 
| Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 4845 |  | 
 | 4846 | 	/* Check first for codec ID */ | 
 | 4847 | 	spec->board_config = snd_hda_check_board_codec_sid_config(codec, | 
 | 4848 | 							STAC_925x_MODELS, | 
 | 4849 | 							stac925x_models, | 
 | 4850 | 							stac925x_codec_id_cfg_tbl); | 
 | 4851 |  | 
 | 4852 | 	/* Now checks for PCI ID, if codec ID is not found */ | 
 | 4853 | 	if (spec->board_config < 0) | 
 | 4854 | 		spec->board_config = snd_hda_check_board_config(codec, | 
 | 4855 | 							STAC_925x_MODELS, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4856 | 							stac925x_models, | 
 | 4857 | 							stac925x_cfg_tbl); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4858 |  again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4859 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4860 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 4861 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4862 | 	else | 
 | 4863 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4864 | 					 stac925x_brd_tbl[spec->board_config]); | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4865 |  | 
 | 4866 | 	spec->multiout.max_channels = 2; | 
 | 4867 | 	spec->multiout.num_dacs = 1; | 
 | 4868 | 	spec->multiout.dac_nids = stac925x_dac_nids; | 
 | 4869 | 	spec->adc_nids = stac925x_adc_nids; | 
 | 4870 | 	spec->mux_nids = stac925x_mux_nids; | 
 | 4871 | 	spec->num_muxes = 1; | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4872 | 	spec->num_adcs = 1; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4873 | 	spec->num_pwrs = 0; | 
| Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4874 | 	switch (codec->vendor_id) { | 
 | 4875 | 	case 0x83847632: /* STAC9202  */ | 
 | 4876 | 	case 0x83847633: /* STAC9202D */ | 
 | 4877 | 	case 0x83847636: /* STAC9251  */ | 
 | 4878 | 	case 0x83847637: /* STAC9251D */ | 
| Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4879 | 		spec->num_dmics = STAC925X_NUM_DMICS; | 
| Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4880 | 		spec->dmic_nids = stac925x_dmic_nids; | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4881 | 		spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); | 
 | 4882 | 		spec->dmux_nids = stac925x_dmux_nids; | 
| Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4883 | 		break; | 
 | 4884 | 	default: | 
 | 4885 | 		spec->num_dmics = 0; | 
 | 4886 | 		break; | 
 | 4887 | 	} | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4888 |  | 
 | 4889 | 	spec->init = stac925x_core_init; | 
 | 4890 | 	spec->mixer = stac925x_mixer; | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4891 | 	spec->num_caps = 1; | 
 | 4892 | 	spec->capvols = stac925x_capvols; | 
 | 4893 | 	spec->capsws = stac925x_capsws; | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4894 |  | 
 | 4895 | 	err = stac92xx_parse_auto_config(codec, 0x8, 0x7); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4896 | 	if (!err) { | 
 | 4897 | 		if (spec->board_config < 0) { | 
 | 4898 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 4899 | 			       "available, default to model=ref\n"); | 
 | 4900 | 			spec->board_config = STAC_925x_REF; | 
 | 4901 | 			goto again; | 
 | 4902 | 		} | 
 | 4903 | 		err = -EINVAL; | 
 | 4904 | 	} | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4905 | 	if (err < 0) { | 
 | 4906 | 		stac92xx_free(codec); | 
 | 4907 | 		return err; | 
 | 4908 | 	} | 
 | 4909 |  | 
 | 4910 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 4911 |  | 
 | 4912 | 	return 0; | 
 | 4913 | } | 
 | 4914 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4915 | static int patch_stac92hd73xx(struct hda_codec *codec) | 
 | 4916 | { | 
 | 4917 | 	struct sigmatel_spec *spec; | 
 | 4918 | 	hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; | 
 | 4919 | 	int err = 0; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4920 | 	int num_dacs; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4921 |  | 
 | 4922 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 4923 | 	if (spec == NULL) | 
 | 4924 | 		return -ENOMEM; | 
 | 4925 |  | 
 | 4926 | 	codec->spec = spec; | 
| Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4927 | 	codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4928 | 	spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); | 
 | 4929 | 	spec->pin_nids = stac92hd73xx_pin_nids; | 
 | 4930 | 	spec->board_config = snd_hda_check_board_config(codec, | 
 | 4931 | 							STAC_92HD73XX_MODELS, | 
 | 4932 | 							stac92hd73xx_models, | 
 | 4933 | 							stac92hd73xx_cfg_tbl); | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 4934 | 	/* check codec subsystem id if not found */ | 
 | 4935 | 	if (spec->board_config < 0) | 
 | 4936 | 		spec->board_config = | 
 | 4937 | 			snd_hda_check_board_codec_sid_config(codec, | 
 | 4938 | 				STAC_92HD73XX_MODELS, stac92hd73xx_models, | 
 | 4939 | 				stac92hd73xx_codec_id_cfg_tbl); | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4940 | again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4941 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 4942 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 4943 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 4944 | 	else | 
 | 4945 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4946 | 				stac92hd73xx_brd_tbl[spec->board_config]); | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4947 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4948 | 	num_dacs = snd_hda_get_connections(codec, 0x0a, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4949 | 			conn, STAC92HD73_DAC_COUNT + 2) - 1; | 
 | 4950 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4951 | 	if (num_dacs < 3 || num_dacs > 5) { | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4952 | 		printk(KERN_WARNING "hda_codec: Could not determine " | 
 | 4953 | 		       "number of channels defaulting to DAC count\n"); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4954 | 		num_dacs = STAC92HD73_DAC_COUNT; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4955 | 	} | 
| Takashi Iwai | e2aec17 | 2009-09-02 01:00:05 +0200 | [diff] [blame] | 4956 | 	spec->init = stac92hd73xx_core_init; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4957 | 	switch (num_dacs) { | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4958 | 	case 0x3: /* 6 Channel */ | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4959 | 		spec->aloopback_ctl = stac92hd73xx_6ch_loopback; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4960 | 		break; | 
 | 4961 | 	case 0x4: /* 8 Channel */ | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4962 | 		spec->aloopback_ctl = stac92hd73xx_8ch_loopback; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4963 | 		break; | 
 | 4964 | 	case 0x5: /* 10 Channel */ | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 4965 | 		spec->aloopback_ctl = stac92hd73xx_10ch_loopback; | 
 | 4966 | 		break; | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4967 | 	} | 
 | 4968 | 	spec->multiout.dac_nids = spec->dac_nids; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4969 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4970 | 	spec->aloopback_mask = 0x01; | 
 | 4971 | 	spec->aloopback_shift = 8; | 
 | 4972 |  | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4973 | 	spec->digbeep_nid = 0x1c; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4974 | 	spec->mux_nids = stac92hd73xx_mux_nids; | 
 | 4975 | 	spec->adc_nids = stac92hd73xx_adc_nids; | 
 | 4976 | 	spec->dmic_nids = stac92hd73xx_dmic_nids; | 
 | 4977 | 	spec->dmux_nids = stac92hd73xx_dmux_nids; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4978 | 	spec->smux_nids = stac92hd73xx_smux_nids; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4979 |  | 
 | 4980 | 	spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); | 
 | 4981 | 	spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4982 | 	spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); | 
| Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4983 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4984 | 	spec->num_caps = STAC92HD73XX_NUM_CAPS; | 
 | 4985 | 	spec->capvols = stac92hd73xx_capvols; | 
 | 4986 | 	spec->capsws = stac92hd73xx_capsws; | 
 | 4987 |  | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4988 | 	switch (spec->board_config) { | 
| Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4989 | 	case STAC_DELL_EQ: | 
| Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4990 | 		spec->init = dell_eq_core_init; | 
| Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4991 | 		/* fallthru */ | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4992 | 	case STAC_DELL_M6_AMIC: | 
 | 4993 | 	case STAC_DELL_M6_DMIC: | 
 | 4994 | 	case STAC_DELL_M6_BOTH: | 
| Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4995 | 		spec->num_smuxes = 0; | 
| Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4996 | 		spec->eapd_switch = 0; | 
| Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4997 |  | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4998 | 		switch (spec->board_config) { | 
 | 4999 | 		case STAC_DELL_M6_AMIC: /* Analog Mics */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5000 | 			snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5001 | 			spec->num_dmics = 0; | 
 | 5002 | 			break; | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5003 | 		case STAC_DELL_M6_DMIC: /* Digital Mics */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5004 | 			snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5005 | 			spec->num_dmics = 1; | 
 | 5006 | 			break; | 
| Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 5007 | 		case STAC_DELL_M6_BOTH: /* Both */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5008 | 			snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); | 
 | 5009 | 			snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5010 | 			spec->num_dmics = 1; | 
 | 5011 | 			break; | 
 | 5012 | 		} | 
 | 5013 | 		break; | 
| Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 5014 | 	case STAC_ALIENWARE_M17X: | 
 | 5015 | 		spec->num_dmics = STAC92HD73XX_NUM_DMICS; | 
 | 5016 | 		spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); | 
 | 5017 | 		spec->eapd_switch = 0; | 
 | 5018 | 		break; | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5019 | 	default: | 
 | 5020 | 		spec->num_dmics = STAC92HD73XX_NUM_DMICS; | 
| Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5021 | 		spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); | 
| Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5022 | 		spec->eapd_switch = 1; | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5023 | 		break; | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5024 | 	} | 
| Takashi Iwai | af6ee30 | 2009-09-14 15:03:12 +0200 | [diff] [blame] | 5025 | 	if (spec->board_config != STAC_92HD73XX_REF) { | 
| Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5026 | 		/* GPIO0 High = Enable EAPD */ | 
 | 5027 | 		spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | 
 | 5028 | 		spec->gpio_data = 0x01; | 
 | 5029 | 	} | 
| Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 5030 |  | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5031 | 	spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); | 
 | 5032 | 	spec->pwr_nids = stac92hd73xx_pwr_nids; | 
 | 5033 |  | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5034 | 	err = stac92xx_parse_auto_config(codec, 0x25, 0x27); | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5035 |  | 
 | 5036 | 	if (!err) { | 
 | 5037 | 		if (spec->board_config < 0) { | 
 | 5038 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 5039 | 			       "available, default to model=ref\n"); | 
 | 5040 | 			spec->board_config = STAC_92HD73XX_REF; | 
 | 5041 | 			goto again; | 
 | 5042 | 		} | 
 | 5043 | 		err = -EINVAL; | 
 | 5044 | 	} | 
 | 5045 |  | 
 | 5046 | 	if (err < 0) { | 
 | 5047 | 		stac92xx_free(codec); | 
 | 5048 | 		return err; | 
 | 5049 | 	} | 
 | 5050 |  | 
| Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 5051 | 	if (spec->board_config == STAC_92HD73XX_NO_JD) | 
 | 5052 | 		spec->hp_detect = 0; | 
 | 5053 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5054 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 5055 |  | 
| Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5056 | 	codec->proc_widget_hook = stac92hd7x_proc_hook; | 
 | 5057 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5058 | 	return 0; | 
 | 5059 | } | 
 | 5060 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5061 | static int patch_stac92hd83xxx(struct hda_codec *codec) | 
 | 5062 | { | 
 | 5063 | 	struct sigmatel_spec *spec; | 
| Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5064 | 	hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5065 | 	int err; | 
| Matthew Ranostay | 65557f3 | 2009-01-20 16:50:25 -0500 | [diff] [blame] | 5066 | 	int num_dacs; | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5067 | 	hda_nid_t nid; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5068 |  | 
 | 5069 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 5070 | 	if (spec == NULL) | 
 | 5071 | 		return -ENOMEM; | 
 | 5072 |  | 
 | 5073 | 	codec->spec = spec; | 
| Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5074 | 	codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5075 | 	spec->digbeep_nid = 0x21; | 
| Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5076 | 	spec->mux_nids = stac92hd83xxx_mux_nids; | 
 | 5077 | 	spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5078 | 	spec->adc_nids = stac92hd83xxx_adc_nids; | 
| Takashi Iwai | 7570ef1 | 2009-08-15 11:57:53 +0200 | [diff] [blame] | 5079 | 	spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5080 | 	spec->pwr_nids = stac92hd83xxx_pwr_nids; | 
 | 5081 | 	spec->pwr_mapping = stac92hd83xxx_pwr_mapping; | 
 | 5082 | 	spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5083 | 	spec->multiout.dac_nids = spec->dac_nids; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5084 |  | 
 | 5085 | 	spec->init = stac92hd83xxx_core_init; | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5086 | 	spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5087 | 	spec->pin_nids = stac92hd83xxx_pin_nids; | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5088 | 	spec->num_caps = STAC92HD83XXX_NUM_CAPS; | 
 | 5089 | 	spec->capvols = stac92hd83xxx_capvols; | 
 | 5090 | 	spec->capsws = stac92hd83xxx_capsws; | 
 | 5091 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5092 | 	spec->board_config = snd_hda_check_board_config(codec, | 
 | 5093 | 							STAC_92HD83XXX_MODELS, | 
 | 5094 | 							stac92hd83xxx_models, | 
 | 5095 | 							stac92hd83xxx_cfg_tbl); | 
 | 5096 | again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5097 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5098 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 5099 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5100 | 	else | 
 | 5101 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5102 | 				stac92hd83xxx_brd_tbl[spec->board_config]); | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5103 |  | 
| Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5104 | 	switch (codec->vendor_id) { | 
 | 5105 | 	case 0x111d7604: | 
 | 5106 | 	case 0x111d7605: | 
| Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5107 | 	case 0x111d76d5: | 
| Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 5108 | 		if (spec->board_config == STAC_92HD83XXX_PWR_REF) | 
 | 5109 | 			break; | 
 | 5110 | 		spec->num_pwrs = 0; | 
 | 5111 | 		break; | 
 | 5112 | 	} | 
 | 5113 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5114 | 	err = stac92xx_parse_auto_config(codec, 0x1d, 0); | 
 | 5115 | 	if (!err) { | 
 | 5116 | 		if (spec->board_config < 0) { | 
 | 5117 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 5118 | 			       "available, default to model=ref\n"); | 
 | 5119 | 			spec->board_config = STAC_92HD83XXX_REF; | 
 | 5120 | 			goto again; | 
 | 5121 | 		} | 
 | 5122 | 		err = -EINVAL; | 
 | 5123 | 	} | 
 | 5124 |  | 
 | 5125 | 	if (err < 0) { | 
 | 5126 | 		stac92xx_free(codec); | 
 | 5127 | 		return err; | 
 | 5128 | 	} | 
 | 5129 |  | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5130 | 	switch (spec->board_config) { | 
 | 5131 | 	case STAC_DELL_S14: | 
 | 5132 | 		nid = 0xf; | 
 | 5133 | 		break; | 
 | 5134 | 	default: | 
 | 5135 | 		nid = 0xe; | 
 | 5136 | 		break; | 
 | 5137 | 	} | 
 | 5138 |  | 
 | 5139 | 	num_dacs = snd_hda_get_connections(codec, nid, | 
 | 5140 | 				conn, STAC92HD83_DAC_COUNT + 1) - 1; | 
| Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 5141 | 	if (num_dacs < 0) | 
 | 5142 | 		num_dacs = STAC92HD83_DAC_COUNT; | 
| Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 5143 |  | 
 | 5144 | 	/* set port X to select the last DAC | 
 | 5145 | 	 */ | 
 | 5146 | 	snd_hda_codec_write_cache(codec, nid, 0, | 
 | 5147 | 			AC_VERB_SET_CONNECT_SEL, num_dacs); | 
 | 5148 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5149 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 5150 |  | 
| Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5151 | 	codec->proc_widget_hook = stac92hd_proc_hook; | 
 | 5152 |  | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5153 | 	return 0; | 
 | 5154 | } | 
 | 5155 |  | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5156 | /* get the pin connection (fixed, none, etc) */ | 
 | 5157 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) | 
 | 5158 | { | 
 | 5159 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 5160 | 	unsigned int cfg; | 
 | 5161 |  | 
 | 5162 | 	cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); | 
 | 5163 | 	return get_defcfg_connect(cfg); | 
 | 5164 | } | 
 | 5165 |  | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5166 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, | 
 | 5167 | 					 hda_nid_t *nids, int num_nids) | 
 | 5168 | { | 
 | 5169 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 5170 | 	int idx, num; | 
 | 5171 | 	unsigned int def_conf; | 
 | 5172 |  | 
 | 5173 | 	for (num = 0; num < num_nids; num++) { | 
 | 5174 | 		for (idx = 0; idx < spec->num_pins; idx++) | 
 | 5175 | 			if (spec->pin_nids[idx] == nids[num]) | 
 | 5176 | 				break; | 
 | 5177 | 		if (idx >= spec->num_pins) | 
 | 5178 | 			break; | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5179 | 		def_conf = stac_get_defcfg_connect(codec, idx); | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5180 | 		if (def_conf == AC_JACK_PORT_NONE) | 
 | 5181 | 			break; | 
 | 5182 | 	} | 
 | 5183 | 	return num; | 
 | 5184 | } | 
 | 5185 |  | 
 | 5186 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, | 
 | 5187 | 					  hda_nid_t dig0pin) | 
 | 5188 | { | 
 | 5189 | 	struct sigmatel_spec *spec = codec->spec; | 
 | 5190 | 	int idx; | 
 | 5191 |  | 
 | 5192 | 	for (idx = 0; idx < spec->num_pins; idx++) | 
 | 5193 | 		if (spec->pin_nids[idx] == dig0pin) | 
 | 5194 | 			break; | 
 | 5195 | 	if ((idx + 2) >= spec->num_pins) | 
 | 5196 | 		return 0; | 
 | 5197 |  | 
 | 5198 | 	/* dig1pin case */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5199 | 	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] | 5200 | 		return 2; | 
 | 5201 |  | 
 | 5202 | 	/* dig0pin + dig2pin case */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5203 | 	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] | 5204 | 		return 2; | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5205 | 	if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5206 | 		return 1; | 
 | 5207 | 	else | 
 | 5208 | 		return 0; | 
 | 5209 | } | 
 | 5210 |  | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5211 | static int patch_stac92hd71bxx(struct hda_codec *codec) | 
 | 5212 | { | 
 | 5213 | 	struct sigmatel_spec *spec; | 
| Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5214 | 	struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5215 | 	int err = 0; | 
 | 5216 |  | 
 | 5217 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 5218 | 	if (spec == NULL) | 
 | 5219 | 		return -ENOMEM; | 
 | 5220 |  | 
 | 5221 | 	codec->spec = spec; | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5222 | 	codec->patch_ops = stac92xx_patch_ops; | 
| Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 5223 | 	spec->num_pins = STAC92HD71BXX_NUM_PINS; | 
 | 5224 | 	switch (codec->vendor_id) { | 
 | 5225 | 	case 0x111d76b6: | 
 | 5226 | 	case 0x111d76b7: | 
 | 5227 | 		spec->pin_nids = stac92hd71bxx_pin_nids_4port; | 
 | 5228 | 		break; | 
 | 5229 | 	case 0x111d7603: | 
 | 5230 | 	case 0x111d7608: | 
 | 5231 | 		/* On 92HD75Bx 0x27 isn't a pin nid */ | 
 | 5232 | 		spec->num_pins--; | 
 | 5233 | 		/* fallthrough */ | 
 | 5234 | 	default: | 
 | 5235 | 		spec->pin_nids = stac92hd71bxx_pin_nids_6port; | 
 | 5236 | 	} | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5237 | 	spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5238 | 	spec->board_config = snd_hda_check_board_config(codec, | 
 | 5239 | 							STAC_92HD71BXX_MODELS, | 
 | 5240 | 							stac92hd71bxx_models, | 
 | 5241 | 							stac92hd71bxx_cfg_tbl); | 
 | 5242 | again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5243 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5244 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 5245 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5246 | 	else | 
 | 5247 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5248 | 				stac92hd71bxx_brd_tbl[spec->board_config]); | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5249 |  | 
| Takashi Iwai | fc64b26 | 2009-09-14 15:33:01 +0200 | [diff] [blame] | 5250 | 	if (spec->board_config != STAC_92HD71BXX_REF) { | 
| Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 5251 | 		/* GPIO0 = EAPD */ | 
 | 5252 | 		spec->gpio_mask = 0x01; | 
 | 5253 | 		spec->gpio_dir = 0x01; | 
 | 5254 | 		spec->gpio_data = 0x01; | 
 | 5255 | 	} | 
 | 5256 |  | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5257 | 	spec->dmic_nids = stac92hd71bxx_dmic_nids; | 
 | 5258 | 	spec->dmux_nids = stac92hd71bxx_dmux_nids; | 
 | 5259 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5260 | 	spec->num_caps = STAC92HD71BXX_NUM_CAPS; | 
 | 5261 | 	spec->capvols = stac92hd71bxx_capvols; | 
 | 5262 | 	spec->capsws = stac92hd71bxx_capsws; | 
 | 5263 |  | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5264 | 	switch (codec->vendor_id) { | 
 | 5265 | 	case 0x111d76b6: /* 4 Port without Analog Mixer */ | 
 | 5266 | 	case 0x111d76b7: | 
| Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 5267 | 		unmute_init++; | 
 | 5268 | 		/* fallthru */ | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5269 | 	case 0x111d76b4: /* 6 Port without Analog Mixer */ | 
 | 5270 | 	case 0x111d76b5: | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5271 | 		spec->init = stac92hd71bxx_core_init; | 
| Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5272 | 		codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5273 | 		spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 
 | 5274 | 					stac92hd71bxx_dmic_nids, | 
 | 5275 | 					STAC92HD71BXX_NUM_DMICS); | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5276 | 		break; | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5277 | 	case 0x111d7608: /* 5 Port with Analog Mixer */ | 
| Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 5278 | 		switch (spec->board_config) { | 
 | 5279 | 		case STAC_HP_M4: | 
| Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5280 | 			/* Enable VREF power saving on GPIO1 detect */ | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5281 | 			err = stac_add_event(spec, codec->afg, | 
 | 5282 | 					     STAC_VREF_EVENT, 0x02); | 
 | 5283 | 			if (err < 0) | 
 | 5284 | 				return err; | 
| Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5285 | 			snd_hda_codec_write_cache(codec, codec->afg, 0, | 
| Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5286 | 				AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); | 
 | 5287 | 			snd_hda_codec_write_cache(codec, codec->afg, 0, | 
| Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5288 | 				AC_VERB_SET_UNSOLICITED_ENABLE, | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5289 | 				AC_USRSP_EN | err); | 
| Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 5290 | 			spec->gpio_mask |= 0x02; | 
 | 5291 | 			break; | 
 | 5292 | 		} | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5293 | 		if ((codec->revision_id & 0xf) == 0 || | 
| Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5294 | 		    (codec->revision_id & 0xf) == 1) | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5295 | 			spec->stream_delay = 40; /* 40 milliseconds */ | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5296 |  | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5297 | 		/* no output amps */ | 
 | 5298 | 		spec->num_pwrs = 0; | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5299 | 		/* disable VSW */ | 
| Takashi Iwai | 26a2798 | 2009-07-29 16:28:09 +0200 | [diff] [blame] | 5300 | 		spec->init = stac92hd71bxx_core_init; | 
| Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5301 | 		unmute_init++; | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5302 | 		snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); | 
 | 5303 | 		snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5304 | 		stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; | 
 | 5305 | 		spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 
 | 5306 | 					stac92hd71bxx_dmic_nids, | 
 | 5307 | 					STAC92HD71BXX_NUM_DMICS - 1); | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5308 | 		break; | 
 | 5309 | 	case 0x111d7603: /* 6 Port with Analog Mixer */ | 
| Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5310 | 		if ((codec->revision_id & 0xf) == 1) | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5311 | 			spec->stream_delay = 40; /* 40 milliseconds */ | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5312 |  | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5313 | 		/* no output amps */ | 
 | 5314 | 		spec->num_pwrs = 0; | 
 | 5315 | 		/* fallthru */ | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5316 | 	default: | 
| Takashi Iwai | 26a2798 | 2009-07-29 16:28:09 +0200 | [diff] [blame] | 5317 | 		spec->init = stac92hd71bxx_core_init; | 
| Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 5318 | 		codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5319 | 		spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 
 | 5320 | 					stac92hd71bxx_dmic_nids, | 
 | 5321 | 					STAC92HD71BXX_NUM_DMICS); | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5322 | 		break; | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5323 | 	} | 
 | 5324 |  | 
| Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 5325 | 	if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) | 
 | 5326 | 		snd_hda_sequence_write_cache(codec, unmute_init); | 
 | 5327 |  | 
| Takashi Iwai | b20f3b8 | 2009-06-02 01:20:22 +0200 | [diff] [blame] | 5328 | 	/* Some HP machines seem to have unstable codec communications | 
 | 5329 | 	 * especially with ATI fglrx driver.  For recovering from the | 
 | 5330 | 	 * CORB/RIRB stall, allow the BUS reset and keep always sync | 
 | 5331 | 	 */ | 
 | 5332 | 	if (spec->board_config == STAC_HP_DV5) { | 
 | 5333 | 		codec->bus->sync_write = 1; | 
 | 5334 | 		codec->bus->allow_bus_reset = 1; | 
 | 5335 | 	} | 
 | 5336 |  | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5337 | 	spec->aloopback_ctl = stac92hd71bxx_loopback; | 
| Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 5338 | 	spec->aloopback_mask = 0x50; | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5339 | 	spec->aloopback_shift = 0; | 
 | 5340 |  | 
| Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5341 | 	spec->powerdown_adcs = 1; | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5342 | 	spec->digbeep_nid = 0x26; | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5343 | 	spec->mux_nids = stac92hd71bxx_mux_nids; | 
 | 5344 | 	spec->adc_nids = stac92hd71bxx_adc_nids; | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5345 | 	spec->smux_nids = stac92hd71bxx_smux_nids; | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5346 | 	spec->pwr_nids = stac92hd71bxx_pwr_nids; | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5347 |  | 
 | 5348 | 	spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); | 
 | 5349 | 	spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); | 
| Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5350 | 	spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | 
| Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 5351 | 	spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5352 |  | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5353 | 	switch (spec->board_config) { | 
 | 5354 | 	case STAC_HP_M4: | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5355 | 		/* enable internal microphone */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5356 | 		snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); | 
| Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 5357 | 		stac92xx_auto_set_pinctl(codec, 0x0e, | 
 | 5358 | 			AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); | 
| Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 5359 | 		/* fallthru */ | 
 | 5360 | 	case STAC_DELL_M4_2: | 
 | 5361 | 		spec->num_dmics = 0; | 
 | 5362 | 		spec->num_smuxes = 0; | 
 | 5363 | 		spec->num_dmuxes = 0; | 
 | 5364 | 		break; | 
 | 5365 | 	case STAC_DELL_M4_1: | 
 | 5366 | 	case STAC_DELL_M4_3: | 
 | 5367 | 		spec->num_dmics = 1; | 
 | 5368 | 		spec->num_smuxes = 0; | 
| Takashi Iwai | ea18aa4 | 2009-02-27 17:36:33 +0100 | [diff] [blame] | 5369 | 		spec->num_dmuxes = 1; | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5370 | 		break; | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5371 | 	case STAC_HP_DV4_1222NR: | 
 | 5372 | 		spec->num_dmics = 1; | 
 | 5373 | 		/* I don't know if it needs 1 or 2 smuxes - will wait for | 
 | 5374 | 		 * bug reports to fix if needed | 
 | 5375 | 		 */ | 
 | 5376 | 		spec->num_smuxes = 1; | 
 | 5377 | 		spec->num_dmuxes = 1; | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5378 | 		spec->gpio_led = 0x01; | 
| James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 5379 | 		/* fallthrough */ | 
| Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5380 | 	case STAC_HP_DV5: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5381 | 		snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); | 
| Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5382 | 		stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); | 
| Takashi Iwai | 6e34c03 | 2009-09-14 15:42:18 +0200 | [diff] [blame] | 5383 | 		/* HP dv6 gives the headphone pin as a line-out.  Thus we | 
 | 5384 | 		 * need to set hp_detect flag here to force to enable HP | 
 | 5385 | 		 * detection. | 
 | 5386 | 		 */ | 
 | 5387 | 		spec->hp_detect = 1; | 
| Herton Ronaldo Krzesinski | e2ea57a | 2009-02-16 10:23:00 +0100 | [diff] [blame] | 5388 | 		break; | 
| Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 5389 | 	case STAC_HP_HDX: | 
 | 5390 | 		spec->num_dmics = 1; | 
 | 5391 | 		spec->num_dmuxes = 1; | 
 | 5392 | 		spec->num_smuxes = 1; | 
| Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5393 | 		/* orange/white mute led on GPIO3, orange=0, white=1 */ | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5394 | 		spec->gpio_led = 0x08; | 
 | 5395 | 		break; | 
 | 5396 | 	} | 
| Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5397 |  | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5398 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 
 | 5399 | 	if (spec->gpio_led) { | 
 | 5400 | 		spec->gpio_mask |= spec->gpio_led; | 
 | 5401 | 		spec->gpio_dir |= spec->gpio_led; | 
 | 5402 | 		spec->gpio_data |= spec->gpio_led; | 
| Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5403 | 		/* register check_power_status callback. */ | 
| Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 5404 | 		codec->patch_ops.check_power_status = | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5405 | 			stac92xx_hp_check_power_status; | 
 | 5406 | 	} | 
| Christoph Plattner | 443e26d | 2009-03-10 00:05:56 +0100 | [diff] [blame] | 5407 | #endif	 | 
| Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 5408 |  | 
| Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5409 | 	spec->multiout.dac_nids = spec->dac_nids; | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5410 |  | 
| Herton Ronaldo Krzesinski | 29d4ab4 | 2009-02-04 11:37:27 -0500 | [diff] [blame] | 5411 | 	err = stac92xx_parse_auto_config(codec, 0x21, 0); | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5412 | 	if (!err) { | 
 | 5413 | 		if (spec->board_config < 0) { | 
 | 5414 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 5415 | 			       "available, default to model=ref\n"); | 
 | 5416 | 			spec->board_config = STAC_92HD71BXX_REF; | 
 | 5417 | 			goto again; | 
 | 5418 | 		} | 
 | 5419 | 		err = -EINVAL; | 
 | 5420 | 	} | 
 | 5421 |  | 
 | 5422 | 	if (err < 0) { | 
 | 5423 | 		stac92xx_free(codec); | 
 | 5424 | 		return err; | 
 | 5425 | 	} | 
 | 5426 |  | 
| Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5427 | 	codec->proc_widget_hook = stac92hd7x_proc_hook; | 
 | 5428 |  | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5429 | 	return 0; | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5430 | } | 
| Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 5431 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5432 | static int patch_stac922x(struct hda_codec *codec) | 
 | 5433 | { | 
 | 5434 | 	struct sigmatel_spec *spec; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5435 | 	int err; | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5436 |  | 
| Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 5437 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5438 | 	if (spec == NULL) | 
 | 5439 | 		return -ENOMEM; | 
 | 5440 |  | 
 | 5441 | 	codec->spec = spec; | 
| Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5442 | 	spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); | 
| Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5443 | 	spec->pin_nids = stac922x_pin_nids; | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5444 | 	spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, | 
 | 5445 | 							stac922x_models, | 
 | 5446 | 							stac922x_cfg_tbl); | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5447 | 	if (spec->board_config == STAC_INTEL_MAC_AUTO) { | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5448 | 		spec->gpio_mask = spec->gpio_dir = 0x03; | 
 | 5449 | 		spec->gpio_data = 0x03; | 
| Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5450 | 		/* Intel Macs have all same PCI SSID, so we need to check | 
 | 5451 | 		 * codec SSID to distinguish the exact models | 
 | 5452 | 		 */ | 
| Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5453 | 		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] | 5454 | 		switch (codec->subsystem_id) { | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5455 |  | 
 | 5456 | 		case 0x106b0800: | 
 | 5457 | 			spec->board_config = STAC_INTEL_MAC_V1; | 
| Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 5458 | 			break; | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5459 | 		case 0x106b0600: | 
 | 5460 | 		case 0x106b0700: | 
 | 5461 | 			spec->board_config = STAC_INTEL_MAC_V2; | 
| Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 5462 | 			break; | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5463 | 		case 0x106b0e00: | 
 | 5464 | 		case 0x106b0f00: | 
 | 5465 | 		case 0x106b1600: | 
 | 5466 | 		case 0x106b1700: | 
 | 5467 | 		case 0x106b0200: | 
 | 5468 | 		case 0x106b1e00: | 
 | 5469 | 			spec->board_config = STAC_INTEL_MAC_V3; | 
| Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5470 | 			break; | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5471 | 		case 0x106b1a00: | 
 | 5472 | 		case 0x00000100: | 
 | 5473 | 			spec->board_config = STAC_INTEL_MAC_V4; | 
| Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5474 | 			break; | 
| Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5475 | 		case 0x106b0a00: | 
 | 5476 | 		case 0x106b2200: | 
 | 5477 | 			spec->board_config = STAC_INTEL_MAC_V5; | 
| Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5478 | 			break; | 
| Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5479 | 		default: | 
 | 5480 | 			spec->board_config = STAC_INTEL_MAC_V3; | 
 | 5481 | 			break; | 
| Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5482 | 		} | 
 | 5483 | 	} | 
 | 5484 |  | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5485 |  again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5486 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5487 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 5488 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5489 | 	else | 
 | 5490 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5491 | 				stac922x_brd_tbl[spec->board_config]); | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5492 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5493 | 	spec->adc_nids = stac922x_adc_nids; | 
 | 5494 | 	spec->mux_nids = stac922x_mux_nids; | 
| Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5495 | 	spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5496 | 	spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5497 | 	spec->num_dmics = 0; | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5498 | 	spec->num_pwrs = 0; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5499 |  | 
 | 5500 | 	spec->init = stac922x_core_init; | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5501 |  | 
 | 5502 | 	spec->num_caps = STAC922X_NUM_CAPS; | 
 | 5503 | 	spec->capvols = stac922x_capvols; | 
 | 5504 | 	spec->capsws = stac922x_capsws; | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5505 |  | 
 | 5506 | 	spec->multiout.dac_nids = spec->dac_nids; | 
| Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5507 | 	 | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5508 | 	err = stac92xx_parse_auto_config(codec, 0x08, 0x09); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5509 | 	if (!err) { | 
 | 5510 | 		if (spec->board_config < 0) { | 
 | 5511 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 5512 | 			       "available, default to model=ref\n"); | 
 | 5513 | 			spec->board_config = STAC_D945_REF; | 
 | 5514 | 			goto again; | 
 | 5515 | 		} | 
 | 5516 | 		err = -EINVAL; | 
 | 5517 | 	} | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5518 | 	if (err < 0) { | 
 | 5519 | 		stac92xx_free(codec); | 
 | 5520 | 		return err; | 
 | 5521 | 	} | 
 | 5522 |  | 
 | 5523 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 5524 |  | 
| Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5525 | 	/* Fix Mux capture level; max to 2 */ | 
 | 5526 | 	snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, | 
 | 5527 | 				  (0 << AC_AMPCAP_OFFSET_SHIFT) | | 
 | 5528 | 				  (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | | 
 | 5529 | 				  (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | | 
 | 5530 | 				  (0 << AC_AMPCAP_MUTE_SHIFT)); | 
 | 5531 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5532 | 	return 0; | 
 | 5533 | } | 
 | 5534 |  | 
 | 5535 | static int patch_stac927x(struct hda_codec *codec) | 
 | 5536 | { | 
 | 5537 | 	struct sigmatel_spec *spec; | 
 | 5538 | 	int err; | 
 | 5539 |  | 
 | 5540 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 5541 | 	if (spec == NULL) | 
 | 5542 | 		return -ENOMEM; | 
 | 5543 |  | 
 | 5544 | 	codec->spec = spec; | 
| Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 5545 | 	codec->slave_dig_outs = stac927x_slave_dig_outs; | 
| Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5546 | 	spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); | 
| Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5547 | 	spec->pin_nids = stac927x_pin_nids; | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5548 | 	spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, | 
 | 5549 | 							stac927x_models, | 
 | 5550 | 							stac927x_cfg_tbl); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5551 |  again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5552 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5553 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 5554 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5555 | 	else | 
 | 5556 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5557 | 				stac927x_brd_tbl[spec->board_config]); | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5558 |  | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5559 | 	spec->digbeep_nid = 0x23; | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5560 | 	spec->adc_nids = stac927x_adc_nids; | 
 | 5561 | 	spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); | 
 | 5562 | 	spec->mux_nids = stac927x_mux_nids; | 
 | 5563 | 	spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5564 | 	spec->smux_nids = stac927x_smux_nids; | 
 | 5565 | 	spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); | 
| Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5566 | 	spec->spdif_labels = stac927x_spdif_labels; | 
| Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5567 | 	spec->dac_list = stac927x_dac_nids; | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5568 | 	spec->multiout.dac_nids = spec->dac_nids; | 
 | 5569 |  | 
| Takashi Iwai | af6ee30 | 2009-09-14 15:03:12 +0200 | [diff] [blame] | 5570 | 	if (spec->board_config != STAC_D965_REF) { | 
 | 5571 | 		/* GPIO0 High = Enable EAPD */ | 
 | 5572 | 		spec->eapd_mask = spec->gpio_mask = 0x01; | 
 | 5573 | 		spec->gpio_dir = spec->gpio_data = 0x01; | 
 | 5574 | 	} | 
 | 5575 |  | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5576 | 	switch (spec->board_config) { | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5577 | 	case STAC_D965_3ST: | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5578 | 	case STAC_D965_5ST: | 
 | 5579 | 		/* GPIO0 High = Enable EAPD */ | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5580 | 		spec->num_dmics = 0; | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5581 | 		spec->init = d965_core_init; | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5582 | 		break; | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5583 | 	case STAC_DELL_BIOS: | 
| Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5584 | 		switch (codec->subsystem_id) { | 
 | 5585 | 		case 0x10280209: | 
 | 5586 | 		case 0x1028022e: | 
 | 5587 | 			/* correct the device field to SPDIF out */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5588 | 			snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); | 
| Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5589 | 			break; | 
| Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 5590 | 		} | 
| Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5591 | 		/* configure the analog microphone on some laptops */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5592 | 		snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); | 
| Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5593 | 		/* correct the front output jack as a hp out */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5594 | 		snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); | 
| Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5595 | 		/* correct the front input jack as a mic */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5596 | 		snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); | 
| Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5597 | 		/* fallthru */ | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5598 | 	case STAC_DELL_3ST: | 
| Takashi Iwai | af6ee30 | 2009-09-14 15:03:12 +0200 | [diff] [blame] | 5599 | 		if (codec->subsystem_id != 0x1028022f) { | 
 | 5600 | 			/* GPIO2 High = Enable EAPD */ | 
 | 5601 | 			spec->eapd_mask = spec->gpio_mask = 0x04; | 
 | 5602 | 			spec->gpio_dir = spec->gpio_data = 0x04; | 
 | 5603 | 		} | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5604 | 		spec->dmic_nids = stac927x_dmic_nids; | 
 | 5605 | 		spec->num_dmics = STAC927X_NUM_DMICS; | 
 | 5606 |  | 
| Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5607 | 		spec->init = d965_core_init; | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5608 | 		spec->dmux_nids = stac927x_dmux_nids; | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5609 | 		spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5610 | 		break; | 
 | 5611 | 	default: | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5612 | 		spec->num_dmics = 0; | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5613 | 		spec->init = stac927x_core_init; | 
| Takashi Iwai | af6ee30 | 2009-09-14 15:03:12 +0200 | [diff] [blame] | 5614 | 		break; | 
| Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5615 | 	} | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5616 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5617 | 	spec->num_caps = STAC927X_NUM_CAPS; | 
 | 5618 | 	spec->capvols = stac927x_capvols; | 
 | 5619 | 	spec->capsws = stac927x_capsws; | 
 | 5620 |  | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5621 | 	spec->num_pwrs = 0; | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5622 | 	spec->aloopback_ctl = stac927x_loopback; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5623 | 	spec->aloopback_mask = 0x40; | 
 | 5624 | 	spec->aloopback_shift = 0; | 
| Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5625 | 	spec->eapd_switch = 1; | 
| Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5626 |  | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5627 | 	err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5628 | 	if (!err) { | 
 | 5629 | 		if (spec->board_config < 0) { | 
 | 5630 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 5631 | 			       "available, default to model=ref\n"); | 
 | 5632 | 			spec->board_config = STAC_D965_REF; | 
 | 5633 | 			goto again; | 
 | 5634 | 		} | 
 | 5635 | 		err = -EINVAL; | 
 | 5636 | 	} | 
| Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5637 | 	if (err < 0) { | 
 | 5638 | 		stac92xx_free(codec); | 
 | 5639 | 		return err; | 
 | 5640 | 	} | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5641 |  | 
 | 5642 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 5643 |  | 
| Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5644 | 	codec->proc_widget_hook = stac927x_proc_hook; | 
 | 5645 |  | 
| Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5646 | 	/* | 
 | 5647 | 	 * !!FIXME!! | 
 | 5648 | 	 * The STAC927x seem to require fairly long delays for certain | 
 | 5649 | 	 * command sequences.  With too short delays (even if the answer | 
 | 5650 | 	 * is set to RIRB properly), it results in the silence output | 
 | 5651 | 	 * on some hardwares like Dell. | 
 | 5652 | 	 * | 
 | 5653 | 	 * The below flag enables the longer delay (see get_response | 
 | 5654 | 	 * in hda_intel.c). | 
 | 5655 | 	 */ | 
 | 5656 | 	codec->bus->needs_damn_long_delay = 1; | 
 | 5657 |  | 
| Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 5658 | 	/* no jack detecion for ref-no-jd model */ | 
 | 5659 | 	if (spec->board_config == STAC_D965_REF_NO_JD) | 
 | 5660 | 		spec->hp_detect = 0; | 
 | 5661 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5662 | 	return 0; | 
 | 5663 | } | 
 | 5664 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5665 | static int patch_stac9205(struct hda_codec *codec) | 
 | 5666 | { | 
 | 5667 | 	struct sigmatel_spec *spec; | 
| Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5668 | 	int err; | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5669 |  | 
 | 5670 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 5671 | 	if (spec == NULL) | 
 | 5672 | 		return -ENOMEM; | 
 | 5673 |  | 
 | 5674 | 	codec->spec = spec; | 
| Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5675 | 	spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); | 
| Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5676 | 	spec->pin_nids = stac9205_pin_nids; | 
| Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5677 | 	spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, | 
 | 5678 | 							stac9205_models, | 
 | 5679 | 							stac9205_cfg_tbl); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5680 |  again: | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5681 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5682 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 5683 | 			    codec->chip_name); | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5684 | 	else | 
 | 5685 | 		stac92xx_set_config_regs(codec, | 
| Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5686 | 					 stac9205_brd_tbl[spec->board_config]); | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5687 |  | 
| Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5688 | 	spec->digbeep_nid = 0x23; | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5689 | 	spec->adc_nids = stac9205_adc_nids; | 
| Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5690 | 	spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5691 | 	spec->mux_nids = stac9205_mux_nids; | 
| Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5692 | 	spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); | 
| Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5693 | 	spec->smux_nids = stac9205_smux_nids; | 
 | 5694 | 	spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); | 
| Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5695 | 	spec->dmic_nids = stac9205_dmic_nids; | 
| Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5696 | 	spec->num_dmics = STAC9205_NUM_DMICS; | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5697 | 	spec->dmux_nids = stac9205_dmux_nids; | 
| Takashi Iwai | 1697055 | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5698 | 	spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); | 
| Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5699 | 	spec->num_pwrs = 0; | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5700 |  | 
 | 5701 | 	spec->init = stac9205_core_init; | 
| Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 5702 | 	spec->aloopback_ctl = stac9205_loopback; | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5703 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5704 | 	spec->num_caps = STAC9205_NUM_CAPS; | 
 | 5705 | 	spec->capvols = stac9205_capvols; | 
 | 5706 | 	spec->capsws = stac9205_capsws; | 
 | 5707 |  | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5708 | 	spec->aloopback_mask = 0x40; | 
 | 5709 | 	spec->aloopback_shift = 0; | 
| Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 5710 | 	/* Turn on/off EAPD per HP plugging */ | 
 | 5711 | 	if (spec->board_config != STAC_9205_EAPD) | 
 | 5712 | 		spec->eapd_switch = 1; | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5713 | 	spec->multiout.dac_nids = spec->dac_nids; | 
| Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5714 | 	 | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5715 | 	switch (spec->board_config){ | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5716 | 	case STAC_9205_DELL_M43: | 
| Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5717 | 		/* Enable SPDIF in/out */ | 
| Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5718 | 		snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); | 
 | 5719 | 		snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); | 
| Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5720 |  | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5721 | 		/* Enable unsol response for GPIO4/Dock HP connection */ | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5722 | 		err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); | 
 | 5723 | 		if (err < 0) | 
 | 5724 | 			return err; | 
| Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5725 | 		snd_hda_codec_write_cache(codec, codec->afg, 0, | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5726 | 			AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); | 
 | 5727 | 		snd_hda_codec_write_cache(codec, codec->afg, 0, | 
| Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5728 | 					  AC_VERB_SET_UNSOLICITED_ENABLE, | 
 | 5729 | 					  AC_USRSP_EN | err); | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5730 |  | 
 | 5731 | 		spec->gpio_dir = 0x0b; | 
| Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5732 | 		spec->eapd_mask = 0x01; | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5733 | 		spec->gpio_mask = 0x1b; | 
 | 5734 | 		spec->gpio_mute = 0x10; | 
| Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5735 | 		/* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5736 | 		 * GPIO3 Low = DRM | 
| Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5737 | 		 */ | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5738 | 		spec->gpio_data = 0x01; | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5739 | 		break; | 
| Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5740 | 	case STAC_9205_REF: | 
 | 5741 | 		/* SPDIF-In enabled */ | 
 | 5742 | 		break; | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5743 | 	default: | 
 | 5744 | 		/* GPIO0 High = EAPD */ | 
| Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5745 | 		spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; | 
| Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5746 | 		spec->gpio_data = 0x01; | 
| Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5747 | 		break; | 
 | 5748 | 	} | 
| Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5749 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5750 | 	err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); | 
| Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5751 | 	if (!err) { | 
 | 5752 | 		if (spec->board_config < 0) { | 
 | 5753 | 			printk(KERN_WARNING "hda_codec: No auto-config is " | 
 | 5754 | 			       "available, default to model=ref\n"); | 
 | 5755 | 			spec->board_config = STAC_9205_REF; | 
 | 5756 | 			goto again; | 
 | 5757 | 		} | 
 | 5758 | 		err = -EINVAL; | 
 | 5759 | 	} | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5760 | 	if (err < 0) { | 
 | 5761 | 		stac92xx_free(codec); | 
 | 5762 | 		return err; | 
 | 5763 | 	} | 
 | 5764 |  | 
 | 5765 | 	codec->patch_ops = stac92xx_patch_ops; | 
 | 5766 |  | 
| Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 5767 | 	codec->proc_widget_hook = stac9205_proc_hook; | 
 | 5768 |  | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5769 | 	return 0; | 
 | 5770 | } | 
 | 5771 |  | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5772 | /* | 
| Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5773 |  * STAC9872 hack | 
| Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5774 |  */ | 
 | 5775 |  | 
| Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5776 | static struct hda_verb stac9872_core_init[] = { | 
| Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5777 | 	{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] | 5778 | 	{0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ | 
 | 5779 | 	{} | 
 | 5780 | }; | 
 | 5781 |  | 
| Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5782 | static hda_nid_t stac9872_pin_nids[] = { | 
 | 5783 | 	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | 
 | 5784 | 	0x11, 0x13, 0x14, | 
 | 5785 | }; | 
 | 5786 |  | 
 | 5787 | static hda_nid_t stac9872_adc_nids[] = { | 
 | 5788 | 	0x8 /*,0x6*/ | 
 | 5789 | }; | 
 | 5790 |  | 
 | 5791 | static hda_nid_t stac9872_mux_nids[] = { | 
 | 5792 | 	0x15 | 
 | 5793 | }; | 
 | 5794 |  | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5795 | static unsigned long stac9872_capvols[] = { | 
 | 5796 | 	HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), | 
 | 5797 | }; | 
 | 5798 | #define stac9872_capsws		stac9872_capvols | 
 | 5799 |  | 
| Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5800 | static unsigned int stac9872_vaio_pin_configs[9] = { | 
 | 5801 | 	0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, | 
 | 5802 | 	0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, | 
 | 5803 | 	0x90a7013e | 
 | 5804 | }; | 
 | 5805 |  | 
 | 5806 | static const char *stac9872_models[STAC_9872_MODELS] = { | 
 | 5807 | 	[STAC_9872_AUTO] = "auto", | 
 | 5808 | 	[STAC_9872_VAIO] = "vaio", | 
 | 5809 | }; | 
 | 5810 |  | 
 | 5811 | static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = { | 
 | 5812 | 	[STAC_9872_VAIO] = stac9872_vaio_pin_configs, | 
 | 5813 | }; | 
 | 5814 |  | 
 | 5815 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { | 
| Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 5816 | 	SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, | 
 | 5817 | 			   "Sony VAIO F/S", STAC_9872_VAIO), | 
| Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5818 | 	{} /* terminator */ | 
 | 5819 | }; | 
 | 5820 |  | 
| Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5821 | static int patch_stac9872(struct hda_codec *codec) | 
| Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5822 | { | 
 | 5823 | 	struct sigmatel_spec *spec; | 
| Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5824 | 	int err; | 
| Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5825 |  | 
| Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5826 | 	spec  = kzalloc(sizeof(*spec), GFP_KERNEL); | 
 | 5827 | 	if (spec == NULL) | 
 | 5828 | 		return -ENOMEM; | 
| Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5829 | 	codec->spec = spec; | 
| Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 5830 | 	spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); | 
 | 5831 | 	spec->pin_nids = stac9872_pin_nids; | 
| Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5832 |  | 
 | 5833 | 	spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, | 
 | 5834 | 							stac9872_models, | 
 | 5835 | 							stac9872_cfg_tbl); | 
| Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5836 | 	if (spec->board_config < 0) | 
| Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 5837 | 		snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", | 
 | 5838 | 			    codec->chip_name); | 
| Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 5839 | 	else | 
 | 5840 | 		stac92xx_set_config_regs(codec, | 
 | 5841 | 					 stac9872_brd_tbl[spec->board_config]); | 
| Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5842 |  | 
| Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5843 | 	spec->multiout.dac_nids = spec->dac_nids; | 
 | 5844 | 	spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); | 
 | 5845 | 	spec->adc_nids = stac9872_adc_nids; | 
 | 5846 | 	spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); | 
 | 5847 | 	spec->mux_nids = stac9872_mux_nids; | 
| Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5848 | 	spec->init = stac9872_core_init; | 
| Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5849 | 	spec->num_caps = 1; | 
 | 5850 | 	spec->capvols = stac9872_capvols; | 
 | 5851 | 	spec->capsws = stac9872_capsws; | 
| Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5852 |  | 
| Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5853 | 	err = stac92xx_parse_auto_config(codec, 0x10, 0x12); | 
 | 5854 | 	if (err < 0) { | 
 | 5855 | 		stac92xx_free(codec); | 
 | 5856 | 		return -EINVAL; | 
| Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 5857 | 	} | 
| Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 5858 | 	spec->input_mux = &spec->private_imux; | 
 | 5859 | 	codec->patch_ops = stac92xx_patch_ops; | 
| Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5860 | 	return 0; | 
 | 5861 | } | 
 | 5862 |  | 
 | 5863 |  | 
 | 5864 | /* | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5865 |  * patch entries | 
 | 5866 |  */ | 
| Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5867 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5868 |  	{ .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, | 
 | 5869 |  	{ .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, | 
 | 5870 |  	{ .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, | 
 | 5871 |  	{ .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, | 
 | 5872 |  	{ .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, | 
 | 5873 |  	{ .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, | 
 | 5874 |  	{ .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, | 
| Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5875 |  	{ .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, | 
 | 5876 |  	{ .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, | 
 | 5877 |  	{ .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, | 
 | 5878 |  	{ .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, | 
 | 5879 |  	{ .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, | 
 | 5880 |  	{ .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, | 
| Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5881 |  	{ .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, | 
 | 5882 |  	{ .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, | 
 | 5883 |  	{ .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, | 
 | 5884 |  	{ .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, | 
 | 5885 |  	{ .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, | 
 | 5886 |  	{ .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, | 
 | 5887 |  	{ .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, | 
 | 5888 |  	{ .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, | 
 | 5889 |  	{ .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, | 
 | 5890 |  	{ .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, | 
| Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5891 | 	{ .id = 0x83847632, .name = "STAC9202",  .patch = patch_stac925x }, | 
 | 5892 | 	{ .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, | 
 | 5893 | 	{ .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, | 
 | 5894 | 	{ .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, | 
 | 5895 | 	{ .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, | 
 | 5896 | 	{ .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, | 
| Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5897 | 	{ .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, | 
 | 5898 | 	{ .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, | 
| Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5899 |  	/* The following does not take into account .id=0x83847661 when subsys = | 
 | 5900 |  	 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are | 
 | 5901 |  	 * currently not fully supported. | 
 | 5902 |  	 */ | 
 | 5903 |  	{ .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, | 
 | 5904 |  	{ .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, | 
 | 5905 |  	{ .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, | 
| Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 5906 | 	{ .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, | 
| Matt Porter | f3302a59 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5907 |  	{ .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, | 
 | 5908 |  	{ .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, | 
 | 5909 |  	{ .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, | 
 | 5910 |  	{ .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, | 
 | 5911 |  	{ .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, | 
 | 5912 |  	{ .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, | 
 | 5913 |  	{ .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, | 
 | 5914 |  	{ .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5915 | 	{ .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, | 
| Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5916 | 	{ .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, | 
 | 5917 | 	{ .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, | 
| Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 5918 | 	{ .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, | 
| Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5919 | 	{ .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5920 | 	{ .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, | 
 | 5921 | 	{ .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, | 
| Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5922 | 	{ .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, | 
| Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5923 | 	{ .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, | 
 | 5924 | 	{ .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, | 
 | 5925 | 	{ .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, | 
 | 5926 | 	{ .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, | 
 | 5927 | 	{ .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, | 
 | 5928 | 	{ .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, | 
 | 5929 | 	{ .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, | 
 | 5930 | 	{ .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, | 
| Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5931 | 	{} /* terminator */ | 
 | 5932 | }; | 
| Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5933 |  | 
 | 5934 | MODULE_ALIAS("snd-hda-codec-id:8384*"); | 
 | 5935 | MODULE_ALIAS("snd-hda-codec-id:111d*"); | 
 | 5936 |  | 
 | 5937 | MODULE_LICENSE("GPL"); | 
 | 5938 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); | 
 | 5939 |  | 
 | 5940 | static struct hda_codec_preset_list sigmatel_list = { | 
 | 5941 | 	.preset = snd_hda_preset_sigmatel, | 
 | 5942 | 	.owner = THIS_MODULE, | 
 | 5943 | }; | 
 | 5944 |  | 
 | 5945 | static int __init patch_sigmatel_init(void) | 
 | 5946 | { | 
 | 5947 | 	return snd_hda_add_codec_preset(&sigmatel_list); | 
 | 5948 | } | 
 | 5949 |  | 
 | 5950 | static void __exit patch_sigmatel_exit(void) | 
 | 5951 | { | 
 | 5952 | 	snd_hda_delete_codec_preset(&sigmatel_list); | 
 | 5953 | } | 
 | 5954 |  | 
 | 5955 | module_init(patch_sigmatel_init) | 
 | 5956 | module_exit(patch_sigmatel_exit) |