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> |
Vitaliy Kulikov | 5bdaaad | 2009-11-04 07:57:45 +0100 | [diff] [blame] | 31 | #include <linux/dmi.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 32 | #include <linux/module.h> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 33 | #include <sound/core.h> |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 34 | #include <sound/asoundef.h> |
Matthew Ranostay | 45a6ac1 | 2008-10-15 14:45:38 -0400 | [diff] [blame] | 35 | #include <sound/jack.h> |
Clemens Ladisch | a74ccea | 2010-10-22 15:52:34 +0200 | [diff] [blame] | 36 | #include <sound/tlv.h> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 37 | #include "hda_codec.h" |
| 38 | #include "hda_local.h" |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 39 | #include "hda_auto_parser.h" |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 40 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 41 | #include "hda_jack.h" |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 42 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 43 | enum { |
| 44 | STAC_VREF_EVENT = 1, |
| 45 | STAC_INSERT_EVENT, |
| 46 | STAC_PWR_EVENT, |
| 47 | STAC_HP_EVENT, |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 48 | STAC_LO_EVENT, |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 49 | STAC_MIC_EVENT, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 50 | }; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 51 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 52 | enum { |
| 53 | STAC_REF, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 54 | STAC_9200_OQO, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 55 | STAC_9200_DELL_D21, |
| 56 | STAC_9200_DELL_D22, |
| 57 | STAC_9200_DELL_D23, |
| 58 | STAC_9200_DELL_M21, |
| 59 | STAC_9200_DELL_M22, |
| 60 | STAC_9200_DELL_M23, |
| 61 | STAC_9200_DELL_M24, |
| 62 | STAC_9200_DELL_M25, |
| 63 | STAC_9200_DELL_M26, |
| 64 | STAC_9200_DELL_M27, |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 65 | STAC_9200_M4, |
| 66 | STAC_9200_M4_2, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 67 | STAC_9200_PANASONIC, |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 68 | STAC_9200_EAPD_INIT, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 69 | STAC_9200_MODELS |
| 70 | }; |
| 71 | |
| 72 | enum { |
| 73 | STAC_9205_REF, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 74 | STAC_9205_DELL_M42, |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 75 | STAC_9205_DELL_M43, |
| 76 | STAC_9205_DELL_M44, |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 77 | STAC_9205_EAPD, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 78 | STAC_9205_MODELS |
| 79 | }; |
| 80 | |
| 81 | enum { |
Takashi Iwai | 9e43f0d | 2008-12-17 14:51:01 +0100 | [diff] [blame] | 82 | STAC_92HD73XX_NO_JD, /* no jack-detection */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 83 | STAC_92HD73XX_REF, |
Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame] | 84 | STAC_92HD73XX_INTEL, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 85 | STAC_DELL_M6_AMIC, |
| 86 | STAC_DELL_M6_DMIC, |
| 87 | STAC_DELL_M6_BOTH, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 88 | STAC_DELL_EQ, |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 89 | STAC_ALIENWARE_M17X, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 90 | STAC_92HD73XX_MODELS |
| 91 | }; |
| 92 | |
| 93 | enum { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 94 | STAC_92HD83XXX_REF, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 95 | STAC_92HD83XXX_PWR_REF, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 96 | STAC_DELL_S14, |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 97 | STAC_DELL_VOSTRO_3500, |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 98 | STAC_92HD83XXX_HP_cNB11_INTQUAD, |
Steven Eastland | 4831559 | 2010-08-06 15:07:35 -0600 | [diff] [blame] | 99 | STAC_HP_DV7_4000, |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 100 | STAC_HP_ZEPHYR, |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 101 | STAC_92HD83XXX_HP_LED, |
Takashi Iwai | ff8a1e2 | 2012-07-31 10:16:59 +0200 | [diff] [blame] | 102 | STAC_92HD83XXX_HP_INV_LED, |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 103 | STAC_92HD83XXX_HP_MIC_LED, |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 104 | STAC_92HD83XXX_HEADSET_JACK, |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 105 | STAC_92HD83XXX_HP, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 106 | STAC_92HD83XXX_MODELS |
| 107 | }; |
| 108 | |
| 109 | enum { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 110 | STAC_92HD71BXX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 111 | STAC_DELL_M4_1, |
| 112 | STAC_DELL_M4_2, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 113 | STAC_DELL_M4_3, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 114 | STAC_HP_M4, |
Takashi Iwai | 2a6ce6e | 2010-05-12 10:16:20 +0200 | [diff] [blame] | 115 | STAC_HP_DV4, |
Takashi Iwai | 1b0652e | 2009-01-14 08:27:35 +0100 | [diff] [blame] | 116 | STAC_HP_DV5, |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 117 | STAC_HP_HDX, |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 118 | STAC_HP_DV4_1222NR, |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 119 | STAC_92HD71BXX_HP, |
| 120 | STAC_92HD71BXX_NO_DMIC, |
| 121 | STAC_92HD71BXX_NO_SMUX, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 122 | STAC_92HD71BXX_MODELS |
| 123 | }; |
| 124 | |
| 125 | enum { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 126 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 127 | STAC_M1, |
| 128 | STAC_M1_2, |
| 129 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 130 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 131 | STAC_M3, |
| 132 | STAC_M5, |
| 133 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 134 | STAC_925x_MODELS |
| 135 | }; |
| 136 | |
| 137 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 138 | STAC_D945_REF, |
| 139 | STAC_D945GTP3, |
| 140 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 141 | STAC_INTEL_MAC_V1, |
| 142 | STAC_INTEL_MAC_V2, |
| 143 | STAC_INTEL_MAC_V3, |
| 144 | STAC_INTEL_MAC_V4, |
| 145 | STAC_INTEL_MAC_V5, |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 146 | STAC_INTEL_MAC_AUTO, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 147 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 148 | STAC_922X_DELL_D81, |
| 149 | STAC_922X_DELL_D82, |
| 150 | STAC_922X_DELL_M81, |
| 151 | STAC_922X_DELL_M82, |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 152 | STAC_922X_INTEL_MAC_GPIO, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 153 | STAC_922X_MODELS |
| 154 | }; |
| 155 | |
| 156 | enum { |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 157 | STAC_D965_REF_NO_JD, /* no jack-detection */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 158 | STAC_D965_REF, |
| 159 | STAC_D965_3ST, |
| 160 | STAC_D965_5ST, |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 161 | STAC_D965_5ST_NO_FP, |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 162 | STAC_D965_VERBS, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 163 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 164 | STAC_DELL_BIOS, |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 165 | STAC_DELL_BIOS_SPDIF, |
| 166 | STAC_927X_DELL_DMIC, |
Takashi Iwai | 5493053 | 2009-10-11 17:38:29 +0200 | [diff] [blame] | 167 | STAC_927X_VOLKNOB, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 168 | STAC_927X_MODELS |
| 169 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 170 | |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 171 | enum { |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 172 | STAC_9872_VAIO, |
| 173 | STAC_9872_MODELS |
| 174 | }; |
| 175 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 176 | struct sigmatel_mic_route { |
| 177 | hda_nid_t pin; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 178 | signed char mux_idx; |
| 179 | signed char dmux_idx; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 180 | }; |
| 181 | |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 182 | #define MAX_PINS_NUM 16 |
| 183 | #define MAX_ADCS_NUM 4 |
| 184 | #define MAX_DMICS_NUM 4 |
| 185 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 186 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 187 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 188 | unsigned int num_mixers; |
| 189 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 190 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 191 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 192 | unsigned int surr_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 193 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 194 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 195 | unsigned int spdif_mute: 1; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 196 | unsigned int check_volume_offset:1; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 197 | unsigned int auto_mic:1; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 198 | unsigned int linear_tone_beep:1; |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 199 | unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */ |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 200 | unsigned int volknob_init:1; /* special volume-knob initialization */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 201 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 202 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 203 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 204 | unsigned int gpio_mask; |
| 205 | unsigned int gpio_dir; |
| 206 | unsigned int gpio_data; |
| 207 | unsigned int gpio_mute; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 208 | unsigned int gpio_led; |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 209 | unsigned int gpio_led_polarity; |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 210 | unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */ |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 211 | unsigned int vref_led; |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 212 | int default_polarity; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 213 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 214 | unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */ |
| 215 | bool mic_mute_led_on; /* current mic mute state */ |
| 216 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 217 | /* stream */ |
| 218 | unsigned int stream_delay; |
| 219 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 220 | /* analog loopback */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 221 | const struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 222 | unsigned char aloopback_mask; |
| 223 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 224 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 225 | /* power management */ |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 226 | unsigned int power_map_bits; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 227 | unsigned int num_pwrs; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 228 | const hda_nid_t *pwr_nids; |
| 229 | const hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 230 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 231 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 232 | struct hda_input_mux *mono_mux; |
| 233 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 234 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 235 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 236 | hda_nid_t hp_dacs[5]; |
| 237 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 238 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 239 | int volume_offset; |
| 240 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 241 | /* capture */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 242 | const hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 243 | unsigned int num_adcs; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 244 | const hda_nid_t *mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 245 | unsigned int num_muxes; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 246 | const hda_nid_t *dmic_nids; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 247 | unsigned int num_dmics; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 248 | const hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 249 | unsigned int num_dmuxes; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 250 | const hda_nid_t *smux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 251 | unsigned int num_smuxes; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 252 | unsigned int num_analog_muxes; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 253 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 254 | const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ |
| 255 | const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 256 | unsigned int num_caps; /* number of capture volume/switch elements */ |
| 257 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 258 | struct sigmatel_mic_route ext_mic; |
| 259 | struct sigmatel_mic_route int_mic; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 260 | struct sigmatel_mic_route dock_mic; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 261 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 262 | const char * const *spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 263 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 264 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 265 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 266 | hda_nid_t anabeep_nid; |
| 267 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 268 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 269 | /* pin widgets */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 270 | const hda_nid_t *pin_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 271 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 272 | |
| 273 | /* codec specific stuff */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 274 | const struct hda_verb *init; |
| 275 | const struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 276 | |
| 277 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 278 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 279 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 280 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 281 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 282 | struct hda_input_mux *sinput_mux; |
| 283 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 284 | unsigned int cur_amux; |
| 285 | hda_nid_t *amp_nids; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 286 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 287 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 288 | /* i/o switches */ |
| 289 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 290 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 291 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 292 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 293 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 294 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 295 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 296 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 297 | |
| 298 | /* dynamic controls and input_mux */ |
| 299 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 300 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 301 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 302 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 303 | struct hda_input_mux private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 304 | struct hda_input_mux private_mono_mux; |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 305 | |
| 306 | /* auto spec */ |
| 307 | unsigned auto_pin_cnt; |
| 308 | hda_nid_t auto_pin_nids[MAX_PINS_NUM]; |
| 309 | unsigned auto_adc_cnt; |
| 310 | hda_nid_t auto_adc_nids[MAX_ADCS_NUM]; |
| 311 | hda_nid_t auto_mux_nids[MAX_ADCS_NUM]; |
| 312 | hda_nid_t auto_dmux_nids[MAX_ADCS_NUM]; |
| 313 | unsigned long auto_capvols[MAX_ADCS_NUM]; |
| 314 | unsigned auto_dmic_cnt; |
| 315 | hda_nid_t auto_dmic_nids[MAX_DMICS_NUM]; |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 316 | |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 317 | struct hda_vmaster_mute_hook vmaster_mute; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 318 | }; |
| 319 | |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 320 | #define AC_VERB_IDT_SET_POWER_MAP 0x7ec |
| 321 | #define AC_VERB_IDT_GET_POWER_MAP 0xfec |
| 322 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 323 | static const hda_nid_t stac9200_adc_nids[1] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 324 | 0x03, |
| 325 | }; |
| 326 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 327 | static const hda_nid_t stac9200_mux_nids[1] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 328 | 0x0c, |
| 329 | }; |
| 330 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 331 | static const hda_nid_t stac9200_dac_nids[1] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 332 | 0x02, |
| 333 | }; |
| 334 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 335 | static const hda_nid_t stac92hd73xx_pwr_nids[8] = { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 336 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 337 | 0x0f, 0x10, 0x11 |
| 338 | }; |
| 339 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 340 | static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 341 | 0x26, 0, |
| 342 | }; |
| 343 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 344 | static const hda_nid_t stac92hd73xx_adc_nids[2] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 345 | 0x1a, 0x1b |
| 346 | }; |
| 347 | |
| 348 | #define STAC92HD73XX_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 349 | static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 350 | 0x13, 0x14, 0 |
| 351 | }; |
| 352 | |
| 353 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 354 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 355 | static const hda_nid_t stac92hd73xx_mux_nids[2] = { |
Takashi Iwai | e2aec17 | 2009-09-02 01:00:05 +0200 | [diff] [blame] | 356 | 0x20, 0x21, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 357 | }; |
| 358 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 359 | static const hda_nid_t stac92hd73xx_dmux_nids[2] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 360 | 0x20, 0x21, |
| 361 | }; |
| 362 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 363 | static const hda_nid_t stac92hd73xx_smux_nids[2] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 364 | 0x22, 0x23, |
| 365 | }; |
| 366 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 367 | #define STAC92HD73XX_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 368 | static const unsigned long stac92hd73xx_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 369 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
| 370 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 371 | }; |
| 372 | #define stac92hd73xx_capsws stac92hd73xx_capvols |
| 373 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 374 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 375 | |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 376 | static const hda_nid_t stac92hd83xxx_pwr_nids[7] = { |
| 377 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 378 | 0x0f, 0x10 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 379 | }; |
| 380 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 381 | static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 382 | 0x1e, 0, |
| 383 | }; |
| 384 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 385 | static const hda_nid_t stac92hd83xxx_dmic_nids[] = { |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 386 | 0x11, 0x20, |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 387 | }; |
| 388 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 389 | static const hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 390 | 0x0a, 0x0d, 0x0f |
| 391 | }; |
| 392 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 393 | static const hda_nid_t stac92hd71bxx_adc_nids[2] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 394 | 0x12, 0x13, |
| 395 | }; |
| 396 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 397 | static const hda_nid_t stac92hd71bxx_mux_nids[2] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 398 | 0x1a, 0x1b |
| 399 | }; |
| 400 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 401 | static const hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 402 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 403 | }; |
| 404 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 405 | static const hda_nid_t stac92hd71bxx_smux_nids[2] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 406 | 0x24, 0x25, |
| 407 | }; |
| 408 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 409 | #define STAC92HD71BXX_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 410 | static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 411 | 0x18, 0x19, 0 |
| 412 | }; |
| 413 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 414 | static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = { |
| 415 | 0x18, 0 |
| 416 | }; |
| 417 | |
| 418 | static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 419 | 0x22, 0 |
| 420 | }; |
| 421 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 422 | #define STAC92HD71BXX_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 423 | static const unsigned long stac92hd71bxx_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 424 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 425 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 426 | }; |
| 427 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols |
| 428 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 429 | static const hda_nid_t stac925x_adc_nids[1] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 430 | 0x03, |
| 431 | }; |
| 432 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 433 | static const hda_nid_t stac925x_mux_nids[1] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 434 | 0x0f, |
| 435 | }; |
| 436 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 437 | static const hda_nid_t stac925x_dac_nids[1] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 438 | 0x02, |
| 439 | }; |
| 440 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 441 | #define STAC925X_NUM_DMICS 1 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 442 | static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 443 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 444 | }; |
| 445 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 446 | static const hda_nid_t stac925x_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 447 | 0x14, |
| 448 | }; |
| 449 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 450 | static const unsigned long stac925x_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 451 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), |
| 452 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 453 | static const unsigned long stac925x_capsws[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 454 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 455 | }; |
| 456 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 457 | static const hda_nid_t stac922x_adc_nids[2] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 458 | 0x06, 0x07, |
| 459 | }; |
| 460 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 461 | static const hda_nid_t stac922x_mux_nids[2] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 462 | 0x12, 0x13, |
| 463 | }; |
| 464 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 465 | #define STAC922X_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 466 | static const unsigned long stac922x_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 467 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), |
| 468 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 469 | }; |
| 470 | #define stac922x_capsws stac922x_capvols |
| 471 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 472 | static const hda_nid_t stac927x_slave_dig_outs[2] = { |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 473 | 0x1f, 0, |
| 474 | }; |
| 475 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 476 | static const hda_nid_t stac927x_adc_nids[3] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 477 | 0x07, 0x08, 0x09 |
| 478 | }; |
| 479 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 480 | static const hda_nid_t stac927x_mux_nids[3] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 481 | 0x15, 0x16, 0x17 |
| 482 | }; |
| 483 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 484 | static const hda_nid_t stac927x_smux_nids[1] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 485 | 0x21, |
| 486 | }; |
| 487 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 488 | static const hda_nid_t stac927x_dac_nids[6] = { |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 489 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 490 | }; |
| 491 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 492 | static const hda_nid_t stac927x_dmux_nids[1] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 493 | 0x1b, |
| 494 | }; |
| 495 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 496 | #define STAC927X_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 497 | static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 498 | 0x13, 0x14, 0 |
| 499 | }; |
| 500 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 501 | #define STAC927X_NUM_CAPS 3 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 502 | static const unsigned long stac927x_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 503 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 504 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), |
| 505 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), |
| 506 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 507 | static const unsigned long stac927x_capsws[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 508 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 509 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 510 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 511 | }; |
| 512 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 513 | static const char * const stac927x_spdif_labels[5] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 514 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 515 | "Analog Mux 2", "Analog Mux 3" |
| 516 | }; |
| 517 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 518 | static const hda_nid_t stac9205_adc_nids[2] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 519 | 0x12, 0x13 |
| 520 | }; |
| 521 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 522 | static const hda_nid_t stac9205_mux_nids[2] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 523 | 0x19, 0x1a |
| 524 | }; |
| 525 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 526 | static const hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 527 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 528 | }; |
| 529 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 530 | static const hda_nid_t stac9205_smux_nids[1] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 531 | 0x21, |
| 532 | }; |
| 533 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 534 | #define STAC9205_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 535 | static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 536 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 537 | }; |
| 538 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 539 | #define STAC9205_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 540 | static const unsigned long stac9205_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 541 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), |
| 542 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), |
| 543 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 544 | static const unsigned long stac9205_capsws[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 545 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 546 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), |
| 547 | }; |
| 548 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 549 | static const hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 550 | 0x08, 0x09, 0x0d, 0x0e, |
| 551 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 552 | }; |
| 553 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 554 | static const hda_nid_t stac925x_pin_nids[8] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 555 | 0x07, 0x08, 0x0a, 0x0b, |
| 556 | 0x0c, 0x0d, 0x10, 0x11, |
| 557 | }; |
| 558 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 559 | static const hda_nid_t stac922x_pin_nids[10] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 560 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 561 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 562 | }; |
| 563 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 564 | static const hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 565 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 566 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 567 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 568 | }; |
| 569 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 570 | #define STAC92HD71BXX_NUM_PINS 13 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 571 | static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = { |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 572 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 573 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 574 | 0x1f, 0x20, 0x27 |
| 575 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 576 | static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 577 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 578 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 579 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 580 | }; |
| 581 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 582 | static const hda_nid_t stac927x_pin_nids[14] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 583 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 584 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 585 | 0x14, 0x21, 0x22, 0x23, |
| 586 | }; |
| 587 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 588 | static const hda_nid_t stac9205_pin_nids[12] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 589 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 590 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 591 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 592 | }; |
| 593 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 594 | static int stac_add_event(struct hda_codec *codec, hda_nid_t nid, |
| 595 | unsigned char type, int data); |
| 596 | static int stac_add_hp_bass_switch(struct hda_codec *codec); |
| 597 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, |
| 598 | hda_nid_t nid, int pin_type); |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 599 | static int hp_bnb2011_with_dock(struct hda_codec *codec); |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 600 | static int hp_blike_system(u32 subsystem_id); |
| 601 | static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity); |
| 602 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 603 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 604 | struct snd_ctl_elem_info *uinfo) |
| 605 | { |
| 606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 607 | struct sigmatel_spec *spec = codec->spec; |
| 608 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 609 | } |
| 610 | |
| 611 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 612 | struct snd_ctl_elem_value *ucontrol) |
| 613 | { |
| 614 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 615 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 616 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 617 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 618 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 623 | struct snd_ctl_elem_value *ucontrol) |
| 624 | { |
| 625 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 626 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 627 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 628 | |
| 629 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 630 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 631 | } |
| 632 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 633 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 634 | struct snd_ctl_elem_info *uinfo) |
| 635 | { |
| 636 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 637 | struct sigmatel_spec *spec = codec->spec; |
| 638 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 639 | } |
| 640 | |
| 641 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 642 | struct snd_ctl_elem_value *ucontrol) |
| 643 | { |
| 644 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 645 | struct sigmatel_spec *spec = codec->spec; |
| 646 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 647 | |
| 648 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 653 | struct snd_ctl_elem_value *ucontrol) |
| 654 | { |
| 655 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 656 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 657 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 658 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 659 | int err, val; |
| 660 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 661 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 662 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 663 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 664 | if (err < 0) |
| 665 | return err; |
| 666 | |
| 667 | if (spec->spdif_mute) { |
| 668 | if (smux_idx == 0) |
| 669 | nid = spec->multiout.dig_out_nid; |
| 670 | else |
| 671 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 672 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 673 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 674 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 675 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 676 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 677 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 678 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 679 | } |
| 680 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 681 | } |
| 682 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 683 | static int stac_vrefout_set(struct hda_codec *codec, |
| 684 | hda_nid_t nid, unsigned int new_vref) |
| 685 | { |
| 686 | int error, pinctl; |
| 687 | |
| 688 | snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref); |
| 689 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 690 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 691 | |
| 692 | if (pinctl < 0) |
| 693 | return pinctl; |
| 694 | |
| 695 | pinctl &= 0xff; |
| 696 | pinctl &= ~AC_PINCTL_VREFEN; |
| 697 | pinctl |= (new_vref & AC_PINCTL_VREFEN); |
| 698 | |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 699 | error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl); |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 700 | if (error < 0) |
| 701 | return error; |
| 702 | |
| 703 | return 1; |
| 704 | } |
| 705 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 706 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 707 | hda_nid_t nid, unsigned int new_vref) |
| 708 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 709 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 710 | unsigned int pincfg; |
| 711 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 712 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 713 | |
| 714 | pincfg &= 0xff; |
| 715 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 716 | pincfg |= new_vref; |
| 717 | |
| 718 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 719 | pincfg |= AC_PINCTL_OUT_EN; |
| 720 | else |
| 721 | pincfg |= AC_PINCTL_IN_EN; |
| 722 | |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 723 | error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg); |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 724 | if (error < 0) |
| 725 | return error; |
| 726 | else |
| 727 | return 1; |
| 728 | } |
| 729 | |
| 730 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 731 | { |
| 732 | unsigned int vref; |
| 733 | vref = snd_hda_codec_read(codec, nid, 0, |
| 734 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 735 | vref &= AC_PINCTL_VREFEN; |
| 736 | return vref; |
| 737 | } |
| 738 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 739 | 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] | 740 | { |
| 741 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 742 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 743 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 744 | } |
| 745 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 746 | 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] | 747 | { |
| 748 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 749 | struct sigmatel_spec *spec = codec->spec; |
| 750 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 751 | |
| 752 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 753 | return 0; |
| 754 | } |
| 755 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 756 | 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] | 757 | { |
| 758 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 759 | struct sigmatel_spec *spec = codec->spec; |
| 760 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 761 | const struct hda_input_mux *imux = spec->input_mux; |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 762 | unsigned int idx, prev_idx, didx; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 763 | |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 764 | idx = ucontrol->value.enumerated.item[0]; |
| 765 | if (idx >= imux->num_items) |
| 766 | idx = imux->num_items - 1; |
| 767 | prev_idx = spec->cur_mux[adc_idx]; |
| 768 | if (prev_idx == idx) |
| 769 | return 0; |
| 770 | if (idx < spec->num_analog_muxes) { |
| 771 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, |
| 772 | AC_VERB_SET_CONNECT_SEL, |
| 773 | imux->items[idx].index); |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 774 | if (prev_idx >= spec->num_analog_muxes && |
| 775 | spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) { |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 776 | imux = spec->dinput_mux; |
| 777 | /* 0 = analog */ |
| 778 | snd_hda_codec_write_cache(codec, |
| 779 | spec->dmux_nids[adc_idx], 0, |
| 780 | AC_VERB_SET_CONNECT_SEL, |
| 781 | imux->items[0].index); |
| 782 | } |
| 783 | } else { |
| 784 | imux = spec->dinput_mux; |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 785 | /* first dimux item is hardcoded to select analog imux, |
| 786 | * so lets skip it |
| 787 | */ |
| 788 | didx = idx - spec->num_analog_muxes + 1; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 789 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, |
| 790 | AC_VERB_SET_CONNECT_SEL, |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 791 | imux->items[didx].index); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 792 | } |
| 793 | spec->cur_mux[adc_idx] = idx; |
| 794 | return 1; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 795 | } |
| 796 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 797 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 798 | struct snd_ctl_elem_info *uinfo) |
| 799 | { |
| 800 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 801 | struct sigmatel_spec *spec = codec->spec; |
| 802 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 803 | } |
| 804 | |
| 805 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 806 | struct snd_ctl_elem_value *ucontrol) |
| 807 | { |
| 808 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 809 | struct sigmatel_spec *spec = codec->spec; |
| 810 | |
| 811 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 812 | return 0; |
| 813 | } |
| 814 | |
| 815 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 816 | struct snd_ctl_elem_value *ucontrol) |
| 817 | { |
| 818 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 819 | struct sigmatel_spec *spec = codec->spec; |
| 820 | |
| 821 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 822 | spec->mono_nid, &spec->cur_mmux); |
| 823 | } |
| 824 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 825 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 826 | |
| 827 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 828 | struct snd_ctl_elem_value *ucontrol) |
| 829 | { |
| 830 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 831 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 832 | struct sigmatel_spec *spec = codec->spec; |
| 833 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 834 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 835 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 836 | return 0; |
| 837 | } |
| 838 | |
| 839 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 840 | struct snd_ctl_elem_value *ucontrol) |
| 841 | { |
| 842 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 843 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 844 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 845 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 846 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 847 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 848 | idx_val = spec->aloopback_mask << idx; |
| 849 | if (ucontrol->value.integer.value[0]) |
| 850 | val = spec->aloopback | idx_val; |
| 851 | else |
| 852 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 853 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 854 | return 0; |
| 855 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 856 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 857 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 858 | /* Only return the bits defined by the shift value of the |
| 859 | * first two bytes of the mask |
| 860 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 861 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 862 | kcontrol->private_value & 0xFFFF, 0x0); |
| 863 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 864 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 865 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 866 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 867 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 868 | } else { |
| 869 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 870 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 874 | kcontrol->private_value >> 16, dac_mode); |
| 875 | |
| 876 | return 1; |
| 877 | } |
| 878 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 879 | static const struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 880 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 881 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 882 | {} |
| 883 | }; |
| 884 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 885 | static const struct hda_verb stac9200_eapd_init[] = { |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 886 | /* set dac0mux for dac converter */ |
| 887 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 888 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 889 | {} |
| 890 | }; |
| 891 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 892 | static const struct hda_verb dell_eq_core_init[] = { |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 893 | /* set master volume to max value without distortion |
| 894 | * and direct control */ |
| 895 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 896 | {} |
| 897 | }; |
| 898 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 899 | static const struct hda_verb stac92hd73xx_core_init[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 900 | /* set master volume and direct control */ |
| 901 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 902 | {} |
| 903 | }; |
| 904 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 905 | static const struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 906 | /* power state controls amps */ |
| 907 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 908 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 909 | }; |
| 910 | |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 911 | static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = { |
| 912 | { 0x22, 0x785, 0x43 }, |
| 913 | { 0x22, 0x782, 0xe0 }, |
| 914 | { 0x22, 0x795, 0x00 }, |
| 915 | {} |
| 916 | }; |
| 917 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 918 | static const struct hda_verb stac92hd71bxx_core_init[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 919 | /* set master volume and direct control */ |
| 920 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 921 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 922 | }; |
| 923 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 924 | static const struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 925 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 926 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 927 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 928 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 929 | {} |
| 930 | }; |
| 931 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 932 | static const struct hda_verb stac925x_core_init[] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 933 | /* set dac0mux for dac converter */ |
| 934 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 935 | /* mute the master volume */ |
| 936 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 937 | {} |
| 938 | }; |
| 939 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 940 | static const struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 941 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 942 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 943 | {} |
| 944 | }; |
| 945 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 946 | static const struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 947 | /* unmute node 0x1b */ |
| 948 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 949 | /* select node 0x03 as DAC */ |
| 950 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 951 | {} |
| 952 | }; |
| 953 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 954 | static const struct hda_verb dell_3st_core_init[] = { |
Takashi Iwai | ccca7cd | 2009-10-13 15:32:21 +0200 | [diff] [blame] | 955 | /* don't set delta bit */ |
| 956 | {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f}, |
| 957 | /* unmute node 0x1b */ |
| 958 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 959 | /* select node 0x03 as DAC */ |
| 960 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 961 | {} |
| 962 | }; |
| 963 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 964 | static const struct hda_verb stac927x_core_init[] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 965 | /* set master volume and direct control */ |
| 966 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 967 | /* enable analog pc beep path */ |
| 968 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 969 | {} |
| 970 | }; |
| 971 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 972 | static const struct hda_verb stac927x_volknob_core_init[] = { |
Takashi Iwai | 5493053 | 2009-10-11 17:38:29 +0200 | [diff] [blame] | 973 | /* don't set delta bit */ |
| 974 | {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f}, |
| 975 | /* enable analog pc beep path */ |
| 976 | {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
| 977 | {} |
| 978 | }; |
| 979 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 980 | static const struct hda_verb stac9205_core_init[] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 981 | /* set master volume and direct control */ |
| 982 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 983 | /* enable analog pc beep path */ |
| 984 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 985 | {} |
| 986 | }; |
| 987 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 988 | #define STAC_MONO_MUX \ |
| 989 | { \ |
| 990 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 991 | .name = "Mono Mux", \ |
| 992 | .count = 1, \ |
| 993 | .info = stac92xx_mono_mux_enum_info, \ |
| 994 | .get = stac92xx_mono_mux_enum_get, \ |
| 995 | .put = stac92xx_mono_mux_enum_put, \ |
| 996 | } |
| 997 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 998 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 999 | { \ |
| 1000 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1001 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1002 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1003 | .info = stac92xx_aloopback_info, \ |
| 1004 | .get = stac92xx_aloopback_get, \ |
| 1005 | .put = stac92xx_aloopback_put, \ |
| 1006 | .private_value = verb_read | (verb_write << 16), \ |
| 1007 | } |
| 1008 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1009 | #define DC_BIAS(xname, idx, nid) \ |
| 1010 | { \ |
| 1011 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1012 | .name = xname, \ |
| 1013 | .index = idx, \ |
| 1014 | .info = stac92xx_dc_bias_info, \ |
| 1015 | .get = stac92xx_dc_bias_get, \ |
| 1016 | .put = stac92xx_dc_bias_put, \ |
| 1017 | .private_value = nid, \ |
| 1018 | } |
| 1019 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1020 | static const struct snd_kcontrol_new stac9200_mixer[] = { |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1021 | HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1022 | HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1023 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1024 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1025 | { } /* end */ |
| 1026 | }; |
| 1027 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1028 | static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1029 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1030 | {} |
| 1031 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1032 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1033 | static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1034 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1035 | {} |
| 1036 | }; |
| 1037 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1038 | static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1039 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1040 | {} |
| 1041 | }; |
| 1042 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1043 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1044 | static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1045 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1046 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1047 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1048 | static const struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1049 | HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT), |
| 1050 | HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1051 | { } /* end */ |
| 1052 | }; |
| 1053 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1054 | static const struct snd_kcontrol_new stac9205_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1055 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1056 | {} |
| 1057 | }; |
| 1058 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1059 | static const struct snd_kcontrol_new stac927x_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1060 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1061 | {} |
| 1062 | }; |
| 1063 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1064 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1065 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1066 | .name = "Digital Input Source", |
| 1067 | /* count set later */ |
| 1068 | .info = stac92xx_dmux_enum_info, |
| 1069 | .get = stac92xx_dmux_enum_get, |
| 1070 | .put = stac92xx_dmux_enum_put, |
| 1071 | }; |
| 1072 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1073 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1074 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1075 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1076 | /* count set later */ |
| 1077 | .info = stac92xx_smux_enum_info, |
| 1078 | .get = stac92xx_smux_enum_get, |
| 1079 | .put = stac92xx_smux_enum_put, |
| 1080 | }; |
| 1081 | |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1082 | static const char * const slave_pfxs[] = { |
| 1083 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 1084 | "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1085 | NULL |
| 1086 | }; |
| 1087 | |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1088 | static void stac92xx_update_led_status(struct hda_codec *codec, int enabled); |
| 1089 | |
| 1090 | static void stac92xx_vmaster_hook(void *private_data, int val) |
| 1091 | { |
| 1092 | stac92xx_update_led_status(private_data, val); |
| 1093 | } |
| 1094 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1095 | static void stac92xx_free_kctls(struct hda_codec *codec); |
| 1096 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1097 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1098 | { |
| 1099 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1100 | unsigned int vmaster_tlv[4]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1101 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1102 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1103 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 1104 | if (spec->mixer) { |
| 1105 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1106 | if (err < 0) |
| 1107 | return err; |
| 1108 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1109 | |
| 1110 | for (i = 0; i < spec->num_mixers; i++) { |
| 1111 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1112 | if (err < 0) |
| 1113 | return err; |
| 1114 | } |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 1115 | if (!spec->auto_mic && spec->num_dmuxes > 0 && |
| 1116 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1117 | stac_dmux_mixer.count = spec->num_dmuxes; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 1118 | err = snd_hda_ctl_add(codec, 0, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1119 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1120 | if (err < 0) |
| 1121 | return err; |
| 1122 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1123 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1124 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1125 | struct hda_input_mux *smux = &spec->private_smux; |
| 1126 | /* check for mute support on SPDIF out */ |
| 1127 | if (wcaps & AC_WCAP_OUT_AMP) { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 1128 | snd_hda_add_imux_item(smux, "Off", 0, NULL); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1129 | spec->spdif_mute = 1; |
| 1130 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1131 | stac_smux_mixer.count = spec->num_smuxes; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 1132 | err = snd_hda_ctl_add(codec, 0, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1133 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1134 | if (err < 0) |
| 1135 | return err; |
| 1136 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1137 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1138 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1139 | err = snd_hda_create_dig_out_ctls(codec, |
| 1140 | spec->multiout.dig_out_nid, |
| 1141 | spec->multiout.dig_out_nid, |
| 1142 | spec->autocfg.dig_out_type[0]); |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1143 | if (err < 0) |
| 1144 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1145 | err = snd_hda_create_spdif_share_sw(codec, |
| 1146 | &spec->multiout); |
| 1147 | if (err < 0) |
| 1148 | return err; |
| 1149 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1150 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1151 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1152 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1153 | if (err < 0) |
| 1154 | return err; |
| 1155 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1156 | |
| 1157 | /* if we have no master control, let's create it */ |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1158 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
| 1159 | HDA_OUTPUT, vmaster_tlv); |
| 1160 | /* correct volume offset */ |
| 1161 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
| 1162 | /* minimum value is actually mute */ |
| 1163 | vmaster_tlv[3] |= TLV_DB_SCALE_MUTE; |
| 1164 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
| 1165 | vmaster_tlv, slave_pfxs, |
| 1166 | "Playback Volume"); |
| 1167 | if (err < 0) |
| 1168 | return err; |
| 1169 | |
| 1170 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1171 | NULL, slave_pfxs, |
| 1172 | "Playback Switch", true, |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1173 | &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1174 | if (err < 0) |
| 1175 | return err; |
| 1176 | |
| 1177 | if (spec->gpio_led) { |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1178 | spec->vmaster_mute.hook = stac92xx_vmaster_hook; |
Takashi Iwai | f29735cb | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 1179 | err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1180 | if (err < 0) |
| 1181 | return err; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1182 | } |
| 1183 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1184 | if (spec->aloopback_ctl && |
| 1185 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1186 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1187 | if (err < 0) |
| 1188 | return err; |
| 1189 | } |
| 1190 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1191 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1192 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1193 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1194 | if (err < 0) |
| 1195 | return err; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1196 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1197 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1198 | } |
| 1199 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1200 | static const struct hda_pintbl ref9200_pin_configs[] = { |
| 1201 | { 0x08, 0x01c47010 }, |
| 1202 | { 0x09, 0x01447010 }, |
| 1203 | { 0x0d, 0x0221401f }, |
| 1204 | { 0x0e, 0x01114010 }, |
| 1205 | { 0x0f, 0x02a19020 }, |
| 1206 | { 0x10, 0x01a19021 }, |
| 1207 | { 0x11, 0x90100140 }, |
| 1208 | { 0x12, 0x01813122 }, |
| 1209 | {} |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1210 | }; |
| 1211 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1212 | static const struct hda_pintbl gateway9200_m4_pin_configs[] = { |
| 1213 | { 0x08, 0x400000fe }, |
| 1214 | { 0x09, 0x404500f4 }, |
| 1215 | { 0x0d, 0x400100f0 }, |
| 1216 | { 0x0e, 0x90110010 }, |
| 1217 | { 0x0f, 0x400100f1 }, |
| 1218 | { 0x10, 0x02a1902e }, |
| 1219 | { 0x11, 0x500000f2 }, |
| 1220 | { 0x12, 0x500000f3 }, |
| 1221 | {} |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1222 | }; |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1223 | |
| 1224 | static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = { |
| 1225 | { 0x08, 0x400000fe }, |
| 1226 | { 0x09, 0x404500f4 }, |
| 1227 | { 0x0d, 0x400100f0 }, |
| 1228 | { 0x0e, 0x90110010 }, |
| 1229 | { 0x0f, 0x400100f1 }, |
| 1230 | { 0x10, 0x02a1902e }, |
| 1231 | { 0x11, 0x500000f2 }, |
| 1232 | { 0x12, 0x500000f3 }, |
| 1233 | {} |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1234 | }; |
| 1235 | |
| 1236 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1237 | STAC 9200 pin configs for |
| 1238 | 102801A8 |
| 1239 | 102801DE |
| 1240 | 102801E8 |
| 1241 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1242 | static const struct hda_pintbl dell9200_d21_pin_configs[] = { |
| 1243 | { 0x08, 0x400001f0 }, |
| 1244 | { 0x09, 0x400001f1 }, |
| 1245 | { 0x0d, 0x02214030 }, |
| 1246 | { 0x0e, 0x01014010 }, |
| 1247 | { 0x0f, 0x02a19020 }, |
| 1248 | { 0x10, 0x01a19021 }, |
| 1249 | { 0x11, 0x90100140 }, |
| 1250 | { 0x12, 0x01813122 }, |
| 1251 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1252 | }; |
| 1253 | |
| 1254 | /* |
| 1255 | STAC 9200 pin configs for |
| 1256 | 102801C0 |
| 1257 | 102801C1 |
| 1258 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1259 | static const struct hda_pintbl dell9200_d22_pin_configs[] = { |
| 1260 | { 0x08, 0x400001f0 }, |
| 1261 | { 0x09, 0x400001f1 }, |
| 1262 | { 0x0d, 0x0221401f }, |
| 1263 | { 0x0e, 0x01014010 }, |
| 1264 | { 0x0f, 0x01813020 }, |
| 1265 | { 0x10, 0x02a19021 }, |
| 1266 | { 0x11, 0x90100140 }, |
| 1267 | { 0x12, 0x400001f2 }, |
| 1268 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1269 | }; |
| 1270 | |
| 1271 | /* |
| 1272 | STAC 9200 pin configs for |
| 1273 | 102801C4 (Dell Dimension E310) |
| 1274 | 102801C5 |
| 1275 | 102801C7 |
| 1276 | 102801D9 |
| 1277 | 102801DA |
| 1278 | 102801E3 |
| 1279 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1280 | static const struct hda_pintbl dell9200_d23_pin_configs[] = { |
| 1281 | { 0x08, 0x400001f0 }, |
| 1282 | { 0x09, 0x400001f1 }, |
| 1283 | { 0x0d, 0x0221401f }, |
| 1284 | { 0x0e, 0x01014010 }, |
| 1285 | { 0x0f, 0x01813020 }, |
| 1286 | { 0x10, 0x01a19021 }, |
| 1287 | { 0x11, 0x90100140 }, |
| 1288 | { 0x12, 0x400001f2 }, |
| 1289 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1290 | }; |
| 1291 | |
| 1292 | |
| 1293 | /* |
| 1294 | STAC 9200-32 pin configs for |
| 1295 | 102801B5 (Dell Inspiron 630m) |
| 1296 | 102801D8 (Dell Inspiron 640m) |
| 1297 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1298 | static const struct hda_pintbl dell9200_m21_pin_configs[] = { |
| 1299 | { 0x08, 0x40c003fa }, |
| 1300 | { 0x09, 0x03441340 }, |
| 1301 | { 0x0d, 0x0321121f }, |
| 1302 | { 0x0e, 0x90170310 }, |
| 1303 | { 0x0f, 0x408003fb }, |
| 1304 | { 0x10, 0x03a11020 }, |
| 1305 | { 0x11, 0x401003fc }, |
| 1306 | { 0x12, 0x403003fd }, |
| 1307 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1308 | }; |
| 1309 | |
| 1310 | /* |
| 1311 | STAC 9200-32 pin configs for |
| 1312 | 102801C2 (Dell Latitude D620) |
| 1313 | 102801C8 |
| 1314 | 102801CC (Dell Latitude D820) |
| 1315 | 102801D4 |
| 1316 | 102801D6 |
| 1317 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1318 | static const struct hda_pintbl dell9200_m22_pin_configs[] = { |
| 1319 | { 0x08, 0x40c003fa }, |
| 1320 | { 0x09, 0x0144131f }, |
| 1321 | { 0x0d, 0x0321121f }, |
| 1322 | { 0x0e, 0x90170310 }, |
| 1323 | { 0x0f, 0x90a70321 }, |
| 1324 | { 0x10, 0x03a11020 }, |
| 1325 | { 0x11, 0x401003fb }, |
| 1326 | { 0x12, 0x40f000fc }, |
| 1327 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1328 | }; |
| 1329 | |
| 1330 | /* |
| 1331 | STAC 9200-32 pin configs for |
| 1332 | 102801CE (Dell XPS M1710) |
| 1333 | 102801CF (Dell Precision M90) |
| 1334 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1335 | static const struct hda_pintbl dell9200_m23_pin_configs[] = { |
| 1336 | { 0x08, 0x40c003fa }, |
| 1337 | { 0x09, 0x01441340 }, |
| 1338 | { 0x0d, 0x0421421f }, |
| 1339 | { 0x0e, 0x90170310 }, |
| 1340 | { 0x0f, 0x408003fb }, |
| 1341 | { 0x10, 0x04a1102e }, |
| 1342 | { 0x11, 0x90170311 }, |
| 1343 | { 0x12, 0x403003fc }, |
| 1344 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1345 | }; |
| 1346 | |
| 1347 | /* |
| 1348 | STAC 9200-32 pin configs for |
| 1349 | 102801C9 |
| 1350 | 102801CA |
| 1351 | 102801CB (Dell Latitude 120L) |
| 1352 | 102801D3 |
| 1353 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1354 | static const struct hda_pintbl dell9200_m24_pin_configs[] = { |
| 1355 | { 0x08, 0x40c003fa }, |
| 1356 | { 0x09, 0x404003fb }, |
| 1357 | { 0x0d, 0x0321121f }, |
| 1358 | { 0x0e, 0x90170310 }, |
| 1359 | { 0x0f, 0x408003fc }, |
| 1360 | { 0x10, 0x03a11020 }, |
| 1361 | { 0x11, 0x401003fd }, |
| 1362 | { 0x12, 0x403003fe }, |
| 1363 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1364 | }; |
| 1365 | |
| 1366 | /* |
| 1367 | STAC 9200-32 pin configs for |
| 1368 | 102801BD (Dell Inspiron E1505n) |
| 1369 | 102801EE |
| 1370 | 102801EF |
| 1371 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1372 | static const struct hda_pintbl dell9200_m25_pin_configs[] = { |
| 1373 | { 0x08, 0x40c003fa }, |
| 1374 | { 0x09, 0x01441340 }, |
| 1375 | { 0x0d, 0x0421121f }, |
| 1376 | { 0x0e, 0x90170310 }, |
| 1377 | { 0x0f, 0x408003fb }, |
| 1378 | { 0x10, 0x04a11020 }, |
| 1379 | { 0x11, 0x401003fc }, |
| 1380 | { 0x12, 0x403003fd }, |
| 1381 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1382 | }; |
| 1383 | |
| 1384 | /* |
| 1385 | STAC 9200-32 pin configs for |
| 1386 | 102801F5 (Dell Inspiron 1501) |
| 1387 | 102801F6 |
| 1388 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1389 | static const struct hda_pintbl dell9200_m26_pin_configs[] = { |
| 1390 | { 0x08, 0x40c003fa }, |
| 1391 | { 0x09, 0x404003fb }, |
| 1392 | { 0x0d, 0x0421121f }, |
| 1393 | { 0x0e, 0x90170310 }, |
| 1394 | { 0x0f, 0x408003fc }, |
| 1395 | { 0x10, 0x04a11020 }, |
| 1396 | { 0x11, 0x401003fd }, |
| 1397 | { 0x12, 0x403003fe }, |
| 1398 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1399 | }; |
| 1400 | |
| 1401 | /* |
| 1402 | STAC 9200-32 |
| 1403 | 102801CD (Dell Inspiron E1705/9400) |
| 1404 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1405 | static const struct hda_pintbl dell9200_m27_pin_configs[] = { |
| 1406 | { 0x08, 0x40c003fa }, |
| 1407 | { 0x09, 0x01441340 }, |
| 1408 | { 0x0d, 0x0421121f }, |
| 1409 | { 0x0e, 0x90170310 }, |
| 1410 | { 0x0f, 0x90170310 }, |
| 1411 | { 0x10, 0x04a11020 }, |
| 1412 | { 0x11, 0x90170310 }, |
| 1413 | { 0x12, 0x40f003fc }, |
| 1414 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1415 | }; |
| 1416 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1417 | static const struct hda_pintbl oqo9200_pin_configs[] = { |
| 1418 | { 0x08, 0x40c000f0 }, |
| 1419 | { 0x09, 0x404000f1 }, |
| 1420 | { 0x0d, 0x0221121f }, |
| 1421 | { 0x0e, 0x02211210 }, |
| 1422 | { 0x0f, 0x90170111 }, |
| 1423 | { 0x10, 0x90a70120 }, |
| 1424 | { 0x11, 0x400000f2 }, |
| 1425 | { 0x12, 0x400000f3 }, |
| 1426 | {} |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1427 | }; |
| 1428 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1429 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1430 | static void stac9200_fixup_panasonic(struct hda_codec *codec, |
| 1431 | const struct hda_fixup *fix, int action) |
| 1432 | { |
| 1433 | struct sigmatel_spec *spec = codec->spec; |
| 1434 | |
| 1435 | switch (action) { |
| 1436 | case HDA_FIXUP_ACT_PRE_PROBE: |
| 1437 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 1438 | spec->gpio_data = 0x00; |
| 1439 | break; |
| 1440 | case HDA_FIXUP_ACT_PROBE: |
| 1441 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 1442 | * do detection and HP/speaker toggle because the hardware does it. |
| 1443 | */ |
| 1444 | spec->hp_detect = 0; |
| 1445 | break; |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | |
| 1450 | static const struct hda_fixup stac9200_fixups[] = { |
| 1451 | [STAC_REF] = { |
| 1452 | .type = HDA_FIXUP_PINS, |
| 1453 | .v.pins = ref9200_pin_configs, |
| 1454 | }, |
| 1455 | [STAC_9200_OQO] = { |
| 1456 | .type = HDA_FIXUP_PINS, |
| 1457 | .v.pins = oqo9200_pin_configs, |
| 1458 | .chained = true, |
| 1459 | .chain_id = STAC_9200_EAPD_INIT, |
| 1460 | }, |
| 1461 | [STAC_9200_DELL_D21] = { |
| 1462 | .type = HDA_FIXUP_PINS, |
| 1463 | .v.pins = dell9200_d21_pin_configs, |
| 1464 | }, |
| 1465 | [STAC_9200_DELL_D22] = { |
| 1466 | .type = HDA_FIXUP_PINS, |
| 1467 | .v.pins = dell9200_d22_pin_configs, |
| 1468 | }, |
| 1469 | [STAC_9200_DELL_D23] = { |
| 1470 | .type = HDA_FIXUP_PINS, |
| 1471 | .v.pins = dell9200_d23_pin_configs, |
| 1472 | }, |
| 1473 | [STAC_9200_DELL_M21] = { |
| 1474 | .type = HDA_FIXUP_PINS, |
| 1475 | .v.pins = dell9200_m21_pin_configs, |
| 1476 | }, |
| 1477 | [STAC_9200_DELL_M22] = { |
| 1478 | .type = HDA_FIXUP_PINS, |
| 1479 | .v.pins = dell9200_m22_pin_configs, |
| 1480 | }, |
| 1481 | [STAC_9200_DELL_M23] = { |
| 1482 | .type = HDA_FIXUP_PINS, |
| 1483 | .v.pins = dell9200_m23_pin_configs, |
| 1484 | }, |
| 1485 | [STAC_9200_DELL_M24] = { |
| 1486 | .type = HDA_FIXUP_PINS, |
| 1487 | .v.pins = dell9200_m24_pin_configs, |
| 1488 | }, |
| 1489 | [STAC_9200_DELL_M25] = { |
| 1490 | .type = HDA_FIXUP_PINS, |
| 1491 | .v.pins = dell9200_m25_pin_configs, |
| 1492 | }, |
| 1493 | [STAC_9200_DELL_M26] = { |
| 1494 | .type = HDA_FIXUP_PINS, |
| 1495 | .v.pins = dell9200_m26_pin_configs, |
| 1496 | }, |
| 1497 | [STAC_9200_DELL_M27] = { |
| 1498 | .type = HDA_FIXUP_PINS, |
| 1499 | .v.pins = dell9200_m27_pin_configs, |
| 1500 | }, |
| 1501 | [STAC_9200_M4] = { |
| 1502 | .type = HDA_FIXUP_PINS, |
| 1503 | .v.pins = gateway9200_m4_pin_configs, |
| 1504 | .chained = true, |
| 1505 | .chain_id = STAC_9200_EAPD_INIT, |
| 1506 | }, |
| 1507 | [STAC_9200_M4_2] = { |
| 1508 | .type = HDA_FIXUP_PINS, |
| 1509 | .v.pins = gateway9200_m4_2_pin_configs, |
| 1510 | .chained = true, |
| 1511 | .chain_id = STAC_9200_EAPD_INIT, |
| 1512 | }, |
| 1513 | [STAC_9200_PANASONIC] = { |
| 1514 | .type = HDA_FIXUP_FUNC, |
| 1515 | .v.func = stac9200_fixup_panasonic, |
| 1516 | }, |
| 1517 | [STAC_9200_EAPD_INIT] = { |
| 1518 | .type = HDA_FIXUP_VERBS, |
| 1519 | .v.verbs = (const struct hda_verb[]) { |
| 1520 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 1521 | {} |
| 1522 | }, |
| 1523 | }, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1524 | }; |
| 1525 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1526 | static const struct hda_model_fixup stac9200_models[] = { |
| 1527 | { .id = STAC_REF, .name = "ref" }, |
| 1528 | { .id = STAC_9200_OQO, .name = "oqo" }, |
| 1529 | { .id = STAC_9200_DELL_D21, .name = "dell-d21" }, |
| 1530 | { .id = STAC_9200_DELL_D22, .name = "dell-d22" }, |
| 1531 | { .id = STAC_9200_DELL_D23, .name = "dell-d23" }, |
| 1532 | { .id = STAC_9200_DELL_M21, .name = "dell-m21" }, |
| 1533 | { .id = STAC_9200_DELL_M22, .name = "dell-m22" }, |
| 1534 | { .id = STAC_9200_DELL_M23, .name = "dell-m23" }, |
| 1535 | { .id = STAC_9200_DELL_M24, .name = "dell-m24" }, |
| 1536 | { .id = STAC_9200_DELL_M25, .name = "dell-m25" }, |
| 1537 | { .id = STAC_9200_DELL_M26, .name = "dell-m26" }, |
| 1538 | { .id = STAC_9200_DELL_M27, .name = "dell-m27" }, |
| 1539 | { .id = STAC_9200_M4, .name = "gateway-m4" }, |
| 1540 | { .id = STAC_9200_M4_2, .name = "gateway-m4-2" }, |
| 1541 | { .id = STAC_9200_PANASONIC, .name = "panasonic" }, |
| 1542 | {} |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1543 | }; |
| 1544 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1545 | static const struct snd_pci_quirk stac9200_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1546 | /* SigmaTel reference board */ |
| 1547 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1548 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1550 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1551 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1552 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1553 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1554 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1555 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1556 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1557 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1558 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1559 | "unknown Dell", STAC_9200_DELL_D22), |
| 1560 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1561 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1562 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1563 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1564 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1565 | "unknown Dell", STAC_9200_DELL_D23), |
| 1566 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1567 | "unknown Dell", STAC_9200_DELL_D23), |
| 1568 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1569 | "unknown Dell", STAC_9200_DELL_M22), |
| 1570 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1571 | "unknown Dell", STAC_9200_DELL_M24), |
| 1572 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1573 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1574 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1575 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1576 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1577 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1578 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1579 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1580 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1581 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1582 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1583 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1584 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1585 | "unknown Dell", STAC_9200_DELL_M22), |
| 1586 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1587 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1588 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1589 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1590 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1591 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1592 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1593 | "unknown Dell", STAC_9200_DELL_D23), |
| 1594 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1595 | "unknown Dell", STAC_9200_DELL_D23), |
| 1596 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1597 | "unknown Dell", STAC_9200_DELL_D21), |
| 1598 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1599 | "unknown Dell", STAC_9200_DELL_D23), |
| 1600 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1601 | "unknown Dell", STAC_9200_DELL_D21), |
| 1602 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1603 | "unknown Dell", STAC_9200_DELL_M25), |
| 1604 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1605 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1606 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1607 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1608 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1609 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1610 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1611 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1612 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1613 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1614 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1615 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1616 | /* OQO Mobile */ |
| 1617 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1618 | {} /* terminator */ |
| 1619 | }; |
| 1620 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1621 | static const struct hda_pintbl ref925x_pin_configs[] = { |
| 1622 | { 0x07, 0x40c003f0 }, |
| 1623 | { 0x08, 0x424503f2 }, |
| 1624 | { 0x0a, 0x01813022 }, |
| 1625 | { 0x0b, 0x02a19021 }, |
| 1626 | { 0x0c, 0x90a70320 }, |
| 1627 | { 0x0d, 0x02214210 }, |
| 1628 | { 0x10, 0x01019020 }, |
| 1629 | { 0x11, 0x9033032e }, |
| 1630 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1631 | }; |
| 1632 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1633 | static const struct hda_pintbl stac925xM1_pin_configs[] = { |
| 1634 | { 0x07, 0x40c003f4 }, |
| 1635 | { 0x08, 0x424503f2 }, |
| 1636 | { 0x0a, 0x400000f3 }, |
| 1637 | { 0x0b, 0x02a19020 }, |
| 1638 | { 0x0c, 0x40a000f0 }, |
| 1639 | { 0x0d, 0x90100210 }, |
| 1640 | { 0x10, 0x400003f1 }, |
| 1641 | { 0x11, 0x9033032e }, |
| 1642 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1643 | }; |
| 1644 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1645 | static const struct hda_pintbl stac925xM1_2_pin_configs[] = { |
| 1646 | { 0x07, 0x40c003f4 }, |
| 1647 | { 0x08, 0x424503f2 }, |
| 1648 | { 0x0a, 0x400000f3 }, |
| 1649 | { 0x0b, 0x02a19020 }, |
| 1650 | { 0x0c, 0x40a000f0 }, |
| 1651 | { 0x0d, 0x90100210 }, |
| 1652 | { 0x10, 0x400003f1 }, |
| 1653 | { 0x11, 0x9033032e }, |
| 1654 | {} |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1655 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1656 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1657 | static const struct hda_pintbl stac925xM2_pin_configs[] = { |
| 1658 | { 0x07, 0x40c003f4 }, |
| 1659 | { 0x08, 0x424503f2 }, |
| 1660 | { 0x0a, 0x400000f3 }, |
| 1661 | { 0x0b, 0x02a19020 }, |
| 1662 | { 0x0c, 0x40a000f0 }, |
| 1663 | { 0x0d, 0x90100210 }, |
| 1664 | { 0x10, 0x400003f1 }, |
| 1665 | { 0x11, 0x9033032e }, |
| 1666 | {} |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1667 | }; |
| 1668 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1669 | static const struct hda_pintbl stac925xM2_2_pin_configs[] = { |
| 1670 | { 0x07, 0x40c003f4 }, |
| 1671 | { 0x08, 0x424503f2 }, |
| 1672 | { 0x0a, 0x400000f3 }, |
| 1673 | { 0x0b, 0x02a19020 }, |
| 1674 | { 0x0c, 0x40a000f0 }, |
| 1675 | { 0x0d, 0x90100210 }, |
| 1676 | { 0x10, 0x400003f1 }, |
| 1677 | { 0x11, 0x9033032e }, |
| 1678 | {} |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1679 | }; |
| 1680 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1681 | static const struct hda_pintbl stac925xM3_pin_configs[] = { |
| 1682 | { 0x07, 0x40c003f4 }, |
| 1683 | { 0x08, 0x424503f2 }, |
| 1684 | { 0x0a, 0x400000f3 }, |
| 1685 | { 0x0b, 0x02a19020 }, |
| 1686 | { 0x0c, 0x40a000f0 }, |
| 1687 | { 0x0d, 0x90100210 }, |
| 1688 | { 0x10, 0x400003f1 }, |
| 1689 | { 0x11, 0x503303f3 }, |
| 1690 | {} |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1691 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1692 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1693 | static const struct hda_pintbl stac925xM5_pin_configs[] = { |
| 1694 | { 0x07, 0x40c003f4 }, |
| 1695 | { 0x08, 0x424503f2 }, |
| 1696 | { 0x0a, 0x400000f3 }, |
| 1697 | { 0x0b, 0x02a19020 }, |
| 1698 | { 0x0c, 0x40a000f0 }, |
| 1699 | { 0x0d, 0x90100210 }, |
| 1700 | { 0x10, 0x400003f1 }, |
| 1701 | { 0x11, 0x9033032e }, |
| 1702 | {} |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1703 | }; |
| 1704 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1705 | static const struct hda_pintbl stac925xM6_pin_configs[] = { |
| 1706 | { 0x07, 0x40c003f4 }, |
| 1707 | { 0x08, 0x424503f2 }, |
| 1708 | { 0x0a, 0x400000f3 }, |
| 1709 | { 0x0b, 0x02a19020 }, |
| 1710 | { 0x0c, 0x40a000f0 }, |
| 1711 | { 0x0d, 0x90100210 }, |
| 1712 | { 0x10, 0x400003f1 }, |
| 1713 | { 0x11, 0x90330320 }, |
| 1714 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1715 | }; |
| 1716 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1717 | static const struct hda_fixup stac925x_fixups[] = { |
| 1718 | [STAC_REF] = { |
| 1719 | .type = HDA_FIXUP_PINS, |
| 1720 | .v.pins = ref925x_pin_configs, |
| 1721 | }, |
| 1722 | [STAC_M1] = { |
| 1723 | .type = HDA_FIXUP_PINS, |
| 1724 | .v.pins = stac925xM1_pin_configs, |
| 1725 | }, |
| 1726 | [STAC_M1_2] = { |
| 1727 | .type = HDA_FIXUP_PINS, |
| 1728 | .v.pins = stac925xM1_2_pin_configs, |
| 1729 | }, |
| 1730 | [STAC_M2] = { |
| 1731 | .type = HDA_FIXUP_PINS, |
| 1732 | .v.pins = stac925xM2_pin_configs, |
| 1733 | }, |
| 1734 | [STAC_M2_2] = { |
| 1735 | .type = HDA_FIXUP_PINS, |
| 1736 | .v.pins = stac925xM2_2_pin_configs, |
| 1737 | }, |
| 1738 | [STAC_M3] = { |
| 1739 | .type = HDA_FIXUP_PINS, |
| 1740 | .v.pins = stac925xM3_pin_configs, |
| 1741 | }, |
| 1742 | [STAC_M5] = { |
| 1743 | .type = HDA_FIXUP_PINS, |
| 1744 | .v.pins = stac925xM5_pin_configs, |
| 1745 | }, |
| 1746 | [STAC_M6] = { |
| 1747 | .type = HDA_FIXUP_PINS, |
| 1748 | .v.pins = stac925xM6_pin_configs, |
| 1749 | }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1750 | }; |
| 1751 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1752 | static const struct hda_model_fixup stac925x_models[] = { |
| 1753 | { .id = STAC_REF, .name = "ref" }, |
| 1754 | { .id = STAC_M1, .name = "m1" }, |
| 1755 | { .id = STAC_M1_2, .name = "m1-2" }, |
| 1756 | { .id = STAC_M2, .name = "m2" }, |
| 1757 | { .id = STAC_M2_2, .name = "m2-2" }, |
| 1758 | { .id = STAC_M3, .name = "m3" }, |
| 1759 | { .id = STAC_M5, .name = "m5" }, |
| 1760 | { .id = STAC_M6, .name = "m6" }, |
| 1761 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1762 | }; |
| 1763 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1764 | static const struct snd_pci_quirk stac925x_fixup_tbl[] = { |
| 1765 | /* SigmaTel reference board */ |
| 1766 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
| 1767 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
| 1768 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
| 1769 | |
| 1770 | /* Default table for unknown ID */ |
| 1771 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1772 | |
| 1773 | /* gateway machines are checked via codec ssid */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1774 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1775 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1776 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1777 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1778 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1779 | /* Not sure about the brand name for those */ |
| 1780 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1781 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1782 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1783 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1784 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1785 | }; |
| 1786 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1787 | static const struct hda_pintbl ref92hd73xx_pin_configs[] = { |
| 1788 | { 0x0a, 0x02214030 }, |
| 1789 | { 0x0b, 0x02a19040 }, |
| 1790 | { 0x0c, 0x01a19020 }, |
| 1791 | { 0x0d, 0x02214030 }, |
| 1792 | { 0x0e, 0x0181302e }, |
| 1793 | { 0x0f, 0x01014010 }, |
| 1794 | { 0x10, 0x01014020 }, |
| 1795 | { 0x11, 0x01014030 }, |
| 1796 | { 0x12, 0x02319040 }, |
| 1797 | { 0x13, 0x90a000f0 }, |
| 1798 | { 0x14, 0x90a000f0 }, |
| 1799 | { 0x22, 0x01452050 }, |
| 1800 | { 0x23, 0x01452050 }, |
| 1801 | {} |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1802 | }; |
| 1803 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1804 | static const struct hda_pintbl dell_m6_pin_configs[] = { |
| 1805 | { 0x0a, 0x0321101f }, |
| 1806 | { 0x0b, 0x4f00000f }, |
| 1807 | { 0x0c, 0x4f0000f0 }, |
| 1808 | { 0x0d, 0x90170110 }, |
| 1809 | { 0x0e, 0x03a11020 }, |
| 1810 | { 0x0f, 0x0321101f }, |
| 1811 | { 0x10, 0x4f0000f0 }, |
| 1812 | { 0x11, 0x4f0000f0 }, |
| 1813 | { 0x12, 0x4f0000f0 }, |
| 1814 | { 0x13, 0x90a60160 }, |
| 1815 | { 0x14, 0x4f0000f0 }, |
| 1816 | { 0x22, 0x4f0000f0 }, |
| 1817 | { 0x23, 0x4f0000f0 }, |
| 1818 | {} |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1819 | }; |
| 1820 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1821 | static const struct hda_pintbl alienware_m17x_pin_configs[] = { |
| 1822 | { 0x0a, 0x0321101f }, |
| 1823 | { 0x0b, 0x0321101f }, |
| 1824 | { 0x0c, 0x03a11020 }, |
| 1825 | { 0x0d, 0x03014020 }, |
| 1826 | { 0x0e, 0x90170110 }, |
| 1827 | { 0x0f, 0x4f0000f0 }, |
| 1828 | { 0x10, 0x4f0000f0 }, |
| 1829 | { 0x11, 0x4f0000f0 }, |
| 1830 | { 0x12, 0x4f0000f0 }, |
| 1831 | { 0x13, 0x90a60160 }, |
| 1832 | { 0x14, 0x4f0000f0 }, |
| 1833 | { 0x22, 0x4f0000f0 }, |
| 1834 | { 0x23, 0x904601b0 }, |
| 1835 | {} |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 1836 | }; |
| 1837 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1838 | static const struct hda_pintbl intel_dg45id_pin_configs[] = { |
| 1839 | { 0x0a, 0x02214230 }, |
| 1840 | { 0x0b, 0x02A19240 }, |
| 1841 | { 0x0c, 0x01013214 }, |
| 1842 | { 0x0d, 0x01014210 }, |
| 1843 | { 0x0e, 0x01A19250 }, |
| 1844 | { 0x0f, 0x01011212 }, |
| 1845 | { 0x10, 0x01016211 }, |
| 1846 | {} |
Alexey Fisher | 52dc438 | 2009-12-12 11:16:41 +0200 | [diff] [blame] | 1847 | }; |
| 1848 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1849 | static void stac92hd73xx_fixup_ref(struct hda_codec *codec, |
| 1850 | const struct hda_fixup *fix, int action) |
| 1851 | { |
| 1852 | struct sigmatel_spec *spec = codec->spec; |
| 1853 | |
| 1854 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1855 | return; |
| 1856 | |
| 1857 | snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs); |
| 1858 | spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0; |
| 1859 | } |
| 1860 | |
| 1861 | static void stac92hd73xx_fixup_dell(struct hda_codec *codec) |
| 1862 | { |
| 1863 | struct sigmatel_spec *spec = codec->spec; |
| 1864 | |
| 1865 | snd_hda_apply_pincfgs(codec, dell_m6_pin_configs); |
| 1866 | spec->num_smuxes = 0; |
| 1867 | spec->eapd_switch = 0; |
| 1868 | } |
| 1869 | |
| 1870 | static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec, |
| 1871 | const struct hda_fixup *fix, int action) |
| 1872 | { |
| 1873 | struct sigmatel_spec *spec = codec->spec; |
| 1874 | |
| 1875 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1876 | return; |
| 1877 | |
| 1878 | stac92hd73xx_fixup_dell(codec); |
| 1879 | snd_hda_add_verbs(codec, dell_eq_core_init); |
| 1880 | spec->volknob_init = 1; |
| 1881 | } |
| 1882 | |
| 1883 | /* Analog Mics */ |
| 1884 | static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec, |
| 1885 | const struct hda_fixup *fix, int action) |
| 1886 | { |
| 1887 | struct sigmatel_spec *spec = codec->spec; |
| 1888 | |
| 1889 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1890 | return; |
| 1891 | |
| 1892 | stac92hd73xx_fixup_dell(codec); |
| 1893 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 1894 | spec->num_dmics = 0; |
| 1895 | } |
| 1896 | |
| 1897 | /* Digital Mics */ |
| 1898 | static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec, |
| 1899 | const struct hda_fixup *fix, int action) |
| 1900 | { |
| 1901 | struct sigmatel_spec *spec = codec->spec; |
| 1902 | |
| 1903 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1904 | return; |
| 1905 | |
| 1906 | stac92hd73xx_fixup_dell(codec); |
| 1907 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
| 1908 | spec->num_dmics = 1; |
| 1909 | } |
| 1910 | |
| 1911 | /* Both */ |
| 1912 | static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec, |
| 1913 | const struct hda_fixup *fix, int action) |
| 1914 | { |
| 1915 | struct sigmatel_spec *spec = codec->spec; |
| 1916 | |
| 1917 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1918 | return; |
| 1919 | |
| 1920 | stac92hd73xx_fixup_dell(codec); |
| 1921 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 1922 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
| 1923 | spec->num_dmics = 1; |
| 1924 | } |
| 1925 | |
| 1926 | static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec, |
| 1927 | const struct hda_fixup *fix, int action) |
| 1928 | { |
| 1929 | struct sigmatel_spec *spec = codec->spec; |
| 1930 | |
| 1931 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1932 | return; |
| 1933 | |
| 1934 | snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs); |
| 1935 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
| 1936 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
| 1937 | spec->eapd_switch = 0; |
| 1938 | } |
| 1939 | |
| 1940 | static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec, |
| 1941 | const struct hda_fixup *fix, int action) |
| 1942 | { |
| 1943 | struct sigmatel_spec *spec = codec->spec; |
| 1944 | |
| 1945 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1946 | return; |
| 1947 | spec->hp_detect = 0; |
| 1948 | } |
| 1949 | |
| 1950 | static const struct hda_fixup stac92hd73xx_fixups[] = { |
| 1951 | [STAC_92HD73XX_REF] = { |
| 1952 | .type = HDA_FIXUP_FUNC, |
| 1953 | .v.func = stac92hd73xx_fixup_ref, |
| 1954 | }, |
| 1955 | [STAC_DELL_M6_AMIC] = { |
| 1956 | .type = HDA_FIXUP_FUNC, |
| 1957 | .v.func = stac92hd73xx_fixup_dell_m6_amic, |
| 1958 | }, |
| 1959 | [STAC_DELL_M6_DMIC] = { |
| 1960 | .type = HDA_FIXUP_FUNC, |
| 1961 | .v.func = stac92hd73xx_fixup_dell_m6_dmic, |
| 1962 | }, |
| 1963 | [STAC_DELL_M6_BOTH] = { |
| 1964 | .type = HDA_FIXUP_FUNC, |
| 1965 | .v.func = stac92hd73xx_fixup_dell_m6_both, |
| 1966 | }, |
| 1967 | [STAC_DELL_EQ] = { |
| 1968 | .type = HDA_FIXUP_FUNC, |
| 1969 | .v.func = stac92hd73xx_fixup_dell_eq, |
| 1970 | }, |
| 1971 | [STAC_ALIENWARE_M17X] = { |
| 1972 | .type = HDA_FIXUP_FUNC, |
| 1973 | .v.func = stac92hd73xx_fixup_alienware_m17x, |
| 1974 | }, |
| 1975 | [STAC_92HD73XX_INTEL] = { |
| 1976 | .type = HDA_FIXUP_PINS, |
| 1977 | .v.pins = intel_dg45id_pin_configs, |
| 1978 | }, |
| 1979 | [STAC_92HD73XX_NO_JD] = { |
| 1980 | .type = HDA_FIXUP_FUNC, |
| 1981 | .v.func = stac92hd73xx_fixup_no_jd, |
| 1982 | } |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1983 | }; |
| 1984 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1985 | static const struct hda_model_fixup stac92hd73xx_models[] = { |
| 1986 | { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" }, |
| 1987 | { .id = STAC_92HD73XX_REF, .name = "ref" }, |
| 1988 | { .id = STAC_92HD73XX_INTEL, .name = "intel" }, |
| 1989 | { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" }, |
| 1990 | { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" }, |
| 1991 | { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" }, |
| 1992 | { .id = STAC_DELL_EQ, .name = "dell-eq" }, |
| 1993 | { .id = STAC_ALIENWARE_M17X, .name = "alienware" }, |
| 1994 | {} |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1995 | }; |
| 1996 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 1997 | static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1998 | /* SigmaTel reference board */ |
| 1999 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2000 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2001 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2002 | "DFI LanParty", STAC_92HD73XX_REF), |
Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame] | 2003 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, |
| 2004 | "Intel DG45ID", STAC_92HD73XX_INTEL), |
| 2005 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, |
| 2006 | "Intel DG45FC", STAC_92HD73XX_INTEL), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2007 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2008 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2009 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2010 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2011 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2012 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2013 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2014 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2015 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2016 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2017 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2018 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2019 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2020 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 2021 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 2022 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 2023 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2024 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 2025 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 2026 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Takashi Iwai | 626f5ce | 2009-07-28 00:54:39 +0200 | [diff] [blame] | 2027 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, |
| 2028 | "Dell Studio 1555", STAC_DELL_M6_DMIC), |
Daniel J Blueman | 8ef5837 | 2009-11-14 18:20:04 +0000 | [diff] [blame] | 2029 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd, |
| 2030 | "Dell Studio 1557", STAC_DELL_M6_DMIC), |
Daniel T Chen | aac78da | 2010-04-21 20:41:52 -0400 | [diff] [blame] | 2031 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe, |
David Henningsson | ffe535e | 2012-01-16 10:52:20 +0100 | [diff] [blame] | 2032 | "Dell Studio XPS 1645", STAC_DELL_M6_DMIC), |
Daniel T Chen | 5c1bccf | 2010-04-22 17:54:45 -0400 | [diff] [blame] | 2033 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413, |
David Henningsson | e033ebf | 2011-05-16 12:09:29 +0200 | [diff] [blame] | 2034 | "Dell Studio 1558", STAC_DELL_M6_DMIC), |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 2035 | /* codec SSID matching */ |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 2036 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1, |
| 2037 | "Alienware M17x", STAC_ALIENWARE_M17X), |
Daniel T Chen | 0defe09 | 2010-12-01 19:16:07 -0500 | [diff] [blame] | 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a, |
| 2039 | "Alienware M17x", STAC_ALIENWARE_M17X), |
Takashi Iwai | dbd1b54 | 2011-11-19 11:41:30 +0100 | [diff] [blame] | 2040 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490, |
Albert Pool | b9ecc4e | 2012-01-19 22:08:50 +0100 | [diff] [blame] | 2041 | "Alienware M17x R3", STAC_DELL_EQ), |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 2042 | {} /* terminator */ |
| 2043 | }; |
| 2044 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2045 | static const struct hda_pintbl ref92hd83xxx_pin_configs[] = { |
| 2046 | { 0x0a, 0x02214030 }, |
| 2047 | { 0x0b, 0x02211010 }, |
| 2048 | { 0x0c, 0x02a19020 }, |
| 2049 | { 0x0d, 0x02170130 }, |
| 2050 | { 0x0e, 0x01014050 }, |
| 2051 | { 0x0f, 0x01819040 }, |
| 2052 | { 0x10, 0x01014020 }, |
| 2053 | { 0x11, 0x90a3014e }, |
| 2054 | { 0x1f, 0x01451160 }, |
| 2055 | { 0x20, 0x98560170 }, |
| 2056 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2057 | }; |
| 2058 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2059 | static const struct hda_pintbl dell_s14_pin_configs[] = { |
| 2060 | { 0x0a, 0x0221403f }, |
| 2061 | { 0x0b, 0x0221101f }, |
| 2062 | { 0x0c, 0x02a19020 }, |
| 2063 | { 0x0d, 0x90170110 }, |
| 2064 | { 0x0e, 0x40f000f0 }, |
| 2065 | { 0x0f, 0x40f000f0 }, |
| 2066 | { 0x10, 0x40f000f0 }, |
| 2067 | { 0x11, 0x90a60160 }, |
| 2068 | { 0x1f, 0x40f000f0 }, |
| 2069 | { 0x20, 0x40f000f0 }, |
| 2070 | {} |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 2071 | }; |
| 2072 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2073 | static const struct hda_pintbl dell_vostro_3500_pin_configs[] = { |
| 2074 | { 0x0a, 0x02a11020 }, |
| 2075 | { 0x0b, 0x0221101f }, |
| 2076 | { 0x0c, 0x400000f0 }, |
| 2077 | { 0x0d, 0x90170110 }, |
| 2078 | { 0x0e, 0x400000f1 }, |
| 2079 | { 0x0f, 0x400000f2 }, |
| 2080 | { 0x10, 0x400000f3 }, |
| 2081 | { 0x11, 0x90a60160 }, |
| 2082 | { 0x1f, 0x400000f4 }, |
| 2083 | { 0x20, 0x400000f5 }, |
| 2084 | {} |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 2085 | }; |
| 2086 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2087 | static const struct hda_pintbl hp_dv7_4000_pin_configs[] = { |
| 2088 | { 0x0a, 0x03a12050 }, |
| 2089 | { 0x0b, 0x0321201f }, |
| 2090 | { 0x0c, 0x40f000f0 }, |
| 2091 | { 0x0d, 0x90170110 }, |
| 2092 | { 0x0e, 0x40f000f0 }, |
| 2093 | { 0x0f, 0x40f000f0 }, |
| 2094 | { 0x10, 0x90170110 }, |
| 2095 | { 0x11, 0xd5a30140 }, |
| 2096 | { 0x1f, 0x40f000f0 }, |
| 2097 | { 0x20, 0x40f000f0 }, |
| 2098 | {} |
Steven Eastland | 4831559 | 2010-08-06 15:07:35 -0600 | [diff] [blame] | 2099 | }; |
| 2100 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2101 | static const struct hda_pintbl hp_zephyr_pin_configs[] = { |
| 2102 | { 0x0a, 0x01813050 }, |
| 2103 | { 0x0b, 0x0421201f }, |
| 2104 | { 0x0c, 0x04a1205e }, |
| 2105 | { 0x0d, 0x96130310 }, |
| 2106 | { 0x0e, 0x96130310 }, |
| 2107 | { 0x0f, 0x0101401f }, |
| 2108 | { 0x10, 0x1111611f }, |
| 2109 | { 0x11, 0xd5a30130 }, |
| 2110 | {} |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2111 | }; |
| 2112 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2113 | static const struct hda_pintbl hp_cNB11_intquad_pin_configs[] = { |
| 2114 | { 0x0a, 0x40f000f0 }, |
| 2115 | { 0x0b, 0x0221101f }, |
| 2116 | { 0x0c, 0x02a11020 }, |
| 2117 | { 0x0d, 0x92170110 }, |
| 2118 | { 0x0e, 0x40f000f0 }, |
| 2119 | { 0x0f, 0x92170110 }, |
| 2120 | { 0x10, 0x40f000f0 }, |
| 2121 | { 0x11, 0xd5a30130 }, |
| 2122 | { 0x1f, 0x40f000f0 }, |
| 2123 | { 0x20, 0x40f000f0 }, |
| 2124 | {} |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2125 | }; |
| 2126 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2127 | static void stac92hd83xxx_fixup_hp(struct hda_codec *codec, |
| 2128 | const struct hda_fixup *fix, int action) |
| 2129 | { |
| 2130 | struct sigmatel_spec *spec = codec->spec; |
| 2131 | |
| 2132 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2133 | return; |
| 2134 | |
| 2135 | if (hp_bnb2011_with_dock(codec)) { |
| 2136 | snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f); |
| 2137 | snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e); |
| 2138 | } |
| 2139 | |
| 2140 | if (find_mute_led_cfg(codec, spec->default_polarity)) |
| 2141 | snd_printd("mute LED gpio %d polarity %d\n", |
| 2142 | spec->gpio_led, |
| 2143 | spec->gpio_led_polarity); |
| 2144 | } |
| 2145 | |
| 2146 | static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec, |
| 2147 | const struct hda_fixup *fix, int action) |
| 2148 | { |
| 2149 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2150 | return; |
| 2151 | |
| 2152 | snd_hda_apply_pincfgs(codec, hp_zephyr_pin_configs); |
| 2153 | snd_hda_add_verbs(codec, stac92hd83xxx_hp_zephyr_init); |
| 2154 | } |
| 2155 | |
| 2156 | static void stac92hd83xxx_fixup_hp_led(struct hda_codec *codec, |
| 2157 | const struct hda_fixup *fix, int action) |
| 2158 | { |
| 2159 | struct sigmatel_spec *spec = codec->spec; |
| 2160 | |
| 2161 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 2162 | spec->default_polarity = 0; |
| 2163 | } |
| 2164 | |
| 2165 | static void stac92hd83xxx_fixup_hp_inv_led(struct hda_codec *codec, |
| 2166 | const struct hda_fixup *fix, int action) |
| 2167 | { |
| 2168 | struct sigmatel_spec *spec = codec->spec; |
| 2169 | |
| 2170 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 2171 | spec->default_polarity = 1; |
| 2172 | } |
| 2173 | |
| 2174 | static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec, |
| 2175 | const struct hda_fixup *fix, int action) |
| 2176 | { |
| 2177 | struct sigmatel_spec *spec = codec->spec; |
| 2178 | |
| 2179 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 2180 | spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ |
| 2181 | } |
| 2182 | |
| 2183 | static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, |
| 2184 | const struct hda_fixup *fix, int action) |
| 2185 | { |
| 2186 | struct sigmatel_spec *spec = codec->spec; |
| 2187 | |
| 2188 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 2189 | spec->headset_jack = 1; |
| 2190 | } |
| 2191 | |
| 2192 | static const struct hda_fixup stac92hd83xxx_fixups[] = { |
| 2193 | [STAC_92HD83XXX_REF] = { |
| 2194 | .type = HDA_FIXUP_PINS, |
| 2195 | .v.pins = ref92hd83xxx_pin_configs, |
| 2196 | }, |
| 2197 | [STAC_92HD83XXX_PWR_REF] = { |
| 2198 | .type = HDA_FIXUP_PINS, |
| 2199 | .v.pins = ref92hd83xxx_pin_configs, |
| 2200 | }, |
| 2201 | [STAC_DELL_S14] = { |
| 2202 | .type = HDA_FIXUP_PINS, |
| 2203 | .v.pins = dell_s14_pin_configs, |
| 2204 | }, |
| 2205 | [STAC_DELL_VOSTRO_3500] = { |
| 2206 | .type = HDA_FIXUP_PINS, |
| 2207 | .v.pins = dell_vostro_3500_pin_configs, |
| 2208 | }, |
| 2209 | [STAC_92HD83XXX_HP_cNB11_INTQUAD] = { |
| 2210 | .type = HDA_FIXUP_PINS, |
| 2211 | .v.pins = hp_cNB11_intquad_pin_configs, |
| 2212 | .chained = true, |
| 2213 | .chain_id = STAC_92HD83XXX_HP, |
| 2214 | }, |
| 2215 | [STAC_92HD83XXX_HP] = { |
| 2216 | .type = HDA_FIXUP_FUNC, |
| 2217 | .v.func = stac92hd83xxx_fixup_hp, |
| 2218 | }, |
| 2219 | [STAC_HP_DV7_4000] = { |
| 2220 | .type = HDA_FIXUP_PINS, |
| 2221 | .v.pins = hp_dv7_4000_pin_configs, |
| 2222 | .chained = true, |
| 2223 | .chain_id = STAC_92HD83XXX_HP, |
| 2224 | }, |
| 2225 | [STAC_HP_ZEPHYR] = { |
| 2226 | .type = HDA_FIXUP_FUNC, |
| 2227 | .v.func = stac92hd83xxx_fixup_hp_zephyr, |
| 2228 | .chained = true, |
| 2229 | .chain_id = STAC_92HD83XXX_HP, |
| 2230 | }, |
| 2231 | [STAC_92HD83XXX_HP_LED] = { |
| 2232 | .type = HDA_FIXUP_FUNC, |
| 2233 | .v.func = stac92hd83xxx_fixup_hp_led, |
| 2234 | .chained = true, |
| 2235 | .chain_id = STAC_92HD83XXX_HP, |
| 2236 | }, |
| 2237 | [STAC_92HD83XXX_HP_INV_LED] = { |
| 2238 | .type = HDA_FIXUP_FUNC, |
| 2239 | .v.func = stac92hd83xxx_fixup_hp_inv_led, |
| 2240 | .chained = true, |
| 2241 | .chain_id = STAC_92HD83XXX_HP, |
| 2242 | }, |
| 2243 | [STAC_92HD83XXX_HP_MIC_LED] = { |
| 2244 | .type = HDA_FIXUP_FUNC, |
| 2245 | .v.func = stac92hd83xxx_fixup_hp_mic_led, |
| 2246 | .chained = true, |
| 2247 | .chain_id = STAC_92HD83XXX_HP, |
| 2248 | }, |
| 2249 | [STAC_92HD83XXX_HEADSET_JACK] = { |
| 2250 | .type = HDA_FIXUP_FUNC, |
| 2251 | .v.func = stac92hd83xxx_fixup_headset_jack, |
| 2252 | }, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2253 | }; |
| 2254 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2255 | static const struct hda_model_fixup stac92hd83xxx_models[] = { |
| 2256 | { .id = STAC_92HD83XXX_REF, .name = "ref" }, |
| 2257 | { .id = STAC_92HD83XXX_PWR_REF, .name = "mic-ref" }, |
| 2258 | { .id = STAC_DELL_S14, .name = "dell-s14" }, |
| 2259 | { .id = STAC_DELL_VOSTRO_3500, .name = "dell-vostro-3500" }, |
| 2260 | { .id = STAC_92HD83XXX_HP_cNB11_INTQUAD, .name = "hp_cNB11_intquad" }, |
| 2261 | { .id = STAC_HP_DV7_4000, .name = "hp-dv7-4000" }, |
| 2262 | { .id = STAC_HP_ZEPHYR, .name = "hp-zephyr" }, |
| 2263 | { .id = STAC_92HD83XXX_HP_LED, .name = "hp-led" }, |
| 2264 | { .id = STAC_92HD83XXX_HP_INV_LED, .name = "hp-inv-led" }, |
| 2265 | { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" }, |
| 2266 | { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" }, |
| 2267 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2268 | }; |
| 2269 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2270 | static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2271 | /* SigmaTel reference board */ |
| 2272 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 2273 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2274 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2275 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 2276 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 2277 | "unknown Dell", STAC_DELL_S14), |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 2278 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532, |
| 2279 | "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK), |
| 2280 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533, |
| 2281 | "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK), |
| 2282 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534, |
| 2283 | "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK), |
| 2284 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535, |
| 2285 | "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK), |
| 2286 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c, |
| 2287 | "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK), |
| 2288 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d, |
| 2289 | "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK), |
| 2290 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549, |
| 2291 | "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK), |
| 2292 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d, |
| 2293 | "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK), |
| 2294 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584, |
| 2295 | "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK), |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 2296 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028, |
| 2297 | "Dell Vostro 3500", STAC_DELL_VOSTRO_3500), |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2298 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656, |
| 2299 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2300 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657, |
| 2301 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2302 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658, |
| 2303 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2304 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659, |
Takashi Iwai | 8ae5865 | 2012-12-13 14:33:42 +0100 | [diff] [blame] | 2305 | "HP Pavilion dv7", STAC_HP_DV7_4000), |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2306 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A, |
| 2307 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2308 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B, |
| 2309 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 2310 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, |
| 2311 | "HP Folio", STAC_92HD83XXX_HP_MIC_LED), |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2312 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388, |
| 2313 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2314 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389, |
| 2315 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2316 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B, |
| 2317 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2318 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C, |
| 2319 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2320 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D, |
| 2321 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2322 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E, |
| 2323 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2324 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F, |
| 2325 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2326 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560, |
| 2327 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2328 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B, |
| 2329 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2330 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C, |
| 2331 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2332 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D, |
| 2333 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2334 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591, |
| 2335 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2336 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592, |
| 2337 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2338 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593, |
| 2339 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2340 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561, |
| 2341 | "HP", STAC_HP_ZEPHYR), |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 2342 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660, |
| 2343 | "HP Mini", STAC_92HD83XXX_HP_LED), |
Gustavo Maciel Dias Vieira | 5afc13a | 2012-10-26 12:51:53 -0200 | [diff] [blame] | 2344 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E, |
| 2345 | "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED), |
Takashi Iwai | 8c698fe | 2013-01-15 11:20:50 +0100 | [diff] [blame^] | 2346 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a, |
| 2347 | "HP Mini", STAC_92HD83XXX_HP_LED), |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 2348 | SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 2349 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2350 | }; |
| 2351 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2352 | static const struct hda_pintbl ref92hd71bxx_pin_configs[] = { |
| 2353 | { 0x0a, 0x02214030 }, |
| 2354 | { 0x0b, 0x02a19040 }, |
| 2355 | { 0x0c, 0x01a19020 }, |
| 2356 | { 0x0d, 0x01014010 }, |
| 2357 | { 0x0e, 0x0181302e }, |
| 2358 | { 0x0f, 0x01014010 }, |
| 2359 | { 0x14, 0x01019020 }, |
| 2360 | { 0x18, 0x90a000f0 }, |
| 2361 | { 0x19, 0x90a000f0 }, |
| 2362 | { 0x1e, 0x01452050 }, |
| 2363 | { 0x1f, 0x01452050 }, |
| 2364 | {} |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2365 | }; |
| 2366 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2367 | static const struct hda_pintbl dell_m4_1_pin_configs[] = { |
| 2368 | { 0x0a, 0x0421101f }, |
| 2369 | { 0x0b, 0x04a11221 }, |
| 2370 | { 0x0c, 0x40f000f0 }, |
| 2371 | { 0x0d, 0x90170110 }, |
| 2372 | { 0x0e, 0x23a1902e }, |
| 2373 | { 0x0f, 0x23014250 }, |
| 2374 | { 0x14, 0x40f000f0 }, |
| 2375 | { 0x18, 0x90a000f0 }, |
| 2376 | { 0x19, 0x40f000f0 }, |
| 2377 | { 0x1e, 0x4f0000f0 }, |
| 2378 | { 0x1f, 0x4f0000f0 }, |
| 2379 | {} |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2380 | }; |
| 2381 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2382 | static const struct hda_pintbl dell_m4_2_pin_configs[] = { |
| 2383 | { 0x0a, 0x0421101f }, |
| 2384 | { 0x0b, 0x04a11221 }, |
| 2385 | { 0x0c, 0x90a70330 }, |
| 2386 | { 0x0d, 0x90170110 }, |
| 2387 | { 0x0e, 0x23a1902e }, |
| 2388 | { 0x0f, 0x23014250 }, |
| 2389 | { 0x14, 0x40f000f0 }, |
| 2390 | { 0x18, 0x40f000f0 }, |
| 2391 | { 0x19, 0x40f000f0 }, |
| 2392 | { 0x1e, 0x044413b0 }, |
| 2393 | { 0x1f, 0x044413b0 }, |
| 2394 | {} |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2395 | }; |
| 2396 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2397 | static const struct hda_pintbl dell_m4_3_pin_configs[] = { |
| 2398 | { 0x0a, 0x0421101f }, |
| 2399 | { 0x0b, 0x04a11221 }, |
| 2400 | { 0x0c, 0x90a70330 }, |
| 2401 | { 0x0d, 0x90170110 }, |
| 2402 | { 0x0e, 0x40f000f0 }, |
| 2403 | { 0x0f, 0x40f000f0 }, |
| 2404 | { 0x14, 0x40f000f0 }, |
| 2405 | { 0x18, 0x90a000f0 }, |
| 2406 | { 0x19, 0x40f000f0 }, |
| 2407 | { 0x1e, 0x044413b0 }, |
| 2408 | { 0x1f, 0x044413b0 }, |
| 2409 | {} |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 2410 | }; |
| 2411 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2412 | static void stac92hd71bxx_fixup_ref(struct hda_codec *codec, |
| 2413 | const struct hda_fixup *fix, int action) |
| 2414 | { |
| 2415 | struct sigmatel_spec *spec = codec->spec; |
| 2416 | |
| 2417 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2418 | return; |
| 2419 | |
| 2420 | snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs); |
| 2421 | spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0; |
| 2422 | } |
| 2423 | |
| 2424 | static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec, |
| 2425 | const struct hda_fixup *fix, int action) |
| 2426 | { |
| 2427 | struct sigmatel_spec *spec = codec->spec; |
| 2428 | |
| 2429 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2430 | return; |
| 2431 | spec->num_dmics = 0; |
| 2432 | spec->num_smuxes = 0; |
| 2433 | spec->num_dmuxes = 0; |
| 2434 | } |
| 2435 | |
| 2436 | static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec, |
| 2437 | const struct hda_fixup *fix, int action) |
| 2438 | { |
| 2439 | struct sigmatel_spec *spec = codec->spec; |
| 2440 | |
| 2441 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2442 | return; |
| 2443 | spec->num_dmics = 1; |
| 2444 | spec->num_smuxes = 0; |
| 2445 | spec->num_dmuxes = 1; |
| 2446 | } |
| 2447 | |
| 2448 | static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec, |
| 2449 | const struct hda_fixup *fix, int action) |
| 2450 | { |
| 2451 | struct sigmatel_spec *spec = codec->spec; |
| 2452 | |
| 2453 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2454 | return; |
| 2455 | |
| 2456 | /* Enable VREF power saving on GPIO1 detect */ |
| 2457 | stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02); |
| 2458 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 2459 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 2460 | snd_hda_jack_detect_enable(codec, codec->afg, 0); |
| 2461 | spec->gpio_mask |= 0x02; |
| 2462 | |
| 2463 | /* enable internal microphone */ |
| 2464 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
| 2465 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 2466 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
| 2467 | |
| 2468 | stac92hd71bxx_fixup_no_dmic(codec, fix, action); |
| 2469 | } |
| 2470 | |
| 2471 | static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec, |
| 2472 | const struct hda_fixup *fix, int action) |
| 2473 | { |
| 2474 | struct sigmatel_spec *spec = codec->spec; |
| 2475 | |
| 2476 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2477 | return; |
| 2478 | spec->num_dmics = 1; |
| 2479 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 2480 | * bug reports to fix if needed |
| 2481 | */ |
| 2482 | spec->num_smuxes = 1; |
| 2483 | spec->num_dmuxes = 1; |
| 2484 | } |
| 2485 | |
| 2486 | static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec, |
| 2487 | const struct hda_fixup *fix, int action) |
| 2488 | { |
| 2489 | struct sigmatel_spec *spec = codec->spec; |
| 2490 | |
| 2491 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2492 | return; |
| 2493 | spec->gpio_led = 0x01; |
| 2494 | } |
| 2495 | |
| 2496 | static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec, |
| 2497 | const struct hda_fixup *fix, int action) |
| 2498 | { |
| 2499 | struct sigmatel_spec *spec = codec->spec; |
| 2500 | unsigned int cap; |
| 2501 | |
| 2502 | switch (action) { |
| 2503 | case HDA_FIXUP_ACT_PRE_PROBE: |
| 2504 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
| 2505 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 2506 | /* HP dv6 gives the headphone pin as a line-out. Thus we |
| 2507 | * need to set hp_detect flag here to force to enable HP |
| 2508 | * detection. |
| 2509 | */ |
| 2510 | spec->hp_detect = 1; |
| 2511 | break; |
| 2512 | |
| 2513 | case HDA_FIXUP_ACT_PROBE: |
| 2514 | /* enable bass on HP dv7 */ |
| 2515 | cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP); |
| 2516 | cap &= AC_GPIO_IO_COUNT; |
| 2517 | if (cap >= 6) |
| 2518 | stac_add_hp_bass_switch(codec); |
| 2519 | break; |
| 2520 | } |
| 2521 | } |
| 2522 | |
| 2523 | static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec, |
| 2524 | const struct hda_fixup *fix, int action) |
| 2525 | { |
| 2526 | struct sigmatel_spec *spec = codec->spec; |
| 2527 | |
| 2528 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2529 | return; |
| 2530 | spec->gpio_led = 0x08; |
| 2531 | spec->num_dmics = 1; |
| 2532 | spec->num_smuxes = 1; |
| 2533 | spec->num_dmuxes = 1; |
| 2534 | } |
| 2535 | |
| 2536 | |
| 2537 | static void stac92hd71bxx_fixup_hp(struct hda_codec *codec, |
| 2538 | const struct hda_fixup *fix, int action) |
| 2539 | { |
| 2540 | struct sigmatel_spec *spec = codec->spec; |
| 2541 | |
| 2542 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2543 | return; |
| 2544 | |
| 2545 | if (hp_blike_system(codec->subsystem_id)) { |
| 2546 | unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f); |
| 2547 | if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT || |
| 2548 | get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER || |
| 2549 | get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) { |
| 2550 | /* It was changed in the BIOS to just satisfy MS DTM. |
| 2551 | * Lets turn it back into slaved HP |
| 2552 | */ |
| 2553 | pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) |
| 2554 | | (AC_JACK_HP_OUT << |
| 2555 | AC_DEFCFG_DEVICE_SHIFT); |
| 2556 | pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC |
| 2557 | | AC_DEFCFG_SEQUENCE))) |
| 2558 | | 0x1f; |
| 2559 | snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg); |
| 2560 | } |
| 2561 | } |
| 2562 | |
| 2563 | if (find_mute_led_cfg(codec, 1)) |
| 2564 | snd_printd("mute LED gpio %d polarity %d\n", |
| 2565 | spec->gpio_led, |
| 2566 | spec->gpio_led_polarity); |
| 2567 | |
| 2568 | } |
| 2569 | |
| 2570 | static const struct hda_fixup stac92hd71bxx_fixups[] = { |
| 2571 | [STAC_92HD71BXX_REF] = { |
| 2572 | .type = HDA_FIXUP_FUNC, |
| 2573 | .v.func = stac92hd71bxx_fixup_ref, |
| 2574 | }, |
| 2575 | [STAC_DELL_M4_1] = { |
| 2576 | .type = HDA_FIXUP_PINS, |
| 2577 | .v.pins = dell_m4_1_pin_configs, |
| 2578 | .chained = true, |
| 2579 | .chain_id = STAC_92HD71BXX_NO_SMUX, |
| 2580 | }, |
| 2581 | [STAC_DELL_M4_2] = { |
| 2582 | .type = HDA_FIXUP_PINS, |
| 2583 | .v.pins = dell_m4_2_pin_configs, |
| 2584 | .chained = true, |
| 2585 | .chain_id = STAC_92HD71BXX_NO_DMIC, |
| 2586 | }, |
| 2587 | [STAC_DELL_M4_3] = { |
| 2588 | .type = HDA_FIXUP_PINS, |
| 2589 | .v.pins = dell_m4_3_pin_configs, |
| 2590 | .chained = true, |
| 2591 | .chain_id = STAC_92HD71BXX_NO_SMUX, |
| 2592 | }, |
| 2593 | [STAC_HP_M4] = { |
| 2594 | .type = HDA_FIXUP_FUNC, |
| 2595 | .v.func = stac92hd71bxx_fixup_hp_m4, |
| 2596 | .chained = true, |
| 2597 | .chain_id = STAC_92HD71BXX_HP, |
| 2598 | }, |
| 2599 | [STAC_HP_DV4] = { |
| 2600 | .type = HDA_FIXUP_FUNC, |
| 2601 | .v.func = stac92hd71bxx_fixup_hp_dv4, |
| 2602 | .chained = true, |
| 2603 | .chain_id = STAC_HP_DV5, |
| 2604 | }, |
| 2605 | [STAC_HP_DV5] = { |
| 2606 | .type = HDA_FIXUP_FUNC, |
| 2607 | .v.func = stac92hd71bxx_fixup_hp_dv5, |
| 2608 | .chained = true, |
| 2609 | .chain_id = STAC_92HD71BXX_HP, |
| 2610 | }, |
| 2611 | [STAC_HP_HDX] = { |
| 2612 | .type = HDA_FIXUP_FUNC, |
| 2613 | .v.func = stac92hd71bxx_fixup_hp_hdx, |
| 2614 | .chained = true, |
| 2615 | .chain_id = STAC_92HD71BXX_HP, |
| 2616 | }, |
| 2617 | [STAC_HP_DV4_1222NR] = { |
| 2618 | .type = HDA_FIXUP_FUNC, |
| 2619 | .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr, |
| 2620 | .chained = true, |
| 2621 | .chain_id = STAC_HP_DV4, |
| 2622 | }, |
| 2623 | [STAC_92HD71BXX_NO_DMIC] = { |
| 2624 | .type = HDA_FIXUP_FUNC, |
| 2625 | .v.func = stac92hd71bxx_fixup_no_dmic, |
| 2626 | }, |
| 2627 | [STAC_92HD71BXX_NO_SMUX] = { |
| 2628 | .type = HDA_FIXUP_FUNC, |
| 2629 | .v.func = stac92hd71bxx_fixup_no_smux, |
| 2630 | }, |
| 2631 | [STAC_92HD71BXX_HP] = { |
| 2632 | .type = HDA_FIXUP_FUNC, |
| 2633 | .v.func = stac92hd71bxx_fixup_hp, |
| 2634 | }, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2635 | }; |
| 2636 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2637 | static const struct hda_model_fixup stac92hd71bxx_models[] = { |
| 2638 | { .id = STAC_92HD71BXX_REF, .name = "ref" }, |
| 2639 | { .id = STAC_DELL_M4_1, .name = "dell-m4-1" }, |
| 2640 | { .id = STAC_DELL_M4_2, .name = "dell-m4-2" }, |
| 2641 | { .id = STAC_DELL_M4_3, .name = "dell-m4-3" }, |
| 2642 | { .id = STAC_HP_M4, .name = "hp-m4" }, |
| 2643 | { .id = STAC_HP_DV4, .name = "hp-dv4" }, |
| 2644 | { .id = STAC_HP_DV5, .name = "hp-dv5" }, |
| 2645 | { .id = STAC_HP_HDX, .name = "hp-hdx" }, |
| 2646 | { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" }, |
| 2647 | {} |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2648 | }; |
| 2649 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2650 | static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2651 | /* SigmaTel reference board */ |
| 2652 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2653 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2654 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2655 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 2656 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 2657 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Vitaliy Kulikov | 5bdaaad | 2009-11-04 07:57:45 +0100 | [diff] [blame] | 2658 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720, |
| 2659 | "HP", STAC_HP_DV5), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 2660 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 2661 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 2662 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
Takashi Iwai | 2a6ce6e | 2010-05-12 10:16:20 +0200 | [diff] [blame] | 2663 | "HP dv4-7", STAC_HP_DV4), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 2664 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 2665 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 2666 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 2667 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 2668 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 2669 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 2670 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 2671 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Takashi Iwai | 6e34c03 | 2009-09-14 15:42:18 +0200 | [diff] [blame] | 2672 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620, |
| 2673 | "HP dv6", STAC_HP_DV5), |
Kunal Gangakhedkar | e3d2530 | 2010-03-20 23:08:01 +0530 | [diff] [blame] | 2674 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061, |
| 2675 | "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */ |
Luke Yelavich | 9b2167d | 2010-10-06 15:45:46 +1100 | [diff] [blame] | 2676 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e, |
| 2677 | "HP DV6", STAC_HP_DV5), |
Takashi Iwai | 1972d02 | 2009-08-06 08:44:43 +0200 | [diff] [blame] | 2678 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, |
| 2679 | "HP", STAC_HP_DV5), |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2680 | SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2681 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 2682 | "unknown Dell", STAC_DELL_M4_1), |
| 2683 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 2684 | "unknown Dell", STAC_DELL_M4_1), |
| 2685 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 2686 | "unknown Dell", STAC_DELL_M4_1), |
| 2687 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 2688 | "unknown Dell", STAC_DELL_M4_1), |
| 2689 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 2690 | "unknown Dell", STAC_DELL_M4_1), |
| 2691 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 2692 | "unknown Dell", STAC_DELL_M4_1), |
| 2693 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 2694 | "unknown Dell", STAC_DELL_M4_1), |
| 2695 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 2696 | "unknown Dell", STAC_DELL_M4_2), |
| 2697 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 2698 | "unknown Dell", STAC_DELL_M4_2), |
| 2699 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 2700 | "unknown Dell", STAC_DELL_M4_2), |
| 2701 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 2702 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 2703 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 2704 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2705 | {} /* terminator */ |
| 2706 | }; |
| 2707 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2708 | static const struct hda_pintbl ref922x_pin_configs[] = { |
| 2709 | { 0x0a, 0x01014010 }, |
| 2710 | { 0x0b, 0x01016011 }, |
| 2711 | { 0x0c, 0x01012012 }, |
| 2712 | { 0x0d, 0x0221401f }, |
| 2713 | { 0x0e, 0x01813122 }, |
| 2714 | { 0x0f, 0x01011014 }, |
| 2715 | { 0x10, 0x01441030 }, |
| 2716 | { 0x11, 0x01c41030 }, |
| 2717 | { 0x15, 0x40000100 }, |
| 2718 | { 0x1b, 0x40000100 }, |
| 2719 | {} |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2720 | }; |
| 2721 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2722 | /* |
| 2723 | STAC 922X pin configs for |
| 2724 | 102801A7 |
| 2725 | 102801AB |
| 2726 | 102801A9 |
| 2727 | 102801D1 |
| 2728 | 102801D2 |
| 2729 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2730 | static const struct hda_pintbl dell_922x_d81_pin_configs[] = { |
| 2731 | { 0x0a, 0x02214030 }, |
| 2732 | { 0x0b, 0x01a19021 }, |
| 2733 | { 0x0c, 0x01111012 }, |
| 2734 | { 0x0d, 0x01114010 }, |
| 2735 | { 0x0e, 0x02a19020 }, |
| 2736 | { 0x0f, 0x01117011 }, |
| 2737 | { 0x10, 0x400001f0 }, |
| 2738 | { 0x11, 0x400001f1 }, |
| 2739 | { 0x15, 0x01813122 }, |
| 2740 | { 0x1b, 0x400001f2 }, |
| 2741 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2742 | }; |
| 2743 | |
| 2744 | /* |
| 2745 | STAC 922X pin configs for |
| 2746 | 102801AC |
| 2747 | 102801D0 |
| 2748 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2749 | static const struct hda_pintbl dell_922x_d82_pin_configs[] = { |
| 2750 | { 0x0a, 0x02214030 }, |
| 2751 | { 0x0b, 0x01a19021 }, |
| 2752 | { 0x0c, 0x01111012 }, |
| 2753 | { 0x0d, 0x01114010 }, |
| 2754 | { 0x0e, 0x02a19020 }, |
| 2755 | { 0x0f, 0x01117011 }, |
| 2756 | { 0x10, 0x01451140 }, |
| 2757 | { 0x11, 0x400001f0 }, |
| 2758 | { 0x15, 0x01813122 }, |
| 2759 | { 0x1b, 0x400001f1 }, |
| 2760 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2761 | }; |
| 2762 | |
| 2763 | /* |
| 2764 | STAC 922X pin configs for |
| 2765 | 102801BF |
| 2766 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2767 | static const struct hda_pintbl dell_922x_m81_pin_configs[] = { |
| 2768 | { 0x0a, 0x0321101f }, |
| 2769 | { 0x0b, 0x01112024 }, |
| 2770 | { 0x0c, 0x01111222 }, |
| 2771 | { 0x0d, 0x91174220 }, |
| 2772 | { 0x0e, 0x03a11050 }, |
| 2773 | { 0x0f, 0x01116221 }, |
| 2774 | { 0x10, 0x90a70330 }, |
| 2775 | { 0x11, 0x01452340 }, |
| 2776 | { 0x15, 0x40C003f1 }, |
| 2777 | { 0x1b, 0x405003f0 }, |
| 2778 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2779 | }; |
| 2780 | |
| 2781 | /* |
| 2782 | STAC 9221 A1 pin configs for |
| 2783 | 102801D7 (Dell XPS M1210) |
| 2784 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2785 | static const struct hda_pintbl dell_922x_m82_pin_configs[] = { |
| 2786 | { 0x0a, 0x02211211 }, |
| 2787 | { 0x0b, 0x408103ff }, |
| 2788 | { 0x0c, 0x02a1123e }, |
| 2789 | { 0x0d, 0x90100310 }, |
| 2790 | { 0x0e, 0x408003f1 }, |
| 2791 | { 0x0f, 0x0221121f }, |
| 2792 | { 0x10, 0x03451340 }, |
| 2793 | { 0x11, 0x40c003f2 }, |
| 2794 | { 0x15, 0x508003f3 }, |
| 2795 | { 0x1b, 0x405003f4 }, |
| 2796 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2797 | }; |
| 2798 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2799 | static const struct hda_pintbl d945gtp3_pin_configs[] = { |
| 2800 | { 0x0a, 0x0221401f }, |
| 2801 | { 0x0b, 0x01a19022 }, |
| 2802 | { 0x0c, 0x01813021 }, |
| 2803 | { 0x0d, 0x01014010 }, |
| 2804 | { 0x0e, 0x40000100 }, |
| 2805 | { 0x0f, 0x40000100 }, |
| 2806 | { 0x10, 0x40000100 }, |
| 2807 | { 0x11, 0x40000100 }, |
| 2808 | { 0x15, 0x02a19120 }, |
| 2809 | { 0x1b, 0x40000100 }, |
| 2810 | {} |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2811 | }; |
| 2812 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2813 | static const struct hda_pintbl d945gtp5_pin_configs[] = { |
| 2814 | { 0x0a, 0x0221401f }, |
| 2815 | { 0x0b, 0x01011012 }, |
| 2816 | { 0x0c, 0x01813024 }, |
| 2817 | { 0x0d, 0x01014010 }, |
| 2818 | { 0x0e, 0x01a19021 }, |
| 2819 | { 0x0f, 0x01016011 }, |
| 2820 | { 0x10, 0x01452130 }, |
| 2821 | { 0x11, 0x40000100 }, |
| 2822 | { 0x15, 0x02a19320 }, |
| 2823 | { 0x1b, 0x40000100 }, |
| 2824 | {} |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2825 | }; |
| 2826 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2827 | static const struct hda_pintbl intel_mac_v1_pin_configs[] = { |
| 2828 | { 0x0a, 0x0121e21f }, |
| 2829 | { 0x0b, 0x400000ff }, |
| 2830 | { 0x0c, 0x9017e110 }, |
| 2831 | { 0x0d, 0x400000fd }, |
| 2832 | { 0x0e, 0x400000fe }, |
| 2833 | { 0x0f, 0x0181e020 }, |
| 2834 | { 0x10, 0x1145e030 }, |
| 2835 | { 0x11, 0x11c5e240 }, |
| 2836 | { 0x15, 0x400000fc }, |
| 2837 | { 0x1b, 0x400000fb }, |
| 2838 | {} |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2839 | }; |
| 2840 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2841 | static const struct hda_pintbl intel_mac_v2_pin_configs[] = { |
| 2842 | { 0x0a, 0x0121e21f }, |
| 2843 | { 0x0b, 0x90a7012e }, |
| 2844 | { 0x0c, 0x9017e110 }, |
| 2845 | { 0x0d, 0x400000fd }, |
| 2846 | { 0x0e, 0x400000fe }, |
| 2847 | { 0x0f, 0x0181e020 }, |
| 2848 | { 0x10, 0x1145e230 }, |
| 2849 | { 0x11, 0x500000fa }, |
| 2850 | { 0x15, 0x400000fc }, |
| 2851 | { 0x1b, 0x400000fb }, |
| 2852 | {} |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2853 | }; |
| 2854 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2855 | static const struct hda_pintbl intel_mac_v3_pin_configs[] = { |
| 2856 | { 0x0a, 0x0121e21f }, |
| 2857 | { 0x0b, 0x90a7012e }, |
| 2858 | { 0x0c, 0x9017e110 }, |
| 2859 | { 0x0d, 0x400000fd }, |
| 2860 | { 0x0e, 0x400000fe }, |
| 2861 | { 0x0f, 0x0181e020 }, |
| 2862 | { 0x10, 0x1145e230 }, |
| 2863 | { 0x11, 0x11c5e240 }, |
| 2864 | { 0x15, 0x400000fc }, |
| 2865 | { 0x1b, 0x400000fb }, |
| 2866 | {} |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2867 | }; |
| 2868 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2869 | static const struct hda_pintbl intel_mac_v4_pin_configs[] = { |
| 2870 | { 0x0a, 0x0321e21f }, |
| 2871 | { 0x0b, 0x03a1e02e }, |
| 2872 | { 0x0c, 0x9017e110 }, |
| 2873 | { 0x0d, 0x9017e11f }, |
| 2874 | { 0x0e, 0x400000fe }, |
| 2875 | { 0x0f, 0x0381e020 }, |
| 2876 | { 0x10, 0x1345e230 }, |
| 2877 | { 0x11, 0x13c5e240 }, |
| 2878 | { 0x15, 0x400000fc }, |
| 2879 | { 0x1b, 0x400000fb }, |
| 2880 | {} |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2881 | }; |
| 2882 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2883 | static const struct hda_pintbl intel_mac_v5_pin_configs[] = { |
| 2884 | { 0x0a, 0x0321e21f }, |
| 2885 | { 0x0b, 0x03a1e02e }, |
| 2886 | { 0x0c, 0x9017e110 }, |
| 2887 | { 0x0d, 0x9017e11f }, |
| 2888 | { 0x0e, 0x400000fe }, |
| 2889 | { 0x0f, 0x0381e020 }, |
| 2890 | { 0x10, 0x1345e230 }, |
| 2891 | { 0x11, 0x13c5e240 }, |
| 2892 | { 0x15, 0x400000fc }, |
| 2893 | { 0x1b, 0x400000fb }, |
| 2894 | {} |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2895 | }; |
| 2896 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2897 | static const struct hda_pintbl ecs202_pin_configs[] = { |
| 2898 | { 0x0a, 0x0221401f }, |
| 2899 | { 0x0b, 0x02a19020 }, |
| 2900 | { 0x0c, 0x01a19020 }, |
| 2901 | { 0x0d, 0x01114010 }, |
| 2902 | { 0x0e, 0x408000f0 }, |
| 2903 | { 0x0f, 0x01813022 }, |
| 2904 | { 0x10, 0x074510a0 }, |
| 2905 | { 0x11, 0x40c400f1 }, |
| 2906 | { 0x15, 0x9037012e }, |
| 2907 | { 0x1b, 0x40e000f2 }, |
| 2908 | {} |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2909 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2910 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2911 | /* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */ |
| 2912 | static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = { |
| 2913 | SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1), |
| 2914 | SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2), |
| 2915 | SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2), |
| 2916 | SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3), |
| 2917 | SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3), |
| 2918 | SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3), |
| 2919 | SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3), |
| 2920 | SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3), |
| 2921 | SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3), |
| 2922 | SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4), |
| 2923 | SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5), |
| 2924 | SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5), |
| 2925 | {} |
| 2926 | }; |
| 2927 | |
| 2928 | static const struct hda_fixup stac922x_fixups[]; |
| 2929 | |
| 2930 | /* remap the fixup from codec SSID and apply it */ |
| 2931 | static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec, |
| 2932 | const struct hda_fixup *fix, |
| 2933 | int action) |
| 2934 | { |
| 2935 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2936 | return; |
| 2937 | snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl, |
| 2938 | stac922x_fixups); |
| 2939 | if (codec->fixup_id != STAC_INTEL_MAC_AUTO) |
| 2940 | snd_hda_apply_fixup(codec, action); |
| 2941 | } |
| 2942 | |
| 2943 | static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec, |
| 2944 | const struct hda_fixup *fix, |
| 2945 | int action) |
| 2946 | { |
| 2947 | struct sigmatel_spec *spec = codec->spec; |
| 2948 | |
| 2949 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 2950 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 2951 | spec->gpio_data = 0x03; |
| 2952 | } |
| 2953 | } |
| 2954 | |
| 2955 | static const struct hda_fixup stac922x_fixups[] = { |
| 2956 | [STAC_D945_REF] = { |
| 2957 | .type = HDA_FIXUP_PINS, |
| 2958 | .v.pins = ref922x_pin_configs, |
| 2959 | }, |
| 2960 | [STAC_D945GTP3] = { |
| 2961 | .type = HDA_FIXUP_PINS, |
| 2962 | .v.pins = d945gtp3_pin_configs, |
| 2963 | }, |
| 2964 | [STAC_D945GTP5] = { |
| 2965 | .type = HDA_FIXUP_PINS, |
| 2966 | .v.pins = d945gtp5_pin_configs, |
| 2967 | }, |
| 2968 | [STAC_INTEL_MAC_AUTO] = { |
| 2969 | .type = HDA_FIXUP_FUNC, |
| 2970 | .v.func = stac922x_fixup_intel_mac_auto, |
| 2971 | }, |
| 2972 | [STAC_INTEL_MAC_V1] = { |
| 2973 | .type = HDA_FIXUP_PINS, |
| 2974 | .v.pins = intel_mac_v1_pin_configs, |
| 2975 | .chained = true, |
| 2976 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2977 | }, |
| 2978 | [STAC_INTEL_MAC_V2] = { |
| 2979 | .type = HDA_FIXUP_PINS, |
| 2980 | .v.pins = intel_mac_v2_pin_configs, |
| 2981 | .chained = true, |
| 2982 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2983 | }, |
| 2984 | [STAC_INTEL_MAC_V3] = { |
| 2985 | .type = HDA_FIXUP_PINS, |
| 2986 | .v.pins = intel_mac_v3_pin_configs, |
| 2987 | .chained = true, |
| 2988 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2989 | }, |
| 2990 | [STAC_INTEL_MAC_V4] = { |
| 2991 | .type = HDA_FIXUP_PINS, |
| 2992 | .v.pins = intel_mac_v4_pin_configs, |
| 2993 | .chained = true, |
| 2994 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2995 | }, |
| 2996 | [STAC_INTEL_MAC_V5] = { |
| 2997 | .type = HDA_FIXUP_PINS, |
| 2998 | .v.pins = intel_mac_v5_pin_configs, |
| 2999 | .chained = true, |
| 3000 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 3001 | }, |
| 3002 | [STAC_922X_INTEL_MAC_GPIO] = { |
| 3003 | .type = HDA_FIXUP_FUNC, |
| 3004 | .v.func = stac922x_fixup_intel_mac_gpio, |
| 3005 | }, |
| 3006 | [STAC_ECS_202] = { |
| 3007 | .type = HDA_FIXUP_PINS, |
| 3008 | .v.pins = ecs202_pin_configs, |
| 3009 | }, |
| 3010 | [STAC_922X_DELL_D81] = { |
| 3011 | .type = HDA_FIXUP_PINS, |
| 3012 | .v.pins = dell_922x_d81_pin_configs, |
| 3013 | }, |
| 3014 | [STAC_922X_DELL_D82] = { |
| 3015 | .type = HDA_FIXUP_PINS, |
| 3016 | .v.pins = dell_922x_d82_pin_configs, |
| 3017 | }, |
| 3018 | [STAC_922X_DELL_M81] = { |
| 3019 | .type = HDA_FIXUP_PINS, |
| 3020 | .v.pins = dell_922x_m81_pin_configs, |
| 3021 | }, |
| 3022 | [STAC_922X_DELL_M82] = { |
| 3023 | .type = HDA_FIXUP_PINS, |
| 3024 | .v.pins = dell_922x_m82_pin_configs, |
| 3025 | }, |
| 3026 | }; |
| 3027 | |
| 3028 | static const struct hda_model_fixup stac922x_models[] = { |
| 3029 | { .id = STAC_D945_REF, .name = "ref" }, |
| 3030 | { .id = STAC_D945GTP5, .name = "5stack" }, |
| 3031 | { .id = STAC_D945GTP3, .name = "3stack" }, |
| 3032 | { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" }, |
| 3033 | { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" }, |
| 3034 | { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" }, |
| 3035 | { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" }, |
| 3036 | { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" }, |
| 3037 | { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" }, |
| 3038 | { .id = STAC_ECS_202, .name = "ecs202" }, |
| 3039 | { .id = STAC_922X_DELL_D81, .name = "dell-d81" }, |
| 3040 | { .id = STAC_922X_DELL_D82, .name = "dell-d82" }, |
| 3041 | { .id = STAC_922X_DELL_M81, .name = "dell-m81" }, |
| 3042 | { .id = STAC_922X_DELL_M82, .name = "dell-m82" }, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3043 | /* for backward compatibility */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 3044 | { .id = STAC_INTEL_MAC_V3, .name = "macmini" }, |
| 3045 | { .id = STAC_INTEL_MAC_V5, .name = "macbook" }, |
| 3046 | { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" }, |
| 3047 | { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" }, |
| 3048 | { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" }, |
| 3049 | { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" }, |
| 3050 | {} |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3051 | }; |
| 3052 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 3053 | static const struct snd_pci_quirk stac922x_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3054 | /* SigmaTel reference board */ |
| 3055 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 3056 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 3057 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 3058 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3059 | /* Intel 945G based systems */ |
| 3060 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 3061 | "Intel D945G", STAC_D945GTP3), |
| 3062 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 3063 | "Intel D945G", STAC_D945GTP3), |
| 3064 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 3065 | "Intel D945G", STAC_D945GTP3), |
| 3066 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 3067 | "Intel D945G", STAC_D945GTP3), |
| 3068 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 3069 | "Intel D945G", STAC_D945GTP3), |
| 3070 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 3071 | "Intel D945G", STAC_D945GTP3), |
| 3072 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 3073 | "Intel D945G", STAC_D945GTP3), |
| 3074 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 3075 | "Intel D945G", STAC_D945GTP3), |
| 3076 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 3077 | "Intel D945G", STAC_D945GTP3), |
| 3078 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 3079 | "Intel D945G", STAC_D945GTP3), |
| 3080 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 3081 | "Intel D945G", STAC_D945GTP3), |
| 3082 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 3083 | "Intel D945G", STAC_D945GTP3), |
| 3084 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 3085 | "Intel D945G", STAC_D945GTP3), |
| 3086 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 3087 | "Intel D945G", STAC_D945GTP3), |
| 3088 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 3089 | "Intel D945G", STAC_D945GTP3), |
| 3090 | /* Intel D945G 5-stack systems */ |
| 3091 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 3092 | "Intel D945G", STAC_D945GTP5), |
| 3093 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 3094 | "Intel D945G", STAC_D945GTP5), |
| 3095 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 3096 | "Intel D945G", STAC_D945GTP5), |
| 3097 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 3098 | "Intel D945G", STAC_D945GTP5), |
| 3099 | /* Intel 945P based systems */ |
| 3100 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 3101 | "Intel D945P", STAC_D945GTP3), |
| 3102 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 3103 | "Intel D945P", STAC_D945GTP3), |
| 3104 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 3105 | "Intel D945P", STAC_D945GTP3), |
| 3106 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 3107 | "Intel D945P", STAC_D945GTP3), |
| 3108 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 3109 | "Intel D945P", STAC_D945GTP3), |
| 3110 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 3111 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 3112 | /* other intel */ |
| 3113 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 3114 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3115 | /* other systems */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 3116 | |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 3117 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 3118 | SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO), |
| 3119 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3120 | /* Dell systems */ |
| 3121 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 3122 | "unknown Dell", STAC_922X_DELL_D81), |
| 3123 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 3124 | "unknown Dell", STAC_922X_DELL_D81), |
| 3125 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 3126 | "unknown Dell", STAC_922X_DELL_D81), |
| 3127 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 3128 | "unknown Dell", STAC_922X_DELL_D82), |
| 3129 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 3130 | "unknown Dell", STAC_922X_DELL_M81), |
| 3131 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 3132 | "unknown Dell", STAC_922X_DELL_D82), |
| 3133 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 3134 | "unknown Dell", STAC_922X_DELL_D81), |
| 3135 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 3136 | "unknown Dell", STAC_922X_DELL_D81), |
| 3137 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 3138 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 3139 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 3140 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 3141 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3142 | {} /* terminator */ |
| 3143 | }; |
| 3144 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3145 | static const struct hda_pintbl ref927x_pin_configs[] = { |
| 3146 | { 0x0a, 0x02214020 }, |
| 3147 | { 0x0b, 0x02a19080 }, |
| 3148 | { 0x0c, 0x0181304e }, |
| 3149 | { 0x0d, 0x01014010 }, |
| 3150 | { 0x0e, 0x01a19040 }, |
| 3151 | { 0x0f, 0x01011012 }, |
| 3152 | { 0x10, 0x01016011 }, |
| 3153 | { 0x11, 0x0101201f }, |
| 3154 | { 0x12, 0x183301f0 }, |
| 3155 | { 0x13, 0x18a001f0 }, |
| 3156 | { 0x14, 0x18a001f0 }, |
| 3157 | { 0x21, 0x01442070 }, |
| 3158 | { 0x22, 0x01c42190 }, |
| 3159 | { 0x23, 0x40000100 }, |
| 3160 | {} |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3161 | }; |
| 3162 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3163 | static const struct hda_pintbl d965_3st_pin_configs[] = { |
| 3164 | { 0x0a, 0x0221401f }, |
| 3165 | { 0x0b, 0x02a19120 }, |
| 3166 | { 0x0c, 0x40000100 }, |
| 3167 | { 0x0d, 0x01014011 }, |
| 3168 | { 0x0e, 0x01a19021 }, |
| 3169 | { 0x0f, 0x01813024 }, |
| 3170 | { 0x10, 0x40000100 }, |
| 3171 | { 0x11, 0x40000100 }, |
| 3172 | { 0x12, 0x40000100 }, |
| 3173 | { 0x13, 0x40000100 }, |
| 3174 | { 0x14, 0x40000100 }, |
| 3175 | { 0x21, 0x40000100 }, |
| 3176 | { 0x22, 0x40000100 }, |
| 3177 | { 0x23, 0x40000100 }, |
| 3178 | {} |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3179 | }; |
| 3180 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3181 | static const struct hda_pintbl d965_5st_pin_configs[] = { |
| 3182 | { 0x0a, 0x02214020 }, |
| 3183 | { 0x0b, 0x02a19080 }, |
| 3184 | { 0x0c, 0x0181304e }, |
| 3185 | { 0x0d, 0x01014010 }, |
| 3186 | { 0x0e, 0x01a19040 }, |
| 3187 | { 0x0f, 0x01011012 }, |
| 3188 | { 0x10, 0x01016011 }, |
| 3189 | { 0x11, 0x40000100 }, |
| 3190 | { 0x12, 0x40000100 }, |
| 3191 | { 0x13, 0x40000100 }, |
| 3192 | { 0x14, 0x40000100 }, |
| 3193 | { 0x21, 0x01442070 }, |
| 3194 | { 0x22, 0x40000100 }, |
| 3195 | { 0x23, 0x40000100 }, |
| 3196 | {} |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3197 | }; |
| 3198 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3199 | static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = { |
| 3200 | { 0x0a, 0x40000100 }, |
| 3201 | { 0x0b, 0x40000100 }, |
| 3202 | { 0x0c, 0x0181304e }, |
| 3203 | { 0x0d, 0x01014010 }, |
| 3204 | { 0x0e, 0x01a19040 }, |
| 3205 | { 0x0f, 0x01011012 }, |
| 3206 | { 0x10, 0x01016011 }, |
| 3207 | { 0x11, 0x40000100 }, |
| 3208 | { 0x12, 0x40000100 }, |
| 3209 | { 0x13, 0x40000100 }, |
| 3210 | { 0x14, 0x40000100 }, |
| 3211 | { 0x21, 0x01442070 }, |
| 3212 | { 0x22, 0x40000100 }, |
| 3213 | { 0x23, 0x40000100 }, |
| 3214 | {} |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 3215 | }; |
| 3216 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3217 | static const struct hda_pintbl dell_3st_pin_configs[] = { |
| 3218 | { 0x0a, 0x02211230 }, |
| 3219 | { 0x0b, 0x02a11220 }, |
| 3220 | { 0x0c, 0x01a19040 }, |
| 3221 | { 0x0d, 0x01114210 }, |
| 3222 | { 0x0e, 0x01111212 }, |
| 3223 | { 0x0f, 0x01116211 }, |
| 3224 | { 0x10, 0x01813050 }, |
| 3225 | { 0x11, 0x01112214 }, |
| 3226 | { 0x12, 0x403003fa }, |
| 3227 | { 0x13, 0x90a60040 }, |
| 3228 | { 0x14, 0x90a60040 }, |
| 3229 | { 0x21, 0x404003fb }, |
| 3230 | { 0x22, 0x40c003fc }, |
| 3231 | { 0x23, 0x40000100 }, |
| 3232 | {} |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 3233 | }; |
| 3234 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3235 | static void stac927x_fixup_ref_no_jd(struct hda_codec *codec, |
| 3236 | const struct hda_fixup *fix, int action) |
| 3237 | { |
| 3238 | struct sigmatel_spec *spec = codec->spec; |
| 3239 | |
| 3240 | /* no jack detecion for ref-no-jd model */ |
| 3241 | if (action == HDA_FIXUP_ACT_PROBE) |
| 3242 | spec->hp_detect = 0; |
| 3243 | } |
| 3244 | |
| 3245 | static void stac927x_fixup_ref(struct hda_codec *codec, |
| 3246 | const struct hda_fixup *fix, int action) |
| 3247 | { |
| 3248 | struct sigmatel_spec *spec = codec->spec; |
| 3249 | |
| 3250 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3251 | snd_hda_apply_pincfgs(codec, ref927x_pin_configs); |
| 3252 | spec->eapd_mask = spec->gpio_mask = 0; |
| 3253 | spec->gpio_dir = spec->gpio_data = 0; |
| 3254 | } |
| 3255 | } |
| 3256 | |
| 3257 | static void stac927x_fixup_dell_dmic(struct hda_codec *codec, |
| 3258 | const struct hda_fixup *fix, int action) |
| 3259 | { |
| 3260 | struct sigmatel_spec *spec = codec->spec; |
| 3261 | |
| 3262 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 3263 | return; |
| 3264 | |
| 3265 | if (codec->subsystem_id != 0x1028022f) { |
| 3266 | /* GPIO2 High = Enable EAPD */ |
| 3267 | spec->eapd_mask = spec->gpio_mask = 0x04; |
| 3268 | spec->gpio_dir = spec->gpio_data = 0x04; |
| 3269 | } |
| 3270 | spec->dmic_nids = stac927x_dmic_nids; |
| 3271 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 3272 | |
| 3273 | snd_hda_add_verbs(codec, dell_3st_core_init); |
| 3274 | spec->volknob_init = 1; |
| 3275 | spec->dmux_nids = stac927x_dmux_nids; |
| 3276 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
| 3277 | } |
| 3278 | |
| 3279 | static void stac927x_fixup_volknob(struct hda_codec *codec, |
| 3280 | const struct hda_fixup *fix, int action) |
| 3281 | { |
| 3282 | struct sigmatel_spec *spec = codec->spec; |
| 3283 | |
| 3284 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3285 | snd_hda_add_verbs(codec, stac927x_volknob_core_init); |
| 3286 | spec->volknob_init = 1; |
| 3287 | } |
| 3288 | } |
| 3289 | |
| 3290 | static const struct hda_fixup stac927x_fixups[] = { |
| 3291 | [STAC_D965_REF_NO_JD] = { |
| 3292 | .type = HDA_FIXUP_FUNC, |
| 3293 | .v.func = stac927x_fixup_ref_no_jd, |
| 3294 | .chained = true, |
| 3295 | .chain_id = STAC_D965_REF, |
| 3296 | }, |
| 3297 | [STAC_D965_REF] = { |
| 3298 | .type = HDA_FIXUP_FUNC, |
| 3299 | .v.func = stac927x_fixup_ref, |
| 3300 | }, |
| 3301 | [STAC_D965_3ST] = { |
| 3302 | .type = HDA_FIXUP_PINS, |
| 3303 | .v.pins = d965_3st_pin_configs, |
| 3304 | .chained = true, |
| 3305 | .chain_id = STAC_D965_VERBS, |
| 3306 | }, |
| 3307 | [STAC_D965_5ST] = { |
| 3308 | .type = HDA_FIXUP_PINS, |
| 3309 | .v.pins = d965_5st_pin_configs, |
| 3310 | .chained = true, |
| 3311 | .chain_id = STAC_D965_VERBS, |
| 3312 | }, |
| 3313 | [STAC_D965_VERBS] = { |
| 3314 | .type = HDA_FIXUP_VERBS, |
| 3315 | .v.verbs = d965_core_init, |
| 3316 | }, |
| 3317 | [STAC_D965_5ST_NO_FP] = { |
| 3318 | .type = HDA_FIXUP_PINS, |
| 3319 | .v.pins = d965_5st_no_fp_pin_configs, |
| 3320 | }, |
| 3321 | [STAC_DELL_3ST] = { |
| 3322 | .type = HDA_FIXUP_PINS, |
| 3323 | .v.pins = dell_3st_pin_configs, |
| 3324 | .chained = true, |
| 3325 | .chain_id = STAC_927X_DELL_DMIC, |
| 3326 | }, |
| 3327 | [STAC_DELL_BIOS] = { |
| 3328 | .type = HDA_FIXUP_PINS, |
| 3329 | .v.pins = (const struct hda_pintbl[]) { |
| 3330 | /* configure the analog microphone on some laptops */ |
| 3331 | { 0x0c, 0x90a79130 }, |
| 3332 | /* correct the front output jack as a hp out */ |
| 3333 | { 0x0f, 0x0227011f }, |
| 3334 | /* correct the front input jack as a mic */ |
| 3335 | { 0x0e, 0x02a79130 }, |
| 3336 | {} |
| 3337 | }, |
| 3338 | .chained = true, |
| 3339 | .chain_id = STAC_927X_DELL_DMIC, |
| 3340 | }, |
| 3341 | [STAC_DELL_BIOS_SPDIF] = { |
| 3342 | .type = HDA_FIXUP_PINS, |
| 3343 | .v.pins = (const struct hda_pintbl[]) { |
| 3344 | /* correct the device field to SPDIF out */ |
| 3345 | { 0x21, 0x01442070 }, |
| 3346 | {} |
| 3347 | }, |
| 3348 | .chained = true, |
| 3349 | .chain_id = STAC_DELL_BIOS, |
| 3350 | }, |
| 3351 | [STAC_927X_DELL_DMIC] = { |
| 3352 | .type = HDA_FIXUP_FUNC, |
| 3353 | .v.func = stac927x_fixup_dell_dmic, |
| 3354 | }, |
| 3355 | [STAC_927X_VOLKNOB] = { |
| 3356 | .type = HDA_FIXUP_FUNC, |
| 3357 | .v.func = stac927x_fixup_volknob, |
| 3358 | }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3359 | }; |
| 3360 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3361 | static const struct hda_model_fixup stac927x_models[] = { |
| 3362 | { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" }, |
| 3363 | { .id = STAC_D965_REF, .name = "ref" }, |
| 3364 | { .id = STAC_D965_3ST, .name = "3stack" }, |
| 3365 | { .id = STAC_D965_5ST, .name = "5stack" }, |
| 3366 | { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" }, |
| 3367 | { .id = STAC_DELL_3ST, .name = "dell-3stack" }, |
| 3368 | { .id = STAC_DELL_BIOS, .name = "dell-bios" }, |
| 3369 | { .id = STAC_927X_VOLKNOB, .name = "volknob" }, |
| 3370 | {} |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3371 | }; |
| 3372 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3373 | static const struct snd_pci_quirk stac927x_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3374 | /* SigmaTel reference board */ |
| 3375 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 3376 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 3377 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 3378 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3379 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3380 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 3381 | 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] | 3382 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 3383 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 3384 | "Intel D965", STAC_D965_3ST), |
| 3385 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 3386 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 3387 | /* Dell 3 stack systems */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3388 | 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] | 3389 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 3390 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 3391 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 3392 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
Daniel T Chen | 66668b6 | 2010-05-23 20:47:45 -0400 | [diff] [blame] | 3393 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS), |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 3394 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3395 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF), |
Chengu Wang | 84d3dc2 | 2009-07-30 19:43:55 +0800 | [diff] [blame] | 3396 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 3397 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 3398 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 3399 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3400 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3401 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 3402 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 3403 | "Intel D965", STAC_D965_5ST), |
| 3404 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 3405 | "Intel D965", STAC_D965_5ST), |
Takashi Iwai | 5493053 | 2009-10-11 17:38:29 +0200 | [diff] [blame] | 3406 | /* volume-knob fixes */ |
| 3407 | SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3408 | {} /* terminator */ |
| 3409 | }; |
| 3410 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3411 | static const struct hda_pintbl ref9205_pin_configs[] = { |
| 3412 | { 0x0a, 0x40000100 }, |
| 3413 | { 0x0b, 0x40000100 }, |
| 3414 | { 0x0c, 0x01016011 }, |
| 3415 | { 0x0d, 0x01014010 }, |
| 3416 | { 0x0e, 0x01813122 }, |
| 3417 | { 0x0f, 0x01a19021 }, |
| 3418 | { 0x14, 0x01019020 }, |
| 3419 | { 0x16, 0x40000100 }, |
| 3420 | { 0x17, 0x90a000f0 }, |
| 3421 | { 0x18, 0x90a000f0 }, |
| 3422 | { 0x21, 0x01441030 }, |
| 3423 | { 0x22, 0x01c41030 }, |
| 3424 | {} |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3425 | }; |
| 3426 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3427 | /* |
| 3428 | STAC 9205 pin configs for |
| 3429 | 102801F1 |
| 3430 | 102801F2 |
| 3431 | 102801FC |
| 3432 | 102801FD |
| 3433 | 10280204 |
| 3434 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 3435 | 10280228 (Dell Vostro 1500) |
Anisse Astier | 95e70e8 | 2009-12-23 17:28:45 +0100 | [diff] [blame] | 3436 | 10280229 (Dell Vostro 1700) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3437 | */ |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3438 | static const struct hda_pintbl dell_9205_m42_pin_configs[] = { |
| 3439 | { 0x0a, 0x0321101F }, |
| 3440 | { 0x0b, 0x03A11020 }, |
| 3441 | { 0x0c, 0x400003FA }, |
| 3442 | { 0x0d, 0x90170310 }, |
| 3443 | { 0x0e, 0x400003FB }, |
| 3444 | { 0x0f, 0x400003FC }, |
| 3445 | { 0x14, 0x400003FD }, |
| 3446 | { 0x16, 0x40F000F9 }, |
| 3447 | { 0x17, 0x90A60330 }, |
| 3448 | { 0x18, 0x400003FF }, |
| 3449 | { 0x21, 0x0144131F }, |
| 3450 | { 0x22, 0x40C003FE }, |
| 3451 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3452 | }; |
| 3453 | |
| 3454 | /* |
| 3455 | STAC 9205 pin configs for |
| 3456 | 102801F9 |
| 3457 | 102801FA |
| 3458 | 102801FE |
| 3459 | 102801FF (Dell Precision M4300) |
| 3460 | 10280206 |
| 3461 | 10280200 |
| 3462 | 10280201 |
| 3463 | */ |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3464 | static const struct hda_pintbl dell_9205_m43_pin_configs[] = { |
| 3465 | { 0x0a, 0x0321101f }, |
| 3466 | { 0x0b, 0x03a11020 }, |
| 3467 | { 0x0c, 0x90a70330 }, |
| 3468 | { 0x0d, 0x90170310 }, |
| 3469 | { 0x0e, 0x400000fe }, |
| 3470 | { 0x0f, 0x400000ff }, |
| 3471 | { 0x14, 0x400000fd }, |
| 3472 | { 0x16, 0x40f000f9 }, |
| 3473 | { 0x17, 0x400000fa }, |
| 3474 | { 0x18, 0x400000fc }, |
| 3475 | { 0x21, 0x0144131f }, |
| 3476 | { 0x22, 0x40c003f8 }, |
| 3477 | /* Enable SPDIF in/out */ |
| 3478 | { 0x1f, 0x01441030 }, |
| 3479 | { 0x20, 0x1c410030 }, |
| 3480 | {} |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3481 | }; |
| 3482 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3483 | static const struct hda_pintbl dell_9205_m44_pin_configs[] = { |
| 3484 | { 0x0a, 0x0421101f }, |
| 3485 | { 0x0b, 0x04a11020 }, |
| 3486 | { 0x0c, 0x400003fa }, |
| 3487 | { 0x0d, 0x90170310 }, |
| 3488 | { 0x0e, 0x400003fb }, |
| 3489 | { 0x0f, 0x400003fc }, |
| 3490 | { 0x14, 0x400003fd }, |
| 3491 | { 0x16, 0x400003f9 }, |
| 3492 | { 0x17, 0x90a60330 }, |
| 3493 | { 0x18, 0x400003ff }, |
| 3494 | { 0x21, 0x01441340 }, |
| 3495 | { 0x22, 0x40c003fe }, |
| 3496 | {} |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3497 | }; |
| 3498 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3499 | static void stac9205_fixup_ref(struct hda_codec *codec, |
| 3500 | const struct hda_fixup *fix, int action) |
| 3501 | { |
| 3502 | struct sigmatel_spec *spec = codec->spec; |
| 3503 | |
| 3504 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3505 | snd_hda_apply_pincfgs(codec, ref9205_pin_configs); |
| 3506 | /* SPDIF-In enabled */ |
| 3507 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0; |
| 3508 | } |
| 3509 | } |
| 3510 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3511 | static void stac9205_fixup_dell_m43(struct hda_codec *codec, |
| 3512 | const struct hda_fixup *fix, int action) |
| 3513 | { |
| 3514 | struct sigmatel_spec *spec = codec->spec; |
| 3515 | int err; |
| 3516 | |
| 3517 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3518 | snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs); |
| 3519 | |
| 3520 | /* Enable unsol response for GPIO4/Dock HP connection */ |
| 3521 | err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 3522 | if (err < 0) |
| 3523 | return; |
| 3524 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 3525 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 3526 | snd_hda_jack_detect_enable(codec, codec->afg, 0); |
| 3527 | |
| 3528 | spec->gpio_dir = 0x0b; |
| 3529 | spec->eapd_mask = 0x01; |
| 3530 | spec->gpio_mask = 0x1b; |
| 3531 | spec->gpio_mute = 0x10; |
| 3532 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
| 3533 | * GPIO3 Low = DRM |
| 3534 | */ |
| 3535 | spec->gpio_data = 0x01; |
| 3536 | } |
| 3537 | } |
| 3538 | |
| 3539 | static void stac9205_fixup_eapd(struct hda_codec *codec, |
| 3540 | const struct hda_fixup *fix, int action) |
| 3541 | { |
| 3542 | struct sigmatel_spec *spec = codec->spec; |
| 3543 | |
| 3544 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 3545 | spec->eapd_switch = 0; |
| 3546 | } |
| 3547 | |
| 3548 | static const struct hda_fixup stac9205_fixups[] = { |
| 3549 | [STAC_9205_REF] = { |
| 3550 | .type = HDA_FIXUP_FUNC, |
| 3551 | .v.func = stac9205_fixup_ref, |
| 3552 | }, |
| 3553 | [STAC_9205_DELL_M42] = { |
| 3554 | .type = HDA_FIXUP_PINS, |
| 3555 | .v.pins = dell_9205_m42_pin_configs, |
| 3556 | }, |
| 3557 | [STAC_9205_DELL_M43] = { |
| 3558 | .type = HDA_FIXUP_FUNC, |
| 3559 | .v.func = stac9205_fixup_dell_m43, |
| 3560 | }, |
| 3561 | [STAC_9205_DELL_M44] = { |
| 3562 | .type = HDA_FIXUP_PINS, |
| 3563 | .v.pins = dell_9205_m44_pin_configs, |
| 3564 | }, |
| 3565 | [STAC_9205_EAPD] = { |
| 3566 | .type = HDA_FIXUP_FUNC, |
| 3567 | .v.func = stac9205_fixup_eapd, |
| 3568 | }, |
| 3569 | {} |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3570 | }; |
| 3571 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3572 | static const struct hda_model_fixup stac9205_models[] = { |
| 3573 | { .id = STAC_9205_REF, .name = "ref" }, |
| 3574 | { .id = STAC_9205_DELL_M42, .name = "dell-m42" }, |
| 3575 | { .id = STAC_9205_DELL_M43, .name = "dell-m43" }, |
| 3576 | { .id = STAC_9205_DELL_M44, .name = "dell-m44" }, |
| 3577 | { .id = STAC_9205_EAPD, .name = "eapd" }, |
| 3578 | {} |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3579 | }; |
| 3580 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3581 | static const struct snd_pci_quirk stac9205_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3582 | /* SigmaTel reference board */ |
| 3583 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 3584 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 3585 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 3586 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 3587 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 3588 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 3589 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3590 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 3591 | "unknown Dell", STAC_9205_DELL_M42), |
| 3592 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 3593 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3594 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 3595 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3596 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 3597 | "Dell Precision", STAC_9205_DELL_M43), |
| 3598 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 3599 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3600 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 3601 | "unknown Dell", STAC_9205_DELL_M42), |
| 3602 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 3603 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3604 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 3605 | "Dell Precision", STAC_9205_DELL_M43), |
| 3606 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3607 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3608 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 3609 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 3610 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 3611 | "Dell Precision", STAC_9205_DELL_M43), |
| 3612 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 3613 | "Dell Precision", STAC_9205_DELL_M43), |
| 3614 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 3615 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3616 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 3617 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 3618 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 3619 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Anisse Astier | 95e70e8 | 2009-12-23 17:28:45 +0100 | [diff] [blame] | 3620 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229, |
| 3621 | "Dell Vostro 1700", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 3622 | /* Gateway */ |
Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 3623 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 3624 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3625 | {} /* terminator */ |
| 3626 | }; |
| 3627 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3628 | /* |
| 3629 | * Analog playback callbacks |
| 3630 | */ |
| 3631 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 3632 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3633 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3634 | { |
| 3635 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3636 | if (spec->stream_delay) |
| 3637 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 3638 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 3639 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3640 | } |
| 3641 | |
| 3642 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3643 | struct hda_codec *codec, |
| 3644 | unsigned int stream_tag, |
| 3645 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3646 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3647 | { |
| 3648 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3649 | 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] | 3650 | } |
| 3651 | |
| 3652 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3653 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3654 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3655 | { |
| 3656 | struct sigmatel_spec *spec = codec->spec; |
| 3657 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 3658 | } |
| 3659 | |
| 3660 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3661 | * Digital playback callbacks |
| 3662 | */ |
| 3663 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 3664 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3665 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3666 | { |
| 3667 | struct sigmatel_spec *spec = codec->spec; |
| 3668 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 3669 | } |
| 3670 | |
| 3671 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 3672 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3673 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3674 | { |
| 3675 | struct sigmatel_spec *spec = codec->spec; |
| 3676 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 3677 | } |
| 3678 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 3679 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3680 | struct hda_codec *codec, |
| 3681 | unsigned int stream_tag, |
| 3682 | unsigned int format, |
| 3683 | struct snd_pcm_substream *substream) |
| 3684 | { |
| 3685 | struct sigmatel_spec *spec = codec->spec; |
| 3686 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 3687 | stream_tag, format, substream); |
| 3688 | } |
| 3689 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 3690 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3691 | struct hda_codec *codec, |
| 3692 | struct snd_pcm_substream *substream) |
| 3693 | { |
| 3694 | struct sigmatel_spec *spec = codec->spec; |
| 3695 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 3696 | } |
| 3697 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3698 | |
| 3699 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3700 | * Analog capture callbacks |
| 3701 | */ |
| 3702 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3703 | struct hda_codec *codec, |
| 3704 | unsigned int stream_tag, |
| 3705 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3706 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3707 | { |
| 3708 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3709 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3710 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3711 | if (spec->powerdown_adcs) { |
| 3712 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3713 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3714 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 3715 | } |
| 3716 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3717 | return 0; |
| 3718 | } |
| 3719 | |
| 3720 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3721 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3722 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3723 | { |
| 3724 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3725 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3726 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3727 | snd_hda_codec_cleanup_stream(codec, nid); |
| 3728 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3729 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3730 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3731 | return 0; |
| 3732 | } |
| 3733 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3734 | static const struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3735 | .substreams = 1, |
| 3736 | .channels_min = 2, |
| 3737 | .channels_max = 2, |
| 3738 | /* NID is set in stac92xx_build_pcms */ |
| 3739 | .ops = { |
| 3740 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 3741 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 3742 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 3743 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3744 | }, |
| 3745 | }; |
| 3746 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3747 | static const struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3748 | .substreams = 1, |
| 3749 | .channels_min = 2, |
| 3750 | .channels_max = 2, |
| 3751 | /* NID is set in stac92xx_build_pcms */ |
| 3752 | }; |
| 3753 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3754 | static const struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3755 | .substreams = 1, |
| 3756 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3757 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3758 | .nid = 0x02, /* NID to query formats and rates */ |
| 3759 | .ops = { |
| 3760 | .open = stac92xx_playback_pcm_open, |
| 3761 | .prepare = stac92xx_playback_pcm_prepare, |
| 3762 | .cleanup = stac92xx_playback_pcm_cleanup |
| 3763 | }, |
| 3764 | }; |
| 3765 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3766 | static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3767 | .substreams = 1, |
| 3768 | .channels_min = 2, |
| 3769 | .channels_max = 2, |
| 3770 | .nid = 0x06, /* NID to query formats and rates */ |
| 3771 | .ops = { |
| 3772 | .open = stac92xx_playback_pcm_open, |
| 3773 | .prepare = stac92xx_playback_pcm_prepare, |
| 3774 | .cleanup = stac92xx_playback_pcm_cleanup |
| 3775 | }, |
| 3776 | }; |
| 3777 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3778 | static const struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3779 | .channels_min = 2, |
| 3780 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3781 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3782 | .ops = { |
| 3783 | .prepare = stac92xx_capture_pcm_prepare, |
| 3784 | .cleanup = stac92xx_capture_pcm_cleanup |
| 3785 | }, |
| 3786 | }; |
| 3787 | |
| 3788 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 3789 | { |
| 3790 | struct sigmatel_spec *spec = codec->spec; |
| 3791 | struct hda_pcm *info = spec->pcm_rec; |
| 3792 | |
| 3793 | codec->num_pcms = 1; |
| 3794 | codec->pcm_info = info; |
| 3795 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3796 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3797 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 3798 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 3799 | spec->multiout.dac_nids[0]; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 3800 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3801 | spec->autocfg.line_outs == 2) |
| 3802 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 3803 | snd_pcm_2_1_chmaps; |
| 3804 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3805 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3806 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3807 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3808 | |
| 3809 | if (spec->alt_switch) { |
| 3810 | codec->num_pcms++; |
| 3811 | info++; |
| 3812 | info->name = "STAC92xx Analog Alt"; |
| 3813 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 3814 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3815 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3816 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 3817 | codec->num_pcms++; |
| 3818 | info++; |
| 3819 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3820 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3821 | if (spec->multiout.dig_out_nid) { |
| 3822 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 3823 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 3824 | } |
| 3825 | if (spec->dig_in_nid) { |
| 3826 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 3827 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 3828 | } |
| 3829 | } |
| 3830 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3831 | return 0; |
| 3832 | } |
| 3833 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3834 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 3835 | |
| 3836 | { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3837 | snd_hda_set_pin_ctl_cache(codec, nid, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3838 | } |
| 3839 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3840 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 3841 | |
| 3842 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 3843 | struct snd_ctl_elem_value *ucontrol) |
| 3844 | { |
| 3845 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3846 | struct sigmatel_spec *spec = codec->spec; |
| 3847 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3848 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3849 | return 0; |
| 3850 | } |
| 3851 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 3852 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3853 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3854 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 3855 | struct snd_ctl_elem_value *ucontrol) |
| 3856 | { |
| 3857 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3858 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3859 | int nid = kcontrol->private_value; |
| 3860 | |
| 3861 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3862 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 3863 | /* check to be sure that the ports are up to date with |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3864 | * switch changes |
| 3865 | */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 3866 | stac_issue_unsol_event(codec, nid); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3867 | |
| 3868 | return 1; |
| 3869 | } |
| 3870 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3871 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 3872 | struct snd_ctl_elem_info *uinfo) |
| 3873 | { |
| 3874 | int i; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3875 | static const char * const texts[] = { |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3876 | "Mic In", "Line In", "Line Out" |
| 3877 | }; |
| 3878 | |
| 3879 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3880 | struct sigmatel_spec *spec = codec->spec; |
| 3881 | hda_nid_t nid = kcontrol->private_value; |
| 3882 | |
| 3883 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 3884 | i = 3; |
| 3885 | else |
| 3886 | i = 2; |
| 3887 | |
| 3888 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3889 | uinfo->value.enumerated.items = i; |
| 3890 | uinfo->count = 1; |
| 3891 | if (uinfo->value.enumerated.item >= i) |
| 3892 | uinfo->value.enumerated.item = i-1; |
| 3893 | strcpy(uinfo->value.enumerated.name, |
| 3894 | texts[uinfo->value.enumerated.item]); |
| 3895 | |
| 3896 | return 0; |
| 3897 | } |
| 3898 | |
| 3899 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 3900 | struct snd_ctl_elem_value *ucontrol) |
| 3901 | { |
| 3902 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3903 | hda_nid_t nid = kcontrol->private_value; |
| 3904 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 3905 | |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 3906 | if (vref == snd_hda_get_default_vref(codec, nid)) |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3907 | ucontrol->value.enumerated.item[0] = 0; |
| 3908 | else if (vref == AC_PINCTL_VREF_GRD) |
| 3909 | ucontrol->value.enumerated.item[0] = 1; |
| 3910 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 3911 | ucontrol->value.enumerated.item[0] = 2; |
| 3912 | |
| 3913 | return 0; |
| 3914 | } |
| 3915 | |
| 3916 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 3917 | struct snd_ctl_elem_value *ucontrol) |
| 3918 | { |
| 3919 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3920 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 3921 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3922 | hda_nid_t nid = kcontrol->private_value; |
| 3923 | |
| 3924 | if (ucontrol->value.enumerated.item[0] == 0) |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 3925 | new_vref = snd_hda_get_default_vref(codec, nid); |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3926 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 3927 | new_vref = AC_PINCTL_VREF_GRD; |
| 3928 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 3929 | new_vref = AC_PINCTL_VREF_HIZ; |
| 3930 | else |
| 3931 | return 0; |
| 3932 | |
| 3933 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 3934 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 3935 | return error; |
| 3936 | } |
| 3937 | |
| 3938 | return 0; |
| 3939 | } |
| 3940 | |
| 3941 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 3942 | struct snd_ctl_elem_info *uinfo) |
| 3943 | { |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3944 | char *texts[2]; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3945 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3946 | struct sigmatel_spec *spec = codec->spec; |
| 3947 | |
| 3948 | if (kcontrol->private_value == spec->line_switch) |
| 3949 | texts[0] = "Line In"; |
| 3950 | else |
| 3951 | texts[0] = "Mic In"; |
| 3952 | texts[1] = "Line Out"; |
| 3953 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3954 | uinfo->value.enumerated.items = 2; |
| 3955 | uinfo->count = 1; |
| 3956 | |
| 3957 | if (uinfo->value.enumerated.item >= 2) |
| 3958 | uinfo->value.enumerated.item = 1; |
| 3959 | strcpy(uinfo->value.enumerated.name, |
| 3960 | texts[uinfo->value.enumerated.item]); |
| 3961 | |
| 3962 | return 0; |
| 3963 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3964 | |
| 3965 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 3966 | { |
| 3967 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3968 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3969 | hda_nid_t nid = kcontrol->private_value; |
| 3970 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3971 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3972 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3973 | return 0; |
| 3974 | } |
| 3975 | |
| 3976 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 3977 | { |
| 3978 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3979 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3980 | hda_nid_t nid = kcontrol->private_value; |
| 3981 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 3982 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3983 | |
| 3984 | spec->io_switch[io_idx] = val; |
| 3985 | |
| 3986 | if (val) |
| 3987 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3988 | else { |
| 3989 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 3990 | if (io_idx) /* set VREF for mic */ |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 3991 | pinctl |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3992 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 3993 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 3994 | |
| 3995 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 3996 | * appropriately according to the pin direction |
| 3997 | */ |
| 3998 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 3999 | stac_issue_unsol_event(codec, nid); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 4000 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4001 | return 1; |
| 4002 | } |
| 4003 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4004 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 4005 | |
| 4006 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 4007 | struct snd_ctl_elem_value *ucontrol) |
| 4008 | { |
| 4009 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4010 | struct sigmatel_spec *spec = codec->spec; |
| 4011 | |
| 4012 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 4013 | return 0; |
| 4014 | } |
| 4015 | |
| 4016 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 4017 | struct snd_ctl_elem_value *ucontrol) |
| 4018 | { |
| 4019 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4020 | struct sigmatel_spec *spec = codec->spec; |
| 4021 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 4022 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4023 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 4024 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4025 | return 0; |
| 4026 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 4027 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4028 | |
| 4029 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 4030 | spec->clfe_swap ? 0x4 : 0x0); |
| 4031 | |
| 4032 | return 1; |
| 4033 | } |
| 4034 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4035 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 4036 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 4037 | .name = xname, \ |
| 4038 | .index = 0, \ |
| 4039 | .info = stac92xx_hp_switch_info, \ |
| 4040 | .get = stac92xx_hp_switch_get, \ |
| 4041 | .put = stac92xx_hp_switch_put, \ |
| 4042 | } |
| 4043 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4044 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 4045 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 4046 | .name = xname, \ |
| 4047 | .index = 0, \ |
| 4048 | .info = stac92xx_io_switch_info, \ |
| 4049 | .get = stac92xx_io_switch_get, \ |
| 4050 | .put = stac92xx_io_switch_put, \ |
| 4051 | .private_value = xpval, \ |
| 4052 | } |
| 4053 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4054 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 4055 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 4056 | .name = xname, \ |
| 4057 | .index = 0, \ |
| 4058 | .info = stac92xx_clfe_switch_info, \ |
| 4059 | .get = stac92xx_clfe_switch_get, \ |
| 4060 | .put = stac92xx_clfe_switch_put, \ |
| 4061 | .private_value = xpval, \ |
| 4062 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4063 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4064 | enum { |
| 4065 | STAC_CTL_WIDGET_VOL, |
| 4066 | STAC_CTL_WIDGET_MUTE, |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4067 | STAC_CTL_WIDGET_MUTE_BEEP, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 4068 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4069 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4070 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 4071 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 4072 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4073 | }; |
| 4074 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4075 | static const struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4076 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 4077 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4078 | HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 4079 | STAC_MONO_MUX, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4080 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4081 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4082 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 4083 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4084 | }; |
| 4085 | |
| 4086 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4087 | static struct snd_kcontrol_new * |
| 4088 | stac_control_new(struct sigmatel_spec *spec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4089 | const struct snd_kcontrol_new *ktemp, |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 4090 | const char *name, |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 4091 | unsigned int subdev) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4092 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 4093 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4094 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4095 | knew = snd_array_new(&spec->kctls); |
| 4096 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4097 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4098 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 4099 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4100 | if (!knew->name) { |
| 4101 | /* roolback */ |
| 4102 | memset(knew, 0, sizeof(*knew)); |
| 4103 | spec->kctls.alloced--; |
| 4104 | return NULL; |
| 4105 | } |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 4106 | knew->subdevice = subdev; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4107 | return knew; |
| 4108 | } |
| 4109 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4110 | static struct snd_kcontrol_new * |
| 4111 | add_control_temp(struct sigmatel_spec *spec, |
| 4112 | const struct snd_kcontrol_new *ktemp, |
| 4113 | int idx, const char *name, |
| 4114 | unsigned long val) |
| 4115 | { |
| 4116 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, |
| 4117 | HDA_SUBDEV_AMP_FLAG); |
| 4118 | if (!knew) |
| 4119 | return NULL; |
| 4120 | knew->index = idx; |
| 4121 | knew->private_value = val; |
| 4122 | return knew; |
| 4123 | } |
| 4124 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4125 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4126 | const struct snd_kcontrol_new *ktemp, |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4127 | int idx, const char *name, |
| 4128 | unsigned long val) |
| 4129 | { |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4130 | return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4131 | } |
| 4132 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4133 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 4134 | int type, int idx, const char *name, |
| 4135 | unsigned long val) |
| 4136 | { |
| 4137 | return stac92xx_add_control_temp(spec, |
| 4138 | &stac92xx_control_templates[type], |
| 4139 | idx, name, val); |
| 4140 | } |
| 4141 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4142 | |
| 4143 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4144 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 4145 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4146 | { |
| 4147 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 4148 | } |
| 4149 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4150 | static const struct snd_kcontrol_new stac_input_src_temp = { |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4151 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4152 | .name = "Input Source", |
| 4153 | .info = stac92xx_mux_enum_info, |
| 4154 | .get = stac92xx_mux_enum_get, |
| 4155 | .put = stac92xx_mux_enum_put, |
| 4156 | }; |
| 4157 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4158 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 4159 | hda_nid_t nid, int idx) |
| 4160 | { |
| 4161 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 4162 | int control = 0; |
| 4163 | struct sigmatel_spec *spec = codec->spec; |
| 4164 | char name[22]; |
| 4165 | |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4166 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 4167 | if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf) |
| 4168 | != INPUT_PIN_ATTR_DOCK) |
| 4169 | return 0; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 4170 | if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4171 | && nid == spec->line_switch) |
| 4172 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 4173 | else if (snd_hda_query_pin_caps(codec, nid) |
| 4174 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 4175 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 4176 | else if (nid == spec->mic_switch) |
| 4177 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 4178 | } |
| 4179 | |
| 4180 | if (control) { |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 4181 | snd_hda_get_pin_label(codec, nid, &spec->autocfg, |
| 4182 | name, sizeof(name), NULL); |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4183 | return stac92xx_add_control(codec->spec, control, |
| 4184 | strcat(name, " Jack Mode"), nid); |
| 4185 | } |
| 4186 | |
| 4187 | return 0; |
| 4188 | } |
| 4189 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4190 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 4191 | { |
| 4192 | struct snd_kcontrol_new *knew; |
| 4193 | struct hda_input_mux *imux = &spec->private_imux; |
| 4194 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4195 | if (spec->auto_mic) |
| 4196 | return 0; /* no need for input source */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4197 | if (!spec->num_adcs || imux->num_items <= 1) |
| 4198 | return 0; /* no need for input source control */ |
| 4199 | knew = stac_control_new(spec, &stac_input_src_temp, |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 4200 | stac_input_src_temp.name, 0); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4201 | if (!knew) |
| 4202 | return -ENOMEM; |
| 4203 | knew->count = spec->num_adcs; |
| 4204 | return 0; |
| 4205 | } |
| 4206 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4207 | /* check whether the line-input can be used as line-out */ |
| 4208 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4209 | { |
| 4210 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4211 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4212 | hda_nid_t nid; |
| 4213 | unsigned int pincap; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4214 | int i; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4215 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4216 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 4217 | return 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4218 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4219 | if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) { |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4220 | nid = cfg->inputs[i].pin; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 4221 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4222 | if (pincap & AC_PINCAP_OUT) |
| 4223 | return nid; |
| 4224 | } |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4225 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4226 | return 0; |
| 4227 | } |
| 4228 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4229 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid); |
| 4230 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4231 | /* check whether the mic-input can be used as line-out */ |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4232 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4233 | { |
| 4234 | struct sigmatel_spec *spec = codec->spec; |
| 4235 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4236 | unsigned int def_conf, pincap; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4237 | int i; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4238 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4239 | *dac = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4240 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 4241 | return 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4242 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4243 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4244 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4245 | continue; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4246 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 4247 | /* some laptops have an internal analog microphone |
| 4248 | * which can't be used as a output */ |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4249 | if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4250 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4251 | if (pincap & AC_PINCAP_OUT) { |
| 4252 | *dac = get_unassigned_dac(codec, nid); |
| 4253 | if (*dac) |
| 4254 | return nid; |
| 4255 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4256 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4257 | } |
| 4258 | return 0; |
| 4259 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4260 | |
| 4261 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 4262 | { |
| 4263 | int i; |
| 4264 | |
| 4265 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 4266 | if (spec->multiout.dac_nids[i] == nid) |
| 4267 | return 1; |
| 4268 | } |
| 4269 | |
| 4270 | return 0; |
| 4271 | } |
| 4272 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4273 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 4274 | { |
| 4275 | int i; |
| 4276 | if (is_in_dac_nids(spec, nid)) |
| 4277 | return 1; |
| 4278 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 4279 | if (spec->hp_dacs[i] == nid) |
| 4280 | return 1; |
| 4281 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 4282 | if (spec->speaker_dacs[i] == nid) |
| 4283 | return 1; |
| 4284 | return 0; |
| 4285 | } |
| 4286 | |
| 4287 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 4288 | { |
| 4289 | struct sigmatel_spec *spec = codec->spec; |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4290 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4291 | int j, conn_len; |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4292 | hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4293 | unsigned int wcaps, wtype; |
| 4294 | |
| 4295 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 4296 | HDA_MAX_CONNECTIONS); |
Charles Chin | 3670600 | 2010-01-29 12:05:51 +0100 | [diff] [blame] | 4297 | /* 92HD88: trace back up the link of nids to find the DAC */ |
| 4298 | while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0])) |
| 4299 | != AC_WID_AUD_OUT)) { |
| 4300 | nid = conn[0]; |
| 4301 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 4302 | HDA_MAX_CONNECTIONS); |
| 4303 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4304 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 4305 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 4306 | wtype = get_wcaps_type(wcaps); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4307 | /* we check only analog outputs */ |
| 4308 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 4309 | continue; |
| 4310 | /* if this route has a free DAC, assign it */ |
| 4311 | if (!check_all_dac_nids(spec, conn[j])) { |
| 4312 | if (conn_len > 1) { |
| 4313 | /* select this DAC in the pin's input mux */ |
| 4314 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4315 | AC_VERB_SET_CONNECT_SEL, j); |
| 4316 | } |
| 4317 | return conn[j]; |
| 4318 | } |
| 4319 | } |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4320 | |
| 4321 | /* if all DACs are already assigned, connect to the primary DAC, |
| 4322 | unless we're assigning a secondary headphone */ |
| 4323 | fallback_dac = spec->multiout.dac_nids[0]; |
| 4324 | if (spec->multiout.hp_nid) { |
| 4325 | for (j = 0; j < cfg->hp_outs; j++) |
| 4326 | if (cfg->hp_pins[j] == nid) { |
| 4327 | fallback_dac = spec->multiout.hp_nid; |
| 4328 | break; |
| 4329 | } |
| 4330 | } |
| 4331 | |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 4332 | if (conn_len > 1) { |
| 4333 | for (j = 0; j < conn_len; j++) { |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4334 | if (conn[j] == fallback_dac) { |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 4335 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4336 | AC_VERB_SET_CONNECT_SEL, j); |
| 4337 | break; |
| 4338 | } |
| 4339 | } |
| 4340 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4341 | return 0; |
| 4342 | } |
| 4343 | |
| 4344 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 4345 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 4346 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4347 | /* |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4348 | * Fill in the dac_nids table from the parsed pin configuration |
| 4349 | * This function only works when every pin in line_out_pins[] |
| 4350 | * contains atleast one DAC in its connection list. Some 92xx |
| 4351 | * codecs are not connected directly to a DAC, such as the 9200 |
| 4352 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4353 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4354 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4355 | { |
| 4356 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4357 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4358 | int i; |
| 4359 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4360 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4361 | for (i = 0; i < cfg->line_outs; i++) { |
| 4362 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4363 | dac = get_unassigned_dac(codec, nid); |
| 4364 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 4365 | if (spec->multiout.num_dacs > 0) { |
| 4366 | /* we have already working output pins, |
| 4367 | * so let's drop the broken ones again |
| 4368 | */ |
| 4369 | cfg->line_outs = spec->multiout.num_dacs; |
| 4370 | break; |
| 4371 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4372 | /* error out, no available DAC found */ |
| 4373 | snd_printk(KERN_ERR |
| 4374 | "%s: No available DAC for pin 0x%x\n", |
| 4375 | __func__, nid); |
| 4376 | return -ENODEV; |
| 4377 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4378 | add_spec_dacs(spec, dac); |
| 4379 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4380 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 4381 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4382 | nid = cfg->hp_pins[i]; |
| 4383 | dac = get_unassigned_dac(codec, nid); |
| 4384 | if (dac) { |
| 4385 | if (!spec->multiout.hp_nid) |
| 4386 | spec->multiout.hp_nid = dac; |
| 4387 | else |
| 4388 | add_spec_extra_dacs(spec, dac); |
| 4389 | } |
| 4390 | spec->hp_dacs[i] = dac; |
| 4391 | } |
| 4392 | |
| 4393 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 4394 | nid = cfg->speaker_pins[i]; |
| 4395 | dac = get_unassigned_dac(codec, nid); |
| 4396 | if (dac) |
| 4397 | add_spec_extra_dacs(spec, dac); |
| 4398 | spec->speaker_dacs[i] = dac; |
| 4399 | } |
| 4400 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4401 | /* add line-in as output */ |
| 4402 | nid = check_line_out_switch(codec); |
| 4403 | if (nid) { |
| 4404 | dac = get_unassigned_dac(codec, nid); |
| 4405 | if (dac) { |
| 4406 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 4407 | nid, cfg->line_outs); |
| 4408 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 4409 | cfg->line_outs++; |
| 4410 | spec->line_switch = nid; |
| 4411 | add_spec_dacs(spec, dac); |
| 4412 | } |
| 4413 | } |
| 4414 | /* add mic as output */ |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4415 | nid = check_mic_out_switch(codec, &dac); |
| 4416 | if (nid && dac) { |
| 4417 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 4418 | nid, cfg->line_outs); |
| 4419 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 4420 | cfg->line_outs++; |
| 4421 | spec->mic_switch = nid; |
| 4422 | add_spec_dacs(spec, dac); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4423 | } |
| 4424 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4425 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4426 | spec->multiout.num_dacs, |
| 4427 | spec->multiout.dac_nids[0], |
| 4428 | spec->multiout.dac_nids[1], |
| 4429 | spec->multiout.dac_nids[2], |
| 4430 | spec->multiout.dac_nids[3], |
| 4431 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4432 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4433 | return 0; |
| 4434 | } |
| 4435 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4436 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4437 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 4438 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4439 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4440 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4441 | char name[32]; |
| 4442 | int err; |
| 4443 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4444 | if (!spec->check_volume_offset) { |
| 4445 | unsigned int caps, step, nums, db_scale; |
| 4446 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 4447 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 4448 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 4449 | step = (step + 1) * 25; /* in .01dB unit */ |
| 4450 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 4451 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 4452 | db_scale = nums * step; |
| 4453 | /* if dB scale is over -64dB, and finer enough, |
| 4454 | * let's reduce it to half |
| 4455 | */ |
| 4456 | if (db_scale > 6400 && nums >= 0x1f) |
| 4457 | spec->volume_offset = nums / 2; |
| 4458 | spec->check_volume_offset = 1; |
| 4459 | } |
| 4460 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4461 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4462 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4463 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 4464 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4465 | if (err < 0) |
| 4466 | return err; |
| 4467 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4468 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4469 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 4470 | if (err < 0) |
| 4471 | return err; |
| 4472 | return 0; |
| 4473 | } |
| 4474 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4475 | #define create_controls(codec, pfx, nid, chs) \ |
| 4476 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 4477 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4478 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 4479 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4480 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4481 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 4482 | return 1; |
| 4483 | } else { |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 4484 | snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids); |
| 4485 | spec->dac_nids[spec->multiout.num_dacs] = nid; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4486 | spec->multiout.num_dacs++; |
| 4487 | } |
| 4488 | return 0; |
| 4489 | } |
| 4490 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4491 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4492 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4493 | int i; |
| 4494 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 4495 | if (!spec->multiout.extra_out_nid[i]) { |
| 4496 | spec->multiout.extra_out_nid[i] = nid; |
| 4497 | return 0; |
| 4498 | } |
| 4499 | } |
| 4500 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 4501 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4502 | } |
| 4503 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4504 | /* Create output controls |
| 4505 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 4506 | */ |
| 4507 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 4508 | const hda_nid_t *pins, |
| 4509 | const hda_nid_t *dac_nids, |
| 4510 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4511 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 4512 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4513 | static const char * const chname[4] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 4514 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 4515 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4516 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 4517 | int i, err; |
| 4518 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4519 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4520 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 4521 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 4522 | if (is_jack_detectable(codec, pins[i])) |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 4523 | spec->hp_detect = 1; |
| 4524 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4525 | nid = dac_nids[i]; |
| 4526 | if (!nid) |
| 4527 | continue; |
| 4528 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4529 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4530 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4531 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4532 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4533 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4534 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4535 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4536 | |
| 4537 | wid_caps = get_wcaps(codec, nid); |
| 4538 | |
| 4539 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 4540 | err = stac92xx_add_control(spec, |
| 4541 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 4542 | "Swap Center/LFE Playback Switch", nid); |
| 4543 | |
| 4544 | if (err < 0) |
| 4545 | return err; |
| 4546 | } |
| 4547 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4548 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4549 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4550 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4551 | switch (type) { |
| 4552 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4553 | name = "Headphone"; |
| 4554 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4555 | break; |
| 4556 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 4557 | if (num_outs <= 2) { |
| 4558 | name = i ? "Bass Speaker" : "Speaker"; |
| 4559 | idx = 0; |
David Henningsson | 298efee | 2012-09-06 11:17:58 +0200 | [diff] [blame] | 4560 | break; |
| 4561 | } |
| 4562 | /* Fall through in case of multi speaker outs */ |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4563 | default: |
| 4564 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4565 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4566 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 4567 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4568 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4569 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4570 | return err; |
| 4571 | } |
| 4572 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4573 | return 0; |
| 4574 | } |
| 4575 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4576 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
| 4577 | unsigned int dir_mask, unsigned int data); |
| 4578 | |
| 4579 | /* hook for controlling mic-mute LED GPIO */ |
| 4580 | static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol, |
| 4581 | struct snd_ctl_elem_value *ucontrol) |
| 4582 | { |
| 4583 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4584 | struct sigmatel_spec *spec = codec->spec; |
| 4585 | int err; |
| 4586 | bool mute; |
| 4587 | |
| 4588 | err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
| 4589 | if (err <= 0) |
| 4590 | return err; |
| 4591 | mute = !(ucontrol->value.integer.value[0] && |
| 4592 | ucontrol->value.integer.value[1]); |
| 4593 | if (spec->mic_mute_led_on != mute) { |
| 4594 | spec->mic_mute_led_on = mute; |
| 4595 | if (mute) |
| 4596 | spec->gpio_data |= spec->mic_mute_led_gpio; |
| 4597 | else |
| 4598 | spec->gpio_data &= ~spec->mic_mute_led_gpio; |
| 4599 | stac_gpio_set(codec, spec->gpio_mask, |
| 4600 | spec->gpio_dir, spec->gpio_data); |
| 4601 | } |
| 4602 | return err; |
| 4603 | } |
| 4604 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4605 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, |
| 4606 | unsigned long sw, int idx) |
| 4607 | { |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4608 | struct sigmatel_spec *spec = codec->spec; |
| 4609 | struct snd_kcontrol_new *knew; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4610 | int err; |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4611 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4612 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, |
Takashi Iwai | bf677bd8 | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 4613 | "Capture Volume", vol); |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4614 | if (err < 0) |
| 4615 | return err; |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4616 | |
| 4617 | knew = add_control_temp(spec, |
| 4618 | &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE], |
| 4619 | idx, "Capture Switch", sw); |
| 4620 | if (!knew) |
| 4621 | return -ENOMEM; |
| 4622 | /* add a LED hook for some HP laptops */ |
| 4623 | if (spec->mic_mute_led_gpio) |
| 4624 | knew->put = stac92xx_capture_sw_put_led; |
| 4625 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4626 | return 0; |
| 4627 | } |
| 4628 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4629 | /* add playback controls from the parsed DAC table */ |
| 4630 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 4631 | const struct auto_pin_cfg *cfg) |
| 4632 | { |
| 4633 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4634 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4635 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4636 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4637 | |
| 4638 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 4639 | spec->multiout.dac_nids, |
| 4640 | cfg->line_out_type); |
| 4641 | if (err < 0) |
| 4642 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4643 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 4644 | 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] | 4645 | err = stac92xx_add_control(spec, |
| 4646 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4647 | "Headphone as Line Out Switch", |
| 4648 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4649 | if (err < 0) |
| 4650 | return err; |
| 4651 | } |
| 4652 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4653 | for (idx = 0; idx < cfg->num_inputs; idx++) { |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4654 | if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4655 | break; |
| 4656 | nid = cfg->inputs[idx].pin; |
| 4657 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 4658 | if (err < 0) |
| 4659 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 4660 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4661 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4662 | return 0; |
| 4663 | } |
| 4664 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4665 | /* add playback controls for Speaker and HP outputs */ |
| 4666 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 4667 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4668 | { |
| 4669 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4670 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4671 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4672 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 4673 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 4674 | if (err < 0) |
| 4675 | return err; |
| 4676 | |
| 4677 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 4678 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 4679 | if (err < 0) |
| 4680 | return err; |
| 4681 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4682 | return 0; |
| 4683 | } |
| 4684 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4685 | /* labels for mono mux outputs */ |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4686 | static const char * const stac92xx_mono_labels[4] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4687 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4688 | }; |
| 4689 | |
| 4690 | /* create mono mux for mono out on capable codecs */ |
| 4691 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 4692 | { |
| 4693 | struct sigmatel_spec *spec = codec->spec; |
| 4694 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 4695 | int i, num_cons; |
| 4696 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 4697 | |
| 4698 | num_cons = snd_hda_get_connections(codec, |
| 4699 | spec->mono_nid, |
| 4700 | con_lst, |
| 4701 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 4702 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4703 | return -EINVAL; |
| 4704 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4705 | for (i = 0; i < num_cons; i++) |
| 4706 | snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i, |
| 4707 | NULL); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 4708 | |
| 4709 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 4710 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4711 | } |
| 4712 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4713 | /* create PC beep volume controls */ |
| 4714 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 4715 | hda_nid_t nid) |
| 4716 | { |
| 4717 | struct sigmatel_spec *spec = codec->spec; |
| 4718 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4719 | int err, type = STAC_CTL_WIDGET_MUTE_BEEP; |
| 4720 | |
| 4721 | if (spec->anabeep_nid == nid) |
| 4722 | type = STAC_CTL_WIDGET_MUTE; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4723 | |
| 4724 | /* check for mute support for the the amp */ |
| 4725 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4726 | err = stac92xx_add_control(spec, type, |
Jaroslav Kysela | d355c82a | 2009-11-03 15:47:25 +0100 | [diff] [blame] | 4727 | "Beep Playback Switch", |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4728 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 4729 | if (err < 0) |
| 4730 | return err; |
| 4731 | } |
| 4732 | |
| 4733 | /* check to see if there is volume support for the amp */ |
| 4734 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 4735 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
Jaroslav Kysela | d355c82a | 2009-11-03 15:47:25 +0100 | [diff] [blame] | 4736 | "Beep Playback Volume", |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4737 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 4738 | if (err < 0) |
| 4739 | return err; |
| 4740 | } |
| 4741 | return 0; |
| 4742 | } |
| 4743 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4744 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4745 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 4746 | |
| 4747 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 4748 | struct snd_ctl_elem_value *ucontrol) |
| 4749 | { |
| 4750 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4751 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 4752 | return 0; |
| 4753 | } |
| 4754 | |
| 4755 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 4756 | struct snd_ctl_elem_value *ucontrol) |
| 4757 | { |
| 4758 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4759 | return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]); |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4760 | } |
| 4761 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4762 | static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4763 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4764 | .info = stac92xx_dig_beep_switch_info, |
| 4765 | .get = stac92xx_dig_beep_switch_get, |
| 4766 | .put = stac92xx_dig_beep_switch_put, |
| 4767 | }; |
| 4768 | |
| 4769 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 4770 | { |
| 4771 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
Jaroslav Kysela | d355c82a | 2009-11-03 15:47:25 +0100 | [diff] [blame] | 4772 | 0, "Beep Playback Switch", 0); |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4773 | } |
| 4774 | #endif |
| 4775 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4776 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 4777 | { |
| 4778 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4779 | int i, j, err = 0; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4780 | |
| 4781 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4782 | hda_nid_t nid; |
| 4783 | unsigned int wcaps; |
| 4784 | unsigned long val; |
| 4785 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4786 | nid = spec->mux_nids[i]; |
| 4787 | wcaps = get_wcaps(codec, nid); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4788 | if (!(wcaps & AC_WCAP_OUT_AMP)) |
| 4789 | continue; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4790 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4791 | /* check whether already the same control was created as |
| 4792 | * normal Capture Volume. |
| 4793 | */ |
| 4794 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 4795 | for (j = 0; j < spec->num_caps; j++) { |
| 4796 | if (spec->capvols[j] == val) |
| 4797 | break; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4798 | } |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4799 | if (j < spec->num_caps) |
| 4800 | continue; |
| 4801 | |
| 4802 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i, |
| 4803 | "Mux Capture Volume", val); |
| 4804 | if (err < 0) |
| 4805 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4806 | } |
| 4807 | return 0; |
| 4808 | }; |
| 4809 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4810 | static const char * const stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4811 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4812 | }; |
| 4813 | |
| 4814 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 4815 | { |
| 4816 | struct sigmatel_spec *spec = codec->spec; |
| 4817 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4818 | const char * const *labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4819 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4820 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4821 | |
| 4822 | num_cons = snd_hda_get_connections(codec, |
| 4823 | spec->smux_nids[0], |
| 4824 | con_lst, |
| 4825 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 4826 | if (num_cons <= 0) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4827 | return -EINVAL; |
| 4828 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4829 | if (!labels) |
| 4830 | labels = stac92xx_spdif_labels; |
| 4831 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4832 | for (i = 0; i < num_cons; i++) |
| 4833 | snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4834 | |
| 4835 | return 0; |
| 4836 | } |
| 4837 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4838 | /* labels for dmic mux inputs */ |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4839 | static const char * const stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4840 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 4841 | "Digital Mic 3", "Digital Mic 4" |
| 4842 | }; |
| 4843 | |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 4844 | static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux, |
| 4845 | int idx) |
| 4846 | { |
| 4847 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
| 4848 | int nums; |
| 4849 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 4850 | if (idx >= 0 && idx < nums) |
| 4851 | return conn[idx]; |
| 4852 | return 0; |
| 4853 | } |
| 4854 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 4855 | /* look for NID recursively */ |
| 4856 | #define get_connection_index(codec, mux, nid) \ |
| 4857 | snd_hda_get_conn_index(codec, mux, nid, 1) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4858 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4859 | /* create a volume assigned to the given pin (only if supported) */ |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4860 | /* return 1 if the volume control is created */ |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4861 | static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4862 | const char *label, int idx, int direction) |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4863 | { |
| 4864 | unsigned int caps, nums; |
| 4865 | char name[32]; |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4866 | int err; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4867 | |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4868 | if (direction == HDA_OUTPUT) |
| 4869 | caps = AC_WCAP_OUT_AMP; |
| 4870 | else |
| 4871 | caps = AC_WCAP_IN_AMP; |
| 4872 | if (!(get_wcaps(codec, nid) & caps)) |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4873 | return 0; |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4874 | caps = query_amp_caps(codec, nid, direction); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4875 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; |
| 4876 | if (!nums) |
| 4877 | return 0; |
| 4878 | snprintf(name, sizeof(name), "%s Capture Volume", label); |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4879 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name, |
| 4880 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4881 | if (err < 0) |
| 4882 | return err; |
| 4883 | return 1; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4884 | } |
| 4885 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4886 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 4887 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 4888 | const struct auto_pin_cfg *cfg) |
| 4889 | { |
| 4890 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4891 | struct hda_input_mux *imux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4892 | struct hda_input_mux *dimux = &spec->private_dimux; |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 4893 | int err, i; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4894 | unsigned int def_conf; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4895 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4896 | snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4897 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4898 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 4899 | hda_nid_t nid; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4900 | int index, type_idx; |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 4901 | char label[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4902 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4903 | nid = spec->dmic_nids[i]; |
| 4904 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 4905 | continue; |
| 4906 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4907 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 4908 | continue; |
| 4909 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4910 | index = get_connection_index(codec, spec->dmux_nids[0], nid); |
| 4911 | if (index < 0) |
| 4912 | continue; |
| 4913 | |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 4914 | snd_hda_get_pin_label(codec, nid, &spec->autocfg, |
| 4915 | label, sizeof(label), NULL); |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4916 | snd_hda_add_imux_item(dimux, label, index, &type_idx); |
Takashi Iwai | 2d7ec12 | 2010-12-23 10:16:05 +0100 | [diff] [blame] | 4917 | if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) |
| 4918 | snd_hda_add_imux_item(imux, label, index, &type_idx); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4919 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4920 | err = create_elem_capture_vol(codec, nid, label, type_idx, |
| 4921 | HDA_INPUT); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4922 | if (err < 0) |
| 4923 | return err; |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4924 | if (!err) { |
| 4925 | err = create_elem_capture_vol(codec, nid, label, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4926 | type_idx, HDA_OUTPUT); |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4927 | if (err < 0) |
| 4928 | return err; |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 4929 | if (!err) { |
| 4930 | nid = get_connected_node(codec, |
| 4931 | spec->dmux_nids[0], index); |
| 4932 | if (nid) |
| 4933 | err = create_elem_capture_vol(codec, |
| 4934 | nid, label, |
| 4935 | type_idx, HDA_INPUT); |
| 4936 | if (err < 0) |
| 4937 | return err; |
| 4938 | } |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4939 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4940 | } |
| 4941 | |
| 4942 | return 0; |
| 4943 | } |
| 4944 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4945 | static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4946 | hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4947 | { |
| 4948 | unsigned int cfg; |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4949 | unsigned int type; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4950 | |
| 4951 | if (!nid) |
| 4952 | return 0; |
| 4953 | cfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4954 | type = get_defcfg_device(cfg); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4955 | switch (snd_hda_get_input_pin_attr(cfg)) { |
| 4956 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4957 | if (*fixed) |
| 4958 | return 1; /* already occupied */ |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4959 | if (type != AC_JACK_MIC_IN) |
| 4960 | return 1; /* invalid type */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4961 | *fixed = nid; |
| 4962 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4963 | case INPUT_PIN_ATTR_UNUSED: |
| 4964 | break; |
| 4965 | case INPUT_PIN_ATTR_DOCK: |
| 4966 | if (*dock) |
| 4967 | return 1; /* already occupied */ |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4968 | if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN) |
| 4969 | return 1; /* invalid type */ |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4970 | *dock = nid; |
| 4971 | break; |
| 4972 | default: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4973 | if (*ext) |
| 4974 | return 1; /* already occupied */ |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4975 | if (type != AC_JACK_MIC_IN) |
| 4976 | return 1; /* invalid type */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4977 | *ext = nid; |
| 4978 | break; |
| 4979 | } |
| 4980 | return 0; |
| 4981 | } |
| 4982 | |
| 4983 | static int set_mic_route(struct hda_codec *codec, |
| 4984 | struct sigmatel_mic_route *mic, |
| 4985 | hda_nid_t pin) |
| 4986 | { |
| 4987 | struct sigmatel_spec *spec = codec->spec; |
| 4988 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4989 | int i; |
| 4990 | |
| 4991 | mic->pin = pin; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4992 | if (pin == 0) |
| 4993 | return 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4994 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4995 | if (pin == cfg->inputs[i].pin) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4996 | break; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4997 | } |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4998 | if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4999 | /* analog pin */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5000 | i = get_connection_index(codec, spec->mux_nids[0], pin); |
| 5001 | if (i < 0) |
| 5002 | return -1; |
| 5003 | mic->mux_idx = i; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 5004 | mic->dmux_idx = -1; |
| 5005 | if (spec->dmux_nids) |
| 5006 | mic->dmux_idx = get_connection_index(codec, |
| 5007 | spec->dmux_nids[0], |
| 5008 | spec->mux_nids[0]); |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 5009 | } else if (spec->dmux_nids) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5010 | /* digital pin */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5011 | i = get_connection_index(codec, spec->dmux_nids[0], pin); |
| 5012 | if (i < 0) |
| 5013 | return -1; |
| 5014 | mic->dmux_idx = i; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 5015 | mic->mux_idx = -1; |
| 5016 | if (spec->mux_nids) |
| 5017 | mic->mux_idx = get_connection_index(codec, |
| 5018 | spec->mux_nids[0], |
| 5019 | spec->dmux_nids[0]); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5020 | } |
| 5021 | return 0; |
| 5022 | } |
| 5023 | |
| 5024 | /* return non-zero if the device is for automatic mic switch */ |
| 5025 | static int stac_check_auto_mic(struct hda_codec *codec) |
| 5026 | { |
| 5027 | struct sigmatel_spec *spec = codec->spec; |
| 5028 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5029 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5030 | int i; |
| 5031 | |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5032 | fixed = ext = dock = 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5033 | for (i = 0; i < cfg->num_inputs; i++) |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5034 | if (check_mic_pin(codec, cfg->inputs[i].pin, |
| 5035 | &fixed, &ext, &dock)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5036 | return 0; |
| 5037 | for (i = 0; i < spec->num_dmics; i++) |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5038 | if (check_mic_pin(codec, spec->dmic_nids[i], |
| 5039 | &fixed, &ext, &dock)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5040 | return 0; |
Takashi Iwai | 80c6785 | 2011-01-13 08:08:08 +0100 | [diff] [blame] | 5041 | if (!fixed || (!ext && !dock)) |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5042 | return 0; /* no input to switch */ |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 5043 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5044 | return 0; /* no unsol support */ |
| 5045 | if (set_mic_route(codec, &spec->ext_mic, ext) || |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5046 | set_mic_route(codec, &spec->int_mic, fixed) || |
| 5047 | set_mic_route(codec, &spec->dock_mic, dock)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5048 | return 0; /* something is wrong */ |
| 5049 | return 1; |
| 5050 | } |
| 5051 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5052 | /* create playback/capture controls for input pins */ |
| 5053 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 5054 | { |
| 5055 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5056 | struct hda_input_mux *imux = &spec->private_imux; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5057 | int i, j; |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 5058 | const char *label; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5059 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5060 | for (i = 0; i < cfg->num_inputs; i++) { |
| 5061 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 5062 | int index, err, type_idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5063 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5064 | index = -1; |
| 5065 | for (j = 0; j < spec->num_muxes; j++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5066 | index = get_connection_index(codec, spec->mux_nids[j], |
| 5067 | nid); |
| 5068 | if (index >= 0) |
| 5069 | break; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5070 | } |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5071 | if (index < 0) |
| 5072 | continue; |
| 5073 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 5074 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 5075 | snd_hda_add_imux_item(imux, label, index, &type_idx); |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 5076 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5077 | err = create_elem_capture_vol(codec, nid, |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 5078 | label, type_idx, |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 5079 | HDA_INPUT); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 5080 | if (err < 0) |
| 5081 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5082 | } |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 5083 | spec->num_analog_muxes = imux->num_items; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5084 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 5085 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5086 | /* |
| 5087 | * Set the current input for the muxes. |
| 5088 | * The STAC9221 has two input muxes with identical source |
| 5089 | * NID lists. Hopefully this won't get confused. |
| 5090 | */ |
| 5091 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 5092 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 5093 | AC_VERB_SET_CONNECT_SEL, |
| 5094 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5095 | } |
| 5096 | } |
| 5097 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5098 | return 0; |
| 5099 | } |
| 5100 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5101 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 5102 | { |
| 5103 | struct sigmatel_spec *spec = codec->spec; |
| 5104 | int i; |
| 5105 | |
| 5106 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 5107 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 5108 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 5109 | } |
| 5110 | } |
| 5111 | |
| 5112 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 5113 | { |
| 5114 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5115 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5116 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5117 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 5118 | hda_nid_t pin; |
| 5119 | pin = spec->autocfg.hp_pins[i]; |
| 5120 | if (pin) /* connect to front */ |
| 5121 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 5122 | } |
| 5123 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 5124 | hda_nid_t pin; |
| 5125 | pin = spec->autocfg.speaker_pins[i]; |
| 5126 | if (pin) /* connect to front */ |
| 5127 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 5128 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5129 | } |
| 5130 | |
Takashi Iwai | 8af3aeb | 2009-11-18 14:23:37 +0100 | [diff] [blame] | 5131 | static int is_dual_headphones(struct hda_codec *codec) |
| 5132 | { |
| 5133 | struct sigmatel_spec *spec = codec->spec; |
| 5134 | int i, valid_hps; |
| 5135 | |
| 5136 | if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT || |
| 5137 | spec->autocfg.hp_outs <= 1) |
| 5138 | return 0; |
| 5139 | valid_hps = 0; |
| 5140 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 5141 | hda_nid_t nid = spec->autocfg.hp_pins[i]; |
| 5142 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid); |
| 5143 | if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE) |
| 5144 | continue; |
| 5145 | valid_hps++; |
| 5146 | } |
| 5147 | return (valid_hps > 1); |
| 5148 | } |
| 5149 | |
| 5150 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 5151 | static int stac92xx_parse_auto_config(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5152 | { |
| 5153 | struct sigmatel_spec *spec = codec->spec; |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 5154 | hda_nid_t dig_out = 0, dig_in = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5155 | int hp_swap = 0; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5156 | int i, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5157 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5158 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 5159 | &spec->autocfg, |
| 5160 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5161 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5162 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 5163 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5164 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5165 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 5166 | * be set up as multi-channel outputs. |
| 5167 | */ |
Takashi Iwai | 8af3aeb | 2009-11-18 14:23:37 +0100 | [diff] [blame] | 5168 | if (is_dual_headphones(codec)) { |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5169 | /* Copy hp_outs to line_outs, backup line_outs in |
| 5170 | * speaker_outs so that the following routines can handle |
| 5171 | * HP pins as primary outputs. |
| 5172 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5173 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5174 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 5175 | sizeof(spec->autocfg.line_out_pins)); |
| 5176 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 5177 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 5178 | sizeof(spec->autocfg.hp_pins)); |
| 5179 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5180 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 5181 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5182 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5183 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5184 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5185 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 5186 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5187 | u32 caps = query_amp_caps(codec, |
| 5188 | spec->autocfg.mono_out_pin, dir); |
| 5189 | hda_nid_t conn_list[1]; |
| 5190 | |
| 5191 | /* get the mixer node and then the mono mux if it exists */ |
| 5192 | if (snd_hda_get_connections(codec, |
| 5193 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 5194 | snd_hda_get_connections(codec, conn_list[0], |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 5195 | conn_list, 1) > 0) { |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5196 | |
| 5197 | int wcaps = get_wcaps(codec, conn_list[0]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 5198 | int wid_type = get_wcaps_type(wcaps); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5199 | /* LR swap check, some stac925x have a mux that |
| 5200 | * changes the DACs output path instead of the |
| 5201 | * mono-mux path. |
| 5202 | */ |
| 5203 | if (wid_type == AC_WID_AUD_SEL && |
| 5204 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 5205 | spec->mono_nid = conn_list[0]; |
| 5206 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5207 | if (dir) { |
| 5208 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 5209 | |
| 5210 | /* most mono outs have a least a mute/unmute switch */ |
| 5211 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 5212 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 5213 | "Mono Playback Switch", |
| 5214 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5215 | if (err < 0) |
| 5216 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5217 | /* check for volume support for the amp */ |
| 5218 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 5219 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 5220 | err = stac92xx_add_control(spec, |
| 5221 | STAC_CTL_WIDGET_VOL, |
| 5222 | "Mono Playback Volume", |
| 5223 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 5224 | if (err < 0) |
| 5225 | return err; |
| 5226 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5227 | } |
| 5228 | |
| 5229 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 5230 | AC_PINCTL_OUT_EN); |
| 5231 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5232 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5233 | if (!spec->multiout.num_dacs) { |
| 5234 | err = stac92xx_auto_fill_dac_nids(codec); |
| 5235 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5236 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 5237 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 5238 | &spec->autocfg); |
| 5239 | if (err < 0) |
| 5240 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5241 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5242 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5243 | /* setup analog beep controls */ |
| 5244 | if (spec->anabeep_nid > 0) { |
| 5245 | err = stac92xx_auto_create_beep_ctls(codec, |
| 5246 | spec->anabeep_nid); |
| 5247 | if (err < 0) |
| 5248 | return err; |
| 5249 | } |
| 5250 | |
| 5251 | /* setup digital beep controls and input device */ |
| 5252 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 5253 | if (spec->digbeep_nid > 0) { |
| 5254 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 5255 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5256 | |
| 5257 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 5258 | if (err < 0) |
| 5259 | return err; |
| 5260 | err = snd_hda_attach_beep_device(codec, nid); |
| 5261 | if (err < 0) |
| 5262 | return err; |
Takashi Iwai | d8d881d | 2009-12-22 07:52:49 +0100 | [diff] [blame] | 5263 | if (codec->beep) { |
| 5264 | /* IDT/STAC codecs have linear beep tone parameter */ |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 5265 | codec->beep->linear_tone = spec->linear_tone_beep; |
Takashi Iwai | d8d881d | 2009-12-22 07:52:49 +0100 | [diff] [blame] | 5266 | /* if no beep switch is available, make its own one */ |
| 5267 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 5268 | if (!(caps & AC_AMPCAP_MUTE)) { |
| 5269 | err = stac92xx_beep_switch_ctl(codec); |
| 5270 | if (err < 0) |
| 5271 | return err; |
| 5272 | } |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 5273 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5274 | } |
| 5275 | #endif |
| 5276 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5277 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5278 | if (err < 0) |
| 5279 | return err; |
| 5280 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5281 | /* All output parsing done, now restore the swapped hp pins */ |
| 5282 | if (hp_swap) { |
| 5283 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 5284 | sizeof(spec->autocfg.hp_pins)); |
| 5285 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 5286 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 5287 | spec->autocfg.line_outs = 0; |
| 5288 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5289 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5290 | if (stac_check_auto_mic(codec)) { |
| 5291 | spec->auto_mic = 1; |
| 5292 | /* only one capture for auto-mic */ |
| 5293 | spec->num_adcs = 1; |
| 5294 | spec->num_caps = 1; |
| 5295 | spec->num_muxes = 1; |
| 5296 | } |
| 5297 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5298 | for (i = 0; i < spec->num_caps; i++) { |
| 5299 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], |
| 5300 | spec->capsws[i], i); |
| 5301 | if (err < 0) |
| 5302 | return err; |
| 5303 | } |
| 5304 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5305 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5306 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5307 | return err; |
| 5308 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 5309 | if (spec->mono_nid > 0) { |
| 5310 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 5311 | if (err < 0) |
| 5312 | return err; |
| 5313 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5314 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5315 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 5316 | &spec->autocfg)) < 0) |
| 5317 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 5318 | if (spec->num_muxes > 0) { |
| 5319 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 5320 | if (err < 0) |
| 5321 | return err; |
| 5322 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5323 | if (spec->num_smuxes > 0) { |
| 5324 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 5325 | if (err < 0) |
| 5326 | return err; |
| 5327 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5328 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 5329 | err = stac92xx_add_input_source(spec); |
| 5330 | if (err < 0) |
| 5331 | return err; |
| 5332 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5333 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 5334 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5335 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5336 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 5337 | /* find digital out and in converters */ |
| 5338 | for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) { |
| 5339 | unsigned int wid_caps = get_wcaps(codec, i); |
| 5340 | if (wid_caps & AC_WCAP_DIGITAL) { |
| 5341 | switch (get_wcaps_type(wid_caps)) { |
| 5342 | case AC_WID_AUD_OUT: |
| 5343 | if (!dig_out) |
| 5344 | dig_out = i; |
| 5345 | break; |
| 5346 | case AC_WID_AUD_IN: |
| 5347 | if (!dig_in) |
| 5348 | dig_in = i; |
| 5349 | break; |
| 5350 | } |
| 5351 | } |
| 5352 | } |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 5353 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5354 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5355 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5356 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5357 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 5358 | if (spec->kctls.list) |
| 5359 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5360 | |
| 5361 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 5362 | if (!spec->dinput_mux) |
| 5363 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5364 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 5365 | spec->mono_mux = &spec->private_mono_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5366 | return 1; |
| 5367 | } |
| 5368 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5369 | /* add playback controls for HP output */ |
| 5370 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 5371 | struct auto_pin_cfg *cfg) |
| 5372 | { |
| 5373 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5374 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5375 | |
| 5376 | if (! pin) |
| 5377 | return 0; |
| 5378 | |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 5379 | if (is_jack_detectable(codec, pin)) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5380 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5381 | |
| 5382 | return 0; |
| 5383 | } |
| 5384 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5385 | /* add playback controls for LFE output */ |
| 5386 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 5387 | struct auto_pin_cfg *cfg) |
| 5388 | { |
| 5389 | struct sigmatel_spec *spec = codec->spec; |
| 5390 | int err; |
| 5391 | hda_nid_t lfe_pin = 0x0; |
| 5392 | int i; |
| 5393 | |
| 5394 | /* |
| 5395 | * search speaker outs and line outs for a mono speaker pin |
| 5396 | * with an amp. If one is found, add LFE controls |
| 5397 | * for it. |
| 5398 | */ |
| 5399 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 5400 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 5401 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5402 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 5403 | if (wcaps == AC_WCAP_OUT_AMP) |
| 5404 | /* found a mono speaker with an amp, must be lfe */ |
| 5405 | lfe_pin = pin; |
| 5406 | } |
| 5407 | |
| 5408 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 5409 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 5410 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 5411 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 5412 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5413 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 5414 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 5415 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5416 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 5417 | if (wcaps == AC_WCAP_OUT_AMP) |
| 5418 | /* found a mono speaker with an amp, |
| 5419 | must be lfe */ |
| 5420 | lfe_pin = pin; |
| 5421 | } |
| 5422 | } |
| 5423 | } |
| 5424 | |
| 5425 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 5426 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5427 | if (err < 0) |
| 5428 | return err; |
| 5429 | } |
| 5430 | |
| 5431 | return 0; |
| 5432 | } |
| 5433 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5434 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 5435 | { |
| 5436 | struct sigmatel_spec *spec = codec->spec; |
| 5437 | int err; |
| 5438 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5439 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5440 | return err; |
| 5441 | |
| 5442 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 5443 | return err; |
| 5444 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5445 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 5446 | return err; |
| 5447 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5448 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 5449 | return err; |
| 5450 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 5451 | if (spec->num_muxes > 0) { |
| 5452 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 5453 | if (err < 0) |
| 5454 | return err; |
| 5455 | } |
| 5456 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 5457 | err = stac92xx_add_input_source(spec); |
| 5458 | if (err < 0) |
| 5459 | return err; |
| 5460 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 5461 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5462 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5463 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5464 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5465 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 5466 | if (spec->kctls.list) |
| 5467 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5468 | |
| 5469 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5470 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5471 | |
| 5472 | return 1; |
| 5473 | } |
| 5474 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5475 | /* |
| 5476 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 5477 | * funky external mute control using GPIO pins. |
| 5478 | */ |
| 5479 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5480 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5481 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5482 | { |
| 5483 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5484 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5485 | snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data); |
| 5486 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5487 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5488 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5489 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5490 | |
| 5491 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5492 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5493 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5494 | |
| 5495 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5496 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5497 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5498 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5499 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5500 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 5501 | |
| 5502 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5503 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5504 | snd_hda_codec_read(codec, codec->afg, 0, |
| 5505 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5506 | |
| 5507 | msleep(1); |
| 5508 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5509 | snd_hda_codec_read(codec, codec->afg, 0, |
| 5510 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5511 | } |
| 5512 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5513 | static int stac_add_event(struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5514 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5515 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5516 | struct hda_jack_tbl *event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5517 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5518 | event = snd_hda_jack_tbl_new(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5519 | if (!event) |
| 5520 | return -ENOMEM; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5521 | event->action = type; |
| 5522 | event->private_data = data; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5523 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5524 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5525 | } |
| 5526 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5527 | static void handle_unsol_event(struct hda_codec *codec, |
| 5528 | struct hda_jack_tbl *event); |
| 5529 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5530 | /* check if given nid is a valid pin and no other events are assigned |
| 5531 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
| 5532 | * Otherwise, returns zero. |
| 5533 | */ |
| 5534 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 5535 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5536 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5537 | struct hda_jack_tbl *event; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5538 | |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 5539 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5540 | return 0; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5541 | event = snd_hda_jack_tbl_new(codec, nid); |
| 5542 | if (!event) |
| 5543 | return -ENOMEM; |
| 5544 | if (event->action && event->action != type) |
| 5545 | return 0; |
| 5546 | event->action = type; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5547 | event->callback = handle_unsol_event; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5548 | snd_hda_jack_detect_enable(codec, nid, 0); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5549 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5550 | } |
| 5551 | |
Takashi Iwai | b4ead01 | 2012-01-23 18:23:36 +0100 | [diff] [blame] | 5552 | static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5553 | { |
| 5554 | int i; |
| 5555 | for (i = 0; i < cfg->hp_outs; i++) |
| 5556 | if (cfg->hp_pins[i] == nid) |
| 5557 | return 1; /* nid is a HP-Out */ |
Takashi Iwai | b4ead01 | 2012-01-23 18:23:36 +0100 | [diff] [blame] | 5558 | for (i = 0; i < cfg->line_outs; i++) |
| 5559 | if (cfg->line_out_pins[i] == nid) |
| 5560 | return 1; /* nid is a line-Out */ |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5561 | return 0; /* nid is not a HP-Out */ |
| 5562 | }; |
| 5563 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5564 | static void stac92xx_power_down(struct hda_codec *codec) |
| 5565 | { |
| 5566 | struct sigmatel_spec *spec = codec->spec; |
| 5567 | |
| 5568 | /* power down inactive DACs */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 5569 | const hda_nid_t *dac; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5570 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5571 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5572 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5573 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 5574 | } |
| 5575 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5576 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 5577 | int enable); |
| 5578 | |
Takashi Iwai | bc75972 | 2013-01-11 17:40:31 +0100 | [diff] [blame] | 5579 | static inline bool get_int_hint(struct hda_codec *codec, const char *key, |
| 5580 | int *valp) |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5581 | { |
Takashi Iwai | bc75972 | 2013-01-11 17:40:31 +0100 | [diff] [blame] | 5582 | return !snd_hda_get_int_hint(codec, key, valp); |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5583 | } |
| 5584 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5585 | /* override some hints from the hwdep entry */ |
| 5586 | static void stac_store_hints(struct hda_codec *codec) |
| 5587 | { |
| 5588 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5589 | int val; |
| 5590 | |
| 5591 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 5592 | if (val >= 0) |
| 5593 | spec->hp_detect = val; |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5594 | if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) { |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5595 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 5596 | spec->gpio_mask; |
| 5597 | } |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5598 | if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) |
| 5599 | spec->gpio_mask &= spec->gpio_mask; |
| 5600 | if (get_int_hint(codec, "gpio_data", &spec->gpio_data)) |
| 5601 | spec->gpio_dir &= spec->gpio_mask; |
| 5602 | if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) |
| 5603 | spec->eapd_mask &= spec->gpio_mask; |
| 5604 | if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) |
| 5605 | spec->gpio_mute &= spec->gpio_mask; |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5606 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 5607 | if (val >= 0) |
| 5608 | spec->eapd_switch = val; |
| 5609 | } |
| 5610 | |
Takashi Iwai | f2cbba7 | 2012-01-11 12:34:11 +0100 | [diff] [blame] | 5611 | static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins, |
| 5612 | const hda_nid_t *pins) |
| 5613 | { |
| 5614 | while (num_pins--) |
| 5615 | stac_issue_unsol_event(codec, *pins++); |
| 5616 | } |
| 5617 | |
| 5618 | /* fake event to set up pins */ |
| 5619 | static void stac_fake_hp_events(struct hda_codec *codec) |
| 5620 | { |
| 5621 | struct sigmatel_spec *spec = codec->spec; |
| 5622 | |
| 5623 | if (spec->autocfg.hp_outs) |
| 5624 | stac_issue_unsol_events(codec, spec->autocfg.hp_outs, |
| 5625 | spec->autocfg.hp_pins); |
| 5626 | if (spec->autocfg.line_outs && |
| 5627 | spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0]) |
| 5628 | stac_issue_unsol_events(codec, spec->autocfg.line_outs, |
| 5629 | spec->autocfg.line_out_pins); |
| 5630 | } |
| 5631 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5632 | static int stac92xx_init(struct hda_codec *codec) |
| 5633 | { |
| 5634 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5635 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5636 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 5637 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5638 | |
David Henningsson | 5e68fb3 | 2012-08-16 14:11:09 +0200 | [diff] [blame] | 5639 | if (spec->init) |
| 5640 | snd_hda_sequence_write(codec, spec->init); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5641 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 5642 | snd_hda_apply_verbs(codec); |
| 5643 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5644 | /* power down adcs initially */ |
| 5645 | if (spec->powerdown_adcs) |
| 5646 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5647 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5648 | spec->adc_nids[i], 0, |
| 5649 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5650 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5651 | /* override some hints */ |
| 5652 | stac_store_hints(codec); |
| 5653 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5654 | /* set up GPIO */ |
| 5655 | gpio = spec->gpio_data; |
| 5656 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 5657 | * otherwise, unsol event will turn it on/off dynamically |
| 5658 | */ |
| 5659 | if (!spec->eapd_switch) |
| 5660 | gpio |= spec->eapd_mask; |
| 5661 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 5662 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5663 | /* set up pins */ |
| 5664 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 5665 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5666 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5667 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5668 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5669 | } |
Takashi Iwai | 1c4bdf9 | 2009-08-13 08:23:24 +0200 | [diff] [blame] | 5670 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && |
| 5671 | cfg->speaker_outs > 0) { |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5672 | /* enable pin-detect for line-outs as well */ |
Takashi Iwai | 15cfa2b | 2009-08-03 14:23:33 +0200 | [diff] [blame] | 5673 | for (i = 0; i < cfg->line_outs; i++) { |
| 5674 | hda_nid_t nid = cfg->line_out_pins[i]; |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5675 | enable_pin_detect(codec, nid, STAC_LO_EVENT); |
| 5676 | } |
| 5677 | } |
| 5678 | |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 5679 | /* force to enable the first line-out; the others are set up |
| 5680 | * in unsol_event |
| 5681 | */ |
| 5682 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5683 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5684 | /* fake event to set up pins */ |
Takashi Iwai | f2cbba7 | 2012-01-11 12:34:11 +0100 | [diff] [blame] | 5685 | stac_fake_hp_events(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5686 | } else { |
| 5687 | stac92xx_auto_init_multi_out(codec); |
| 5688 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 5689 | for (i = 0; i < cfg->hp_outs; i++) |
| 5690 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5691 | } |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5692 | if (spec->auto_mic) { |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 5693 | /* initialize connection to analog input */ |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 5694 | if (spec->dmux_nids) |
| 5695 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 5696 | AC_VERB_SET_CONNECT_SEL, 0); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5697 | if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) |
| 5698 | stac_issue_unsol_event(codec, spec->ext_mic.pin); |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5699 | if (enable_pin_detect(codec, spec->dock_mic.pin, |
| 5700 | STAC_MIC_EVENT)) |
| 5701 | stac_issue_unsol_event(codec, spec->dock_mic.pin); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5702 | } |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5703 | for (i = 0; i < cfg->num_inputs; i++) { |
| 5704 | hda_nid_t nid = cfg->inputs[i].pin; |
| 5705 | int type = cfg->inputs[i].type; |
| 5706 | unsigned int pinctl, conf; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 5707 | if (type == AUTO_PIN_MIC) { |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5708 | /* for mic pins, force to initialize */ |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 5709 | pinctl = snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5710 | pinctl |= AC_PINCTL_IN_EN; |
| 5711 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 5712 | } else { |
| 5713 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 5714 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5715 | /* if PINCTL already set then skip */ |
| 5716 | /* Also, if both INPUT and OUTPUT are set, |
| 5717 | * it must be a BIOS bug; need to override, too |
| 5718 | */ |
| 5719 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 5720 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 5721 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 5722 | pinctl |= AC_PINCTL_IN_EN; |
| 5723 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 5724 | } |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5725 | } |
| 5726 | conf = snd_hda_codec_get_pincfg(codec, nid); |
| 5727 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 5728 | if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT)) |
| 5729 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 5730 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5731 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5732 | for (i = 0; i < spec->num_dmics; i++) |
| 5733 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 5734 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 5735 | if (cfg->dig_out_pins[0]) |
| 5736 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5737 | AC_PINCTL_OUT_EN); |
| 5738 | if (cfg->dig_in_pin) |
| 5739 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 5740 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5741 | for (i = 0; i < spec->num_pwrs; i++) { |
| 5742 | hda_nid_t nid = spec->pwr_nids[i]; |
Takashi Iwai | 6e1c39c | 2012-06-26 17:35:10 +0200 | [diff] [blame] | 5743 | unsigned int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5744 | |
Takashi Iwai | bfc89de | 2012-05-15 09:02:26 +0200 | [diff] [blame] | 5745 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 5746 | def_conf = get_defcfg_connect(def_conf); |
| 5747 | if (def_conf == AC_JACK_PORT_NONE) { |
| 5748 | /* power off unused ports */ |
| 5749 | stac_toggle_power_map(codec, nid, 0); |
| 5750 | continue; |
| 5751 | } |
Takashi Iwai | 6e1c39c | 2012-06-26 17:35:10 +0200 | [diff] [blame] | 5752 | if (def_conf == AC_JACK_PORT_FIXED) { |
| 5753 | /* no need for jack detection for fixed pins */ |
| 5754 | stac_toggle_power_map(codec, nid, 1); |
| 5755 | continue; |
| 5756 | } |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5757 | /* power on when no jack detection is available */ |
Takashi Iwai | 542c9a0 | 2011-11-29 13:01:30 +0100 | [diff] [blame] | 5758 | /* or when the VREF is used for controlling LED */ |
| 5759 | if (!spec->hp_detect || |
Takashi Iwai | bfc89de | 2012-05-15 09:02:26 +0200 | [diff] [blame] | 5760 | spec->vref_mute_led_nid == nid || |
| 5761 | !is_jack_detectable(codec, nid)) { |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5762 | stac_toggle_power_map(codec, nid, 1); |
| 5763 | continue; |
| 5764 | } |
| 5765 | |
Takashi Iwai | b4ead01 | 2012-01-23 18:23:36 +0100 | [diff] [blame] | 5766 | if (is_nid_out_jack_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5767 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5768 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5769 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 5770 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5771 | /* outputs are only ports capable of power management |
| 5772 | * any attempts on powering down a input port cause the |
| 5773 | * referenced VREF to act quirky. |
| 5774 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5775 | if (pinctl & AC_PINCTL_IN_EN) { |
| 5776 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5777 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5778 | } |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 5779 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5780 | stac_issue_unsol_event(codec, nid); |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 5781 | continue; |
| 5782 | } |
| 5783 | /* none of the above, turn the port OFF */ |
| 5784 | stac_toggle_power_map(codec, nid, 0); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5785 | } |
Takashi Iwai | c21bd02 | 2010-02-08 15:16:08 +0100 | [diff] [blame] | 5786 | |
Takashi Iwai | c21bd02 | 2010-02-08 15:16:08 +0100 | [diff] [blame] | 5787 | /* sync mute LED */ |
Takashi Iwai | 1f43f6c | 2012-07-31 10:40:05 +0200 | [diff] [blame] | 5788 | if (spec->gpio_led) { |
| 5789 | if (spec->vmaster_mute.hook) |
| 5790 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 5791 | else /* the very first init call doesn't have vmaster yet */ |
| 5792 | stac92xx_update_led_status(codec, false); |
| 5793 | } |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 5794 | |
| 5795 | /* sync the power-map */ |
| 5796 | if (spec->num_pwrs) |
| 5797 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5798 | AC_VERB_IDT_SET_POWER_MAP, |
| 5799 | spec->power_map_bits); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5800 | if (spec->dac_list) |
| 5801 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5802 | return 0; |
| 5803 | } |
| 5804 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 5805 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 5806 | { |
| 5807 | struct sigmatel_spec *spec = codec->spec; |
| 5808 | |
| 5809 | if (spec->kctls.list) { |
| 5810 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 5811 | int i; |
| 5812 | for (i = 0; i < spec->kctls.used; i++) |
| 5813 | kfree(kctl[i].name); |
| 5814 | } |
| 5815 | snd_array_free(&spec->kctls); |
| 5816 | } |
| 5817 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5818 | static void stac92xx_shutup_pins(struct hda_codec *codec) |
| 5819 | { |
| 5820 | unsigned int i, def_conf; |
| 5821 | |
| 5822 | if (codec->bus->shutdown) |
| 5823 | return; |
| 5824 | for (i = 0; i < codec->init_pins.used; i++) { |
| 5825 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); |
| 5826 | def_conf = snd_hda_codec_get_pincfg(codec, pin->nid); |
| 5827 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5828 | snd_hda_set_pin_ctl(codec, pin->nid, 0); |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5829 | } |
| 5830 | } |
| 5831 | |
Takashi Iwai | 167eae5 | 2009-11-06 15:47:50 +0100 | [diff] [blame] | 5832 | static void stac92xx_shutup(struct hda_codec *codec) |
| 5833 | { |
| 5834 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 167eae5 | 2009-11-06 15:47:50 +0100 | [diff] [blame] | 5835 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5836 | stac92xx_shutup_pins(codec); |
Takashi Iwai | 167eae5 | 2009-11-06 15:47:50 +0100 | [diff] [blame] | 5837 | |
| 5838 | if (spec->eapd_mask) |
| 5839 | stac_gpio_set(codec, spec->gpio_mask, |
| 5840 | spec->gpio_dir, spec->gpio_data & |
| 5841 | ~spec->eapd_mask); |
| 5842 | } |
| 5843 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5844 | static void stac92xx_free(struct hda_codec *codec) |
| 5845 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5846 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5847 | |
| 5848 | if (! spec) |
| 5849 | return; |
| 5850 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5851 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5852 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5853 | } |
| 5854 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5855 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 5856 | unsigned int flag) |
| 5857 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5858 | unsigned int old_ctl, pin_ctl; |
| 5859 | |
| 5860 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5861 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 5862 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 5863 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 5864 | /* |
| 5865 | * we need to check the current set-up direction of |
| 5866 | * shared input pins since they can be switched via |
| 5867 | * "xxx as Output" mixer switch |
| 5868 | */ |
| 5869 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5870 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 5871 | return; |
| 5872 | } |
| 5873 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5874 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 5875 | /* if setting pin direction bits, clear the current |
| 5876 | direction bits first */ |
| 5877 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 5878 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 5879 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5880 | pin_ctl |= flag; |
| 5881 | if (old_ctl != pin_ctl) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5882 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5883 | } |
| 5884 | |
| 5885 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 5886 | unsigned int flag) |
| 5887 | { |
| 5888 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 5889 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5890 | if (pin_ctl & flag) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5891 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5892 | } |
| 5893 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 5894 | static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5895 | { |
| 5896 | if (!nid) |
| 5897 | return 0; |
Takashi Iwai | a252c81 | 2009-12-25 22:56:20 +0100 | [diff] [blame] | 5898 | return snd_hda_jack_detect(codec, nid); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5899 | } |
| 5900 | |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5901 | static void stac92xx_line_out_detect(struct hda_codec *codec, |
| 5902 | int presence) |
| 5903 | { |
| 5904 | struct sigmatel_spec *spec = codec->spec; |
| 5905 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 5906 | int i; |
| 5907 | |
David Henningsson | 042b92c | 2012-08-22 16:10:43 +0200 | [diff] [blame] | 5908 | if (cfg->speaker_outs == 0) |
| 5909 | return; |
| 5910 | |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5911 | for (i = 0; i < cfg->line_outs; i++) { |
| 5912 | if (presence) |
| 5913 | break; |
| 5914 | presence = get_pin_presence(codec, cfg->line_out_pins[i]); |
| 5915 | if (presence) { |
| 5916 | unsigned int pinctl; |
| 5917 | pinctl = snd_hda_codec_read(codec, |
| 5918 | cfg->line_out_pins[i], 0, |
| 5919 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5920 | if (pinctl & AC_PINCTL_IN_EN) |
| 5921 | presence = 0; /* mic- or line-input */ |
| 5922 | } |
| 5923 | } |
| 5924 | |
| 5925 | if (presence) { |
| 5926 | /* disable speakers */ |
| 5927 | for (i = 0; i < cfg->speaker_outs; i++) |
| 5928 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 5929 | AC_PINCTL_OUT_EN); |
| 5930 | if (spec->eapd_mask && spec->eapd_switch) |
| 5931 | stac_gpio_set(codec, spec->gpio_mask, |
| 5932 | spec->gpio_dir, spec->gpio_data & |
| 5933 | ~spec->eapd_mask); |
| 5934 | } else { |
| 5935 | /* enable speakers */ |
| 5936 | for (i = 0; i < cfg->speaker_outs; i++) |
| 5937 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 5938 | AC_PINCTL_OUT_EN); |
| 5939 | if (spec->eapd_mask && spec->eapd_switch) |
| 5940 | stac_gpio_set(codec, spec->gpio_mask, |
| 5941 | spec->gpio_dir, spec->gpio_data | |
| 5942 | spec->eapd_mask); |
| 5943 | } |
| 5944 | } |
| 5945 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5946 | /* return non-zero if the hp-pin of the given array index isn't |
| 5947 | * a jack-detection target |
| 5948 | */ |
| 5949 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 5950 | { |
| 5951 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 5952 | |
| 5953 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5954 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5955 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5956 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5957 | return 1; |
| 5958 | /* ignore if the pin is set as line-out */ |
| 5959 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 5960 | return 1; |
| 5961 | return 0; |
| 5962 | } |
| 5963 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5964 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5965 | { |
| 5966 | struct sigmatel_spec *spec = codec->spec; |
| 5967 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 5968 | int i, presence; |
| 5969 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5970 | presence = 0; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5971 | if (spec->gpio_mute) |
| 5972 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 5973 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 5974 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5975 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5976 | if (presence) |
| 5977 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5978 | if (no_hp_sensing(spec, i)) |
| 5979 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 5980 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 5981 | if (presence) { |
| 5982 | unsigned int pinctl; |
| 5983 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 5984 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5985 | if (pinctl & AC_PINCTL_IN_EN) |
| 5986 | presence = 0; /* mic- or line-input */ |
| 5987 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5988 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5989 | |
| 5990 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5991 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 5992 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5993 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 5994 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5995 | for (i = 0; i < cfg->line_outs; i++) |
| 5996 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 5997 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5998 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5999 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 6000 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 6001 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 6002 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 6003 | for (i = 0; i < cfg->line_outs; i++) |
| 6004 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 6005 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 6006 | } |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 6007 | stac92xx_line_out_detect(codec, presence); |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 6008 | /* toggle hp outs */ |
| 6009 | for (i = 0; i < cfg->hp_outs; i++) { |
| 6010 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 6011 | if (no_hp_sensing(spec, i)) |
| 6012 | continue; |
Takashi Iwai | 7bff172 | 2012-02-29 09:41:17 +0100 | [diff] [blame] | 6013 | if (1 /*presence*/) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 6014 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 6015 | #if 0 /* FIXME */ |
| 6016 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 6017 | * on some devices since they use the HP pin actually for line/speaker |
| 6018 | * outs although the default pin config shows a different pin (that is |
| 6019 | * wrong and useless). |
| 6020 | * |
| 6021 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 6022 | * But, disabling the code below just works around it, and I'm too tired of |
| 6023 | * bug reports with such devices... |
| 6024 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 6025 | else |
| 6026 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 6027 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 6028 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 6029 | } |
| 6030 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 6031 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 6032 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6033 | { |
| 6034 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 6035 | unsigned int idx, val; |
| 6036 | |
| 6037 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 6038 | if (spec->pwr_nids[idx] == nid) |
| 6039 | break; |
| 6040 | } |
| 6041 | if (idx >= spec->num_pwrs) |
| 6042 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6043 | |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 6044 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6045 | |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 6046 | val = spec->power_map_bits; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 6047 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6048 | val &= ~idx; |
| 6049 | else |
| 6050 | val |= idx; |
| 6051 | |
| 6052 | /* power down unused output ports */ |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 6053 | if (val != spec->power_map_bits) { |
| 6054 | spec->power_map_bits = val; |
| 6055 | snd_hda_codec_write(codec, codec->afg, 0, |
| 6056 | AC_VERB_IDT_SET_POWER_MAP, val); |
| 6057 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 6058 | } |
| 6059 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 6060 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 6061 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 6062 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 6063 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6064 | |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6065 | /* get the pin connection (fixed, none, etc) */ |
| 6066 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 6067 | { |
| 6068 | struct sigmatel_spec *spec = codec->spec; |
| 6069 | unsigned int cfg; |
| 6070 | |
| 6071 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 6072 | return get_defcfg_connect(cfg); |
| 6073 | } |
| 6074 | |
| 6075 | static int stac92xx_connected_ports(struct hda_codec *codec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6076 | const hda_nid_t *nids, int num_nids) |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6077 | { |
| 6078 | struct sigmatel_spec *spec = codec->spec; |
| 6079 | int idx, num; |
| 6080 | unsigned int def_conf; |
| 6081 | |
| 6082 | for (num = 0; num < num_nids; num++) { |
| 6083 | for (idx = 0; idx < spec->num_pins; idx++) |
| 6084 | if (spec->pin_nids[idx] == nids[num]) |
| 6085 | break; |
| 6086 | if (idx >= spec->num_pins) |
| 6087 | break; |
| 6088 | def_conf = stac_get_defcfg_connect(codec, idx); |
| 6089 | if (def_conf == AC_JACK_PORT_NONE) |
| 6090 | break; |
| 6091 | } |
| 6092 | return num; |
| 6093 | } |
| 6094 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6095 | static void stac92xx_mic_detect(struct hda_codec *codec) |
| 6096 | { |
| 6097 | struct sigmatel_spec *spec = codec->spec; |
| 6098 | struct sigmatel_mic_route *mic; |
| 6099 | |
| 6100 | if (get_pin_presence(codec, spec->ext_mic.pin)) |
| 6101 | mic = &spec->ext_mic; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 6102 | else if (get_pin_presence(codec, spec->dock_mic.pin)) |
| 6103 | mic = &spec->dock_mic; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6104 | else |
| 6105 | mic = &spec->int_mic; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 6106 | if (mic->dmux_idx >= 0) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6107 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
| 6108 | AC_VERB_SET_CONNECT_SEL, |
| 6109 | mic->dmux_idx); |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 6110 | if (mic->mux_idx >= 0) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6111 | snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, |
| 6112 | AC_VERB_SET_CONNECT_SEL, |
| 6113 | mic->mux_idx); |
| 6114 | } |
| 6115 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 6116 | static void handle_unsol_event(struct hda_codec *codec, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6117 | struct hda_jack_tbl *event) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 6118 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6119 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 6120 | int data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6121 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6122 | switch (event->action) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 6123 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 6124 | case STAC_LO_EVENT: |
Takashi Iwai | 16ffe32 | 2009-08-04 13:40:54 +0200 | [diff] [blame] | 6125 | stac92xx_hp_detect(codec); |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 6126 | break; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6127 | case STAC_MIC_EVENT: |
| 6128 | stac92xx_mic_detect(codec); |
| 6129 | break; |
| 6130 | } |
| 6131 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6132 | switch (event->action) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6133 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 6134 | case STAC_LO_EVENT: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 6135 | case STAC_MIC_EVENT: |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 6136 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6137 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 6138 | if (spec->num_pwrs > 0) |
| 6139 | stac92xx_pin_sense(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 6140 | |
| 6141 | switch (codec->subsystem_id) { |
| 6142 | case 0x103c308f: |
| 6143 | if (event->nid == 0xb) { |
| 6144 | int pin = AC_PINCTL_IN_EN; |
| 6145 | |
| 6146 | if (get_pin_presence(codec, 0xa) |
| 6147 | && get_pin_presence(codec, 0xb)) |
| 6148 | pin |= AC_PINCTL_VREF_80; |
| 6149 | if (!get_pin_presence(codec, 0xb)) |
| 6150 | pin |= AC_PINCTL_VREF_80; |
| 6151 | |
| 6152 | /* toggle VREF state based on mic + hp pin |
| 6153 | * status |
| 6154 | */ |
| 6155 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 6156 | } |
| 6157 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 6158 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 6159 | case STAC_VREF_EVENT: |
| 6160 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 6161 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 6162 | /* toggle VREF state based on GPIOx status */ |
| 6163 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6164 | !!(data & (1 << event->private_data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 6165 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 6166 | } |
| 6167 | } |
| 6168 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 6169 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) |
| 6170 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6171 | struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 6172 | if (!event) |
| 6173 | return; |
| 6174 | handle_unsol_event(codec, event); |
| 6175 | } |
| 6176 | |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6177 | static void set_hp_led_gpio(struct hda_codec *codec) |
| 6178 | { |
| 6179 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 07f8044 | 2010-02-08 15:06:13 +0100 | [diff] [blame] | 6180 | unsigned int gpio; |
| 6181 | |
Takashi Iwai | 26ebe0a | 2010-05-11 08:36:29 +0200 | [diff] [blame] | 6182 | if (spec->gpio_led) |
| 6183 | return; |
| 6184 | |
Takashi Iwai | 07f8044 | 2010-02-08 15:06:13 +0100 | [diff] [blame] | 6185 | gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); |
| 6186 | gpio &= AC_GPIO_IO_COUNT; |
| 6187 | if (gpio > 3) |
| 6188 | spec->gpio_led = 0x08; /* GPIO 3 */ |
| 6189 | else |
| 6190 | spec->gpio_led = 0x01; /* GPIO 0 */ |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6191 | } |
| 6192 | |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6193 | /* |
| 6194 | * This method searches for the mute LED GPIO configuration |
| 6195 | * provided as OEM string in SMBIOS. The format of that string |
| 6196 | * is HP_Mute_LED_P_G or HP_Mute_LED_P |
| 6197 | * where P can be 0 or 1 and defines mute LED GPIO control state (low/high) |
| 6198 | * that corresponds to the NOT muted state of the master volume |
| 6199 | * and G is the index of the GPIO to use as the mute LED control (0..9) |
| 6200 | * If _G portion is missing it is assigned based on the codec ID |
| 6201 | * |
| 6202 | * So, HP B-series like systems may have HP_Mute_LED_0 (current models) |
| 6203 | * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6204 | * |
| 6205 | * |
| 6206 | * The dv-series laptops don't seem to have the HP_Mute_LED* strings in |
| 6207 | * SMBIOS - at least the ones I have seen do not have them - which include |
| 6208 | * my own system (HP Pavilion dv6-1110ax) and my cousin's |
| 6209 | * HP Pavilion dv9500t CTO. |
| 6210 | * Need more information on whether it is true across the entire series. |
| 6211 | * -- kunal |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6212 | */ |
Vitaliy Kulikov | 6a557c9 | 2011-12-12 17:35:13 -0600 | [diff] [blame] | 6213 | static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity) |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6214 | { |
| 6215 | struct sigmatel_spec *spec = codec->spec; |
| 6216 | const struct dmi_device *dev = NULL; |
| 6217 | |
Takashi Iwai | 7560931 | 2012-05-14 16:52:00 +0200 | [diff] [blame] | 6218 | if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) { |
| 6219 | get_int_hint(codec, "gpio_led_polarity", |
| 6220 | &spec->gpio_led_polarity); |
| 6221 | return 1; |
| 6222 | } |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6223 | |
Takashi Iwai | 89bb3e7 | 2013-01-15 11:12:18 +0100 | [diff] [blame] | 6224 | while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) { |
| 6225 | if (sscanf(dev->name, "HP_Mute_LED_%d_%x", |
| 6226 | &spec->gpio_led_polarity, |
| 6227 | &spec->gpio_led) == 2) { |
| 6228 | unsigned int max_gpio; |
| 6229 | max_gpio = snd_hda_param_read(codec, codec->afg, |
| 6230 | AC_PAR_GPIO_CAP); |
| 6231 | max_gpio &= AC_GPIO_IO_COUNT; |
| 6232 | if (spec->gpio_led < max_gpio) |
| 6233 | spec->gpio_led = 1 << spec->gpio_led; |
| 6234 | else |
| 6235 | spec->vref_mute_led_nid = spec->gpio_led; |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6236 | return 1; |
| 6237 | } |
Takashi Iwai | 89bb3e7 | 2013-01-15 11:12:18 +0100 | [diff] [blame] | 6238 | if (sscanf(dev->name, "HP_Mute_LED_%d", |
| 6239 | &spec->gpio_led_polarity) == 1) { |
| 6240 | set_hp_led_gpio(codec); |
| 6241 | return 1; |
| 6242 | } |
| 6243 | /* BIOS bug: unfilled OEM string */ |
| 6244 | if (strstr(dev->name, "HP_Mute_LED_P_G")) { |
| 6245 | set_hp_led_gpio(codec); |
Takashi Iwai | 8c698fe | 2013-01-15 11:20:50 +0100 | [diff] [blame^] | 6246 | if (default_polarity >= 0) |
| 6247 | spec->gpio_led_polarity = default_polarity; |
| 6248 | else |
Takashi Iwai | 89bb3e7 | 2013-01-15 11:12:18 +0100 | [diff] [blame] | 6249 | spec->gpio_led_polarity = 1; |
Takashi Iwai | 89bb3e7 | 2013-01-15 11:12:18 +0100 | [diff] [blame] | 6250 | return 1; |
| 6251 | } |
| 6252 | } |
| 6253 | |
| 6254 | /* |
| 6255 | * Fallback case - if we don't find the DMI strings, |
| 6256 | * we statically set the GPIO - if not a B-series system |
| 6257 | * and default polarity is provided |
| 6258 | */ |
| 6259 | if (!hp_blike_system(codec->subsystem_id) && |
| 6260 | (default_polarity == 0 || default_polarity == 1)) { |
| 6261 | set_hp_led_gpio(codec); |
| 6262 | spec->gpio_led_polarity = default_polarity; |
| 6263 | return 1; |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6264 | } |
| 6265 | return 0; |
| 6266 | } |
| 6267 | |
| 6268 | static int hp_blike_system(u32 subsystem_id) |
Randy Dunlap | 78987bd | 2009-11-05 09:22:30 -0800 | [diff] [blame] | 6269 | { |
| 6270 | switch (subsystem_id) { |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6271 | case 0x103c1520: |
| 6272 | case 0x103c1521: |
| 6273 | case 0x103c1523: |
| 6274 | case 0x103c1524: |
| 6275 | case 0x103c1525: |
Randy Dunlap | 78987bd | 2009-11-05 09:22:30 -0800 | [diff] [blame] | 6276 | case 0x103c1722: |
| 6277 | case 0x103c1723: |
| 6278 | case 0x103c1724: |
| 6279 | case 0x103c1725: |
| 6280 | case 0x103c1726: |
| 6281 | case 0x103c1727: |
| 6282 | case 0x103c1728: |
| 6283 | case 0x103c1729: |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6284 | case 0x103c172a: |
| 6285 | case 0x103c172b: |
| 6286 | case 0x103c307e: |
| 6287 | case 0x103c307f: |
| 6288 | case 0x103c3080: |
| 6289 | case 0x103c3081: |
| 6290 | case 0x103c7007: |
| 6291 | case 0x103c7008: |
Randy Dunlap | 78987bd | 2009-11-05 09:22:30 -0800 | [diff] [blame] | 6292 | return 1; |
| 6293 | } |
| 6294 | return 0; |
| 6295 | } |
| 6296 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6297 | #ifdef CONFIG_PROC_FS |
| 6298 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 6299 | struct hda_codec *codec, hda_nid_t nid) |
| 6300 | { |
| 6301 | if (nid == codec->afg) |
| 6302 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 6303 | snd_hda_codec_read(codec, nid, 0, |
| 6304 | AC_VERB_IDT_GET_POWER_MAP, 0)); |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6305 | } |
| 6306 | |
| 6307 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 6308 | struct hda_codec *codec, |
| 6309 | unsigned int verb) |
| 6310 | { |
| 6311 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 6312 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 6313 | } |
| 6314 | |
| 6315 | /* stac92hd71bxx, stac92hd73xx */ |
| 6316 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 6317 | struct hda_codec *codec, hda_nid_t nid) |
| 6318 | { |
| 6319 | stac92hd_proc_hook(buffer, codec, nid); |
| 6320 | if (nid == codec->afg) |
| 6321 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 6322 | } |
| 6323 | |
| 6324 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 6325 | struct hda_codec *codec, hda_nid_t nid) |
| 6326 | { |
| 6327 | if (nid == codec->afg) |
| 6328 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 6329 | } |
| 6330 | |
| 6331 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 6332 | struct hda_codec *codec, hda_nid_t nid) |
| 6333 | { |
| 6334 | if (nid == codec->afg) |
| 6335 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 6336 | } |
| 6337 | #else |
| 6338 | #define stac92hd_proc_hook NULL |
| 6339 | #define stac92hd7x_proc_hook NULL |
| 6340 | #define stac9205_proc_hook NULL |
| 6341 | #define stac927x_proc_hook NULL |
| 6342 | #endif |
| 6343 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6344 | #ifdef CONFIG_PM |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 6345 | static int stac92xx_resume(struct hda_codec *codec) |
| 6346 | { |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 6347 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 6348 | snd_hda_codec_resume_amp(codec); |
| 6349 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 6350 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | f2cbba7 | 2012-01-11 12:34:11 +0100 | [diff] [blame] | 6351 | stac_fake_hp_events(codec); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 6352 | return 0; |
| 6353 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 6354 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 6355 | static int stac92xx_suspend(struct hda_codec *codec) |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6356 | { |
| 6357 | stac92xx_shutup(codec); |
| 6358 | return 0; |
| 6359 | } |
| 6360 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6361 | static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg, |
| 6362 | unsigned int power_state) |
| 6363 | { |
| 6364 | unsigned int afg_power_state = power_state; |
| 6365 | struct sigmatel_spec *spec = codec->spec; |
| 6366 | |
| 6367 | if (power_state == AC_PWRST_D3) { |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6368 | if (spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6369 | /* with vref-out pin used for mute led control |
| 6370 | * codec AFG is prevented from D3 state |
| 6371 | */ |
| 6372 | afg_power_state = AC_PWRST_D1; |
| 6373 | } |
| 6374 | /* this delay seems necessary to avoid click noise at power-down */ |
| 6375 | msleep(100); |
| 6376 | } |
| 6377 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, |
| 6378 | afg_power_state); |
| 6379 | snd_hda_codec_set_power_to_all(codec, fg, power_state, true); |
| 6380 | } |
Takashi Iwai | 350eba43 | 2012-03-16 16:09:03 +0100 | [diff] [blame] | 6381 | #else |
| 6382 | #define stac92xx_suspend NULL |
| 6383 | #define stac92xx_resume NULL |
Takashi Iwai | 350eba43 | 2012-03-16 16:09:03 +0100 | [diff] [blame] | 6384 | #define stac92xx_set_power_state NULL |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6385 | #endif /* CONFIG_PM */ |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6386 | |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6387 | /* update mute-LED accoring to the master switch */ |
| 6388 | static void stac92xx_update_led_status(struct hda_codec *codec, int enabled) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 6389 | { |
| 6390 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6391 | int muted = !enabled; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 6392 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6393 | if (!spec->gpio_led) |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6394 | return; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6395 | |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6396 | /* LED state is inverted on these systems */ |
| 6397 | if (spec->gpio_led_polarity) |
| 6398 | muted = !muted; |
| 6399 | |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6400 | if (!spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6401 | if (muted) |
Takashi Iwai | 3e84319 | 2012-04-19 12:04:03 +0200 | [diff] [blame] | 6402 | spec->gpio_data |= spec->gpio_led; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6403 | else |
Takashi Iwai | 3e84319 | 2012-04-19 12:04:03 +0200 | [diff] [blame] | 6404 | spec->gpio_data &= ~spec->gpio_led; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6405 | stac_gpio_set(codec, spec->gpio_mask, |
| 6406 | spec->gpio_dir, spec->gpio_data); |
| 6407 | } else { |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6408 | spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD; |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6409 | stac_vrefout_set(codec, spec->vref_mute_led_nid, |
| 6410 | spec->vref_led); |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 6411 | } |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6412 | } |
Vitaliy Kulikov | 7df1ce1 | 2011-07-25 17:52:57 -0500 | [diff] [blame] | 6413 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6414 | static const struct hda_codec_ops stac92xx_patch_ops = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6415 | .build_controls = stac92xx_build_controls, |
| 6416 | .build_pcms = stac92xx_build_pcms, |
| 6417 | .init = stac92xx_init, |
| 6418 | .free = stac92xx_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 6419 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6420 | #ifdef CONFIG_PM |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 6421 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 6422 | .resume = stac92xx_resume, |
| 6423 | #endif |
Takashi Iwai | fb8d1a3 | 2009-11-10 16:02:29 +0100 | [diff] [blame] | 6424 | .reboot_notify = stac92xx_shutup, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6425 | }; |
| 6426 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6427 | static int alloc_stac_spec(struct hda_codec *codec, int num_pins, |
| 6428 | const hda_nid_t *pin_nids) |
| 6429 | { |
| 6430 | struct sigmatel_spec *spec; |
| 6431 | |
| 6432 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6433 | if (!spec) |
| 6434 | return -ENOMEM; |
| 6435 | codec->spec = spec; |
| 6436 | codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */ |
| 6437 | spec->num_pins = num_pins; |
| 6438 | spec->pin_nids = pin_nids; |
| 6439 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 6440 | return 0; |
| 6441 | } |
| 6442 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6443 | static int patch_stac9200(struct hda_codec *codec) |
| 6444 | { |
| 6445 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6446 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6447 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6448 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids), |
| 6449 | stac9200_pin_nids); |
| 6450 | if (err < 0) |
| 6451 | return err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6452 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6453 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6454 | spec->linear_tone_beep = 1; |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6455 | |
| 6456 | snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl, |
| 6457 | stac9200_fixups); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6458 | |
| 6459 | spec->multiout.max_channels = 2; |
| 6460 | spec->multiout.num_dacs = 1; |
| 6461 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 6462 | spec->adc_nids = stac9200_adc_nids; |
| 6463 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 6464 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 6465 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 6466 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6467 | spec->num_pwrs = 0; |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6468 | snd_hda_add_verbs(codec, stac9200_eapd_init); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6469 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6470 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6471 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6472 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 6473 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6474 | err = stac9200_parse_auto_config(codec); |
| 6475 | if (err < 0) { |
| 6476 | stac92xx_free(codec); |
| 6477 | return err; |
| 6478 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6479 | |
| 6480 | codec->patch_ops = stac92xx_patch_ops; |
| 6481 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6482 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6483 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6484 | return 0; |
| 6485 | } |
| 6486 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6487 | static int patch_stac925x(struct hda_codec *codec) |
| 6488 | { |
| 6489 | struct sigmatel_spec *spec; |
| 6490 | int err; |
| 6491 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6492 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids), |
| 6493 | stac925x_pin_nids); |
| 6494 | if (err < 0) |
| 6495 | return err; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6496 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6497 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6498 | spec->linear_tone_beep = 1; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 6499 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6500 | snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl, |
| 6501 | stac925x_fixups); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6502 | |
| 6503 | spec->multiout.max_channels = 2; |
| 6504 | spec->multiout.num_dacs = 1; |
| 6505 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 6506 | spec->adc_nids = stac925x_adc_nids; |
| 6507 | spec->mux_nids = stac925x_mux_nids; |
| 6508 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 6509 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6510 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 6511 | switch (codec->vendor_id) { |
| 6512 | case 0x83847632: /* STAC9202 */ |
| 6513 | case 0x83847633: /* STAC9202D */ |
| 6514 | case 0x83847636: /* STAC9251 */ |
| 6515 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 6516 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 6517 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 6518 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 6519 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 6520 | break; |
| 6521 | default: |
| 6522 | spec->num_dmics = 0; |
| 6523 | break; |
| 6524 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6525 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6526 | snd_hda_add_verbs(codec, stac925x_core_init); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6527 | spec->mixer = stac925x_mixer; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6528 | spec->num_caps = 1; |
| 6529 | spec->capvols = stac925x_capvols; |
| 6530 | spec->capsws = stac925x_capsws; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6531 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6532 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 6533 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6534 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6535 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 6536 | err = -EINVAL; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6537 | if (err < 0) { |
| 6538 | stac92xx_free(codec); |
| 6539 | return err; |
| 6540 | } |
| 6541 | |
| 6542 | codec->patch_ops = stac92xx_patch_ops; |
| 6543 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6544 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6545 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6546 | return 0; |
| 6547 | } |
| 6548 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6549 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 6550 | { |
| 6551 | struct sigmatel_spec *spec; |
| 6552 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6553 | int err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6554 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6555 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6556 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids), |
| 6557 | stac92hd73xx_pin_nids); |
| 6558 | if (err < 0) |
| 6559 | return err; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6560 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6561 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6562 | spec->linear_tone_beep = 0; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 6563 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6564 | |
| 6565 | snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl, |
| 6566 | stac92hd73xx_fixups); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6567 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6568 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6569 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 6570 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6571 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6572 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 6573 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6574 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6575 | } |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6576 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6577 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6578 | case 0x3: /* 6 Channel */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6579 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6580 | break; |
| 6581 | case 0x4: /* 8 Channel */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6582 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6583 | break; |
| 6584 | case 0x5: /* 10 Channel */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6585 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 6586 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6587 | } |
| 6588 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6589 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6590 | spec->aloopback_mask = 0x01; |
| 6591 | spec->aloopback_shift = 8; |
| 6592 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 6593 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6594 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 6595 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 6596 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 6597 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 6598 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6599 | |
| 6600 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 6601 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 6602 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 6603 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6604 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
| 6605 | spec->capvols = stac92hd73xx_capvols; |
| 6606 | spec->capsws = stac92hd73xx_capsws; |
| 6607 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6608 | /* GPIO0 High = Enable EAPD */ |
| 6609 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 6610 | spec->gpio_data = 0x01; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 6611 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6612 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
| 6613 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
| 6614 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 6615 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6616 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 6617 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 6618 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6619 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 6620 | |
| 6621 | if (!spec->volknob_init) |
| 6622 | snd_hda_add_verbs(codec, stac92hd73xx_core_init); |
| 6623 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6624 | err = stac92xx_parse_auto_config(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6625 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6626 | if (!err) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6627 | err = -EINVAL; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6628 | if (err < 0) { |
| 6629 | stac92xx_free(codec); |
| 6630 | return err; |
| 6631 | } |
| 6632 | |
| 6633 | codec->patch_ops = stac92xx_patch_ops; |
| 6634 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6635 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 6636 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame] | 6637 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6638 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6639 | return 0; |
| 6640 | } |
| 6641 | |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6642 | static int hp_bnb2011_with_dock(struct hda_codec *codec) |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6643 | { |
| 6644 | if (codec->vendor_id != 0x111d7605 && |
| 6645 | codec->vendor_id != 0x111d76d1) |
| 6646 | return 0; |
| 6647 | |
| 6648 | switch (codec->subsystem_id) { |
| 6649 | case 0x103c1618: |
| 6650 | case 0x103c1619: |
| 6651 | case 0x103c161a: |
| 6652 | case 0x103c161b: |
| 6653 | case 0x103c161c: |
| 6654 | case 0x103c161d: |
| 6655 | case 0x103c161e: |
| 6656 | case 0x103c161f: |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6657 | |
| 6658 | case 0x103c162a: |
| 6659 | case 0x103c162b: |
| 6660 | |
| 6661 | case 0x103c1630: |
| 6662 | case 0x103c1631: |
| 6663 | |
| 6664 | case 0x103c1633: |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6665 | case 0x103c1634: |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6666 | case 0x103c1635: |
| 6667 | |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6668 | case 0x103c3587: |
| 6669 | case 0x103c3588: |
| 6670 | case 0x103c3589: |
| 6671 | case 0x103c358a: |
| 6672 | |
| 6673 | case 0x103c3667: |
| 6674 | case 0x103c3668: |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6675 | case 0x103c3669: |
| 6676 | |
| 6677 | return 1; |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6678 | } |
| 6679 | return 0; |
| 6680 | } |
| 6681 | |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 6682 | static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid) |
| 6683 | { |
| 6684 | struct sigmatel_spec *spec = codec->spec; |
| 6685 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 6686 | int i; |
| 6687 | |
| 6688 | spec->auto_pin_nids[spec->auto_pin_cnt] = nid; |
| 6689 | spec->auto_pin_cnt++; |
| 6690 | |
| 6691 | if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN && |
| 6692 | get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) { |
| 6693 | for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) { |
| 6694 | if (nid == stac92hd83xxx_dmic_nids[i]) { |
| 6695 | spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid; |
| 6696 | spec->auto_dmic_cnt++; |
| 6697 | } |
| 6698 | } |
| 6699 | } |
| 6700 | } |
| 6701 | |
| 6702 | static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid) |
| 6703 | { |
| 6704 | struct sigmatel_spec *spec = codec->spec; |
| 6705 | |
| 6706 | spec->auto_adc_nids[spec->auto_adc_cnt] = nid; |
| 6707 | spec->auto_adc_cnt++; |
| 6708 | } |
| 6709 | |
| 6710 | static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid) |
| 6711 | { |
| 6712 | int i, j; |
| 6713 | struct sigmatel_spec *spec = codec->spec; |
| 6714 | |
| 6715 | for (i = 0; i < spec->auto_adc_cnt; i++) { |
| 6716 | if (get_connection_index(codec, |
| 6717 | spec->auto_adc_nids[i], nid) >= 0) { |
| 6718 | /* mux and volume for adc_nids[i] */ |
| 6719 | if (!spec->auto_mux_nids[i]) { |
| 6720 | spec->auto_mux_nids[i] = nid; |
| 6721 | /* 92hd codecs capture volume is in mux */ |
| 6722 | spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid, |
| 6723 | 3, 0, HDA_OUTPUT); |
| 6724 | } |
| 6725 | for (j = 0; j < spec->auto_dmic_cnt; j++) { |
| 6726 | if (get_connection_index(codec, nid, |
| 6727 | spec->auto_dmic_nids[j]) >= 0) { |
| 6728 | /* dmux for adc_nids[i] */ |
| 6729 | if (!spec->auto_dmux_nids[i]) |
| 6730 | spec->auto_dmux_nids[i] = nid; |
| 6731 | break; |
| 6732 | } |
| 6733 | } |
| 6734 | break; |
| 6735 | } |
| 6736 | } |
| 6737 | } |
| 6738 | |
| 6739 | static void stac92hd8x_fill_auto_spec(struct hda_codec *codec) |
| 6740 | { |
| 6741 | hda_nid_t nid, end_nid; |
| 6742 | unsigned int wid_caps, wid_type; |
| 6743 | struct sigmatel_spec *spec = codec->spec; |
| 6744 | |
| 6745 | end_nid = codec->start_nid + codec->num_nodes; |
| 6746 | |
| 6747 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 6748 | wid_caps = get_wcaps(codec, nid); |
| 6749 | wid_type = get_wcaps_type(wid_caps); |
| 6750 | |
| 6751 | if (wid_type == AC_WID_PIN) |
| 6752 | stac92hd8x_add_pin(codec, nid); |
| 6753 | |
| 6754 | if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL)) |
| 6755 | stac92hd8x_add_adc(codec, nid); |
| 6756 | } |
| 6757 | |
| 6758 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 6759 | wid_caps = get_wcaps(codec, nid); |
| 6760 | wid_type = get_wcaps_type(wid_caps); |
| 6761 | |
| 6762 | if (wid_type == AC_WID_AUD_SEL) |
| 6763 | stac92hd8x_add_mux(codec, nid); |
| 6764 | } |
| 6765 | |
| 6766 | spec->pin_nids = spec->auto_pin_nids; |
| 6767 | spec->num_pins = spec->auto_pin_cnt; |
| 6768 | spec->adc_nids = spec->auto_adc_nids; |
| 6769 | spec->num_adcs = spec->auto_adc_cnt; |
| 6770 | spec->capvols = spec->auto_capvols; |
| 6771 | spec->capsws = spec->auto_capvols; |
| 6772 | spec->num_caps = spec->auto_adc_cnt; |
| 6773 | spec->mux_nids = spec->auto_mux_nids; |
| 6774 | spec->num_muxes = spec->auto_adc_cnt; |
| 6775 | spec->dmux_nids = spec->auto_dmux_nids; |
| 6776 | spec->num_dmuxes = spec->auto_adc_cnt; |
| 6777 | spec->dmic_nids = spec->auto_dmic_nids; |
| 6778 | spec->num_dmics = spec->auto_dmic_cnt; |
| 6779 | } |
| 6780 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 6781 | static void stac_setup_gpio(struct hda_codec *codec) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6782 | { |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 6783 | struct sigmatel_spec *spec = codec->spec; |
Vitaliy Kulikov | e108c7b | 2010-01-28 19:21:07 +0100 | [diff] [blame] | 6784 | |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6785 | if (spec->gpio_led) { |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6786 | if (!spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6787 | spec->gpio_mask |= spec->gpio_led; |
| 6788 | spec->gpio_dir |= spec->gpio_led; |
| 6789 | spec->gpio_data |= spec->gpio_led; |
| 6790 | } else { |
| 6791 | codec->patch_ops.set_power_state = |
| 6792 | stac92xx_set_power_state; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6793 | } |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6794 | } |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6795 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 6796 | if (spec->mic_mute_led_gpio) { |
| 6797 | spec->gpio_mask |= spec->mic_mute_led_gpio; |
| 6798 | spec->gpio_dir |= spec->mic_mute_led_gpio; |
| 6799 | spec->mic_mute_led_on = true; |
| 6800 | spec->gpio_data |= spec->mic_mute_led_gpio; |
| 6801 | } |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 6802 | } |
| 6803 | |
| 6804 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 6805 | { |
| 6806 | struct sigmatel_spec *spec; |
| 6807 | int err; |
| 6808 | |
| 6809 | err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */ |
| 6810 | if (err < 0) |
| 6811 | return err; |
| 6812 | |
| 6813 | codec->epss = 0; /* longer delay needed for D3 */ |
| 6814 | stac92hd8x_fill_auto_spec(codec); |
| 6815 | |
| 6816 | spec = codec->spec; |
| 6817 | spec->linear_tone_beep = 0; |
| 6818 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
| 6819 | spec->digbeep_nid = 0x21; |
| 6820 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
| 6821 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
| 6822 | spec->multiout.dac_nids = spec->dac_nids; |
| 6823 | |
| 6824 | snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl, |
| 6825 | stac92hd83xxx_fixups); |
| 6826 | |
| 6827 | snd_hda_add_verbs(codec, stac92hd83xxx_core_init); |
| 6828 | spec->default_polarity = -1; /* no default cfg */ |
| 6829 | |
| 6830 | codec->patch_ops = stac92xx_patch_ops; |
| 6831 | |
| 6832 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 6833 | |
| 6834 | stac_setup_gpio(codec); |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 6835 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6836 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 6837 | if (!err) |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6838 | err = -EINVAL; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6839 | if (err < 0) { |
| 6840 | stac92xx_free(codec); |
| 6841 | return err; |
| 6842 | } |
| 6843 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6844 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 6845 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 6846 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6847 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6848 | return 0; |
| 6849 | } |
| 6850 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6851 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 6852 | hda_nid_t dig0pin) |
| 6853 | { |
| 6854 | struct sigmatel_spec *spec = codec->spec; |
| 6855 | int idx; |
| 6856 | |
| 6857 | for (idx = 0; idx < spec->num_pins; idx++) |
| 6858 | if (spec->pin_nids[idx] == dig0pin) |
| 6859 | break; |
| 6860 | if ((idx + 2) >= spec->num_pins) |
| 6861 | return 0; |
| 6862 | |
| 6863 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6864 | if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6865 | return 2; |
| 6866 | |
| 6867 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6868 | if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6869 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6870 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6871 | return 1; |
| 6872 | else |
| 6873 | return 0; |
| 6874 | } |
| 6875 | |
Takashi Iwai | 75d1aeb | 2009-12-22 11:56:32 +0100 | [diff] [blame] | 6876 | /* HP dv7 bass switch - GPIO5 */ |
| 6877 | #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info |
| 6878 | static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol, |
| 6879 | struct snd_ctl_elem_value *ucontrol) |
| 6880 | { |
| 6881 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 6882 | struct sigmatel_spec *spec = codec->spec; |
| 6883 | ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20); |
| 6884 | return 0; |
| 6885 | } |
| 6886 | |
| 6887 | static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol, |
| 6888 | struct snd_ctl_elem_value *ucontrol) |
| 6889 | { |
| 6890 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 6891 | struct sigmatel_spec *spec = codec->spec; |
| 6892 | unsigned int gpio_data; |
| 6893 | |
| 6894 | gpio_data = (spec->gpio_data & ~0x20) | |
| 6895 | (ucontrol->value.integer.value[0] ? 0x20 : 0); |
| 6896 | if (gpio_data == spec->gpio_data) |
| 6897 | return 0; |
| 6898 | spec->gpio_data = gpio_data; |
| 6899 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); |
| 6900 | return 1; |
| 6901 | } |
| 6902 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6903 | static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = { |
Takashi Iwai | 75d1aeb | 2009-12-22 11:56:32 +0100 | [diff] [blame] | 6904 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6905 | .info = stac_hp_bass_gpio_info, |
| 6906 | .get = stac_hp_bass_gpio_get, |
| 6907 | .put = stac_hp_bass_gpio_put, |
| 6908 | }; |
| 6909 | |
| 6910 | static int stac_add_hp_bass_switch(struct hda_codec *codec) |
| 6911 | { |
| 6912 | struct sigmatel_spec *spec = codec->spec; |
| 6913 | |
| 6914 | if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl, |
| 6915 | "Bass Speaker Playback Switch", 0)) |
| 6916 | return -ENOMEM; |
| 6917 | |
| 6918 | spec->gpio_mask |= 0x20; |
| 6919 | spec->gpio_dir |= 0x20; |
| 6920 | spec->gpio_data |= 0x20; |
| 6921 | return 0; |
| 6922 | } |
| 6923 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6924 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 6925 | { |
| 6926 | struct sigmatel_spec *spec; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6927 | const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6928 | int err; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6929 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6930 | err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS, |
| 6931 | stac92hd71bxx_pin_nids_4port); |
| 6932 | if (err < 0) |
| 6933 | return err; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6934 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6935 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6936 | spec->linear_tone_beep = 0; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6937 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 6938 | switch (codec->vendor_id) { |
| 6939 | case 0x111d76b6: |
| 6940 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 6941 | break; |
| 6942 | case 0x111d7603: |
| 6943 | case 0x111d7608: |
| 6944 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 6945 | spec->num_pins--; |
| 6946 | /* fallthrough */ |
| 6947 | default: |
| 6948 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 6949 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6950 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6951 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6952 | snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl, |
| 6953 | stac92hd71bxx_fixups); |
| 6954 | |
| 6955 | /* GPIO0 = EAPD */ |
| 6956 | spec->gpio_mask = 0x01; |
| 6957 | spec->gpio_dir = 0x01; |
| 6958 | spec->gpio_data = 0x01; |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 6959 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6960 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 6961 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 6962 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6963 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; |
| 6964 | spec->capvols = stac92hd71bxx_capvols; |
| 6965 | spec->capsws = stac92hd71bxx_capsws; |
| 6966 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6967 | switch (codec->vendor_id) { |
| 6968 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 6969 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 6970 | unmute_init++; |
| 6971 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6972 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 6973 | case 0x111d76b5: |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 6974 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6975 | spec->num_dmics = stac92xx_connected_ports(codec, |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6976 | stac92hd71bxx_dmic_nids, |
| 6977 | STAC92HD71BXX_NUM_DMICS); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6978 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6979 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6980 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 6981 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6982 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6983 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6984 | /* disable VSW */ |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 6985 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6986 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 6987 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6988 | spec->dmic_nids = stac92hd71bxx_dmic_5port_nids; |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6989 | spec->num_dmics = stac92xx_connected_ports(codec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6990 | stac92hd71bxx_dmic_5port_nids, |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6991 | STAC92HD71BXX_NUM_DMICS - 1); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6992 | break; |
| 6993 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 6994 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6995 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6996 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6997 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6998 | default: |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 6999 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 7000 | spec->num_dmics = stac92xx_connected_ports(codec, |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 7001 | stac92hd71bxx_dmic_nids, |
| 7002 | STAC92HD71BXX_NUM_DMICS); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 7003 | break; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 7004 | } |
| 7005 | |
David Henningsson | 5e68fb3 | 2012-08-16 14:11:09 +0200 | [diff] [blame] | 7006 | if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB) |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 7007 | snd_hda_add_verbs(codec, stac92hd71bxx_core_init); |
David Henningsson | 5e68fb3 | 2012-08-16 14:11:09 +0200 | [diff] [blame] | 7008 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 7009 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 7010 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 7011 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 7012 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 7013 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 7014 | spec->aloopback_shift = 0; |
| 7015 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 7016 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 7017 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7018 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 7019 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 7020 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 7021 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7022 | |
| 7023 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 7024 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 7025 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 7026 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7027 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 7028 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Vitaliy Kulikov | 5bdaaad | 2009-11-04 07:57:45 +0100 | [diff] [blame] | 7029 | |
Takashi Iwai | 372f8c7 | 2013-01-14 18:06:34 +0100 | [diff] [blame] | 7030 | stac_setup_gpio(codec); |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 7031 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 7032 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7033 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7034 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 7035 | if (!err) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7036 | err = -EINVAL; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7037 | if (err < 0) { |
| 7038 | stac92xx_free(codec); |
| 7039 | return err; |
| 7040 | } |
| 7041 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 7042 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 7043 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 7044 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7045 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7046 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 7047 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 7048 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7049 | static int patch_stac922x(struct hda_codec *codec) |
| 7050 | { |
| 7051 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 7052 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7053 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7054 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids), |
| 7055 | stac922x_pin_nids); |
| 7056 | if (err < 0) |
| 7057 | return err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7058 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7059 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7060 | spec->linear_tone_beep = 1; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 7061 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 7062 | snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl, |
| 7063 | stac922x_fixups); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7064 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7065 | spec->adc_nids = stac922x_adc_nids; |
| 7066 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 7067 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 7068 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 7069 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 7070 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 7071 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7072 | spec->num_caps = STAC922X_NUM_CAPS; |
| 7073 | spec->capvols = stac922x_capvols; |
| 7074 | spec->capsws = stac922x_capsws; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 7075 | |
| 7076 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 7077 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 7078 | snd_hda_add_verbs(codec, stac922x_core_init); |
| 7079 | |
| 7080 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 7081 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7082 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 7083 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 7084 | err = -EINVAL; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7085 | if (err < 0) { |
| 7086 | stac92xx_free(codec); |
| 7087 | return err; |
| 7088 | } |
| 7089 | |
| 7090 | codec->patch_ops = stac92xx_patch_ops; |
| 7091 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 7092 | /* Fix Mux capture level; max to 2 */ |
| 7093 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 7094 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 7095 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 7096 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 7097 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 7098 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 7099 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7100 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7101 | return 0; |
| 7102 | } |
| 7103 | |
| 7104 | static int patch_stac927x(struct hda_codec *codec) |
| 7105 | { |
| 7106 | struct sigmatel_spec *spec; |
| 7107 | int err; |
| 7108 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7109 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids), |
| 7110 | stac927x_pin_nids); |
| 7111 | if (err < 0) |
| 7112 | return err; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7113 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7114 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7115 | spec->linear_tone_beep = 1; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 7116 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7117 | |
| 7118 | snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl, |
| 7119 | stac927x_fixups); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7120 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 7121 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 7122 | spec->adc_nids = stac927x_adc_nids; |
| 7123 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 7124 | spec->mux_nids = stac927x_mux_nids; |
| 7125 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 7126 | spec->smux_nids = stac927x_smux_nids; |
| 7127 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 7128 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 7129 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 7130 | spec->multiout.dac_nids = spec->dac_nids; |
| 7131 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7132 | /* GPIO0 High = Enable EAPD */ |
| 7133 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 7134 | spec->gpio_dir = spec->gpio_data = 0x01; |
Takashi Iwai | af6ee30 | 2009-09-14 15:03:12 +0200 | [diff] [blame] | 7135 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7136 | spec->num_dmics = 0; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7137 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7138 | spec->num_caps = STAC927X_NUM_CAPS; |
| 7139 | spec->capvols = stac927x_capvols; |
| 7140 | spec->capsws = stac927x_capsws; |
| 7141 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 7142 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 7143 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7144 | spec->aloopback_mask = 0x40; |
| 7145 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 7146 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 7147 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7148 | if (!spec->volknob_init) |
| 7149 | snd_hda_add_verbs(codec, stac927x_core_init); |
| 7150 | |
| 7151 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 7152 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7153 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7154 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 7155 | err = -EINVAL; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 7156 | if (err < 0) { |
| 7157 | stac92xx_free(codec); |
| 7158 | return err; |
| 7159 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7160 | |
| 7161 | codec->patch_ops = stac92xx_patch_ops; |
| 7162 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 7163 | codec->proc_widget_hook = stac927x_proc_hook; |
| 7164 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 7165 | /* |
| 7166 | * !!FIXME!! |
| 7167 | * The STAC927x seem to require fairly long delays for certain |
| 7168 | * command sequences. With too short delays (even if the answer |
| 7169 | * is set to RIRB properly), it results in the silence output |
| 7170 | * on some hardwares like Dell. |
| 7171 | * |
| 7172 | * The below flag enables the longer delay (see get_response |
| 7173 | * in hda_intel.c). |
| 7174 | */ |
| 7175 | codec->bus->needs_damn_long_delay = 1; |
| 7176 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7177 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 7178 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7179 | return 0; |
| 7180 | } |
| 7181 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7182 | static int patch_stac9205(struct hda_codec *codec) |
| 7183 | { |
| 7184 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 7185 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7186 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7187 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids), |
| 7188 | stac9205_pin_nids); |
| 7189 | if (err < 0) |
| 7190 | return err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7191 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7192 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7193 | spec->linear_tone_beep = 1; |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7194 | |
| 7195 | snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl, |
| 7196 | stac9205_fixups); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7197 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 7198 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7199 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 7200 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7201 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 7202 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 7203 | spec->smux_nids = stac9205_smux_nids; |
| 7204 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 7205 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 7206 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7207 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 7208 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 7209 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7210 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7211 | snd_hda_add_verbs(codec, stac9205_core_init); |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 7212 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7213 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7214 | spec->num_caps = STAC9205_NUM_CAPS; |
| 7215 | spec->capvols = stac9205_capvols; |
| 7216 | spec->capsws = stac9205_capsws; |
| 7217 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7218 | spec->aloopback_mask = 0x40; |
| 7219 | spec->aloopback_shift = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7220 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 7221 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7222 | /* GPIO0 High = EAPD */ |
| 7223 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 7224 | spec->gpio_data = 0x01; |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 7225 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7226 | /* Turn on/off EAPD per HP plugging */ |
| 7227 | spec->eapd_switch = 1; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 7228 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7229 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 7230 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7231 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7232 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 7233 | err = -EINVAL; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7234 | if (err < 0) { |
| 7235 | stac92xx_free(codec); |
| 7236 | return err; |
| 7237 | } |
| 7238 | |
| 7239 | codec->patch_ops = stac92xx_patch_ops; |
| 7240 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 7241 | codec->proc_widget_hook = stac9205_proc_hook; |
| 7242 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7243 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7244 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7245 | return 0; |
| 7246 | } |
| 7247 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7248 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 7249 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7250 | */ |
| 7251 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7252 | static const struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 7253 | {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] | 7254 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 7255 | {} |
| 7256 | }; |
| 7257 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7258 | static const hda_nid_t stac9872_pin_nids[] = { |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7259 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 7260 | 0x11, 0x13, 0x14, |
| 7261 | }; |
| 7262 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7263 | static const hda_nid_t stac9872_adc_nids[] = { |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7264 | 0x8 /*,0x6*/ |
| 7265 | }; |
| 7266 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7267 | static const hda_nid_t stac9872_mux_nids[] = { |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7268 | 0x15 |
| 7269 | }; |
| 7270 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7271 | static const unsigned long stac9872_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7272 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), |
| 7273 | }; |
| 7274 | #define stac9872_capsws stac9872_capvols |
| 7275 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7276 | static const struct hda_pintbl stac9872_vaio_pin_configs[] = { |
| 7277 | { 0x0a, 0x03211020 }, |
| 7278 | { 0x0b, 0x411111f0 }, |
| 7279 | { 0x0c, 0x411111f0 }, |
| 7280 | { 0x0d, 0x03a15030 }, |
| 7281 | { 0x0e, 0x411111f0 }, |
| 7282 | { 0x0f, 0x90170110 }, |
| 7283 | { 0x11, 0x411111f0 }, |
| 7284 | { 0x13, 0x411111f0 }, |
| 7285 | { 0x14, 0x90a7013e }, |
| 7286 | {} |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7287 | }; |
| 7288 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7289 | static const struct hda_model_fixup stac9872_models[] = { |
| 7290 | { .id = STAC_9872_VAIO, .name = "vaio" }, |
| 7291 | {} |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7292 | }; |
| 7293 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7294 | static const struct hda_fixup stac9872_fixups[] = { |
| 7295 | [STAC_9872_VAIO] = { |
| 7296 | .type = HDA_FIXUP_PINS, |
| 7297 | .v.pins = stac9872_vaio_pin_configs, |
| 7298 | }, |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7299 | }; |
| 7300 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7301 | static const struct snd_pci_quirk stac9872_fixup_tbl[] = { |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 7302 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, |
| 7303 | "Sony VAIO F/S", STAC_9872_VAIO), |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7304 | {} /* terminator */ |
| 7305 | }; |
| 7306 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 7307 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7308 | { |
| 7309 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7310 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7311 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7312 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids), |
| 7313 | stac9872_pin_nids); |
| 7314 | if (err < 0) |
| 7315 | return err; |
| 7316 | |
| 7317 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7318 | spec->linear_tone_beep = 1; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7319 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7320 | snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl, |
| 7321 | stac9872_fixups); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7322 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7323 | spec->multiout.dac_nids = spec->dac_nids; |
| 7324 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 7325 | spec->adc_nids = stac9872_adc_nids; |
| 7326 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 7327 | spec->mux_nids = stac9872_mux_nids; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7328 | spec->num_caps = 1; |
| 7329 | spec->capvols = stac9872_capvols; |
| 7330 | spec->capsws = stac9872_capsws; |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7331 | snd_hda_add_verbs(codec, stac9872_core_init); |
| 7332 | |
| 7333 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7334 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7335 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7336 | if (err < 0) { |
| 7337 | stac92xx_free(codec); |
| 7338 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7339 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7340 | spec->input_mux = &spec->private_imux; |
| 7341 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7342 | |
| 7343 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7344 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7345 | return 0; |
| 7346 | } |
| 7347 | |
| 7348 | |
| 7349 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7350 | * patch entries |
| 7351 | */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7352 | static const struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7353 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 7354 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 7355 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 7356 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 7357 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 7358 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 7359 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 7360 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 7361 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 7362 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 7363 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 7364 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 7365 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7366 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 7367 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 7368 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 7369 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 7370 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 7371 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 7372 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 7373 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 7374 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 7375 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 7376 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 7377 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 7378 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 7379 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 7380 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 7381 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 7382 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 7383 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 7384 | /* The following does not take into account .id=0x83847661 when subsys = |
| 7385 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 7386 | * currently not fully supported. |
| 7387 | */ |
| 7388 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 7389 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 7390 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 7391 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7392 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 7393 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 7394 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 7395 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 7396 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 7397 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 7398 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 7399 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 7400 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 7401 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | a9694fa | 2010-02-04 08:58:23 +0100 | [diff] [blame] | 7402 | { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 7403 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 7404 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Charles Chin | 8a345a0 | 2010-08-10 11:43:25 +0200 | [diff] [blame] | 7405 | { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx}, |
| 7406 | { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx}, |
Charles Chin | 3670600 | 2010-01-29 12:05:51 +0100 | [diff] [blame] | 7407 | { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx}, |
| 7408 | { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx}, |
| 7409 | { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx}, |
| 7410 | { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 7411 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 7412 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 7413 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7414 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 7415 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 7416 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 7417 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 7418 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 7419 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 7420 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 7421 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 7422 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Charles Chin | 4d8ec5f | 2010-08-19 08:06:16 +0200 | [diff] [blame] | 7423 | { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx }, |
| 7424 | { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx }, |
| 7425 | { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx }, |
| 7426 | { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx }, |
| 7427 | { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx }, |
| 7428 | { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx }, |
| 7429 | { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx }, |
| 7430 | { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx }, |
| 7431 | { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx }, |
| 7432 | { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx }, |
| 7433 | { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx }, |
| 7434 | { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx }, |
| 7435 | { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx }, |
| 7436 | { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx }, |
| 7437 | { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx }, |
David Henningsson | 46724c2 | 2011-09-20 09:02:22 +0200 | [diff] [blame] | 7438 | { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 7439 | { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | 4dfb8a4 | 2011-02-22 17:32:19 -0600 | [diff] [blame] | 7440 | { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx}, |
| 7441 | { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 7442 | { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx}, |
Charles Chin | ad5d875 | 2011-11-02 07:56:58 +0100 | [diff] [blame] | 7443 | { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx}, |
| 7444 | { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx}, |
| 7445 | { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx}, |
| 7446 | { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx}, |
| 7447 | { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx}, |
| 7448 | { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx}, |
| 7449 | { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx}, |
| 7450 | { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx}, |
| 7451 | { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx}, |
| 7452 | { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx}, |
| 7453 | { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx}, |
| 7454 | { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7455 | {} /* terminator */ |
| 7456 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7457 | |
| 7458 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 7459 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 7460 | |
| 7461 | MODULE_LICENSE("GPL"); |
| 7462 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 7463 | |
| 7464 | static struct hda_codec_preset_list sigmatel_list = { |
| 7465 | .preset = snd_hda_preset_sigmatel, |
| 7466 | .owner = THIS_MODULE, |
| 7467 | }; |
| 7468 | |
| 7469 | static int __init patch_sigmatel_init(void) |
| 7470 | { |
| 7471 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 7472 | } |
| 7473 | |
| 7474 | static void __exit patch_sigmatel_exit(void) |
| 7475 | { |
| 7476 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 7477 | } |
| 7478 | |
| 7479 | module_init(patch_sigmatel_init) |
| 7480 | module_exit(patch_sigmatel_exit) |