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