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 { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 94 | STAC_92HD83XXX_AUTO, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 95 | STAC_92HD83XXX_REF, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 96 | STAC_92HD83XXX_PWR_REF, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 97 | STAC_DELL_S14, |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 98 | STAC_DELL_VOSTRO_3500, |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 99 | STAC_92HD83XXX_HP_cNB11_INTQUAD, |
Steven Eastland | 4831559 | 2010-08-06 15:07:35 -0600 | [diff] [blame] | 100 | STAC_HP_DV7_4000, |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 101 | STAC_HP_ZEPHYR, |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 102 | STAC_92HD83XXX_HP_LED, |
Takashi Iwai | ff8a1e2 | 2012-07-31 10:16:59 +0200 | [diff] [blame] | 103 | STAC_92HD83XXX_HP_INV_LED, |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 104 | STAC_92HD83XXX_HP_MIC_LED, |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 105 | STAC_92HD83XXX_HEADSET_JACK, |
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; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 212 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 213 | unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */ |
| 214 | bool mic_mute_led_on; /* current mic mute state */ |
| 215 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 216 | /* stream */ |
| 217 | unsigned int stream_delay; |
| 218 | |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 219 | /* analog loopback */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 220 | const struct snd_kcontrol_new *aloopback_ctl; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 221 | unsigned char aloopback_mask; |
| 222 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 223 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 224 | /* power management */ |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 225 | unsigned int power_map_bits; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 226 | unsigned int num_pwrs; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 227 | const hda_nid_t *pwr_nids; |
| 228 | const hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 229 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 230 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 231 | struct hda_input_mux *mono_mux; |
| 232 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 233 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 234 | hda_nid_t dac_nids[5]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 235 | hda_nid_t hp_dacs[5]; |
| 236 | hda_nid_t speaker_dacs[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 237 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 238 | int volume_offset; |
| 239 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 240 | /* capture */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 241 | const hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 242 | unsigned int num_adcs; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 243 | const hda_nid_t *mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 244 | unsigned int num_muxes; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 245 | const hda_nid_t *dmic_nids; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 246 | unsigned int num_dmics; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 247 | const hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 248 | unsigned int num_dmuxes; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 249 | const hda_nid_t *smux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 250 | unsigned int num_smuxes; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 251 | unsigned int num_analog_muxes; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 252 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 253 | const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */ |
| 254 | const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */ |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 255 | unsigned int num_caps; /* number of capture volume/switch elements */ |
| 256 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 257 | struct sigmatel_mic_route ext_mic; |
| 258 | struct sigmatel_mic_route int_mic; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 259 | struct sigmatel_mic_route dock_mic; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 260 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 261 | const char * const *spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 262 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 263 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 264 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 265 | hda_nid_t anabeep_nid; |
| 266 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 267 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 268 | /* pin widgets */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 269 | const hda_nid_t *pin_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 270 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 271 | |
| 272 | /* codec specific stuff */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 273 | const struct hda_verb *init; |
| 274 | const struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 275 | |
| 276 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 277 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 278 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 279 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 280 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 281 | struct hda_input_mux *sinput_mux; |
| 282 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 283 | unsigned int cur_amux; |
| 284 | hda_nid_t *amp_nids; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 285 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 286 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 287 | /* i/o switches */ |
| 288 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 289 | unsigned int clfe_swap; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 290 | hda_nid_t line_switch; /* shared line-in for input and output */ |
| 291 | hda_nid_t mic_switch; /* shared mic-in for input and output */ |
| 292 | hda_nid_t hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 293 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 294 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 295 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 296 | |
| 297 | /* dynamic controls and input_mux */ |
| 298 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 299 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 300 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 301 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 302 | struct hda_input_mux private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 303 | struct hda_input_mux private_mono_mux; |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 304 | |
| 305 | /* auto spec */ |
| 306 | unsigned auto_pin_cnt; |
| 307 | hda_nid_t auto_pin_nids[MAX_PINS_NUM]; |
| 308 | unsigned auto_adc_cnt; |
| 309 | hda_nid_t auto_adc_nids[MAX_ADCS_NUM]; |
| 310 | hda_nid_t auto_mux_nids[MAX_ADCS_NUM]; |
| 311 | hda_nid_t auto_dmux_nids[MAX_ADCS_NUM]; |
| 312 | unsigned long auto_capvols[MAX_ADCS_NUM]; |
| 313 | unsigned auto_dmic_cnt; |
| 314 | hda_nid_t auto_dmic_nids[MAX_DMICS_NUM]; |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 315 | |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 316 | struct hda_vmaster_mute_hook vmaster_mute; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 317 | }; |
| 318 | |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 319 | #define AC_VERB_IDT_SET_POWER_MAP 0x7ec |
| 320 | #define AC_VERB_IDT_GET_POWER_MAP 0xfec |
| 321 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 322 | static const hda_nid_t stac9200_adc_nids[1] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 323 | 0x03, |
| 324 | }; |
| 325 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 326 | static const hda_nid_t stac9200_mux_nids[1] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 327 | 0x0c, |
| 328 | }; |
| 329 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 330 | static const hda_nid_t stac9200_dac_nids[1] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 331 | 0x02, |
| 332 | }; |
| 333 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 334 | static const hda_nid_t stac92hd73xx_pwr_nids[8] = { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 335 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 336 | 0x0f, 0x10, 0x11 |
| 337 | }; |
| 338 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 339 | static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 340 | 0x26, 0, |
| 341 | }; |
| 342 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 343 | static const hda_nid_t stac92hd73xx_adc_nids[2] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 344 | 0x1a, 0x1b |
| 345 | }; |
| 346 | |
| 347 | #define STAC92HD73XX_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 348 | static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 349 | 0x13, 0x14, 0 |
| 350 | }; |
| 351 | |
| 352 | #define STAC92HD73_DAC_COUNT 5 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 353 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 354 | static const hda_nid_t stac92hd73xx_mux_nids[2] = { |
Takashi Iwai | e2aec17 | 2009-09-02 01:00:05 +0200 | [diff] [blame] | 355 | 0x20, 0x21, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 356 | }; |
| 357 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 358 | static const hda_nid_t stac92hd73xx_dmux_nids[2] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 359 | 0x20, 0x21, |
| 360 | }; |
| 361 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 362 | static const hda_nid_t stac92hd73xx_smux_nids[2] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 363 | 0x22, 0x23, |
| 364 | }; |
| 365 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 366 | #define STAC92HD73XX_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 367 | static const unsigned long stac92hd73xx_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 368 | HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT), |
| 369 | HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT), |
| 370 | }; |
| 371 | #define stac92hd73xx_capsws stac92hd73xx_capvols |
| 372 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 373 | #define STAC92HD83_DAC_COUNT 3 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 374 | |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 375 | static const hda_nid_t stac92hd83xxx_pwr_nids[7] = { |
| 376 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 377 | 0x0f, 0x10 |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 378 | }; |
| 379 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 380 | static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 381 | 0x1e, 0, |
| 382 | }; |
| 383 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 384 | static const hda_nid_t stac92hd83xxx_dmic_nids[] = { |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 385 | 0x11, 0x20, |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 386 | }; |
| 387 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 388 | static const hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 389 | 0x0a, 0x0d, 0x0f |
| 390 | }; |
| 391 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 392 | static const hda_nid_t stac92hd71bxx_adc_nids[2] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 393 | 0x12, 0x13, |
| 394 | }; |
| 395 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 396 | static const hda_nid_t stac92hd71bxx_mux_nids[2] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 397 | 0x1a, 0x1b |
| 398 | }; |
| 399 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 400 | static const hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 401 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 402 | }; |
| 403 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 404 | static const hda_nid_t stac92hd71bxx_smux_nids[2] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 405 | 0x24, 0x25, |
| 406 | }; |
| 407 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 408 | #define STAC92HD71BXX_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 409 | static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 410 | 0x18, 0x19, 0 |
| 411 | }; |
| 412 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 413 | static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = { |
| 414 | 0x18, 0 |
| 415 | }; |
| 416 | |
| 417 | static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 418 | 0x22, 0 |
| 419 | }; |
| 420 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 421 | #define STAC92HD71BXX_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 422 | static const unsigned long stac92hd71bxx_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 423 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 424 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 425 | }; |
| 426 | #define stac92hd71bxx_capsws stac92hd71bxx_capvols |
| 427 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 428 | static const hda_nid_t stac925x_adc_nids[1] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 429 | 0x03, |
| 430 | }; |
| 431 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 432 | static const hda_nid_t stac925x_mux_nids[1] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 433 | 0x0f, |
| 434 | }; |
| 435 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 436 | static const hda_nid_t stac925x_dac_nids[1] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 437 | 0x02, |
| 438 | }; |
| 439 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 440 | #define STAC925X_NUM_DMICS 1 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 441 | static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 442 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 443 | }; |
| 444 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 445 | static const hda_nid_t stac925x_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 446 | 0x14, |
| 447 | }; |
| 448 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 449 | static const unsigned long stac925x_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 450 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT), |
| 451 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 452 | static const unsigned long stac925x_capsws[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 453 | HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT), |
| 454 | }; |
| 455 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 456 | static const hda_nid_t stac922x_adc_nids[2] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 457 | 0x06, 0x07, |
| 458 | }; |
| 459 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 460 | static const hda_nid_t stac922x_mux_nids[2] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 461 | 0x12, 0x13, |
| 462 | }; |
| 463 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 464 | #define STAC922X_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 465 | static const unsigned long stac922x_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 466 | HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT), |
| 467 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 468 | }; |
| 469 | #define stac922x_capsws stac922x_capvols |
| 470 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 471 | static const hda_nid_t stac927x_slave_dig_outs[2] = { |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 472 | 0x1f, 0, |
| 473 | }; |
| 474 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 475 | static const hda_nid_t stac927x_adc_nids[3] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 476 | 0x07, 0x08, 0x09 |
| 477 | }; |
| 478 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 479 | static const hda_nid_t stac927x_mux_nids[3] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 480 | 0x15, 0x16, 0x17 |
| 481 | }; |
| 482 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 483 | static const hda_nid_t stac927x_smux_nids[1] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 484 | 0x21, |
| 485 | }; |
| 486 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 487 | static const hda_nid_t stac927x_dac_nids[6] = { |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 488 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 489 | }; |
| 490 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 491 | static const hda_nid_t stac927x_dmux_nids[1] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 492 | 0x1b, |
| 493 | }; |
| 494 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 495 | #define STAC927X_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 496 | static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 497 | 0x13, 0x14, 0 |
| 498 | }; |
| 499 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 500 | #define STAC927X_NUM_CAPS 3 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 501 | static const unsigned long stac927x_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 502 | HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT), |
| 503 | HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT), |
| 504 | HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT), |
| 505 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 506 | static const unsigned long stac927x_capsws[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 507 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT), |
| 508 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT), |
| 509 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 510 | }; |
| 511 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 512 | static const char * const stac927x_spdif_labels[5] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 513 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 514 | "Analog Mux 2", "Analog Mux 3" |
| 515 | }; |
| 516 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 517 | static const hda_nid_t stac9205_adc_nids[2] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 518 | 0x12, 0x13 |
| 519 | }; |
| 520 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 521 | static const hda_nid_t stac9205_mux_nids[2] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 522 | 0x19, 0x1a |
| 523 | }; |
| 524 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 525 | static const hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 526 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 527 | }; |
| 528 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 529 | static const hda_nid_t stac9205_smux_nids[1] = { |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 530 | 0x21, |
| 531 | }; |
| 532 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 533 | #define STAC9205_NUM_DMICS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 534 | static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 535 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 536 | }; |
| 537 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 538 | #define STAC9205_NUM_CAPS 2 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 539 | static const unsigned long stac9205_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 540 | HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT), |
| 541 | HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT), |
| 542 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 543 | static const unsigned long stac9205_capsws[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 544 | HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT), |
| 545 | HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT), |
| 546 | }; |
| 547 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 548 | static const hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 549 | 0x08, 0x09, 0x0d, 0x0e, |
| 550 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 551 | }; |
| 552 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 553 | static const hda_nid_t stac925x_pin_nids[8] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 554 | 0x07, 0x08, 0x0a, 0x0b, |
| 555 | 0x0c, 0x0d, 0x10, 0x11, |
| 556 | }; |
| 557 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 558 | static const hda_nid_t stac922x_pin_nids[10] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 559 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 560 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 561 | }; |
| 562 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 563 | static const hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 564 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 565 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 566 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 567 | }; |
| 568 | |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 569 | #define STAC92HD71BXX_NUM_PINS 13 |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 570 | 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] | 571 | 0x0a, 0x0b, 0x0c, 0x0d, 0x00, |
| 572 | 0x00, 0x14, 0x18, 0x19, 0x1e, |
| 573 | 0x1f, 0x20, 0x27 |
| 574 | }; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 575 | static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 576 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 577 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 578 | 0x1f, 0x20, 0x27 |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 579 | }; |
| 580 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 581 | static const hda_nid_t stac927x_pin_nids[14] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 582 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 583 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 584 | 0x14, 0x21, 0x22, 0x23, |
| 585 | }; |
| 586 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 587 | static const hda_nid_t stac9205_pin_nids[12] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 588 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 589 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 590 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 591 | }; |
| 592 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 593 | static int stac_add_event(struct hda_codec *codec, hda_nid_t nid, |
| 594 | unsigned char type, int data); |
| 595 | static int stac_add_hp_bass_switch(struct hda_codec *codec); |
| 596 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, |
| 597 | hda_nid_t nid, int pin_type); |
| 598 | static int hp_blike_system(u32 subsystem_id); |
| 599 | static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity); |
| 600 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 601 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 602 | struct snd_ctl_elem_info *uinfo) |
| 603 | { |
| 604 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 605 | struct sigmatel_spec *spec = codec->spec; |
| 606 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 607 | } |
| 608 | |
| 609 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 610 | struct snd_ctl_elem_value *ucontrol) |
| 611 | { |
| 612 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 613 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 614 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 615 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 616 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 621 | struct snd_ctl_elem_value *ucontrol) |
| 622 | { |
| 623 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 624 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 625 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 626 | |
| 627 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 628 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 629 | } |
| 630 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 631 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 632 | struct snd_ctl_elem_info *uinfo) |
| 633 | { |
| 634 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 635 | struct sigmatel_spec *spec = codec->spec; |
| 636 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 637 | } |
| 638 | |
| 639 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 640 | struct snd_ctl_elem_value *ucontrol) |
| 641 | { |
| 642 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 643 | struct sigmatel_spec *spec = codec->spec; |
| 644 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 645 | |
| 646 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 651 | struct snd_ctl_elem_value *ucontrol) |
| 652 | { |
| 653 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 654 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 655 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 656 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 657 | int err, val; |
| 658 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 659 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 660 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 661 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 662 | if (err < 0) |
| 663 | return err; |
| 664 | |
| 665 | if (spec->spdif_mute) { |
| 666 | if (smux_idx == 0) |
| 667 | nid = spec->multiout.dig_out_nid; |
| 668 | else |
| 669 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 670 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 671 | val = HDA_AMP_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 672 | else |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 673 | val = 0; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 674 | /* un/mute SPDIF out */ |
Takashi Iwai | c9b46f9 | 2008-12-01 11:42:09 +0100 | [diff] [blame] | 675 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 676 | HDA_AMP_MUTE, val); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 677 | } |
| 678 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 679 | } |
| 680 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 681 | static int stac_vrefout_set(struct hda_codec *codec, |
| 682 | hda_nid_t nid, unsigned int new_vref) |
| 683 | { |
| 684 | int error, pinctl; |
| 685 | |
| 686 | snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref); |
| 687 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 688 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 689 | |
| 690 | if (pinctl < 0) |
| 691 | return pinctl; |
| 692 | |
| 693 | pinctl &= 0xff; |
| 694 | pinctl &= ~AC_PINCTL_VREFEN; |
| 695 | pinctl |= (new_vref & AC_PINCTL_VREFEN); |
| 696 | |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 697 | error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl); |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 698 | if (error < 0) |
| 699 | return error; |
| 700 | |
| 701 | return 1; |
| 702 | } |
| 703 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 704 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 705 | hda_nid_t nid, unsigned int new_vref) |
| 706 | { |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 707 | int error; |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 708 | unsigned int pincfg; |
| 709 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 710 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 711 | |
| 712 | pincfg &= 0xff; |
| 713 | pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 714 | pincfg |= new_vref; |
| 715 | |
| 716 | if (new_vref == AC_PINCTL_VREF_HIZ) |
| 717 | pincfg |= AC_PINCTL_OUT_EN; |
| 718 | else |
| 719 | pincfg |= AC_PINCTL_IN_EN; |
| 720 | |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 721 | error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg); |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 722 | if (error < 0) |
| 723 | return error; |
| 724 | else |
| 725 | return 1; |
| 726 | } |
| 727 | |
| 728 | static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid) |
| 729 | { |
| 730 | unsigned int vref; |
| 731 | vref = snd_hda_codec_read(codec, nid, 0, |
| 732 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 733 | vref &= AC_PINCTL_VREFEN; |
| 734 | return vref; |
| 735 | } |
| 736 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 737 | 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] | 738 | { |
| 739 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 740 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 741 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 742 | } |
| 743 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 744 | 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] | 745 | { |
| 746 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 747 | struct sigmatel_spec *spec = codec->spec; |
| 748 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 749 | |
| 750 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 751 | return 0; |
| 752 | } |
| 753 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 754 | 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] | 755 | { |
| 756 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 757 | struct sigmatel_spec *spec = codec->spec; |
| 758 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 759 | const struct hda_input_mux *imux = spec->input_mux; |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 760 | unsigned int idx, prev_idx, didx; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 761 | |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 762 | idx = ucontrol->value.enumerated.item[0]; |
| 763 | if (idx >= imux->num_items) |
| 764 | idx = imux->num_items - 1; |
| 765 | prev_idx = spec->cur_mux[adc_idx]; |
| 766 | if (prev_idx == idx) |
| 767 | return 0; |
| 768 | if (idx < spec->num_analog_muxes) { |
| 769 | snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0, |
| 770 | AC_VERB_SET_CONNECT_SEL, |
| 771 | imux->items[idx].index); |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 772 | if (prev_idx >= spec->num_analog_muxes && |
| 773 | spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) { |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 774 | imux = spec->dinput_mux; |
| 775 | /* 0 = analog */ |
| 776 | snd_hda_codec_write_cache(codec, |
| 777 | spec->dmux_nids[adc_idx], 0, |
| 778 | AC_VERB_SET_CONNECT_SEL, |
| 779 | imux->items[0].index); |
| 780 | } |
| 781 | } else { |
| 782 | imux = spec->dinput_mux; |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 783 | /* first dimux item is hardcoded to select analog imux, |
| 784 | * so lets skip it |
| 785 | */ |
| 786 | didx = idx - spec->num_analog_muxes + 1; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 787 | snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0, |
| 788 | AC_VERB_SET_CONNECT_SEL, |
Vitaliy Kulikov | 094a424 | 2011-03-09 19:47:43 -0600 | [diff] [blame] | 789 | imux->items[didx].index); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 790 | } |
| 791 | spec->cur_mux[adc_idx] = idx; |
| 792 | return 1; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 793 | } |
| 794 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 795 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 796 | struct snd_ctl_elem_info *uinfo) |
| 797 | { |
| 798 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 799 | struct sigmatel_spec *spec = codec->spec; |
| 800 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 801 | } |
| 802 | |
| 803 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 804 | struct snd_ctl_elem_value *ucontrol) |
| 805 | { |
| 806 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 807 | struct sigmatel_spec *spec = codec->spec; |
| 808 | |
| 809 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 810 | return 0; |
| 811 | } |
| 812 | |
| 813 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 814 | struct snd_ctl_elem_value *ucontrol) |
| 815 | { |
| 816 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 817 | struct sigmatel_spec *spec = codec->spec; |
| 818 | |
| 819 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 820 | spec->mono_nid, &spec->cur_mmux); |
| 821 | } |
| 822 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 823 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 824 | |
| 825 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 826 | struct snd_ctl_elem_value *ucontrol) |
| 827 | { |
| 828 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 829 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 830 | struct sigmatel_spec *spec = codec->spec; |
| 831 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 832 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 833 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 834 | return 0; |
| 835 | } |
| 836 | |
| 837 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 838 | struct snd_ctl_elem_value *ucontrol) |
| 839 | { |
| 840 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 841 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 842 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 843 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 844 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 845 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 846 | idx_val = spec->aloopback_mask << idx; |
| 847 | if (ucontrol->value.integer.value[0]) |
| 848 | val = spec->aloopback | idx_val; |
| 849 | else |
| 850 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 851 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 852 | return 0; |
| 853 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 854 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 855 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 856 | /* Only return the bits defined by the shift value of the |
| 857 | * first two bytes of the mask |
| 858 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 859 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 860 | kcontrol->private_value & 0xFFFF, 0x0); |
| 861 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 862 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 863 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 864 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 865 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 866 | } else { |
| 867 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 868 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 872 | kcontrol->private_value >> 16, dac_mode); |
| 873 | |
| 874 | return 1; |
| 875 | } |
| 876 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 877 | static const struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 878 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 879 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 880 | {} |
| 881 | }; |
| 882 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 883 | static const struct hda_verb stac9200_eapd_init[] = { |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 884 | /* set dac0mux for dac converter */ |
| 885 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 886 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 887 | {} |
| 888 | }; |
| 889 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 890 | static const struct hda_verb dell_eq_core_init[] = { |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 891 | /* set master volume to max value without distortion |
| 892 | * and direct control */ |
| 893 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 894 | {} |
| 895 | }; |
| 896 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 897 | static const struct hda_verb stac92hd73xx_core_init[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 898 | /* set master volume and direct control */ |
| 899 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 900 | {} |
| 901 | }; |
| 902 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 903 | static const struct hda_verb stac92hd83xxx_core_init[] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 904 | /* power state controls amps */ |
| 905 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 906 | {} |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 907 | }; |
| 908 | |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 909 | static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = { |
| 910 | { 0x22, 0x785, 0x43 }, |
| 911 | { 0x22, 0x782, 0xe0 }, |
| 912 | { 0x22, 0x795, 0x00 }, |
| 913 | {} |
| 914 | }; |
| 915 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 916 | static const struct hda_verb stac92hd71bxx_core_init[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 917 | /* set master volume and direct control */ |
| 918 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 919 | {} |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 920 | }; |
| 921 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 922 | static const struct hda_verb stac92hd71bxx_unmute_core_init[] = { |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 923 | /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ |
| 924 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 925 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 926 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 927 | {} |
| 928 | }; |
| 929 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 930 | static const struct hda_verb stac925x_core_init[] = { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 931 | /* set dac0mux for dac converter */ |
| 932 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 933 | /* mute the master volume */ |
| 934 | { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 935 | {} |
| 936 | }; |
| 937 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 938 | static const struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 939 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 940 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 941 | {} |
| 942 | }; |
| 943 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 944 | static const struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 945 | /* unmute node 0x1b */ |
| 946 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 947 | /* select node 0x03 as DAC */ |
| 948 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 949 | {} |
| 950 | }; |
| 951 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 952 | static const struct hda_verb dell_3st_core_init[] = { |
Takashi Iwai | ccca7cd | 2009-10-13 15:32:21 +0200 | [diff] [blame] | 953 | /* don't set delta bit */ |
| 954 | {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f}, |
| 955 | /* unmute node 0x1b */ |
| 956 | {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 957 | /* select node 0x03 as DAC */ |
| 958 | {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 959 | {} |
| 960 | }; |
| 961 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 962 | static const struct hda_verb stac927x_core_init[] = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 963 | /* set master volume and direct control */ |
| 964 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 965 | /* enable analog pc beep path */ |
| 966 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 967 | {} |
| 968 | }; |
| 969 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 970 | static const struct hda_verb stac927x_volknob_core_init[] = { |
Takashi Iwai | 5493053 | 2009-10-11 17:38:29 +0200 | [diff] [blame] | 971 | /* don't set delta bit */ |
| 972 | {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f}, |
| 973 | /* enable analog pc beep path */ |
| 974 | {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
| 975 | {} |
| 976 | }; |
| 977 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 978 | static const struct hda_verb stac9205_core_init[] = { |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 979 | /* set master volume and direct control */ |
| 980 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 981 | /* enable analog pc beep path */ |
| 982 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 983 | {} |
| 984 | }; |
| 985 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 986 | #define STAC_MONO_MUX \ |
| 987 | { \ |
| 988 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 989 | .name = "Mono Mux", \ |
| 990 | .count = 1, \ |
| 991 | .info = stac92xx_mono_mux_enum_info, \ |
| 992 | .get = stac92xx_mono_mux_enum_get, \ |
| 993 | .put = stac92xx_mono_mux_enum_put, \ |
| 994 | } |
| 995 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 996 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 997 | { \ |
| 998 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 999 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1000 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1001 | .info = stac92xx_aloopback_info, \ |
| 1002 | .get = stac92xx_aloopback_get, \ |
| 1003 | .put = stac92xx_aloopback_put, \ |
| 1004 | .private_value = verb_read | (verb_write << 16), \ |
| 1005 | } |
| 1006 | |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 1007 | #define DC_BIAS(xname, idx, nid) \ |
| 1008 | { \ |
| 1009 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1010 | .name = xname, \ |
| 1011 | .index = idx, \ |
| 1012 | .info = stac92xx_dc_bias_info, \ |
| 1013 | .get = stac92xx_dc_bias_get, \ |
| 1014 | .put = stac92xx_dc_bias_put, \ |
| 1015 | .private_value = nid, \ |
| 1016 | } |
| 1017 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1018 | static const struct snd_kcontrol_new stac9200_mixer[] = { |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1019 | HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1020 | HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1021 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1022 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1023 | { } /* end */ |
| 1024 | }; |
| 1025 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1026 | static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1027 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1028 | {} |
| 1029 | }; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1030 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1031 | static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1032 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1033 | {} |
| 1034 | }; |
| 1035 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1036 | static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1037 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1038 | {} |
| 1039 | }; |
| 1040 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1041 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1042 | static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1043 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) |
| 1044 | }; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1045 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1046 | static const struct snd_kcontrol_new stac925x_mixer[] = { |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1047 | HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT), |
| 1048 | HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1049 | { } /* end */ |
| 1050 | }; |
| 1051 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1052 | static const struct snd_kcontrol_new stac9205_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1053 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
| 1054 | {} |
| 1055 | }; |
| 1056 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 1057 | static const struct snd_kcontrol_new stac927x_loopback[] = { |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1058 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
| 1059 | {} |
| 1060 | }; |
| 1061 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1062 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1063 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1064 | .name = "Digital Input Source", |
| 1065 | /* count set later */ |
| 1066 | .info = stac92xx_dmux_enum_info, |
| 1067 | .get = stac92xx_dmux_enum_get, |
| 1068 | .put = stac92xx_dmux_enum_put, |
| 1069 | }; |
| 1070 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1071 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1072 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1073 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1074 | /* count set later */ |
| 1075 | .info = stac92xx_smux_enum_info, |
| 1076 | .get = stac92xx_smux_enum_get, |
| 1077 | .put = stac92xx_smux_enum_put, |
| 1078 | }; |
| 1079 | |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1080 | static const char * const slave_pfxs[] = { |
| 1081 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 1082 | "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1083 | NULL |
| 1084 | }; |
| 1085 | |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1086 | static void stac92xx_update_led_status(struct hda_codec *codec, int enabled); |
| 1087 | |
| 1088 | static void stac92xx_vmaster_hook(void *private_data, int val) |
| 1089 | { |
| 1090 | stac92xx_update_led_status(private_data, val); |
| 1091 | } |
| 1092 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1093 | static void stac92xx_free_kctls(struct hda_codec *codec); |
| 1094 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1095 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1096 | { |
| 1097 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1098 | unsigned int vmaster_tlv[4]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1099 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1100 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1101 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 1102 | if (spec->mixer) { |
| 1103 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1104 | if (err < 0) |
| 1105 | return err; |
| 1106 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1107 | |
| 1108 | for (i = 0; i < spec->num_mixers; i++) { |
| 1109 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1110 | if (err < 0) |
| 1111 | return err; |
| 1112 | } |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 1113 | if (!spec->auto_mic && spec->num_dmuxes > 0 && |
| 1114 | snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1115 | stac_dmux_mixer.count = spec->num_dmuxes; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 1116 | err = snd_hda_ctl_add(codec, 0, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1117 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1118 | if (err < 0) |
| 1119 | return err; |
| 1120 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1121 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1122 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1123 | struct hda_input_mux *smux = &spec->private_smux; |
| 1124 | /* check for mute support on SPDIF out */ |
| 1125 | if (wcaps & AC_WCAP_OUT_AMP) { |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 1126 | snd_hda_add_imux_item(smux, "Off", 0, NULL); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1127 | spec->spdif_mute = 1; |
| 1128 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1129 | stac_smux_mixer.count = spec->num_smuxes; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 1130 | err = snd_hda_ctl_add(codec, 0, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1131 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1132 | if (err < 0) |
| 1133 | return err; |
| 1134 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1135 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1136 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1137 | err = snd_hda_create_dig_out_ctls(codec, |
| 1138 | spec->multiout.dig_out_nid, |
| 1139 | spec->multiout.dig_out_nid, |
| 1140 | spec->autocfg.dig_out_type[0]); |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1141 | if (err < 0) |
| 1142 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1143 | err = snd_hda_create_spdif_share_sw(codec, |
| 1144 | &spec->multiout); |
| 1145 | if (err < 0) |
| 1146 | return err; |
| 1147 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1148 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1149 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1150 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1151 | if (err < 0) |
| 1152 | return err; |
| 1153 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1154 | |
| 1155 | /* if we have no master control, let's create it */ |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1156 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
| 1157 | HDA_OUTPUT, vmaster_tlv); |
| 1158 | /* correct volume offset */ |
| 1159 | vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; |
| 1160 | /* minimum value is actually mute */ |
| 1161 | vmaster_tlv[3] |= TLV_DB_SCALE_MUTE; |
| 1162 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
| 1163 | vmaster_tlv, slave_pfxs, |
| 1164 | "Playback Volume"); |
| 1165 | if (err < 0) |
| 1166 | return err; |
| 1167 | |
| 1168 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1169 | NULL, slave_pfxs, |
| 1170 | "Playback Switch", true, |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1171 | &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 1172 | if (err < 0) |
| 1173 | return err; |
| 1174 | |
| 1175 | if (spec->gpio_led) { |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1176 | spec->vmaster_mute.hook = stac92xx_vmaster_hook; |
Takashi Iwai | f29735cb | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 1177 | err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1178 | if (err < 0) |
| 1179 | return err; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1180 | } |
| 1181 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 1182 | if (spec->aloopback_ctl && |
| 1183 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
| 1184 | err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl); |
| 1185 | if (err < 0) |
| 1186 | return err; |
| 1187 | } |
| 1188 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1189 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1190 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1191 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1192 | if (err < 0) |
| 1193 | return err; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1194 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1195 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1196 | } |
| 1197 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1198 | static const struct hda_pintbl ref9200_pin_configs[] = { |
| 1199 | { 0x08, 0x01c47010 }, |
| 1200 | { 0x09, 0x01447010 }, |
| 1201 | { 0x0d, 0x0221401f }, |
| 1202 | { 0x0e, 0x01114010 }, |
| 1203 | { 0x0f, 0x02a19020 }, |
| 1204 | { 0x10, 0x01a19021 }, |
| 1205 | { 0x11, 0x90100140 }, |
| 1206 | { 0x12, 0x01813122 }, |
| 1207 | {} |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1208 | }; |
| 1209 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1210 | static const struct hda_pintbl gateway9200_m4_pin_configs[] = { |
| 1211 | { 0x08, 0x400000fe }, |
| 1212 | { 0x09, 0x404500f4 }, |
| 1213 | { 0x0d, 0x400100f0 }, |
| 1214 | { 0x0e, 0x90110010 }, |
| 1215 | { 0x0f, 0x400100f1 }, |
| 1216 | { 0x10, 0x02a1902e }, |
| 1217 | { 0x11, 0x500000f2 }, |
| 1218 | { 0x12, 0x500000f3 }, |
| 1219 | {} |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1220 | }; |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1221 | |
| 1222 | static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = { |
| 1223 | { 0x08, 0x400000fe }, |
| 1224 | { 0x09, 0x404500f4 }, |
| 1225 | { 0x0d, 0x400100f0 }, |
| 1226 | { 0x0e, 0x90110010 }, |
| 1227 | { 0x0f, 0x400100f1 }, |
| 1228 | { 0x10, 0x02a1902e }, |
| 1229 | { 0x11, 0x500000f2 }, |
| 1230 | { 0x12, 0x500000f3 }, |
| 1231 | {} |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1232 | }; |
| 1233 | |
| 1234 | /* |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1235 | STAC 9200 pin configs for |
| 1236 | 102801A8 |
| 1237 | 102801DE |
| 1238 | 102801E8 |
| 1239 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1240 | static const struct hda_pintbl dell9200_d21_pin_configs[] = { |
| 1241 | { 0x08, 0x400001f0 }, |
| 1242 | { 0x09, 0x400001f1 }, |
| 1243 | { 0x0d, 0x02214030 }, |
| 1244 | { 0x0e, 0x01014010 }, |
| 1245 | { 0x0f, 0x02a19020 }, |
| 1246 | { 0x10, 0x01a19021 }, |
| 1247 | { 0x11, 0x90100140 }, |
| 1248 | { 0x12, 0x01813122 }, |
| 1249 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1250 | }; |
| 1251 | |
| 1252 | /* |
| 1253 | STAC 9200 pin configs for |
| 1254 | 102801C0 |
| 1255 | 102801C1 |
| 1256 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1257 | static const struct hda_pintbl dell9200_d22_pin_configs[] = { |
| 1258 | { 0x08, 0x400001f0 }, |
| 1259 | { 0x09, 0x400001f1 }, |
| 1260 | { 0x0d, 0x0221401f }, |
| 1261 | { 0x0e, 0x01014010 }, |
| 1262 | { 0x0f, 0x01813020 }, |
| 1263 | { 0x10, 0x02a19021 }, |
| 1264 | { 0x11, 0x90100140 }, |
| 1265 | { 0x12, 0x400001f2 }, |
| 1266 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1267 | }; |
| 1268 | |
| 1269 | /* |
| 1270 | STAC 9200 pin configs for |
| 1271 | 102801C4 (Dell Dimension E310) |
| 1272 | 102801C5 |
| 1273 | 102801C7 |
| 1274 | 102801D9 |
| 1275 | 102801DA |
| 1276 | 102801E3 |
| 1277 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1278 | static const struct hda_pintbl dell9200_d23_pin_configs[] = { |
| 1279 | { 0x08, 0x400001f0 }, |
| 1280 | { 0x09, 0x400001f1 }, |
| 1281 | { 0x0d, 0x0221401f }, |
| 1282 | { 0x0e, 0x01014010 }, |
| 1283 | { 0x0f, 0x01813020 }, |
| 1284 | { 0x10, 0x01a19021 }, |
| 1285 | { 0x11, 0x90100140 }, |
| 1286 | { 0x12, 0x400001f2 }, |
| 1287 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1288 | }; |
| 1289 | |
| 1290 | |
| 1291 | /* |
| 1292 | STAC 9200-32 pin configs for |
| 1293 | 102801B5 (Dell Inspiron 630m) |
| 1294 | 102801D8 (Dell Inspiron 640m) |
| 1295 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1296 | static const struct hda_pintbl dell9200_m21_pin_configs[] = { |
| 1297 | { 0x08, 0x40c003fa }, |
| 1298 | { 0x09, 0x03441340 }, |
| 1299 | { 0x0d, 0x0321121f }, |
| 1300 | { 0x0e, 0x90170310 }, |
| 1301 | { 0x0f, 0x408003fb }, |
| 1302 | { 0x10, 0x03a11020 }, |
| 1303 | { 0x11, 0x401003fc }, |
| 1304 | { 0x12, 0x403003fd }, |
| 1305 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1306 | }; |
| 1307 | |
| 1308 | /* |
| 1309 | STAC 9200-32 pin configs for |
| 1310 | 102801C2 (Dell Latitude D620) |
| 1311 | 102801C8 |
| 1312 | 102801CC (Dell Latitude D820) |
| 1313 | 102801D4 |
| 1314 | 102801D6 |
| 1315 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1316 | static const struct hda_pintbl dell9200_m22_pin_configs[] = { |
| 1317 | { 0x08, 0x40c003fa }, |
| 1318 | { 0x09, 0x0144131f }, |
| 1319 | { 0x0d, 0x0321121f }, |
| 1320 | { 0x0e, 0x90170310 }, |
| 1321 | { 0x0f, 0x90a70321 }, |
| 1322 | { 0x10, 0x03a11020 }, |
| 1323 | { 0x11, 0x401003fb }, |
| 1324 | { 0x12, 0x40f000fc }, |
| 1325 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1326 | }; |
| 1327 | |
| 1328 | /* |
| 1329 | STAC 9200-32 pin configs for |
| 1330 | 102801CE (Dell XPS M1710) |
| 1331 | 102801CF (Dell Precision M90) |
| 1332 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1333 | static const struct hda_pintbl dell9200_m23_pin_configs[] = { |
| 1334 | { 0x08, 0x40c003fa }, |
| 1335 | { 0x09, 0x01441340 }, |
| 1336 | { 0x0d, 0x0421421f }, |
| 1337 | { 0x0e, 0x90170310 }, |
| 1338 | { 0x0f, 0x408003fb }, |
| 1339 | { 0x10, 0x04a1102e }, |
| 1340 | { 0x11, 0x90170311 }, |
| 1341 | { 0x12, 0x403003fc }, |
| 1342 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1343 | }; |
| 1344 | |
| 1345 | /* |
| 1346 | STAC 9200-32 pin configs for |
| 1347 | 102801C9 |
| 1348 | 102801CA |
| 1349 | 102801CB (Dell Latitude 120L) |
| 1350 | 102801D3 |
| 1351 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1352 | static const struct hda_pintbl dell9200_m24_pin_configs[] = { |
| 1353 | { 0x08, 0x40c003fa }, |
| 1354 | { 0x09, 0x404003fb }, |
| 1355 | { 0x0d, 0x0321121f }, |
| 1356 | { 0x0e, 0x90170310 }, |
| 1357 | { 0x0f, 0x408003fc }, |
| 1358 | { 0x10, 0x03a11020 }, |
| 1359 | { 0x11, 0x401003fd }, |
| 1360 | { 0x12, 0x403003fe }, |
| 1361 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1362 | }; |
| 1363 | |
| 1364 | /* |
| 1365 | STAC 9200-32 pin configs for |
| 1366 | 102801BD (Dell Inspiron E1505n) |
| 1367 | 102801EE |
| 1368 | 102801EF |
| 1369 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1370 | static const struct hda_pintbl dell9200_m25_pin_configs[] = { |
| 1371 | { 0x08, 0x40c003fa }, |
| 1372 | { 0x09, 0x01441340 }, |
| 1373 | { 0x0d, 0x0421121f }, |
| 1374 | { 0x0e, 0x90170310 }, |
| 1375 | { 0x0f, 0x408003fb }, |
| 1376 | { 0x10, 0x04a11020 }, |
| 1377 | { 0x11, 0x401003fc }, |
| 1378 | { 0x12, 0x403003fd }, |
| 1379 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1380 | }; |
| 1381 | |
| 1382 | /* |
| 1383 | STAC 9200-32 pin configs for |
| 1384 | 102801F5 (Dell Inspiron 1501) |
| 1385 | 102801F6 |
| 1386 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1387 | static const struct hda_pintbl dell9200_m26_pin_configs[] = { |
| 1388 | { 0x08, 0x40c003fa }, |
| 1389 | { 0x09, 0x404003fb }, |
| 1390 | { 0x0d, 0x0421121f }, |
| 1391 | { 0x0e, 0x90170310 }, |
| 1392 | { 0x0f, 0x408003fc }, |
| 1393 | { 0x10, 0x04a11020 }, |
| 1394 | { 0x11, 0x401003fd }, |
| 1395 | { 0x12, 0x403003fe }, |
| 1396 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1397 | }; |
| 1398 | |
| 1399 | /* |
| 1400 | STAC 9200-32 |
| 1401 | 102801CD (Dell Inspiron E1705/9400) |
| 1402 | */ |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1403 | static const struct hda_pintbl dell9200_m27_pin_configs[] = { |
| 1404 | { 0x08, 0x40c003fa }, |
| 1405 | { 0x09, 0x01441340 }, |
| 1406 | { 0x0d, 0x0421121f }, |
| 1407 | { 0x0e, 0x90170310 }, |
| 1408 | { 0x0f, 0x90170310 }, |
| 1409 | { 0x10, 0x04a11020 }, |
| 1410 | { 0x11, 0x90170310 }, |
| 1411 | { 0x12, 0x40f003fc }, |
| 1412 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1413 | }; |
| 1414 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1415 | static const struct hda_pintbl oqo9200_pin_configs[] = { |
| 1416 | { 0x08, 0x40c000f0 }, |
| 1417 | { 0x09, 0x404000f1 }, |
| 1418 | { 0x0d, 0x0221121f }, |
| 1419 | { 0x0e, 0x02211210 }, |
| 1420 | { 0x0f, 0x90170111 }, |
| 1421 | { 0x10, 0x90a70120 }, |
| 1422 | { 0x11, 0x400000f2 }, |
| 1423 | { 0x12, 0x400000f3 }, |
| 1424 | {} |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1425 | }; |
| 1426 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1427 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1428 | static void stac9200_fixup_panasonic(struct hda_codec *codec, |
| 1429 | const struct hda_fixup *fix, int action) |
| 1430 | { |
| 1431 | struct sigmatel_spec *spec = codec->spec; |
| 1432 | |
| 1433 | switch (action) { |
| 1434 | case HDA_FIXUP_ACT_PRE_PROBE: |
| 1435 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 1436 | spec->gpio_data = 0x00; |
| 1437 | break; |
| 1438 | case HDA_FIXUP_ACT_PROBE: |
| 1439 | /* CF-74 has no headphone detection, and the driver should *NOT* |
| 1440 | * do detection and HP/speaker toggle because the hardware does it. |
| 1441 | */ |
| 1442 | spec->hp_detect = 0; |
| 1443 | break; |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | |
| 1448 | static const struct hda_fixup stac9200_fixups[] = { |
| 1449 | [STAC_REF] = { |
| 1450 | .type = HDA_FIXUP_PINS, |
| 1451 | .v.pins = ref9200_pin_configs, |
| 1452 | }, |
| 1453 | [STAC_9200_OQO] = { |
| 1454 | .type = HDA_FIXUP_PINS, |
| 1455 | .v.pins = oqo9200_pin_configs, |
| 1456 | .chained = true, |
| 1457 | .chain_id = STAC_9200_EAPD_INIT, |
| 1458 | }, |
| 1459 | [STAC_9200_DELL_D21] = { |
| 1460 | .type = HDA_FIXUP_PINS, |
| 1461 | .v.pins = dell9200_d21_pin_configs, |
| 1462 | }, |
| 1463 | [STAC_9200_DELL_D22] = { |
| 1464 | .type = HDA_FIXUP_PINS, |
| 1465 | .v.pins = dell9200_d22_pin_configs, |
| 1466 | }, |
| 1467 | [STAC_9200_DELL_D23] = { |
| 1468 | .type = HDA_FIXUP_PINS, |
| 1469 | .v.pins = dell9200_d23_pin_configs, |
| 1470 | }, |
| 1471 | [STAC_9200_DELL_M21] = { |
| 1472 | .type = HDA_FIXUP_PINS, |
| 1473 | .v.pins = dell9200_m21_pin_configs, |
| 1474 | }, |
| 1475 | [STAC_9200_DELL_M22] = { |
| 1476 | .type = HDA_FIXUP_PINS, |
| 1477 | .v.pins = dell9200_m22_pin_configs, |
| 1478 | }, |
| 1479 | [STAC_9200_DELL_M23] = { |
| 1480 | .type = HDA_FIXUP_PINS, |
| 1481 | .v.pins = dell9200_m23_pin_configs, |
| 1482 | }, |
| 1483 | [STAC_9200_DELL_M24] = { |
| 1484 | .type = HDA_FIXUP_PINS, |
| 1485 | .v.pins = dell9200_m24_pin_configs, |
| 1486 | }, |
| 1487 | [STAC_9200_DELL_M25] = { |
| 1488 | .type = HDA_FIXUP_PINS, |
| 1489 | .v.pins = dell9200_m25_pin_configs, |
| 1490 | }, |
| 1491 | [STAC_9200_DELL_M26] = { |
| 1492 | .type = HDA_FIXUP_PINS, |
| 1493 | .v.pins = dell9200_m26_pin_configs, |
| 1494 | }, |
| 1495 | [STAC_9200_DELL_M27] = { |
| 1496 | .type = HDA_FIXUP_PINS, |
| 1497 | .v.pins = dell9200_m27_pin_configs, |
| 1498 | }, |
| 1499 | [STAC_9200_M4] = { |
| 1500 | .type = HDA_FIXUP_PINS, |
| 1501 | .v.pins = gateway9200_m4_pin_configs, |
| 1502 | .chained = true, |
| 1503 | .chain_id = STAC_9200_EAPD_INIT, |
| 1504 | }, |
| 1505 | [STAC_9200_M4_2] = { |
| 1506 | .type = HDA_FIXUP_PINS, |
| 1507 | .v.pins = gateway9200_m4_2_pin_configs, |
| 1508 | .chained = true, |
| 1509 | .chain_id = STAC_9200_EAPD_INIT, |
| 1510 | }, |
| 1511 | [STAC_9200_PANASONIC] = { |
| 1512 | .type = HDA_FIXUP_FUNC, |
| 1513 | .v.func = stac9200_fixup_panasonic, |
| 1514 | }, |
| 1515 | [STAC_9200_EAPD_INIT] = { |
| 1516 | .type = HDA_FIXUP_VERBS, |
| 1517 | .v.verbs = (const struct hda_verb[]) { |
| 1518 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 1519 | {} |
| 1520 | }, |
| 1521 | }, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1522 | }; |
| 1523 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1524 | static const struct hda_model_fixup stac9200_models[] = { |
| 1525 | { .id = STAC_REF, .name = "ref" }, |
| 1526 | { .id = STAC_9200_OQO, .name = "oqo" }, |
| 1527 | { .id = STAC_9200_DELL_D21, .name = "dell-d21" }, |
| 1528 | { .id = STAC_9200_DELL_D22, .name = "dell-d22" }, |
| 1529 | { .id = STAC_9200_DELL_D23, .name = "dell-d23" }, |
| 1530 | { .id = STAC_9200_DELL_M21, .name = "dell-m21" }, |
| 1531 | { .id = STAC_9200_DELL_M22, .name = "dell-m22" }, |
| 1532 | { .id = STAC_9200_DELL_M23, .name = "dell-m23" }, |
| 1533 | { .id = STAC_9200_DELL_M24, .name = "dell-m24" }, |
| 1534 | { .id = STAC_9200_DELL_M25, .name = "dell-m25" }, |
| 1535 | { .id = STAC_9200_DELL_M26, .name = "dell-m26" }, |
| 1536 | { .id = STAC_9200_DELL_M27, .name = "dell-m27" }, |
| 1537 | { .id = STAC_9200_M4, .name = "gateway-m4" }, |
| 1538 | { .id = STAC_9200_M4_2, .name = "gateway-m4-2" }, |
| 1539 | { .id = STAC_9200_PANASONIC, .name = "panasonic" }, |
| 1540 | {} |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1541 | }; |
| 1542 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 1543 | static const struct snd_pci_quirk stac9200_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1544 | /* SigmaTel reference board */ |
| 1545 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1546 | "DFI LanParty", STAC_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1547 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 1548 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1549 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1550 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1551 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1552 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1553 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1554 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1555 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1556 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1557 | "unknown Dell", STAC_9200_DELL_D22), |
| 1558 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1559 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1560 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1561 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1562 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1563 | "unknown Dell", STAC_9200_DELL_D23), |
| 1564 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1565 | "unknown Dell", STAC_9200_DELL_D23), |
| 1566 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1567 | "unknown Dell", STAC_9200_DELL_M22), |
| 1568 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1569 | "unknown Dell", STAC_9200_DELL_M24), |
| 1570 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1571 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1572 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1573 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1574 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1575 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1576 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1577 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1578 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1579 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1580 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1581 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1582 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1583 | "unknown Dell", STAC_9200_DELL_M22), |
| 1584 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1585 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1586 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1587 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1588 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1589 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1590 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1591 | "unknown Dell", STAC_9200_DELL_D23), |
| 1592 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1593 | "unknown Dell", STAC_9200_DELL_D23), |
| 1594 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1595 | "unknown Dell", STAC_9200_DELL_D21), |
| 1596 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1597 | "unknown Dell", STAC_9200_DELL_D23), |
| 1598 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1599 | "unknown Dell", STAC_9200_DELL_D21), |
| 1600 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1601 | "unknown Dell", STAC_9200_DELL_M25), |
| 1602 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1603 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1604 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1605 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1606 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1607 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1608 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1609 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1610 | /* Gateway machines needs EAPD to be set on resume */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1611 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4), |
| 1612 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2), |
| 1613 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1614 | /* OQO Mobile */ |
| 1615 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1616 | {} /* terminator */ |
| 1617 | }; |
| 1618 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1619 | static const struct hda_pintbl ref925x_pin_configs[] = { |
| 1620 | { 0x07, 0x40c003f0 }, |
| 1621 | { 0x08, 0x424503f2 }, |
| 1622 | { 0x0a, 0x01813022 }, |
| 1623 | { 0x0b, 0x02a19021 }, |
| 1624 | { 0x0c, 0x90a70320 }, |
| 1625 | { 0x0d, 0x02214210 }, |
| 1626 | { 0x10, 0x01019020 }, |
| 1627 | { 0x11, 0x9033032e }, |
| 1628 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1629 | }; |
| 1630 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1631 | static const struct hda_pintbl stac925xM1_pin_configs[] = { |
| 1632 | { 0x07, 0x40c003f4 }, |
| 1633 | { 0x08, 0x424503f2 }, |
| 1634 | { 0x0a, 0x400000f3 }, |
| 1635 | { 0x0b, 0x02a19020 }, |
| 1636 | { 0x0c, 0x40a000f0 }, |
| 1637 | { 0x0d, 0x90100210 }, |
| 1638 | { 0x10, 0x400003f1 }, |
| 1639 | { 0x11, 0x9033032e }, |
| 1640 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1641 | }; |
| 1642 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1643 | static const struct hda_pintbl stac925xM1_2_pin_configs[] = { |
| 1644 | { 0x07, 0x40c003f4 }, |
| 1645 | { 0x08, 0x424503f2 }, |
| 1646 | { 0x0a, 0x400000f3 }, |
| 1647 | { 0x0b, 0x02a19020 }, |
| 1648 | { 0x0c, 0x40a000f0 }, |
| 1649 | { 0x0d, 0x90100210 }, |
| 1650 | { 0x10, 0x400003f1 }, |
| 1651 | { 0x11, 0x9033032e }, |
| 1652 | {} |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1653 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1654 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1655 | static const struct hda_pintbl stac925xM2_pin_configs[] = { |
| 1656 | { 0x07, 0x40c003f4 }, |
| 1657 | { 0x08, 0x424503f2 }, |
| 1658 | { 0x0a, 0x400000f3 }, |
| 1659 | { 0x0b, 0x02a19020 }, |
| 1660 | { 0x0c, 0x40a000f0 }, |
| 1661 | { 0x0d, 0x90100210 }, |
| 1662 | { 0x10, 0x400003f1 }, |
| 1663 | { 0x11, 0x9033032e }, |
| 1664 | {} |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1665 | }; |
| 1666 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1667 | static const struct hda_pintbl stac925xM2_2_pin_configs[] = { |
| 1668 | { 0x07, 0x40c003f4 }, |
| 1669 | { 0x08, 0x424503f2 }, |
| 1670 | { 0x0a, 0x400000f3 }, |
| 1671 | { 0x0b, 0x02a19020 }, |
| 1672 | { 0x0c, 0x40a000f0 }, |
| 1673 | { 0x0d, 0x90100210 }, |
| 1674 | { 0x10, 0x400003f1 }, |
| 1675 | { 0x11, 0x9033032e }, |
| 1676 | {} |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1677 | }; |
| 1678 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1679 | static const struct hda_pintbl stac925xM3_pin_configs[] = { |
| 1680 | { 0x07, 0x40c003f4 }, |
| 1681 | { 0x08, 0x424503f2 }, |
| 1682 | { 0x0a, 0x400000f3 }, |
| 1683 | { 0x0b, 0x02a19020 }, |
| 1684 | { 0x0c, 0x40a000f0 }, |
| 1685 | { 0x0d, 0x90100210 }, |
| 1686 | { 0x10, 0x400003f1 }, |
| 1687 | { 0x11, 0x503303f3 }, |
| 1688 | {} |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1689 | }; |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1690 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1691 | static const struct hda_pintbl stac925xM5_pin_configs[] = { |
| 1692 | { 0x07, 0x40c003f4 }, |
| 1693 | { 0x08, 0x424503f2 }, |
| 1694 | { 0x0a, 0x400000f3 }, |
| 1695 | { 0x0b, 0x02a19020 }, |
| 1696 | { 0x0c, 0x40a000f0 }, |
| 1697 | { 0x0d, 0x90100210 }, |
| 1698 | { 0x10, 0x400003f1 }, |
| 1699 | { 0x11, 0x9033032e }, |
| 1700 | {} |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1701 | }; |
| 1702 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1703 | static const struct hda_pintbl stac925xM6_pin_configs[] = { |
| 1704 | { 0x07, 0x40c003f4 }, |
| 1705 | { 0x08, 0x424503f2 }, |
| 1706 | { 0x0a, 0x400000f3 }, |
| 1707 | { 0x0b, 0x02a19020 }, |
| 1708 | { 0x0c, 0x40a000f0 }, |
| 1709 | { 0x0d, 0x90100210 }, |
| 1710 | { 0x10, 0x400003f1 }, |
| 1711 | { 0x11, 0x90330320 }, |
| 1712 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1713 | }; |
| 1714 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1715 | static const struct hda_fixup stac925x_fixups[] = { |
| 1716 | [STAC_REF] = { |
| 1717 | .type = HDA_FIXUP_PINS, |
| 1718 | .v.pins = ref925x_pin_configs, |
| 1719 | }, |
| 1720 | [STAC_M1] = { |
| 1721 | .type = HDA_FIXUP_PINS, |
| 1722 | .v.pins = stac925xM1_pin_configs, |
| 1723 | }, |
| 1724 | [STAC_M1_2] = { |
| 1725 | .type = HDA_FIXUP_PINS, |
| 1726 | .v.pins = stac925xM1_2_pin_configs, |
| 1727 | }, |
| 1728 | [STAC_M2] = { |
| 1729 | .type = HDA_FIXUP_PINS, |
| 1730 | .v.pins = stac925xM2_pin_configs, |
| 1731 | }, |
| 1732 | [STAC_M2_2] = { |
| 1733 | .type = HDA_FIXUP_PINS, |
| 1734 | .v.pins = stac925xM2_2_pin_configs, |
| 1735 | }, |
| 1736 | [STAC_M3] = { |
| 1737 | .type = HDA_FIXUP_PINS, |
| 1738 | .v.pins = stac925xM3_pin_configs, |
| 1739 | }, |
| 1740 | [STAC_M5] = { |
| 1741 | .type = HDA_FIXUP_PINS, |
| 1742 | .v.pins = stac925xM5_pin_configs, |
| 1743 | }, |
| 1744 | [STAC_M6] = { |
| 1745 | .type = HDA_FIXUP_PINS, |
| 1746 | .v.pins = stac925xM6_pin_configs, |
| 1747 | }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1748 | }; |
| 1749 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1750 | static const struct hda_model_fixup stac925x_models[] = { |
| 1751 | { .id = STAC_REF, .name = "ref" }, |
| 1752 | { .id = STAC_M1, .name = "m1" }, |
| 1753 | { .id = STAC_M1_2, .name = "m1-2" }, |
| 1754 | { .id = STAC_M2, .name = "m2" }, |
| 1755 | { .id = STAC_M2_2, .name = "m2-2" }, |
| 1756 | { .id = STAC_M3, .name = "m3" }, |
| 1757 | { .id = STAC_M5, .name = "m5" }, |
| 1758 | { .id = STAC_M6, .name = "m6" }, |
| 1759 | {} |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1760 | }; |
| 1761 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 1762 | static const struct snd_pci_quirk stac925x_fixup_tbl[] = { |
| 1763 | /* SigmaTel reference board */ |
| 1764 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
| 1765 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF), |
| 1766 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
| 1767 | |
| 1768 | /* Default table for unknown ID */ |
| 1769 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1770 | |
| 1771 | /* gateway machines are checked via codec ssid */ |
Mauro Carvalho Chehab | 58eec42 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1772 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2), |
| 1773 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5), |
| 1774 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1), |
| 1775 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1776 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1777 | /* Not sure about the brand name for those */ |
| 1778 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1779 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1780 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1781 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 1782 | {} /* terminator */ |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1783 | }; |
| 1784 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1785 | static const struct hda_pintbl ref92hd73xx_pin_configs[] = { |
| 1786 | { 0x0a, 0x02214030 }, |
| 1787 | { 0x0b, 0x02a19040 }, |
| 1788 | { 0x0c, 0x01a19020 }, |
| 1789 | { 0x0d, 0x02214030 }, |
| 1790 | { 0x0e, 0x0181302e }, |
| 1791 | { 0x0f, 0x01014010 }, |
| 1792 | { 0x10, 0x01014020 }, |
| 1793 | { 0x11, 0x01014030 }, |
| 1794 | { 0x12, 0x02319040 }, |
| 1795 | { 0x13, 0x90a000f0 }, |
| 1796 | { 0x14, 0x90a000f0 }, |
| 1797 | { 0x22, 0x01452050 }, |
| 1798 | { 0x23, 0x01452050 }, |
| 1799 | {} |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1800 | }; |
| 1801 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1802 | static const struct hda_pintbl dell_m6_pin_configs[] = { |
| 1803 | { 0x0a, 0x0321101f }, |
| 1804 | { 0x0b, 0x4f00000f }, |
| 1805 | { 0x0c, 0x4f0000f0 }, |
| 1806 | { 0x0d, 0x90170110 }, |
| 1807 | { 0x0e, 0x03a11020 }, |
| 1808 | { 0x0f, 0x0321101f }, |
| 1809 | { 0x10, 0x4f0000f0 }, |
| 1810 | { 0x11, 0x4f0000f0 }, |
| 1811 | { 0x12, 0x4f0000f0 }, |
| 1812 | { 0x13, 0x90a60160 }, |
| 1813 | { 0x14, 0x4f0000f0 }, |
| 1814 | { 0x22, 0x4f0000f0 }, |
| 1815 | { 0x23, 0x4f0000f0 }, |
| 1816 | {} |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1817 | }; |
| 1818 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1819 | static const struct hda_pintbl alienware_m17x_pin_configs[] = { |
| 1820 | { 0x0a, 0x0321101f }, |
| 1821 | { 0x0b, 0x0321101f }, |
| 1822 | { 0x0c, 0x03a11020 }, |
| 1823 | { 0x0d, 0x03014020 }, |
| 1824 | { 0x0e, 0x90170110 }, |
| 1825 | { 0x0f, 0x4f0000f0 }, |
| 1826 | { 0x10, 0x4f0000f0 }, |
| 1827 | { 0x11, 0x4f0000f0 }, |
| 1828 | { 0x12, 0x4f0000f0 }, |
| 1829 | { 0x13, 0x90a60160 }, |
| 1830 | { 0x14, 0x4f0000f0 }, |
| 1831 | { 0x22, 0x4f0000f0 }, |
| 1832 | { 0x23, 0x904601b0 }, |
| 1833 | {} |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 1834 | }; |
| 1835 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1836 | static const struct hda_pintbl intel_dg45id_pin_configs[] = { |
| 1837 | { 0x0a, 0x02214230 }, |
| 1838 | { 0x0b, 0x02A19240 }, |
| 1839 | { 0x0c, 0x01013214 }, |
| 1840 | { 0x0d, 0x01014210 }, |
| 1841 | { 0x0e, 0x01A19250 }, |
| 1842 | { 0x0f, 0x01011212 }, |
| 1843 | { 0x10, 0x01016211 }, |
| 1844 | {} |
Alexey Fisher | 52dc438 | 2009-12-12 11:16:41 +0200 | [diff] [blame] | 1845 | }; |
| 1846 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1847 | static void stac92hd73xx_fixup_ref(struct hda_codec *codec, |
| 1848 | const struct hda_fixup *fix, int action) |
| 1849 | { |
| 1850 | struct sigmatel_spec *spec = codec->spec; |
| 1851 | |
| 1852 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1853 | return; |
| 1854 | |
| 1855 | snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs); |
| 1856 | spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0; |
| 1857 | } |
| 1858 | |
| 1859 | static void stac92hd73xx_fixup_dell(struct hda_codec *codec) |
| 1860 | { |
| 1861 | struct sigmatel_spec *spec = codec->spec; |
| 1862 | |
| 1863 | snd_hda_apply_pincfgs(codec, dell_m6_pin_configs); |
| 1864 | spec->num_smuxes = 0; |
| 1865 | spec->eapd_switch = 0; |
| 1866 | } |
| 1867 | |
| 1868 | static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec, |
| 1869 | const struct hda_fixup *fix, int action) |
| 1870 | { |
| 1871 | struct sigmatel_spec *spec = codec->spec; |
| 1872 | |
| 1873 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1874 | return; |
| 1875 | |
| 1876 | stac92hd73xx_fixup_dell(codec); |
| 1877 | snd_hda_add_verbs(codec, dell_eq_core_init); |
| 1878 | spec->volknob_init = 1; |
| 1879 | } |
| 1880 | |
| 1881 | /* Analog Mics */ |
| 1882 | static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec, |
| 1883 | const struct hda_fixup *fix, int action) |
| 1884 | { |
| 1885 | struct sigmatel_spec *spec = codec->spec; |
| 1886 | |
| 1887 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1888 | return; |
| 1889 | |
| 1890 | stac92hd73xx_fixup_dell(codec); |
| 1891 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 1892 | spec->num_dmics = 0; |
| 1893 | } |
| 1894 | |
| 1895 | /* Digital Mics */ |
| 1896 | static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec, |
| 1897 | const struct hda_fixup *fix, int action) |
| 1898 | { |
| 1899 | struct sigmatel_spec *spec = codec->spec; |
| 1900 | |
| 1901 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1902 | return; |
| 1903 | |
| 1904 | stac92hd73xx_fixup_dell(codec); |
| 1905 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
| 1906 | spec->num_dmics = 1; |
| 1907 | } |
| 1908 | |
| 1909 | /* Both */ |
| 1910 | static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec, |
| 1911 | const struct hda_fixup *fix, int action) |
| 1912 | { |
| 1913 | struct sigmatel_spec *spec = codec->spec; |
| 1914 | |
| 1915 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1916 | return; |
| 1917 | |
| 1918 | stac92hd73xx_fixup_dell(codec); |
| 1919 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
| 1920 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
| 1921 | spec->num_dmics = 1; |
| 1922 | } |
| 1923 | |
| 1924 | static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec, |
| 1925 | const struct hda_fixup *fix, int action) |
| 1926 | { |
| 1927 | struct sigmatel_spec *spec = codec->spec; |
| 1928 | |
| 1929 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1930 | return; |
| 1931 | |
| 1932 | snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs); |
| 1933 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
| 1934 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
| 1935 | spec->eapd_switch = 0; |
| 1936 | } |
| 1937 | |
| 1938 | static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec, |
| 1939 | const struct hda_fixup *fix, int action) |
| 1940 | { |
| 1941 | struct sigmatel_spec *spec = codec->spec; |
| 1942 | |
| 1943 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 1944 | return; |
| 1945 | spec->hp_detect = 0; |
| 1946 | } |
| 1947 | |
| 1948 | static const struct hda_fixup stac92hd73xx_fixups[] = { |
| 1949 | [STAC_92HD73XX_REF] = { |
| 1950 | .type = HDA_FIXUP_FUNC, |
| 1951 | .v.func = stac92hd73xx_fixup_ref, |
| 1952 | }, |
| 1953 | [STAC_DELL_M6_AMIC] = { |
| 1954 | .type = HDA_FIXUP_FUNC, |
| 1955 | .v.func = stac92hd73xx_fixup_dell_m6_amic, |
| 1956 | }, |
| 1957 | [STAC_DELL_M6_DMIC] = { |
| 1958 | .type = HDA_FIXUP_FUNC, |
| 1959 | .v.func = stac92hd73xx_fixup_dell_m6_dmic, |
| 1960 | }, |
| 1961 | [STAC_DELL_M6_BOTH] = { |
| 1962 | .type = HDA_FIXUP_FUNC, |
| 1963 | .v.func = stac92hd73xx_fixup_dell_m6_both, |
| 1964 | }, |
| 1965 | [STAC_DELL_EQ] = { |
| 1966 | .type = HDA_FIXUP_FUNC, |
| 1967 | .v.func = stac92hd73xx_fixup_dell_eq, |
| 1968 | }, |
| 1969 | [STAC_ALIENWARE_M17X] = { |
| 1970 | .type = HDA_FIXUP_FUNC, |
| 1971 | .v.func = stac92hd73xx_fixup_alienware_m17x, |
| 1972 | }, |
| 1973 | [STAC_92HD73XX_INTEL] = { |
| 1974 | .type = HDA_FIXUP_PINS, |
| 1975 | .v.pins = intel_dg45id_pin_configs, |
| 1976 | }, |
| 1977 | [STAC_92HD73XX_NO_JD] = { |
| 1978 | .type = HDA_FIXUP_FUNC, |
| 1979 | .v.func = stac92hd73xx_fixup_no_jd, |
| 1980 | } |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1981 | }; |
| 1982 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1983 | static const struct hda_model_fixup stac92hd73xx_models[] = { |
| 1984 | { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" }, |
| 1985 | { .id = STAC_92HD73XX_REF, .name = "ref" }, |
| 1986 | { .id = STAC_92HD73XX_INTEL, .name = "intel" }, |
| 1987 | { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" }, |
| 1988 | { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" }, |
| 1989 | { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" }, |
| 1990 | { .id = STAC_DELL_EQ, .name = "dell-eq" }, |
| 1991 | { .id = STAC_ALIENWARE_M17X, .name = "alienware" }, |
| 1992 | {} |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1993 | }; |
| 1994 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 1995 | static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1996 | /* SigmaTel reference board */ |
| 1997 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1998 | "DFI LanParty", STAC_92HD73XX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 1999 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2000 | "DFI LanParty", STAC_92HD73XX_REF), |
Wu Fengguang | ae70944 | 2009-08-19 17:05:11 +0800 | [diff] [blame] | 2001 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, |
| 2002 | "Intel DG45ID", STAC_92HD73XX_INTEL), |
| 2003 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, |
| 2004 | "Intel DG45FC", STAC_92HD73XX_INTEL), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2005 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2006 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2007 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2008 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2009 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2010 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2011 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
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, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2014 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2015 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
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, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2018 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 2019 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 2020 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 2021 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 2022 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Joerg Schirottke | fa620e9 | 2008-12-19 08:13:49 +0100 | [diff] [blame] | 2023 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, |
| 2024 | "Dell Studio 17", STAC_DELL_M6_DMIC), |
Takashi Iwai | 626f5ce | 2009-07-28 00:54:39 +0200 | [diff] [blame] | 2025 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be, |
| 2026 | "Dell Studio 1555", STAC_DELL_M6_DMIC), |
Daniel J Blueman | 8ef5837 | 2009-11-14 18:20:04 +0000 | [diff] [blame] | 2027 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd, |
| 2028 | "Dell Studio 1557", STAC_DELL_M6_DMIC), |
Daniel T Chen | aac78da | 2010-04-21 20:41:52 -0400 | [diff] [blame] | 2029 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe, |
David Henningsson | ffe535e | 2012-01-16 10:52:20 +0100 | [diff] [blame] | 2030 | "Dell Studio XPS 1645", STAC_DELL_M6_DMIC), |
Daniel T Chen | 5c1bccf | 2010-04-22 17:54:45 -0400 | [diff] [blame] | 2031 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413, |
David Henningsson | e033ebf | 2011-05-16 12:09:29 +0200 | [diff] [blame] | 2032 | "Dell Studio 1558", STAC_DELL_M6_DMIC), |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 2033 | /* codec SSID matching */ |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 2034 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1, |
| 2035 | "Alienware M17x", STAC_ALIENWARE_M17X), |
Daniel T Chen | 0defe09 | 2010-12-01 19:16:07 -0500 | [diff] [blame] | 2036 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a, |
| 2037 | "Alienware M17x", STAC_ALIENWARE_M17X), |
Takashi Iwai | dbd1b54 | 2011-11-19 11:41:30 +0100 | [diff] [blame] | 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490, |
Albert Pool | b9ecc4e | 2012-01-19 22:08:50 +0100 | [diff] [blame] | 2039 | "Alienware M17x R3", STAC_DELL_EQ), |
Takashi Iwai | 842ae63 | 2009-09-02 07:43:08 +0200 | [diff] [blame] | 2040 | {} /* terminator */ |
| 2041 | }; |
| 2042 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 2043 | static const unsigned int ref92hd83xxx_pin_configs[10] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2044 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 2045 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2046 | 0x01451160, 0x98560170, |
| 2047 | }; |
| 2048 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 2049 | static const unsigned int dell_s14_pin_configs[10] = { |
Takashi Iwai | 69b5655 | 2009-09-15 12:37:42 +0200 | [diff] [blame] | 2050 | 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110, |
| 2051 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 2052 | 0x40f000f0, 0x40f000f0, |
| 2053 | }; |
| 2054 | |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 2055 | static const unsigned int dell_vostro_3500_pin_configs[10] = { |
| 2056 | 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110, |
| 2057 | 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160, |
| 2058 | 0x400000f4, 0x400000f5, |
| 2059 | }; |
| 2060 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 2061 | static const unsigned int hp_dv7_4000_pin_configs[10] = { |
Steven Eastland | 4831559 | 2010-08-06 15:07:35 -0600 | [diff] [blame] | 2062 | 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110, |
| 2063 | 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140, |
| 2064 | 0x40f000f0, 0x40f000f0, |
| 2065 | }; |
| 2066 | |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2067 | static const unsigned int hp_zephyr_pin_configs[10] = { |
| 2068 | 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310, |
| 2069 | 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130, |
| 2070 | 0, 0, |
| 2071 | }; |
| 2072 | |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2073 | static const unsigned int hp_cNB11_intquad_pin_configs[10] = { |
| 2074 | 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110, |
| 2075 | 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130, |
| 2076 | 0x40f000f0, 0x40f000f0, |
| 2077 | }; |
| 2078 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 2079 | static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2080 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 2081 | [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 2082 | [STAC_DELL_S14] = dell_s14_pin_configs, |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 2083 | [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs, |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2084 | [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs, |
Steven Eastland | 4831559 | 2010-08-06 15:07:35 -0600 | [diff] [blame] | 2085 | [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs, |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2086 | [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2087 | }; |
| 2088 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 2089 | static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
Takashi Iwai | 1607b8e | 2009-02-26 16:50:43 +0100 | [diff] [blame] | 2090 | [STAC_92HD83XXX_AUTO] = "auto", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2091 | [STAC_92HD83XXX_REF] = "ref", |
Matthew Ranostay | 32ed3f4 | 2009-01-22 20:53:29 -0500 | [diff] [blame] | 2092 | [STAC_92HD83XXX_PWR_REF] = "mic-ref", |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 2093 | [STAC_DELL_S14] = "dell-s14", |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 2094 | [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500", |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2095 | [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad", |
Steven Eastland | 4831559 | 2010-08-06 15:07:35 -0600 | [diff] [blame] | 2096 | [STAC_HP_DV7_4000] = "hp-dv7-4000", |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2097 | [STAC_HP_ZEPHYR] = "hp-zephyr", |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 2098 | [STAC_92HD83XXX_HP_LED] = "hp-led", |
Takashi Iwai | ff8a1e2 | 2012-07-31 10:16:59 +0200 | [diff] [blame] | 2099 | [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led", |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 2100 | [STAC_92HD83XXX_HP_MIC_LED] = "hp-mic-led", |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 2101 | [STAC_92HD83XXX_HEADSET_JACK] = "headset-jack", |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2102 | }; |
| 2103 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 2104 | static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2105 | /* SigmaTel reference board */ |
| 2106 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Takashi Iwai | f9d088b | 2009-01-13 11:54:49 +0100 | [diff] [blame] | 2107 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2108 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2109 | "DFI LanParty", STAC_92HD83XXX_REF), |
Matthew Ranostay | 8bb0ac5 | 2009-02-12 16:50:01 -0500 | [diff] [blame] | 2110 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba, |
| 2111 | "unknown Dell", STAC_DELL_S14), |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 2112 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532, |
| 2113 | "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK), |
| 2114 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533, |
| 2115 | "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK), |
| 2116 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534, |
| 2117 | "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK), |
| 2118 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535, |
| 2119 | "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK), |
| 2120 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c, |
| 2121 | "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK), |
| 2122 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d, |
| 2123 | "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK), |
| 2124 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549, |
| 2125 | "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK), |
| 2126 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d, |
| 2127 | "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK), |
| 2128 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584, |
| 2129 | "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK), |
Julian Wollrath | f7f9bdf | 2011-11-09 10:02:40 +0100 | [diff] [blame] | 2130 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028, |
| 2131 | "Dell Vostro 3500", STAC_DELL_VOSTRO_3500), |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2132 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656, |
| 2133 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2134 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657, |
| 2135 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2136 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658, |
| 2137 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2138 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659, |
Takashi Iwai | 8ae5865 | 2012-12-13 14:33:42 +0100 | [diff] [blame] | 2139 | "HP Pavilion dv7", STAC_HP_DV7_4000), |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2140 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A, |
| 2141 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2142 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B, |
| 2143 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 2144 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, |
| 2145 | "HP Folio", STAC_92HD83XXX_HP_MIC_LED), |
Vitaliy Kulikov | 0c27c18 | 2011-07-22 17:50:37 -0500 | [diff] [blame] | 2146 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388, |
| 2147 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2148 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389, |
| 2149 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2150 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B, |
| 2151 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2152 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C, |
| 2153 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2154 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D, |
| 2155 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2156 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E, |
| 2157 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2158 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F, |
| 2159 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2160 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560, |
| 2161 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2162 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B, |
| 2163 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2164 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C, |
| 2165 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2166 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D, |
| 2167 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2168 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591, |
| 2169 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2170 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592, |
| 2171 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
| 2172 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593, |
| 2173 | "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2174 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561, |
| 2175 | "HP", STAC_HP_ZEPHYR), |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 2176 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660, |
| 2177 | "HP Mini", STAC_92HD83XXX_HP_LED), |
Gustavo Maciel Dias Vieira | 5afc13a | 2012-10-26 12:51:53 -0200 | [diff] [blame] | 2178 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E, |
| 2179 | "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED), |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 2180 | {} /* terminator */ |
| 2181 | }; |
| 2182 | |
| 2183 | static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = { |
| 2184 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561, |
| 2185 | "HP", STAC_HP_ZEPHYR), |
Herton Ronaldo Krzesinski | 574f3c4 | 2008-12-23 16:53:00 -0200 | [diff] [blame] | 2186 | {} /* terminator */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 2187 | }; |
| 2188 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2189 | static const struct hda_pintbl ref92hd71bxx_pin_configs[] = { |
| 2190 | { 0x0a, 0x02214030 }, |
| 2191 | { 0x0b, 0x02a19040 }, |
| 2192 | { 0x0c, 0x01a19020 }, |
| 2193 | { 0x0d, 0x01014010 }, |
| 2194 | { 0x0e, 0x0181302e }, |
| 2195 | { 0x0f, 0x01014010 }, |
| 2196 | { 0x14, 0x01019020 }, |
| 2197 | { 0x18, 0x90a000f0 }, |
| 2198 | { 0x19, 0x90a000f0 }, |
| 2199 | { 0x1e, 0x01452050 }, |
| 2200 | { 0x1f, 0x01452050 }, |
| 2201 | {} |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2202 | }; |
| 2203 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2204 | static const struct hda_pintbl dell_m4_1_pin_configs[] = { |
| 2205 | { 0x0a, 0x0421101f }, |
| 2206 | { 0x0b, 0x04a11221 }, |
| 2207 | { 0x0c, 0x40f000f0 }, |
| 2208 | { 0x0d, 0x90170110 }, |
| 2209 | { 0x0e, 0x23a1902e }, |
| 2210 | { 0x0f, 0x23014250 }, |
| 2211 | { 0x14, 0x40f000f0 }, |
| 2212 | { 0x18, 0x90a000f0 }, |
| 2213 | { 0x19, 0x40f000f0 }, |
| 2214 | { 0x1e, 0x4f0000f0 }, |
| 2215 | { 0x1f, 0x4f0000f0 }, |
| 2216 | {} |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2217 | }; |
| 2218 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2219 | static const struct hda_pintbl dell_m4_2_pin_configs[] = { |
| 2220 | { 0x0a, 0x0421101f }, |
| 2221 | { 0x0b, 0x04a11221 }, |
| 2222 | { 0x0c, 0x90a70330 }, |
| 2223 | { 0x0d, 0x90170110 }, |
| 2224 | { 0x0e, 0x23a1902e }, |
| 2225 | { 0x0f, 0x23014250 }, |
| 2226 | { 0x14, 0x40f000f0 }, |
| 2227 | { 0x18, 0x40f000f0 }, |
| 2228 | { 0x19, 0x40f000f0 }, |
| 2229 | { 0x1e, 0x044413b0 }, |
| 2230 | { 0x1f, 0x044413b0 }, |
| 2231 | {} |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2232 | }; |
| 2233 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2234 | static const struct hda_pintbl dell_m4_3_pin_configs[] = { |
| 2235 | { 0x0a, 0x0421101f }, |
| 2236 | { 0x0b, 0x04a11221 }, |
| 2237 | { 0x0c, 0x90a70330 }, |
| 2238 | { 0x0d, 0x90170110 }, |
| 2239 | { 0x0e, 0x40f000f0 }, |
| 2240 | { 0x0f, 0x40f000f0 }, |
| 2241 | { 0x14, 0x40f000f0 }, |
| 2242 | { 0x18, 0x90a000f0 }, |
| 2243 | { 0x19, 0x40f000f0 }, |
| 2244 | { 0x1e, 0x044413b0 }, |
| 2245 | { 0x1f, 0x044413b0 }, |
| 2246 | {} |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 2247 | }; |
| 2248 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2249 | static void stac92hd71bxx_fixup_ref(struct hda_codec *codec, |
| 2250 | const struct hda_fixup *fix, int action) |
| 2251 | { |
| 2252 | struct sigmatel_spec *spec = codec->spec; |
| 2253 | |
| 2254 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2255 | return; |
| 2256 | |
| 2257 | snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs); |
| 2258 | spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0; |
| 2259 | } |
| 2260 | |
| 2261 | static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec, |
| 2262 | const struct hda_fixup *fix, int action) |
| 2263 | { |
| 2264 | struct sigmatel_spec *spec = codec->spec; |
| 2265 | |
| 2266 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2267 | return; |
| 2268 | spec->num_dmics = 0; |
| 2269 | spec->num_smuxes = 0; |
| 2270 | spec->num_dmuxes = 0; |
| 2271 | } |
| 2272 | |
| 2273 | static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec, |
| 2274 | const struct hda_fixup *fix, int action) |
| 2275 | { |
| 2276 | struct sigmatel_spec *spec = codec->spec; |
| 2277 | |
| 2278 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2279 | return; |
| 2280 | spec->num_dmics = 1; |
| 2281 | spec->num_smuxes = 0; |
| 2282 | spec->num_dmuxes = 1; |
| 2283 | } |
| 2284 | |
| 2285 | static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec, |
| 2286 | const struct hda_fixup *fix, int action) |
| 2287 | { |
| 2288 | struct sigmatel_spec *spec = codec->spec; |
| 2289 | |
| 2290 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2291 | return; |
| 2292 | |
| 2293 | /* Enable VREF power saving on GPIO1 detect */ |
| 2294 | stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02); |
| 2295 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 2296 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 2297 | snd_hda_jack_detect_enable(codec, codec->afg, 0); |
| 2298 | spec->gpio_mask |= 0x02; |
| 2299 | |
| 2300 | /* enable internal microphone */ |
| 2301 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
| 2302 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 2303 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
| 2304 | |
| 2305 | stac92hd71bxx_fixup_no_dmic(codec, fix, action); |
| 2306 | } |
| 2307 | |
| 2308 | static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec, |
| 2309 | const struct hda_fixup *fix, int action) |
| 2310 | { |
| 2311 | struct sigmatel_spec *spec = codec->spec; |
| 2312 | |
| 2313 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2314 | return; |
| 2315 | spec->num_dmics = 1; |
| 2316 | /* I don't know if it needs 1 or 2 smuxes - will wait for |
| 2317 | * bug reports to fix if needed |
| 2318 | */ |
| 2319 | spec->num_smuxes = 1; |
| 2320 | spec->num_dmuxes = 1; |
| 2321 | } |
| 2322 | |
| 2323 | static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec, |
| 2324 | const struct hda_fixup *fix, int action) |
| 2325 | { |
| 2326 | struct sigmatel_spec *spec = codec->spec; |
| 2327 | |
| 2328 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2329 | return; |
| 2330 | spec->gpio_led = 0x01; |
| 2331 | } |
| 2332 | |
| 2333 | static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec, |
| 2334 | const struct hda_fixup *fix, int action) |
| 2335 | { |
| 2336 | struct sigmatel_spec *spec = codec->spec; |
| 2337 | unsigned int cap; |
| 2338 | |
| 2339 | switch (action) { |
| 2340 | case HDA_FIXUP_ACT_PRE_PROBE: |
| 2341 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
| 2342 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
| 2343 | /* HP dv6 gives the headphone pin as a line-out. Thus we |
| 2344 | * need to set hp_detect flag here to force to enable HP |
| 2345 | * detection. |
| 2346 | */ |
| 2347 | spec->hp_detect = 1; |
| 2348 | break; |
| 2349 | |
| 2350 | case HDA_FIXUP_ACT_PROBE: |
| 2351 | /* enable bass on HP dv7 */ |
| 2352 | cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP); |
| 2353 | cap &= AC_GPIO_IO_COUNT; |
| 2354 | if (cap >= 6) |
| 2355 | stac_add_hp_bass_switch(codec); |
| 2356 | break; |
| 2357 | } |
| 2358 | } |
| 2359 | |
| 2360 | static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec, |
| 2361 | const struct hda_fixup *fix, int action) |
| 2362 | { |
| 2363 | struct sigmatel_spec *spec = codec->spec; |
| 2364 | |
| 2365 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2366 | return; |
| 2367 | spec->gpio_led = 0x08; |
| 2368 | spec->num_dmics = 1; |
| 2369 | spec->num_smuxes = 1; |
| 2370 | spec->num_dmuxes = 1; |
| 2371 | } |
| 2372 | |
| 2373 | |
| 2374 | static void stac92hd71bxx_fixup_hp(struct hda_codec *codec, |
| 2375 | const struct hda_fixup *fix, int action) |
| 2376 | { |
| 2377 | struct sigmatel_spec *spec = codec->spec; |
| 2378 | |
| 2379 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2380 | return; |
| 2381 | |
| 2382 | if (hp_blike_system(codec->subsystem_id)) { |
| 2383 | unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f); |
| 2384 | if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT || |
| 2385 | get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER || |
| 2386 | get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) { |
| 2387 | /* It was changed in the BIOS to just satisfy MS DTM. |
| 2388 | * Lets turn it back into slaved HP |
| 2389 | */ |
| 2390 | pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) |
| 2391 | | (AC_JACK_HP_OUT << |
| 2392 | AC_DEFCFG_DEVICE_SHIFT); |
| 2393 | pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC |
| 2394 | | AC_DEFCFG_SEQUENCE))) |
| 2395 | | 0x1f; |
| 2396 | snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg); |
| 2397 | } |
| 2398 | } |
| 2399 | |
| 2400 | if (find_mute_led_cfg(codec, 1)) |
| 2401 | snd_printd("mute LED gpio %d polarity %d\n", |
| 2402 | spec->gpio_led, |
| 2403 | spec->gpio_led_polarity); |
| 2404 | |
| 2405 | } |
| 2406 | |
| 2407 | static const struct hda_fixup stac92hd71bxx_fixups[] = { |
| 2408 | [STAC_92HD71BXX_REF] = { |
| 2409 | .type = HDA_FIXUP_FUNC, |
| 2410 | .v.func = stac92hd71bxx_fixup_ref, |
| 2411 | }, |
| 2412 | [STAC_DELL_M4_1] = { |
| 2413 | .type = HDA_FIXUP_PINS, |
| 2414 | .v.pins = dell_m4_1_pin_configs, |
| 2415 | .chained = true, |
| 2416 | .chain_id = STAC_92HD71BXX_NO_SMUX, |
| 2417 | }, |
| 2418 | [STAC_DELL_M4_2] = { |
| 2419 | .type = HDA_FIXUP_PINS, |
| 2420 | .v.pins = dell_m4_2_pin_configs, |
| 2421 | .chained = true, |
| 2422 | .chain_id = STAC_92HD71BXX_NO_DMIC, |
| 2423 | }, |
| 2424 | [STAC_DELL_M4_3] = { |
| 2425 | .type = HDA_FIXUP_PINS, |
| 2426 | .v.pins = dell_m4_3_pin_configs, |
| 2427 | .chained = true, |
| 2428 | .chain_id = STAC_92HD71BXX_NO_SMUX, |
| 2429 | }, |
| 2430 | [STAC_HP_M4] = { |
| 2431 | .type = HDA_FIXUP_FUNC, |
| 2432 | .v.func = stac92hd71bxx_fixup_hp_m4, |
| 2433 | .chained = true, |
| 2434 | .chain_id = STAC_92HD71BXX_HP, |
| 2435 | }, |
| 2436 | [STAC_HP_DV4] = { |
| 2437 | .type = HDA_FIXUP_FUNC, |
| 2438 | .v.func = stac92hd71bxx_fixup_hp_dv4, |
| 2439 | .chained = true, |
| 2440 | .chain_id = STAC_HP_DV5, |
| 2441 | }, |
| 2442 | [STAC_HP_DV5] = { |
| 2443 | .type = HDA_FIXUP_FUNC, |
| 2444 | .v.func = stac92hd71bxx_fixup_hp_dv5, |
| 2445 | .chained = true, |
| 2446 | .chain_id = STAC_92HD71BXX_HP, |
| 2447 | }, |
| 2448 | [STAC_HP_HDX] = { |
| 2449 | .type = HDA_FIXUP_FUNC, |
| 2450 | .v.func = stac92hd71bxx_fixup_hp_hdx, |
| 2451 | .chained = true, |
| 2452 | .chain_id = STAC_92HD71BXX_HP, |
| 2453 | }, |
| 2454 | [STAC_HP_DV4_1222NR] = { |
| 2455 | .type = HDA_FIXUP_FUNC, |
| 2456 | .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr, |
| 2457 | .chained = true, |
| 2458 | .chain_id = STAC_HP_DV4, |
| 2459 | }, |
| 2460 | [STAC_92HD71BXX_NO_DMIC] = { |
| 2461 | .type = HDA_FIXUP_FUNC, |
| 2462 | .v.func = stac92hd71bxx_fixup_no_dmic, |
| 2463 | }, |
| 2464 | [STAC_92HD71BXX_NO_SMUX] = { |
| 2465 | .type = HDA_FIXUP_FUNC, |
| 2466 | .v.func = stac92hd71bxx_fixup_no_smux, |
| 2467 | }, |
| 2468 | [STAC_92HD71BXX_HP] = { |
| 2469 | .type = HDA_FIXUP_FUNC, |
| 2470 | .v.func = stac92hd71bxx_fixup_hp, |
| 2471 | }, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2472 | }; |
| 2473 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2474 | static const struct hda_model_fixup stac92hd71bxx_models[] = { |
| 2475 | { .id = STAC_92HD71BXX_REF, .name = "ref" }, |
| 2476 | { .id = STAC_DELL_M4_1, .name = "dell-m4-1" }, |
| 2477 | { .id = STAC_DELL_M4_2, .name = "dell-m4-2" }, |
| 2478 | { .id = STAC_DELL_M4_3, .name = "dell-m4-3" }, |
| 2479 | { .id = STAC_HP_M4, .name = "hp-m4" }, |
| 2480 | { .id = STAC_HP_DV4, .name = "hp-dv4" }, |
| 2481 | { .id = STAC_HP_DV5, .name = "hp-dv5" }, |
| 2482 | { .id = STAC_HP_HDX, .name = "hp-hdx" }, |
| 2483 | { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" }, |
| 2484 | {} |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2485 | }; |
| 2486 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2487 | static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2488 | /* SigmaTel reference board */ |
| 2489 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2490 | "DFI LanParty", STAC_92HD71BXX_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2491 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2492 | "DFI LanParty", STAC_92HD71BXX_REF), |
James Gardiner | 514bf54 | 2009-05-03 04:00:44 -0400 | [diff] [blame] | 2493 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb, |
| 2494 | "HP dv4-1222nr", STAC_HP_DV4_1222NR), |
Vitaliy Kulikov | 5bdaaad | 2009-11-04 07:57:45 +0100 | [diff] [blame] | 2495 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720, |
| 2496 | "HP", STAC_HP_DV5), |
Takashi Iwai | 58d8395 | 2009-03-13 17:04:34 +0100 | [diff] [blame] | 2497 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080, |
| 2498 | "HP", STAC_HP_DV5), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 2499 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0, |
Takashi Iwai | 2a6ce6e | 2010-05-12 10:16:20 +0200 | [diff] [blame] | 2500 | "HP dv4-7", STAC_HP_DV4), |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 2501 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600, |
| 2502 | "HP dv4-7", STAC_HP_DV5), |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 2503 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610, |
| 2504 | "HP HDX", STAC_HP_HDX), /* HDX18 */ |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 2505 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
Takashi Iwai | 2ae466f | 2009-02-16 14:16:36 +0100 | [diff] [blame] | 2506 | "HP mini 1000", STAC_HP_M4), |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 2507 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 2508 | "HP HDX", STAC_HP_HDX), /* HDX16 */ |
Takashi Iwai | 6e34c03 | 2009-09-14 15:42:18 +0200 | [diff] [blame] | 2509 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620, |
| 2510 | "HP dv6", STAC_HP_DV5), |
Kunal Gangakhedkar | e3d2530 | 2010-03-20 23:08:01 +0530 | [diff] [blame] | 2511 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061, |
| 2512 | "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */ |
Luke Yelavich | 9b2167d | 2010-10-06 15:45:46 +1100 | [diff] [blame] | 2513 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e, |
| 2514 | "HP DV6", STAC_HP_DV5), |
Takashi Iwai | 1972d02 | 2009-08-06 08:44:43 +0200 | [diff] [blame] | 2515 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010, |
| 2516 | "HP", STAC_HP_DV5), |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 2517 | SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 2518 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 2519 | "unknown Dell", STAC_DELL_M4_1), |
| 2520 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 2521 | "unknown Dell", STAC_DELL_M4_1), |
| 2522 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 2523 | "unknown Dell", STAC_DELL_M4_1), |
| 2524 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 2525 | "unknown Dell", STAC_DELL_M4_1), |
| 2526 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 2527 | "unknown Dell", STAC_DELL_M4_1), |
| 2528 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 2529 | "unknown Dell", STAC_DELL_M4_1), |
| 2530 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 2531 | "unknown Dell", STAC_DELL_M4_1), |
| 2532 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 2533 | "unknown Dell", STAC_DELL_M4_2), |
| 2534 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 2535 | "unknown Dell", STAC_DELL_M4_2), |
| 2536 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 2537 | "unknown Dell", STAC_DELL_M4_2), |
| 2538 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 2539 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 2540 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 2541 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 2542 | {} /* terminator */ |
| 2543 | }; |
| 2544 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2545 | static const struct hda_pintbl ref922x_pin_configs[] = { |
| 2546 | { 0x0a, 0x01014010 }, |
| 2547 | { 0x0b, 0x01016011 }, |
| 2548 | { 0x0c, 0x01012012 }, |
| 2549 | { 0x0d, 0x0221401f }, |
| 2550 | { 0x0e, 0x01813122 }, |
| 2551 | { 0x0f, 0x01011014 }, |
| 2552 | { 0x10, 0x01441030 }, |
| 2553 | { 0x11, 0x01c41030 }, |
| 2554 | { 0x15, 0x40000100 }, |
| 2555 | { 0x1b, 0x40000100 }, |
| 2556 | {} |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2557 | }; |
| 2558 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2559 | /* |
| 2560 | STAC 922X pin configs for |
| 2561 | 102801A7 |
| 2562 | 102801AB |
| 2563 | 102801A9 |
| 2564 | 102801D1 |
| 2565 | 102801D2 |
| 2566 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2567 | static const struct hda_pintbl dell_922x_d81_pin_configs[] = { |
| 2568 | { 0x0a, 0x02214030 }, |
| 2569 | { 0x0b, 0x01a19021 }, |
| 2570 | { 0x0c, 0x01111012 }, |
| 2571 | { 0x0d, 0x01114010 }, |
| 2572 | { 0x0e, 0x02a19020 }, |
| 2573 | { 0x0f, 0x01117011 }, |
| 2574 | { 0x10, 0x400001f0 }, |
| 2575 | { 0x11, 0x400001f1 }, |
| 2576 | { 0x15, 0x01813122 }, |
| 2577 | { 0x1b, 0x400001f2 }, |
| 2578 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2579 | }; |
| 2580 | |
| 2581 | /* |
| 2582 | STAC 922X pin configs for |
| 2583 | 102801AC |
| 2584 | 102801D0 |
| 2585 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2586 | static const struct hda_pintbl dell_922x_d82_pin_configs[] = { |
| 2587 | { 0x0a, 0x02214030 }, |
| 2588 | { 0x0b, 0x01a19021 }, |
| 2589 | { 0x0c, 0x01111012 }, |
| 2590 | { 0x0d, 0x01114010 }, |
| 2591 | { 0x0e, 0x02a19020 }, |
| 2592 | { 0x0f, 0x01117011 }, |
| 2593 | { 0x10, 0x01451140 }, |
| 2594 | { 0x11, 0x400001f0 }, |
| 2595 | { 0x15, 0x01813122 }, |
| 2596 | { 0x1b, 0x400001f1 }, |
| 2597 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2598 | }; |
| 2599 | |
| 2600 | /* |
| 2601 | STAC 922X pin configs for |
| 2602 | 102801BF |
| 2603 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2604 | static const struct hda_pintbl dell_922x_m81_pin_configs[] = { |
| 2605 | { 0x0a, 0x0321101f }, |
| 2606 | { 0x0b, 0x01112024 }, |
| 2607 | { 0x0c, 0x01111222 }, |
| 2608 | { 0x0d, 0x91174220 }, |
| 2609 | { 0x0e, 0x03a11050 }, |
| 2610 | { 0x0f, 0x01116221 }, |
| 2611 | { 0x10, 0x90a70330 }, |
| 2612 | { 0x11, 0x01452340 }, |
| 2613 | { 0x15, 0x40C003f1 }, |
| 2614 | { 0x1b, 0x405003f0 }, |
| 2615 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2616 | }; |
| 2617 | |
| 2618 | /* |
| 2619 | STAC 9221 A1 pin configs for |
| 2620 | 102801D7 (Dell XPS M1210) |
| 2621 | */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2622 | static const struct hda_pintbl dell_922x_m82_pin_configs[] = { |
| 2623 | { 0x0a, 0x02211211 }, |
| 2624 | { 0x0b, 0x408103ff }, |
| 2625 | { 0x0c, 0x02a1123e }, |
| 2626 | { 0x0d, 0x90100310 }, |
| 2627 | { 0x0e, 0x408003f1 }, |
| 2628 | { 0x0f, 0x0221121f }, |
| 2629 | { 0x10, 0x03451340 }, |
| 2630 | { 0x11, 0x40c003f2 }, |
| 2631 | { 0x15, 0x508003f3 }, |
| 2632 | { 0x1b, 0x405003f4 }, |
| 2633 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2634 | }; |
| 2635 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2636 | static const struct hda_pintbl d945gtp3_pin_configs[] = { |
| 2637 | { 0x0a, 0x0221401f }, |
| 2638 | { 0x0b, 0x01a19022 }, |
| 2639 | { 0x0c, 0x01813021 }, |
| 2640 | { 0x0d, 0x01014010 }, |
| 2641 | { 0x0e, 0x40000100 }, |
| 2642 | { 0x0f, 0x40000100 }, |
| 2643 | { 0x10, 0x40000100 }, |
| 2644 | { 0x11, 0x40000100 }, |
| 2645 | { 0x15, 0x02a19120 }, |
| 2646 | { 0x1b, 0x40000100 }, |
| 2647 | {} |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2648 | }; |
| 2649 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2650 | static const struct hda_pintbl d945gtp5_pin_configs[] = { |
| 2651 | { 0x0a, 0x0221401f }, |
| 2652 | { 0x0b, 0x01011012 }, |
| 2653 | { 0x0c, 0x01813024 }, |
| 2654 | { 0x0d, 0x01014010 }, |
| 2655 | { 0x0e, 0x01a19021 }, |
| 2656 | { 0x0f, 0x01016011 }, |
| 2657 | { 0x10, 0x01452130 }, |
| 2658 | { 0x11, 0x40000100 }, |
| 2659 | { 0x15, 0x02a19320 }, |
| 2660 | { 0x1b, 0x40000100 }, |
| 2661 | {} |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2662 | }; |
| 2663 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2664 | static const struct hda_pintbl intel_mac_v1_pin_configs[] = { |
| 2665 | { 0x0a, 0x0121e21f }, |
| 2666 | { 0x0b, 0x400000ff }, |
| 2667 | { 0x0c, 0x9017e110 }, |
| 2668 | { 0x0d, 0x400000fd }, |
| 2669 | { 0x0e, 0x400000fe }, |
| 2670 | { 0x0f, 0x0181e020 }, |
| 2671 | { 0x10, 0x1145e030 }, |
| 2672 | { 0x11, 0x11c5e240 }, |
| 2673 | { 0x15, 0x400000fc }, |
| 2674 | { 0x1b, 0x400000fb }, |
| 2675 | {} |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 2676 | }; |
| 2677 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2678 | static const struct hda_pintbl intel_mac_v2_pin_configs[] = { |
| 2679 | { 0x0a, 0x0121e21f }, |
| 2680 | { 0x0b, 0x90a7012e }, |
| 2681 | { 0x0c, 0x9017e110 }, |
| 2682 | { 0x0d, 0x400000fd }, |
| 2683 | { 0x0e, 0x400000fe }, |
| 2684 | { 0x0f, 0x0181e020 }, |
| 2685 | { 0x10, 0x1145e230 }, |
| 2686 | { 0x11, 0x500000fa }, |
| 2687 | { 0x15, 0x400000fc }, |
| 2688 | { 0x1b, 0x400000fb }, |
| 2689 | {} |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 2690 | }; |
| 2691 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2692 | static const struct hda_pintbl intel_mac_v3_pin_configs[] = { |
| 2693 | { 0x0a, 0x0121e21f }, |
| 2694 | { 0x0b, 0x90a7012e }, |
| 2695 | { 0x0c, 0x9017e110 }, |
| 2696 | { 0x0d, 0x400000fd }, |
| 2697 | { 0x0e, 0x400000fe }, |
| 2698 | { 0x0f, 0x0181e020 }, |
| 2699 | { 0x10, 0x1145e230 }, |
| 2700 | { 0x11, 0x11c5e240 }, |
| 2701 | { 0x15, 0x400000fc }, |
| 2702 | { 0x1b, 0x400000fb }, |
| 2703 | {} |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2704 | }; |
| 2705 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2706 | static const struct hda_pintbl intel_mac_v4_pin_configs[] = { |
| 2707 | { 0x0a, 0x0321e21f }, |
| 2708 | { 0x0b, 0x03a1e02e }, |
| 2709 | { 0x0c, 0x9017e110 }, |
| 2710 | { 0x0d, 0x9017e11f }, |
| 2711 | { 0x0e, 0x400000fe }, |
| 2712 | { 0x0f, 0x0381e020 }, |
| 2713 | { 0x10, 0x1345e230 }, |
| 2714 | { 0x11, 0x13c5e240 }, |
| 2715 | { 0x15, 0x400000fc }, |
| 2716 | { 0x1b, 0x400000fb }, |
| 2717 | {} |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 2718 | }; |
| 2719 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2720 | static const struct hda_pintbl intel_mac_v5_pin_configs[] = { |
| 2721 | { 0x0a, 0x0321e21f }, |
| 2722 | { 0x0b, 0x03a1e02e }, |
| 2723 | { 0x0c, 0x9017e110 }, |
| 2724 | { 0x0d, 0x9017e11f }, |
| 2725 | { 0x0e, 0x400000fe }, |
| 2726 | { 0x0f, 0x0381e020 }, |
| 2727 | { 0x10, 0x1345e230 }, |
| 2728 | { 0x11, 0x13c5e240 }, |
| 2729 | { 0x15, 0x400000fc }, |
| 2730 | { 0x1b, 0x400000fb }, |
| 2731 | {} |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 2732 | }; |
| 2733 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2734 | static const struct hda_pintbl ecs202_pin_configs[] = { |
| 2735 | { 0x0a, 0x0221401f }, |
| 2736 | { 0x0b, 0x02a19020 }, |
| 2737 | { 0x0c, 0x01a19020 }, |
| 2738 | { 0x0d, 0x01114010 }, |
| 2739 | { 0x0e, 0x408000f0 }, |
| 2740 | { 0x0f, 0x01813022 }, |
| 2741 | { 0x10, 0x074510a0 }, |
| 2742 | { 0x11, 0x40c400f1 }, |
| 2743 | { 0x15, 0x9037012e }, |
| 2744 | { 0x1b, 0x40e000f2 }, |
| 2745 | {} |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2746 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 2747 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2748 | /* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */ |
| 2749 | static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = { |
| 2750 | SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1), |
| 2751 | SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2), |
| 2752 | SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2), |
| 2753 | SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3), |
| 2754 | SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3), |
| 2755 | SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3), |
| 2756 | SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3), |
| 2757 | SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3), |
| 2758 | SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3), |
| 2759 | SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4), |
| 2760 | SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5), |
| 2761 | SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5), |
| 2762 | {} |
| 2763 | }; |
| 2764 | |
| 2765 | static const struct hda_fixup stac922x_fixups[]; |
| 2766 | |
| 2767 | /* remap the fixup from codec SSID and apply it */ |
| 2768 | static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec, |
| 2769 | const struct hda_fixup *fix, |
| 2770 | int action) |
| 2771 | { |
| 2772 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 2773 | return; |
| 2774 | snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl, |
| 2775 | stac922x_fixups); |
| 2776 | if (codec->fixup_id != STAC_INTEL_MAC_AUTO) |
| 2777 | snd_hda_apply_fixup(codec, action); |
| 2778 | } |
| 2779 | |
| 2780 | static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec, |
| 2781 | const struct hda_fixup *fix, |
| 2782 | int action) |
| 2783 | { |
| 2784 | struct sigmatel_spec *spec = codec->spec; |
| 2785 | |
| 2786 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 2787 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 2788 | spec->gpio_data = 0x03; |
| 2789 | } |
| 2790 | } |
| 2791 | |
| 2792 | static const struct hda_fixup stac922x_fixups[] = { |
| 2793 | [STAC_D945_REF] = { |
| 2794 | .type = HDA_FIXUP_PINS, |
| 2795 | .v.pins = ref922x_pin_configs, |
| 2796 | }, |
| 2797 | [STAC_D945GTP3] = { |
| 2798 | .type = HDA_FIXUP_PINS, |
| 2799 | .v.pins = d945gtp3_pin_configs, |
| 2800 | }, |
| 2801 | [STAC_D945GTP5] = { |
| 2802 | .type = HDA_FIXUP_PINS, |
| 2803 | .v.pins = d945gtp5_pin_configs, |
| 2804 | }, |
| 2805 | [STAC_INTEL_MAC_AUTO] = { |
| 2806 | .type = HDA_FIXUP_FUNC, |
| 2807 | .v.func = stac922x_fixup_intel_mac_auto, |
| 2808 | }, |
| 2809 | [STAC_INTEL_MAC_V1] = { |
| 2810 | .type = HDA_FIXUP_PINS, |
| 2811 | .v.pins = intel_mac_v1_pin_configs, |
| 2812 | .chained = true, |
| 2813 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2814 | }, |
| 2815 | [STAC_INTEL_MAC_V2] = { |
| 2816 | .type = HDA_FIXUP_PINS, |
| 2817 | .v.pins = intel_mac_v2_pin_configs, |
| 2818 | .chained = true, |
| 2819 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2820 | }, |
| 2821 | [STAC_INTEL_MAC_V3] = { |
| 2822 | .type = HDA_FIXUP_PINS, |
| 2823 | .v.pins = intel_mac_v3_pin_configs, |
| 2824 | .chained = true, |
| 2825 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2826 | }, |
| 2827 | [STAC_INTEL_MAC_V4] = { |
| 2828 | .type = HDA_FIXUP_PINS, |
| 2829 | .v.pins = intel_mac_v4_pin_configs, |
| 2830 | .chained = true, |
| 2831 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2832 | }, |
| 2833 | [STAC_INTEL_MAC_V5] = { |
| 2834 | .type = HDA_FIXUP_PINS, |
| 2835 | .v.pins = intel_mac_v5_pin_configs, |
| 2836 | .chained = true, |
| 2837 | .chain_id = STAC_922X_INTEL_MAC_GPIO, |
| 2838 | }, |
| 2839 | [STAC_922X_INTEL_MAC_GPIO] = { |
| 2840 | .type = HDA_FIXUP_FUNC, |
| 2841 | .v.func = stac922x_fixup_intel_mac_gpio, |
| 2842 | }, |
| 2843 | [STAC_ECS_202] = { |
| 2844 | .type = HDA_FIXUP_PINS, |
| 2845 | .v.pins = ecs202_pin_configs, |
| 2846 | }, |
| 2847 | [STAC_922X_DELL_D81] = { |
| 2848 | .type = HDA_FIXUP_PINS, |
| 2849 | .v.pins = dell_922x_d81_pin_configs, |
| 2850 | }, |
| 2851 | [STAC_922X_DELL_D82] = { |
| 2852 | .type = HDA_FIXUP_PINS, |
| 2853 | .v.pins = dell_922x_d82_pin_configs, |
| 2854 | }, |
| 2855 | [STAC_922X_DELL_M81] = { |
| 2856 | .type = HDA_FIXUP_PINS, |
| 2857 | .v.pins = dell_922x_m81_pin_configs, |
| 2858 | }, |
| 2859 | [STAC_922X_DELL_M82] = { |
| 2860 | .type = HDA_FIXUP_PINS, |
| 2861 | .v.pins = dell_922x_m82_pin_configs, |
| 2862 | }, |
| 2863 | }; |
| 2864 | |
| 2865 | static const struct hda_model_fixup stac922x_models[] = { |
| 2866 | { .id = STAC_D945_REF, .name = "ref" }, |
| 2867 | { .id = STAC_D945GTP5, .name = "5stack" }, |
| 2868 | { .id = STAC_D945GTP3, .name = "3stack" }, |
| 2869 | { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" }, |
| 2870 | { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" }, |
| 2871 | { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" }, |
| 2872 | { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" }, |
| 2873 | { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" }, |
| 2874 | { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" }, |
| 2875 | { .id = STAC_ECS_202, .name = "ecs202" }, |
| 2876 | { .id = STAC_922X_DELL_D81, .name = "dell-d81" }, |
| 2877 | { .id = STAC_922X_DELL_D82, .name = "dell-d82" }, |
| 2878 | { .id = STAC_922X_DELL_M81, .name = "dell-m81" }, |
| 2879 | { .id = STAC_922X_DELL_M82, .name = "dell-m82" }, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2880 | /* for backward compatibility */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2881 | { .id = STAC_INTEL_MAC_V3, .name = "macmini" }, |
| 2882 | { .id = STAC_INTEL_MAC_V5, .name = "macbook" }, |
| 2883 | { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" }, |
| 2884 | { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" }, |
| 2885 | { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" }, |
| 2886 | { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" }, |
| 2887 | {} |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2888 | }; |
| 2889 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2890 | static const struct snd_pci_quirk stac922x_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2891 | /* SigmaTel reference board */ |
| 2892 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2893 | "DFI LanParty", STAC_D945_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 2894 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 2895 | "DFI LanParty", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2896 | /* Intel 945G based systems */ |
| 2897 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2898 | "Intel D945G", STAC_D945GTP3), |
| 2899 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2900 | "Intel D945G", STAC_D945GTP3), |
| 2901 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2902 | "Intel D945G", STAC_D945GTP3), |
| 2903 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2904 | "Intel D945G", STAC_D945GTP3), |
| 2905 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2906 | "Intel D945G", STAC_D945GTP3), |
| 2907 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2908 | "Intel D945G", STAC_D945GTP3), |
| 2909 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2910 | "Intel D945G", STAC_D945GTP3), |
| 2911 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2912 | "Intel D945G", STAC_D945GTP3), |
| 2913 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2914 | "Intel D945G", STAC_D945GTP3), |
| 2915 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2916 | "Intel D945G", STAC_D945GTP3), |
| 2917 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2918 | "Intel D945G", STAC_D945GTP3), |
| 2919 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2920 | "Intel D945G", STAC_D945GTP3), |
| 2921 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2922 | "Intel D945G", STAC_D945GTP3), |
| 2923 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2924 | "Intel D945G", STAC_D945GTP3), |
| 2925 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2926 | "Intel D945G", STAC_D945GTP3), |
| 2927 | /* Intel D945G 5-stack systems */ |
| 2928 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2929 | "Intel D945G", STAC_D945GTP5), |
| 2930 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2931 | "Intel D945G", STAC_D945GTP5), |
| 2932 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2933 | "Intel D945G", STAC_D945GTP5), |
| 2934 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2935 | "Intel D945G", STAC_D945GTP5), |
| 2936 | /* Intel 945P based systems */ |
| 2937 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2938 | "Intel D945P", STAC_D945GTP3), |
| 2939 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2940 | "Intel D945P", STAC_D945GTP3), |
| 2941 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2942 | "Intel D945P", STAC_D945GTP3), |
| 2943 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2944 | "Intel D945P", STAC_D945GTP3), |
| 2945 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2946 | "Intel D945P", STAC_D945GTP3), |
| 2947 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2948 | "Intel D945P", STAC_D945GTP5), |
Takashi Iwai | 8056d47 | 2009-01-23 09:09:43 +0100 | [diff] [blame] | 2949 | /* other intel */ |
| 2950 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204, |
| 2951 | "Intel D945", STAC_D945_REF), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2952 | /* other systems */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2953 | |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2954 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 2955 | SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO), |
| 2956 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2957 | /* Dell systems */ |
| 2958 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2959 | "unknown Dell", STAC_922X_DELL_D81), |
| 2960 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2961 | "unknown Dell", STAC_922X_DELL_D81), |
| 2962 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2963 | "unknown Dell", STAC_922X_DELL_D81), |
| 2964 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2965 | "unknown Dell", STAC_922X_DELL_D82), |
| 2966 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2967 | "unknown Dell", STAC_922X_DELL_M81), |
| 2968 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2969 | "unknown Dell", STAC_922X_DELL_D82), |
| 2970 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2971 | "unknown Dell", STAC_922X_DELL_D81), |
| 2972 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2973 | "unknown Dell", STAC_922X_DELL_D81), |
| 2974 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2975 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2976 | /* ECS/PC Chips boards */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 2977 | SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000, |
Herton Ronaldo Krzesinski | 8663ae5 | 2009-02-08 19:50:34 -0200 | [diff] [blame] | 2978 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2979 | {} /* terminator */ |
| 2980 | }; |
| 2981 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 2982 | static const struct hda_pintbl ref927x_pin_configs[] = { |
| 2983 | { 0x0a, 0x02214020 }, |
| 2984 | { 0x0b, 0x02a19080 }, |
| 2985 | { 0x0c, 0x0181304e }, |
| 2986 | { 0x0d, 0x01014010 }, |
| 2987 | { 0x0e, 0x01a19040 }, |
| 2988 | { 0x0f, 0x01011012 }, |
| 2989 | { 0x10, 0x01016011 }, |
| 2990 | { 0x11, 0x0101201f }, |
| 2991 | { 0x12, 0x183301f0 }, |
| 2992 | { 0x13, 0x18a001f0 }, |
| 2993 | { 0x14, 0x18a001f0 }, |
| 2994 | { 0x21, 0x01442070 }, |
| 2995 | { 0x22, 0x01c42190 }, |
| 2996 | { 0x23, 0x40000100 }, |
| 2997 | {} |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2998 | }; |
| 2999 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3000 | static const struct hda_pintbl d965_3st_pin_configs[] = { |
| 3001 | { 0x0a, 0x0221401f }, |
| 3002 | { 0x0b, 0x02a19120 }, |
| 3003 | { 0x0c, 0x40000100 }, |
| 3004 | { 0x0d, 0x01014011 }, |
| 3005 | { 0x0e, 0x01a19021 }, |
| 3006 | { 0x0f, 0x01813024 }, |
| 3007 | { 0x10, 0x40000100 }, |
| 3008 | { 0x11, 0x40000100 }, |
| 3009 | { 0x12, 0x40000100 }, |
| 3010 | { 0x13, 0x40000100 }, |
| 3011 | { 0x14, 0x40000100 }, |
| 3012 | { 0x21, 0x40000100 }, |
| 3013 | { 0x22, 0x40000100 }, |
| 3014 | { 0x23, 0x40000100 }, |
| 3015 | {} |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3016 | }; |
| 3017 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3018 | static const struct hda_pintbl d965_5st_pin_configs[] = { |
| 3019 | { 0x0a, 0x02214020 }, |
| 3020 | { 0x0b, 0x02a19080 }, |
| 3021 | { 0x0c, 0x0181304e }, |
| 3022 | { 0x0d, 0x01014010 }, |
| 3023 | { 0x0e, 0x01a19040 }, |
| 3024 | { 0x0f, 0x01011012 }, |
| 3025 | { 0x10, 0x01016011 }, |
| 3026 | { 0x11, 0x40000100 }, |
| 3027 | { 0x12, 0x40000100 }, |
| 3028 | { 0x13, 0x40000100 }, |
| 3029 | { 0x14, 0x40000100 }, |
| 3030 | { 0x21, 0x01442070 }, |
| 3031 | { 0x22, 0x40000100 }, |
| 3032 | { 0x23, 0x40000100 }, |
| 3033 | {} |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 3034 | }; |
| 3035 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3036 | static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = { |
| 3037 | { 0x0a, 0x40000100 }, |
| 3038 | { 0x0b, 0x40000100 }, |
| 3039 | { 0x0c, 0x0181304e }, |
| 3040 | { 0x0d, 0x01014010 }, |
| 3041 | { 0x0e, 0x01a19040 }, |
| 3042 | { 0x0f, 0x01011012 }, |
| 3043 | { 0x10, 0x01016011 }, |
| 3044 | { 0x11, 0x40000100 }, |
| 3045 | { 0x12, 0x40000100 }, |
| 3046 | { 0x13, 0x40000100 }, |
| 3047 | { 0x14, 0x40000100 }, |
| 3048 | { 0x21, 0x01442070 }, |
| 3049 | { 0x22, 0x40000100 }, |
| 3050 | { 0x23, 0x40000100 }, |
| 3051 | {} |
Takashi Iwai | 679d92e | 2009-05-24 19:00:08 +0200 | [diff] [blame] | 3052 | }; |
| 3053 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3054 | static const struct hda_pintbl dell_3st_pin_configs[] = { |
| 3055 | { 0x0a, 0x02211230 }, |
| 3056 | { 0x0b, 0x02a11220 }, |
| 3057 | { 0x0c, 0x01a19040 }, |
| 3058 | { 0x0d, 0x01114210 }, |
| 3059 | { 0x0e, 0x01111212 }, |
| 3060 | { 0x0f, 0x01116211 }, |
| 3061 | { 0x10, 0x01813050 }, |
| 3062 | { 0x11, 0x01112214 }, |
| 3063 | { 0x12, 0x403003fa }, |
| 3064 | { 0x13, 0x90a60040 }, |
| 3065 | { 0x14, 0x90a60040 }, |
| 3066 | { 0x21, 0x404003fb }, |
| 3067 | { 0x22, 0x40c003fc }, |
| 3068 | { 0x23, 0x40000100 }, |
| 3069 | {} |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 3070 | }; |
| 3071 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3072 | static void stac927x_fixup_ref_no_jd(struct hda_codec *codec, |
| 3073 | const struct hda_fixup *fix, int action) |
| 3074 | { |
| 3075 | struct sigmatel_spec *spec = codec->spec; |
| 3076 | |
| 3077 | /* no jack detecion for ref-no-jd model */ |
| 3078 | if (action == HDA_FIXUP_ACT_PROBE) |
| 3079 | spec->hp_detect = 0; |
| 3080 | } |
| 3081 | |
| 3082 | static void stac927x_fixup_ref(struct hda_codec *codec, |
| 3083 | const struct hda_fixup *fix, int action) |
| 3084 | { |
| 3085 | struct sigmatel_spec *spec = codec->spec; |
| 3086 | |
| 3087 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3088 | snd_hda_apply_pincfgs(codec, ref927x_pin_configs); |
| 3089 | spec->eapd_mask = spec->gpio_mask = 0; |
| 3090 | spec->gpio_dir = spec->gpio_data = 0; |
| 3091 | } |
| 3092 | } |
| 3093 | |
| 3094 | static void stac927x_fixup_dell_dmic(struct hda_codec *codec, |
| 3095 | const struct hda_fixup *fix, int action) |
| 3096 | { |
| 3097 | struct sigmatel_spec *spec = codec->spec; |
| 3098 | |
| 3099 | if (action != HDA_FIXUP_ACT_PRE_PROBE) |
| 3100 | return; |
| 3101 | |
| 3102 | if (codec->subsystem_id != 0x1028022f) { |
| 3103 | /* GPIO2 High = Enable EAPD */ |
| 3104 | spec->eapd_mask = spec->gpio_mask = 0x04; |
| 3105 | spec->gpio_dir = spec->gpio_data = 0x04; |
| 3106 | } |
| 3107 | spec->dmic_nids = stac927x_dmic_nids; |
| 3108 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 3109 | |
| 3110 | snd_hda_add_verbs(codec, dell_3st_core_init); |
| 3111 | spec->volknob_init = 1; |
| 3112 | spec->dmux_nids = stac927x_dmux_nids; |
| 3113 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
| 3114 | } |
| 3115 | |
| 3116 | static void stac927x_fixup_volknob(struct hda_codec *codec, |
| 3117 | const struct hda_fixup *fix, int action) |
| 3118 | { |
| 3119 | struct sigmatel_spec *spec = codec->spec; |
| 3120 | |
| 3121 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3122 | snd_hda_add_verbs(codec, stac927x_volknob_core_init); |
| 3123 | spec->volknob_init = 1; |
| 3124 | } |
| 3125 | } |
| 3126 | |
| 3127 | static const struct hda_fixup stac927x_fixups[] = { |
| 3128 | [STAC_D965_REF_NO_JD] = { |
| 3129 | .type = HDA_FIXUP_FUNC, |
| 3130 | .v.func = stac927x_fixup_ref_no_jd, |
| 3131 | .chained = true, |
| 3132 | .chain_id = STAC_D965_REF, |
| 3133 | }, |
| 3134 | [STAC_D965_REF] = { |
| 3135 | .type = HDA_FIXUP_FUNC, |
| 3136 | .v.func = stac927x_fixup_ref, |
| 3137 | }, |
| 3138 | [STAC_D965_3ST] = { |
| 3139 | .type = HDA_FIXUP_PINS, |
| 3140 | .v.pins = d965_3st_pin_configs, |
| 3141 | .chained = true, |
| 3142 | .chain_id = STAC_D965_VERBS, |
| 3143 | }, |
| 3144 | [STAC_D965_5ST] = { |
| 3145 | .type = HDA_FIXUP_PINS, |
| 3146 | .v.pins = d965_5st_pin_configs, |
| 3147 | .chained = true, |
| 3148 | .chain_id = STAC_D965_VERBS, |
| 3149 | }, |
| 3150 | [STAC_D965_VERBS] = { |
| 3151 | .type = HDA_FIXUP_VERBS, |
| 3152 | .v.verbs = d965_core_init, |
| 3153 | }, |
| 3154 | [STAC_D965_5ST_NO_FP] = { |
| 3155 | .type = HDA_FIXUP_PINS, |
| 3156 | .v.pins = d965_5st_no_fp_pin_configs, |
| 3157 | }, |
| 3158 | [STAC_DELL_3ST] = { |
| 3159 | .type = HDA_FIXUP_PINS, |
| 3160 | .v.pins = dell_3st_pin_configs, |
| 3161 | .chained = true, |
| 3162 | .chain_id = STAC_927X_DELL_DMIC, |
| 3163 | }, |
| 3164 | [STAC_DELL_BIOS] = { |
| 3165 | .type = HDA_FIXUP_PINS, |
| 3166 | .v.pins = (const struct hda_pintbl[]) { |
| 3167 | /* configure the analog microphone on some laptops */ |
| 3168 | { 0x0c, 0x90a79130 }, |
| 3169 | /* correct the front output jack as a hp out */ |
| 3170 | { 0x0f, 0x0227011f }, |
| 3171 | /* correct the front input jack as a mic */ |
| 3172 | { 0x0e, 0x02a79130 }, |
| 3173 | {} |
| 3174 | }, |
| 3175 | .chained = true, |
| 3176 | .chain_id = STAC_927X_DELL_DMIC, |
| 3177 | }, |
| 3178 | [STAC_DELL_BIOS_SPDIF] = { |
| 3179 | .type = HDA_FIXUP_PINS, |
| 3180 | .v.pins = (const struct hda_pintbl[]) { |
| 3181 | /* correct the device field to SPDIF out */ |
| 3182 | { 0x21, 0x01442070 }, |
| 3183 | {} |
| 3184 | }, |
| 3185 | .chained = true, |
| 3186 | .chain_id = STAC_DELL_BIOS, |
| 3187 | }, |
| 3188 | [STAC_927X_DELL_DMIC] = { |
| 3189 | .type = HDA_FIXUP_FUNC, |
| 3190 | .v.func = stac927x_fixup_dell_dmic, |
| 3191 | }, |
| 3192 | [STAC_927X_VOLKNOB] = { |
| 3193 | .type = HDA_FIXUP_FUNC, |
| 3194 | .v.func = stac927x_fixup_volknob, |
| 3195 | }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3196 | }; |
| 3197 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3198 | static const struct hda_model_fixup stac927x_models[] = { |
| 3199 | { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" }, |
| 3200 | { .id = STAC_D965_REF, .name = "ref" }, |
| 3201 | { .id = STAC_D965_3ST, .name = "3stack" }, |
| 3202 | { .id = STAC_D965_5ST, .name = "5stack" }, |
| 3203 | { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" }, |
| 3204 | { .id = STAC_DELL_3ST, .name = "dell-3stack" }, |
| 3205 | { .id = STAC_DELL_BIOS, .name = "dell-bios" }, |
| 3206 | { .id = STAC_927X_VOLKNOB, .name = "volknob" }, |
| 3207 | {} |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3208 | }; |
| 3209 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3210 | static const struct snd_pci_quirk stac927x_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3211 | /* SigmaTel reference board */ |
| 3212 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 3213 | "DFI LanParty", STAC_D965_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 3214 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 3215 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 3216 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3217 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 3218 | 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] | 3219 | /* 965 based 3 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 3220 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100, |
| 3221 | "Intel D965", STAC_D965_3ST), |
| 3222 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000, |
| 3223 | "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 3224 | /* Dell 3 stack systems */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3225 | 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] | 3226 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 3227 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 3228 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 3229 | 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] | 3230 | 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] | 3231 | 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] | 3232 | 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] | 3233 | 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] | 3234 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 3235 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 3236 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 3237 | 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] | 3238 | /* 965 based 5 stack systems */ |
Takashi Iwai | dea0a50 | 2009-02-09 17:14:52 +0100 | [diff] [blame] | 3239 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300, |
| 3240 | "Intel D965", STAC_D965_5ST), |
| 3241 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500, |
| 3242 | "Intel D965", STAC_D965_5ST), |
Takashi Iwai | 5493053 | 2009-10-11 17:38:29 +0200 | [diff] [blame] | 3243 | /* volume-knob fixes */ |
| 3244 | SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3245 | {} /* terminator */ |
| 3246 | }; |
| 3247 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3248 | static const struct hda_pintbl ref9205_pin_configs[] = { |
| 3249 | { 0x0a, 0x40000100 }, |
| 3250 | { 0x0b, 0x40000100 }, |
| 3251 | { 0x0c, 0x01016011 }, |
| 3252 | { 0x0d, 0x01014010 }, |
| 3253 | { 0x0e, 0x01813122 }, |
| 3254 | { 0x0f, 0x01a19021 }, |
| 3255 | { 0x14, 0x01019020 }, |
| 3256 | { 0x16, 0x40000100 }, |
| 3257 | { 0x17, 0x90a000f0 }, |
| 3258 | { 0x18, 0x90a000f0 }, |
| 3259 | { 0x21, 0x01441030 }, |
| 3260 | { 0x22, 0x01c41030 }, |
| 3261 | {} |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3262 | }; |
| 3263 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3264 | /* |
| 3265 | STAC 9205 pin configs for |
| 3266 | 102801F1 |
| 3267 | 102801F2 |
| 3268 | 102801FC |
| 3269 | 102801FD |
| 3270 | 10280204 |
| 3271 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 3272 | 10280228 (Dell Vostro 1500) |
Anisse Astier | 95e70e8 | 2009-12-23 17:28:45 +0100 | [diff] [blame] | 3273 | 10280229 (Dell Vostro 1700) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3274 | */ |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3275 | static const struct hda_pintbl dell_9205_m42_pin_configs[] = { |
| 3276 | { 0x0a, 0x0321101F }, |
| 3277 | { 0x0b, 0x03A11020 }, |
| 3278 | { 0x0c, 0x400003FA }, |
| 3279 | { 0x0d, 0x90170310 }, |
| 3280 | { 0x0e, 0x400003FB }, |
| 3281 | { 0x0f, 0x400003FC }, |
| 3282 | { 0x14, 0x400003FD }, |
| 3283 | { 0x16, 0x40F000F9 }, |
| 3284 | { 0x17, 0x90A60330 }, |
| 3285 | { 0x18, 0x400003FF }, |
| 3286 | { 0x21, 0x0144131F }, |
| 3287 | { 0x22, 0x40C003FE }, |
| 3288 | {} |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3289 | }; |
| 3290 | |
| 3291 | /* |
| 3292 | STAC 9205 pin configs for |
| 3293 | 102801F9 |
| 3294 | 102801FA |
| 3295 | 102801FE |
| 3296 | 102801FF (Dell Precision M4300) |
| 3297 | 10280206 |
| 3298 | 10280200 |
| 3299 | 10280201 |
| 3300 | */ |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3301 | static const struct hda_pintbl dell_9205_m43_pin_configs[] = { |
| 3302 | { 0x0a, 0x0321101f }, |
| 3303 | { 0x0b, 0x03a11020 }, |
| 3304 | { 0x0c, 0x90a70330 }, |
| 3305 | { 0x0d, 0x90170310 }, |
| 3306 | { 0x0e, 0x400000fe }, |
| 3307 | { 0x0f, 0x400000ff }, |
| 3308 | { 0x14, 0x400000fd }, |
| 3309 | { 0x16, 0x40f000f9 }, |
| 3310 | { 0x17, 0x400000fa }, |
| 3311 | { 0x18, 0x400000fc }, |
| 3312 | { 0x21, 0x0144131f }, |
| 3313 | { 0x22, 0x40c003f8 }, |
| 3314 | /* Enable SPDIF in/out */ |
| 3315 | { 0x1f, 0x01441030 }, |
| 3316 | { 0x20, 0x1c410030 }, |
| 3317 | {} |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3318 | }; |
| 3319 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3320 | static const struct hda_pintbl dell_9205_m44_pin_configs[] = { |
| 3321 | { 0x0a, 0x0421101f }, |
| 3322 | { 0x0b, 0x04a11020 }, |
| 3323 | { 0x0c, 0x400003fa }, |
| 3324 | { 0x0d, 0x90170310 }, |
| 3325 | { 0x0e, 0x400003fb }, |
| 3326 | { 0x0f, 0x400003fc }, |
| 3327 | { 0x14, 0x400003fd }, |
| 3328 | { 0x16, 0x400003f9 }, |
| 3329 | { 0x17, 0x90a60330 }, |
| 3330 | { 0x18, 0x400003ff }, |
| 3331 | { 0x21, 0x01441340 }, |
| 3332 | { 0x22, 0x40c003fe }, |
| 3333 | {} |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3334 | }; |
| 3335 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3336 | static void stac9205_fixup_ref(struct hda_codec *codec, |
| 3337 | const struct hda_fixup *fix, int action) |
| 3338 | { |
| 3339 | struct sigmatel_spec *spec = codec->spec; |
| 3340 | |
| 3341 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3342 | snd_hda_apply_pincfgs(codec, ref9205_pin_configs); |
| 3343 | /* SPDIF-In enabled */ |
| 3344 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0; |
| 3345 | } |
| 3346 | } |
| 3347 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3348 | static void stac9205_fixup_dell_m43(struct hda_codec *codec, |
| 3349 | const struct hda_fixup *fix, int action) |
| 3350 | { |
| 3351 | struct sigmatel_spec *spec = codec->spec; |
| 3352 | int err; |
| 3353 | |
| 3354 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3355 | snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs); |
| 3356 | |
| 3357 | /* Enable unsol response for GPIO4/Dock HP connection */ |
| 3358 | err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 3359 | if (err < 0) |
| 3360 | return; |
| 3361 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 3362 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 3363 | snd_hda_jack_detect_enable(codec, codec->afg, 0); |
| 3364 | |
| 3365 | spec->gpio_dir = 0x0b; |
| 3366 | spec->eapd_mask = 0x01; |
| 3367 | spec->gpio_mask = 0x1b; |
| 3368 | spec->gpio_mute = 0x10; |
| 3369 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
| 3370 | * GPIO3 Low = DRM |
| 3371 | */ |
| 3372 | spec->gpio_data = 0x01; |
| 3373 | } |
| 3374 | } |
| 3375 | |
| 3376 | static void stac9205_fixup_eapd(struct hda_codec *codec, |
| 3377 | const struct hda_fixup *fix, int action) |
| 3378 | { |
| 3379 | struct sigmatel_spec *spec = codec->spec; |
| 3380 | |
| 3381 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 3382 | spec->eapd_switch = 0; |
| 3383 | } |
| 3384 | |
| 3385 | static const struct hda_fixup stac9205_fixups[] = { |
| 3386 | [STAC_9205_REF] = { |
| 3387 | .type = HDA_FIXUP_FUNC, |
| 3388 | .v.func = stac9205_fixup_ref, |
| 3389 | }, |
| 3390 | [STAC_9205_DELL_M42] = { |
| 3391 | .type = HDA_FIXUP_PINS, |
| 3392 | .v.pins = dell_9205_m42_pin_configs, |
| 3393 | }, |
| 3394 | [STAC_9205_DELL_M43] = { |
| 3395 | .type = HDA_FIXUP_FUNC, |
| 3396 | .v.func = stac9205_fixup_dell_m43, |
| 3397 | }, |
| 3398 | [STAC_9205_DELL_M44] = { |
| 3399 | .type = HDA_FIXUP_PINS, |
| 3400 | .v.pins = dell_9205_m44_pin_configs, |
| 3401 | }, |
| 3402 | [STAC_9205_EAPD] = { |
| 3403 | .type = HDA_FIXUP_FUNC, |
| 3404 | .v.func = stac9205_fixup_eapd, |
| 3405 | }, |
| 3406 | {} |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3407 | }; |
| 3408 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3409 | static const struct hda_model_fixup stac9205_models[] = { |
| 3410 | { .id = STAC_9205_REF, .name = "ref" }, |
| 3411 | { .id = STAC_9205_DELL_M42, .name = "dell-m42" }, |
| 3412 | { .id = STAC_9205_DELL_M43, .name = "dell-m43" }, |
| 3413 | { .id = STAC_9205_DELL_M44, .name = "dell-m44" }, |
| 3414 | { .id = STAC_9205_EAPD, .name = "eapd" }, |
| 3415 | {} |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3416 | }; |
| 3417 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 3418 | static const struct snd_pci_quirk stac9205_fixup_tbl[] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 3419 | /* SigmaTel reference board */ |
| 3420 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 3421 | "DFI LanParty", STAC_9205_REF), |
Herton Ronaldo Krzesinski | 02358fc | 2009-07-04 01:44:59 -0300 | [diff] [blame] | 3422 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30, |
| 3423 | "SigmaTel", STAC_9205_REF), |
Matthew Ranostay | 577aa2c | 2009-01-22 22:55:44 -0500 | [diff] [blame] | 3424 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
| 3425 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 3426 | /* Dell */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3427 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 3428 | "unknown Dell", STAC_9205_DELL_M42), |
| 3429 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 3430 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3431 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 3432 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3433 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 3434 | "Dell Precision", STAC_9205_DELL_M43), |
| 3435 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 3436 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3437 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 3438 | "unknown Dell", STAC_9205_DELL_M42), |
| 3439 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 3440 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3441 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 3442 | "Dell Precision", STAC_9205_DELL_M43), |
| 3443 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3444 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 3445 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 3446 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 3447 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 3448 | "Dell Precision", STAC_9205_DELL_M43), |
| 3449 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 3450 | "Dell Precision", STAC_9205_DELL_M43), |
| 3451 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 3452 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 3453 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 3454 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 3455 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 3456 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Anisse Astier | 95e70e8 | 2009-12-23 17:28:45 +0100 | [diff] [blame] | 3457 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229, |
| 3458 | "Dell Vostro 1700", STAC_9205_DELL_M42), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 3459 | /* Gateway */ |
Hao Song | 42b95f0 | 2009-07-20 15:01:16 +0800 | [diff] [blame] | 3460 | SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD), |
Takashi Iwai | d9a4268 | 2009-01-22 17:40:18 +0100 | [diff] [blame] | 3461 | SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 3462 | {} /* terminator */ |
| 3463 | }; |
| 3464 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3465 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3466 | const unsigned int *pincfgs) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3467 | { |
| 3468 | int i; |
| 3469 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3470 | |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3471 | if (!pincfgs) |
| 3472 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 3473 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 3474 | for (i = 0; i < spec->num_pins; i++) |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 3475 | if (spec->pin_nids[i] && pincfgs[i]) |
| 3476 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
| 3477 | pincfgs[i]); |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 3478 | } |
| 3479 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3480 | /* |
| 3481 | * Analog playback callbacks |
| 3482 | */ |
| 3483 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 3484 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3485 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3486 | { |
| 3487 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3488 | if (spec->stream_delay) |
| 3489 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 3490 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 3491 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3492 | } |
| 3493 | |
| 3494 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3495 | struct hda_codec *codec, |
| 3496 | unsigned int stream_tag, |
| 3497 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3498 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3499 | { |
| 3500 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3501 | 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] | 3502 | } |
| 3503 | |
| 3504 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3505 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3506 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3507 | { |
| 3508 | struct sigmatel_spec *spec = codec->spec; |
| 3509 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 3510 | } |
| 3511 | |
| 3512 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3513 | * Digital playback callbacks |
| 3514 | */ |
| 3515 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 3516 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3517 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3518 | { |
| 3519 | struct sigmatel_spec *spec = codec->spec; |
| 3520 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 3521 | } |
| 3522 | |
| 3523 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 3524 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3525 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3526 | { |
| 3527 | struct sigmatel_spec *spec = codec->spec; |
| 3528 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 3529 | } |
| 3530 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 3531 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3532 | struct hda_codec *codec, |
| 3533 | unsigned int stream_tag, |
| 3534 | unsigned int format, |
| 3535 | struct snd_pcm_substream *substream) |
| 3536 | { |
| 3537 | struct sigmatel_spec *spec = codec->spec; |
| 3538 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 3539 | stream_tag, format, substream); |
| 3540 | } |
| 3541 | |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 3542 | static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3543 | struct hda_codec *codec, |
| 3544 | struct snd_pcm_substream *substream) |
| 3545 | { |
| 3546 | struct sigmatel_spec *spec = codec->spec; |
| 3547 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 3548 | } |
| 3549 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3550 | |
| 3551 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3552 | * Analog capture callbacks |
| 3553 | */ |
| 3554 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 3555 | struct hda_codec *codec, |
| 3556 | unsigned int stream_tag, |
| 3557 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3558 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3559 | { |
| 3560 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3561 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3562 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3563 | if (spec->powerdown_adcs) { |
| 3564 | msleep(40); |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3565 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3566 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 3567 | } |
| 3568 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3569 | return 0; |
| 3570 | } |
| 3571 | |
| 3572 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 3573 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3574 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3575 | { |
| 3576 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3577 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3578 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3579 | snd_hda_codec_cleanup_stream(codec, nid); |
| 3580 | if (spec->powerdown_adcs) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 3581 | snd_hda_codec_write(codec, nid, 0, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3582 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3583 | return 0; |
| 3584 | } |
| 3585 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3586 | static const struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3587 | .substreams = 1, |
| 3588 | .channels_min = 2, |
| 3589 | .channels_max = 2, |
| 3590 | /* NID is set in stac92xx_build_pcms */ |
| 3591 | .ops = { |
| 3592 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 3593 | .close = stac92xx_dig_playback_pcm_close, |
Takashi Iwai | 9411e21 | 2009-02-13 11:32:28 +0100 | [diff] [blame] | 3594 | .prepare = stac92xx_dig_playback_pcm_prepare, |
| 3595 | .cleanup = stac92xx_dig_playback_pcm_cleanup |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3596 | }, |
| 3597 | }; |
| 3598 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3599 | static const struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3600 | .substreams = 1, |
| 3601 | .channels_min = 2, |
| 3602 | .channels_max = 2, |
| 3603 | /* NID is set in stac92xx_build_pcms */ |
| 3604 | }; |
| 3605 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3606 | static const struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3607 | .substreams = 1, |
| 3608 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3609 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3610 | .nid = 0x02, /* NID to query formats and rates */ |
| 3611 | .ops = { |
| 3612 | .open = stac92xx_playback_pcm_open, |
| 3613 | .prepare = stac92xx_playback_pcm_prepare, |
| 3614 | .cleanup = stac92xx_playback_pcm_cleanup |
| 3615 | }, |
| 3616 | }; |
| 3617 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3618 | static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3619 | .substreams = 1, |
| 3620 | .channels_min = 2, |
| 3621 | .channels_max = 2, |
| 3622 | .nid = 0x06, /* NID to query formats and rates */ |
| 3623 | .ops = { |
| 3624 | .open = stac92xx_playback_pcm_open, |
| 3625 | .prepare = stac92xx_playback_pcm_prepare, |
| 3626 | .cleanup = stac92xx_playback_pcm_cleanup |
| 3627 | }, |
| 3628 | }; |
| 3629 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3630 | static const struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3631 | .channels_min = 2, |
| 3632 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3633 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3634 | .ops = { |
| 3635 | .prepare = stac92xx_capture_pcm_prepare, |
| 3636 | .cleanup = stac92xx_capture_pcm_cleanup |
| 3637 | }, |
| 3638 | }; |
| 3639 | |
| 3640 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 3641 | { |
| 3642 | struct sigmatel_spec *spec = codec->spec; |
| 3643 | struct hda_pcm *info = spec->pcm_rec; |
| 3644 | |
| 3645 | codec->num_pcms = 1; |
| 3646 | codec->pcm_info = info; |
| 3647 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3648 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3649 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Takashi Iwai | 00a602d | 2009-01-23 11:55:42 +0100 | [diff] [blame] | 3650 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 3651 | spec->multiout.dac_nids[0]; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 3652 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3653 | spec->autocfg.line_outs == 2) |
| 3654 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 3655 | snd_pcm_2_1_chmaps; |
| 3656 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3657 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3658 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 3659 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3660 | |
| 3661 | if (spec->alt_switch) { |
| 3662 | codec->num_pcms++; |
| 3663 | info++; |
| 3664 | info->name = "STAC92xx Analog Alt"; |
| 3665 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 3666 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3667 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3668 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 3669 | codec->num_pcms++; |
| 3670 | info++; |
| 3671 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 3672 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 3673 | if (spec->multiout.dig_out_nid) { |
| 3674 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 3675 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 3676 | } |
| 3677 | if (spec->dig_in_nid) { |
| 3678 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 3679 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 3680 | } |
| 3681 | } |
| 3682 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 3683 | return 0; |
| 3684 | } |
| 3685 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3686 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 3687 | |
| 3688 | { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3689 | snd_hda_set_pin_ctl_cache(codec, nid, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3690 | } |
| 3691 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3692 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 3693 | |
| 3694 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 3695 | struct snd_ctl_elem_value *ucontrol) |
| 3696 | { |
| 3697 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3698 | struct sigmatel_spec *spec = codec->spec; |
| 3699 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3700 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3701 | return 0; |
| 3702 | } |
| 3703 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 3704 | 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] | 3705 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3706 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 3707 | struct snd_ctl_elem_value *ucontrol) |
| 3708 | { |
| 3709 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3710 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3711 | int nid = kcontrol->private_value; |
| 3712 | |
| 3713 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3714 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 3715 | /* check to be sure that the ports are up to date with |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3716 | * switch changes |
| 3717 | */ |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 3718 | stac_issue_unsol_event(codec, nid); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3719 | |
| 3720 | return 1; |
| 3721 | } |
| 3722 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3723 | static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol, |
| 3724 | struct snd_ctl_elem_info *uinfo) |
| 3725 | { |
| 3726 | int i; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3727 | static const char * const texts[] = { |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3728 | "Mic In", "Line In", "Line Out" |
| 3729 | }; |
| 3730 | |
| 3731 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3732 | struct sigmatel_spec *spec = codec->spec; |
| 3733 | hda_nid_t nid = kcontrol->private_value; |
| 3734 | |
| 3735 | if (nid == spec->mic_switch || nid == spec->line_switch) |
| 3736 | i = 3; |
| 3737 | else |
| 3738 | i = 2; |
| 3739 | |
| 3740 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3741 | uinfo->value.enumerated.items = i; |
| 3742 | uinfo->count = 1; |
| 3743 | if (uinfo->value.enumerated.item >= i) |
| 3744 | uinfo->value.enumerated.item = i-1; |
| 3745 | strcpy(uinfo->value.enumerated.name, |
| 3746 | texts[uinfo->value.enumerated.item]); |
| 3747 | |
| 3748 | return 0; |
| 3749 | } |
| 3750 | |
| 3751 | static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol, |
| 3752 | struct snd_ctl_elem_value *ucontrol) |
| 3753 | { |
| 3754 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3755 | hda_nid_t nid = kcontrol->private_value; |
| 3756 | unsigned int vref = stac92xx_vref_get(codec, nid); |
| 3757 | |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 3758 | if (vref == snd_hda_get_default_vref(codec, nid)) |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3759 | ucontrol->value.enumerated.item[0] = 0; |
| 3760 | else if (vref == AC_PINCTL_VREF_GRD) |
| 3761 | ucontrol->value.enumerated.item[0] = 1; |
| 3762 | else if (vref == AC_PINCTL_VREF_HIZ) |
| 3763 | ucontrol->value.enumerated.item[0] = 2; |
| 3764 | |
| 3765 | return 0; |
| 3766 | } |
| 3767 | |
| 3768 | static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, |
| 3769 | struct snd_ctl_elem_value *ucontrol) |
| 3770 | { |
| 3771 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3772 | unsigned int new_vref = 0; |
Takashi Iwai | b862151 | 2009-06-22 08:00:10 +0200 | [diff] [blame] | 3773 | int error; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3774 | hda_nid_t nid = kcontrol->private_value; |
| 3775 | |
| 3776 | if (ucontrol->value.enumerated.item[0] == 0) |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 3777 | new_vref = snd_hda_get_default_vref(codec, nid); |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3778 | else if (ucontrol->value.enumerated.item[0] == 1) |
| 3779 | new_vref = AC_PINCTL_VREF_GRD; |
| 3780 | else if (ucontrol->value.enumerated.item[0] == 2) |
| 3781 | new_vref = AC_PINCTL_VREF_HIZ; |
| 3782 | else |
| 3783 | return 0; |
| 3784 | |
| 3785 | if (new_vref != stac92xx_vref_get(codec, nid)) { |
| 3786 | error = stac92xx_vref_set(codec, nid, new_vref); |
| 3787 | return error; |
| 3788 | } |
| 3789 | |
| 3790 | return 0; |
| 3791 | } |
| 3792 | |
| 3793 | static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, |
| 3794 | struct snd_ctl_elem_info *uinfo) |
| 3795 | { |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3796 | char *texts[2]; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3797 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3798 | struct sigmatel_spec *spec = codec->spec; |
| 3799 | |
| 3800 | if (kcontrol->private_value == spec->line_switch) |
| 3801 | texts[0] = "Line In"; |
| 3802 | else |
| 3803 | texts[0] = "Mic In"; |
| 3804 | texts[1] = "Line Out"; |
| 3805 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3806 | uinfo->value.enumerated.items = 2; |
| 3807 | uinfo->count = 1; |
| 3808 | |
| 3809 | if (uinfo->value.enumerated.item >= 2) |
| 3810 | uinfo->value.enumerated.item = 1; |
| 3811 | strcpy(uinfo->value.enumerated.name, |
| 3812 | texts[uinfo->value.enumerated.item]); |
| 3813 | |
| 3814 | return 0; |
| 3815 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3816 | |
| 3817 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 3818 | { |
| 3819 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3820 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3821 | hda_nid_t nid = kcontrol->private_value; |
| 3822 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3823 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3824 | ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3825 | return 0; |
| 3826 | } |
| 3827 | |
| 3828 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 3829 | { |
| 3830 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3831 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 3832 | hda_nid_t nid = kcontrol->private_value; |
| 3833 | int io_idx = (nid == spec->mic_switch) ? 1 : 0; |
| 3834 | unsigned short val = !!ucontrol->value.enumerated.item[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3835 | |
| 3836 | spec->io_switch[io_idx] = val; |
| 3837 | |
| 3838 | if (val) |
| 3839 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3840 | else { |
| 3841 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 3842 | if (io_idx) /* set VREF for mic */ |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 3843 | pinctl |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3844 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 3845 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 3846 | |
| 3847 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 3848 | * appropriately according to the pin direction |
| 3849 | */ |
| 3850 | if (spec->hp_detect) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 3851 | stac_issue_unsol_event(codec, nid); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 3852 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3853 | return 1; |
| 3854 | } |
| 3855 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3856 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 3857 | |
| 3858 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 3859 | struct snd_ctl_elem_value *ucontrol) |
| 3860 | { |
| 3861 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3862 | struct sigmatel_spec *spec = codec->spec; |
| 3863 | |
| 3864 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 3865 | return 0; |
| 3866 | } |
| 3867 | |
| 3868 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 3869 | struct snd_ctl_elem_value *ucontrol) |
| 3870 | { |
| 3871 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3872 | struct sigmatel_spec *spec = codec->spec; |
| 3873 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 3874 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3875 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 3876 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3877 | return 0; |
| 3878 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 3879 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3880 | |
| 3881 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 3882 | spec->clfe_swap ? 0x4 : 0x0); |
| 3883 | |
| 3884 | return 1; |
| 3885 | } |
| 3886 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3887 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 3888 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 3889 | .name = xname, \ |
| 3890 | .index = 0, \ |
| 3891 | .info = stac92xx_hp_switch_info, \ |
| 3892 | .get = stac92xx_hp_switch_get, \ |
| 3893 | .put = stac92xx_hp_switch_put, \ |
| 3894 | } |
| 3895 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3896 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 3897 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 3898 | .name = xname, \ |
| 3899 | .index = 0, \ |
| 3900 | .info = stac92xx_io_switch_info, \ |
| 3901 | .get = stac92xx_io_switch_get, \ |
| 3902 | .put = stac92xx_io_switch_put, \ |
| 3903 | .private_value = xpval, \ |
| 3904 | } |
| 3905 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3906 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 3907 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 3908 | .name = xname, \ |
| 3909 | .index = 0, \ |
| 3910 | .info = stac92xx_clfe_switch_info, \ |
| 3911 | .get = stac92xx_clfe_switch_get, \ |
| 3912 | .put = stac92xx_clfe_switch_put, \ |
| 3913 | .private_value = xpval, \ |
| 3914 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3915 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3916 | enum { |
| 3917 | STAC_CTL_WIDGET_VOL, |
| 3918 | STAC_CTL_WIDGET_MUTE, |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 3919 | STAC_CTL_WIDGET_MUTE_BEEP, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3920 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3921 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3922 | STAC_CTL_WIDGET_IO_SWITCH, |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 3923 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3924 | STAC_CTL_WIDGET_DC_BIAS |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3925 | }; |
| 3926 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3927 | static const struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3928 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 3929 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 3930 | HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3931 | STAC_MONO_MUX, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3932 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3933 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3934 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Nickolas Lloyd | 2fc9989 | 2009-05-15 15:33:30 +0200 | [diff] [blame] | 3935 | DC_BIAS(NULL, 0, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3936 | }; |
| 3937 | |
| 3938 | /* add dynamic controls */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3939 | static struct snd_kcontrol_new * |
| 3940 | stac_control_new(struct sigmatel_spec *spec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3941 | const struct snd_kcontrol_new *ktemp, |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 3942 | const char *name, |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 3943 | unsigned int subdev) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3944 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 3945 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3946 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3947 | knew = snd_array_new(&spec->kctls); |
| 3948 | if (!knew) |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3949 | return NULL; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3950 | *knew = *ktemp; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 3951 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3952 | if (!knew->name) { |
| 3953 | /* roolback */ |
| 3954 | memset(knew, 0, sizeof(*knew)); |
| 3955 | spec->kctls.alloced--; |
| 3956 | return NULL; |
| 3957 | } |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 3958 | knew->subdevice = subdev; |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3959 | return knew; |
| 3960 | } |
| 3961 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 3962 | static struct snd_kcontrol_new * |
| 3963 | add_control_temp(struct sigmatel_spec *spec, |
| 3964 | const struct snd_kcontrol_new *ktemp, |
| 3965 | int idx, const char *name, |
| 3966 | unsigned long val) |
| 3967 | { |
| 3968 | struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name, |
| 3969 | HDA_SUBDEV_AMP_FLAG); |
| 3970 | if (!knew) |
| 3971 | return NULL; |
| 3972 | knew->index = idx; |
| 3973 | knew->private_value = val; |
| 3974 | return knew; |
| 3975 | } |
| 3976 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3977 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 3978 | const struct snd_kcontrol_new *ktemp, |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 3979 | int idx, const char *name, |
| 3980 | unsigned long val) |
| 3981 | { |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 3982 | return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3983 | } |
| 3984 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3985 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 3986 | int type, int idx, const char *name, |
| 3987 | unsigned long val) |
| 3988 | { |
| 3989 | return stac92xx_add_control_temp(spec, |
| 3990 | &stac92xx_control_templates[type], |
| 3991 | idx, name, val); |
| 3992 | } |
| 3993 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3994 | |
| 3995 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3996 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 3997 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3998 | { |
| 3999 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 4000 | } |
| 4001 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4002 | static const struct snd_kcontrol_new stac_input_src_temp = { |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4003 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4004 | .name = "Input Source", |
| 4005 | .info = stac92xx_mux_enum_info, |
| 4006 | .get = stac92xx_mux_enum_get, |
| 4007 | .put = stac92xx_mux_enum_put, |
| 4008 | }; |
| 4009 | |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4010 | static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, |
| 4011 | hda_nid_t nid, int idx) |
| 4012 | { |
| 4013 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 4014 | int control = 0; |
| 4015 | struct sigmatel_spec *spec = codec->spec; |
| 4016 | char name[22]; |
| 4017 | |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4018 | 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] | 4019 | if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf) |
| 4020 | != INPUT_PIN_ATTR_DOCK) |
| 4021 | return 0; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 4022 | if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4023 | && nid == spec->line_switch) |
| 4024 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 4025 | else if (snd_hda_query_pin_caps(codec, nid) |
| 4026 | & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT)) |
| 4027 | control = STAC_CTL_WIDGET_DC_BIAS; |
| 4028 | else if (nid == spec->mic_switch) |
| 4029 | control = STAC_CTL_WIDGET_IO_SWITCH; |
| 4030 | } |
| 4031 | |
| 4032 | if (control) { |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 4033 | snd_hda_get_pin_label(codec, nid, &spec->autocfg, |
| 4034 | name, sizeof(name), NULL); |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4035 | return stac92xx_add_control(codec->spec, control, |
| 4036 | strcat(name, " Jack Mode"), nid); |
| 4037 | } |
| 4038 | |
| 4039 | return 0; |
| 4040 | } |
| 4041 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4042 | static int stac92xx_add_input_source(struct sigmatel_spec *spec) |
| 4043 | { |
| 4044 | struct snd_kcontrol_new *knew; |
| 4045 | struct hda_input_mux *imux = &spec->private_imux; |
| 4046 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4047 | if (spec->auto_mic) |
| 4048 | return 0; /* no need for input source */ |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4049 | if (!spec->num_adcs || imux->num_items <= 1) |
| 4050 | return 0; /* no need for input source control */ |
| 4051 | knew = stac_control_new(spec, &stac_input_src_temp, |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 4052 | stac_input_src_temp.name, 0); |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 4053 | if (!knew) |
| 4054 | return -ENOMEM; |
| 4055 | knew->count = spec->num_adcs; |
| 4056 | return 0; |
| 4057 | } |
| 4058 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4059 | /* check whether the line-input can be used as line-out */ |
| 4060 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4061 | { |
| 4062 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4063 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4064 | hda_nid_t nid; |
| 4065 | unsigned int pincap; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4066 | int i; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 4067 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4068 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 4069 | return 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4070 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4071 | if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) { |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4072 | nid = cfg->inputs[i].pin; |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 4073 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4074 | if (pincap & AC_PINCAP_OUT) |
| 4075 | return nid; |
| 4076 | } |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4077 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4078 | return 0; |
| 4079 | } |
| 4080 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4081 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid); |
| 4082 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4083 | /* check whether the mic-input can be used as line-out */ |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4084 | 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] | 4085 | { |
| 4086 | struct sigmatel_spec *spec = codec->spec; |
| 4087 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4088 | unsigned int def_conf, pincap; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4089 | int i; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4090 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4091 | *dac = 0; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4092 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
| 4093 | return 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4094 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4095 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4096 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4097 | continue; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4098 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 4099 | /* some laptops have an internal analog microphone |
| 4100 | * which can't be used as a output */ |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4101 | 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] | 4102 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4103 | if (pincap & AC_PINCAP_OUT) { |
| 4104 | *dac = get_unassigned_dac(codec, nid); |
| 4105 | if (*dac) |
| 4106 | return nid; |
| 4107 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4108 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4109 | } |
| 4110 | return 0; |
| 4111 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4112 | |
| 4113 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 4114 | { |
| 4115 | int i; |
| 4116 | |
| 4117 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 4118 | if (spec->multiout.dac_nids[i] == nid) |
| 4119 | return 1; |
| 4120 | } |
| 4121 | |
| 4122 | return 0; |
| 4123 | } |
| 4124 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4125 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 4126 | { |
| 4127 | int i; |
| 4128 | if (is_in_dac_nids(spec, nid)) |
| 4129 | return 1; |
| 4130 | for (i = 0; i < spec->autocfg.hp_outs; i++) |
| 4131 | if (spec->hp_dacs[i] == nid) |
| 4132 | return 1; |
| 4133 | for (i = 0; i < spec->autocfg.speaker_outs; i++) |
| 4134 | if (spec->speaker_dacs[i] == nid) |
| 4135 | return 1; |
| 4136 | return 0; |
| 4137 | } |
| 4138 | |
| 4139 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) |
| 4140 | { |
| 4141 | struct sigmatel_spec *spec = codec->spec; |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4142 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4143 | int j, conn_len; |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4144 | hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4145 | unsigned int wcaps, wtype; |
| 4146 | |
| 4147 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 4148 | HDA_MAX_CONNECTIONS); |
Charles Chin | 3670600 | 2010-01-29 12:05:51 +0100 | [diff] [blame] | 4149 | /* 92HD88: trace back up the link of nids to find the DAC */ |
| 4150 | while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0])) |
| 4151 | != AC_WID_AUD_OUT)) { |
| 4152 | nid = conn[0]; |
| 4153 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 4154 | HDA_MAX_CONNECTIONS); |
| 4155 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4156 | for (j = 0; j < conn_len; j++) { |
Takashi Iwai | 14bafe3 | 2009-03-23 16:35:39 +0100 | [diff] [blame] | 4157 | wcaps = get_wcaps(codec, conn[j]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 4158 | wtype = get_wcaps_type(wcaps); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4159 | /* we check only analog outputs */ |
| 4160 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) |
| 4161 | continue; |
| 4162 | /* if this route has a free DAC, assign it */ |
| 4163 | if (!check_all_dac_nids(spec, conn[j])) { |
| 4164 | if (conn_len > 1) { |
| 4165 | /* select this DAC in the pin's input mux */ |
| 4166 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4167 | AC_VERB_SET_CONNECT_SEL, j); |
| 4168 | } |
| 4169 | return conn[j]; |
| 4170 | } |
| 4171 | } |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4172 | |
| 4173 | /* if all DACs are already assigned, connect to the primary DAC, |
| 4174 | unless we're assigning a secondary headphone */ |
| 4175 | fallback_dac = spec->multiout.dac_nids[0]; |
| 4176 | if (spec->multiout.hp_nid) { |
| 4177 | for (j = 0; j < cfg->hp_outs; j++) |
| 4178 | if (cfg->hp_pins[j] == nid) { |
| 4179 | fallback_dac = spec->multiout.hp_nid; |
| 4180 | break; |
| 4181 | } |
| 4182 | } |
| 4183 | |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 4184 | if (conn_len > 1) { |
| 4185 | for (j = 0; j < conn_len; j++) { |
David Henningsson | 48718ea | 2011-10-05 09:49:05 +0200 | [diff] [blame] | 4186 | if (conn[j] == fallback_dac) { |
Takashi Iwai | ee58a7c | 2009-03-06 12:00:24 +0100 | [diff] [blame] | 4187 | snd_hda_codec_write_cache(codec, nid, 0, |
| 4188 | AC_VERB_SET_CONNECT_SEL, j); |
| 4189 | break; |
| 4190 | } |
| 4191 | } |
| 4192 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4193 | return 0; |
| 4194 | } |
| 4195 | |
| 4196 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 4197 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); |
| 4198 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4199 | /* |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4200 | * Fill in the dac_nids table from the parsed pin configuration |
| 4201 | * This function only works when every pin in line_out_pins[] |
| 4202 | * contains atleast one DAC in its connection list. Some 92xx |
| 4203 | * codecs are not connected directly to a DAC, such as the 9200 |
| 4204 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 4205 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4206 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4207 | { |
| 4208 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4209 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4210 | int i; |
| 4211 | hda_nid_t nid, dac; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4212 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4213 | for (i = 0; i < cfg->line_outs; i++) { |
| 4214 | nid = cfg->line_out_pins[i]; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4215 | dac = get_unassigned_dac(codec, nid); |
| 4216 | if (!dac) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 4217 | if (spec->multiout.num_dacs > 0) { |
| 4218 | /* we have already working output pins, |
| 4219 | * so let's drop the broken ones again |
| 4220 | */ |
| 4221 | cfg->line_outs = spec->multiout.num_dacs; |
| 4222 | break; |
| 4223 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4224 | /* error out, no available DAC found */ |
| 4225 | snd_printk(KERN_ERR |
| 4226 | "%s: No available DAC for pin 0x%x\n", |
| 4227 | __func__, nid); |
| 4228 | return -ENODEV; |
| 4229 | } |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4230 | add_spec_dacs(spec, dac); |
| 4231 | } |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4232 | |
Takashi Iwai | 139e071 | 2009-03-06 12:10:41 +0100 | [diff] [blame] | 4233 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4234 | nid = cfg->hp_pins[i]; |
| 4235 | dac = get_unassigned_dac(codec, nid); |
| 4236 | if (dac) { |
| 4237 | if (!spec->multiout.hp_nid) |
| 4238 | spec->multiout.hp_nid = dac; |
| 4239 | else |
| 4240 | add_spec_extra_dacs(spec, dac); |
| 4241 | } |
| 4242 | spec->hp_dacs[i] = dac; |
| 4243 | } |
| 4244 | |
| 4245 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 4246 | nid = cfg->speaker_pins[i]; |
| 4247 | dac = get_unassigned_dac(codec, nid); |
| 4248 | if (dac) |
| 4249 | add_spec_extra_dacs(spec, dac); |
| 4250 | spec->speaker_dacs[i] = dac; |
| 4251 | } |
| 4252 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4253 | /* add line-in as output */ |
| 4254 | nid = check_line_out_switch(codec); |
| 4255 | if (nid) { |
| 4256 | dac = get_unassigned_dac(codec, nid); |
| 4257 | if (dac) { |
| 4258 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
| 4259 | nid, cfg->line_outs); |
| 4260 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 4261 | cfg->line_outs++; |
| 4262 | spec->line_switch = nid; |
| 4263 | add_spec_dacs(spec, dac); |
| 4264 | } |
| 4265 | } |
| 4266 | /* add mic as output */ |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4267 | nid = check_mic_out_switch(codec, &dac); |
| 4268 | if (nid && dac) { |
| 4269 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", |
| 4270 | nid, cfg->line_outs); |
| 4271 | cfg->line_out_pins[cfg->line_outs] = nid; |
| 4272 | cfg->line_outs++; |
| 4273 | spec->mic_switch = nid; |
| 4274 | add_spec_dacs(spec, dac); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4275 | } |
| 4276 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4277 | 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] | 4278 | spec->multiout.num_dacs, |
| 4279 | spec->multiout.dac_nids[0], |
| 4280 | spec->multiout.dac_nids[1], |
| 4281 | spec->multiout.dac_nids[2], |
| 4282 | spec->multiout.dac_nids[3], |
| 4283 | spec->multiout.dac_nids[4]); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4284 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4285 | return 0; |
| 4286 | } |
| 4287 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4288 | /* create volume control/switch for the given prefx type */ |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4289 | static int create_controls_idx(struct hda_codec *codec, const char *pfx, |
| 4290 | int idx, hda_nid_t nid, int chs) |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4291 | { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4292 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4293 | char name[32]; |
| 4294 | int err; |
| 4295 | |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4296 | if (!spec->check_volume_offset) { |
| 4297 | unsigned int caps, step, nums, db_scale; |
| 4298 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 4299 | step = (caps & AC_AMPCAP_STEP_SIZE) >> |
| 4300 | AC_AMPCAP_STEP_SIZE_SHIFT; |
| 4301 | step = (step + 1) * 25; /* in .01dB unit */ |
| 4302 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> |
| 4303 | AC_AMPCAP_NUM_STEPS_SHIFT; |
| 4304 | db_scale = nums * step; |
| 4305 | /* if dB scale is over -64dB, and finer enough, |
| 4306 | * let's reduce it to half |
| 4307 | */ |
| 4308 | if (db_scale > 6400 && nums >= 0x1f) |
| 4309 | spec->volume_offset = nums / 2; |
| 4310 | spec->check_volume_offset = 1; |
| 4311 | } |
| 4312 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4313 | sprintf(name, "%s Playback Volume", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4314 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name, |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4315 | HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT, |
| 4316 | spec->volume_offset)); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4317 | if (err < 0) |
| 4318 | return err; |
| 4319 | sprintf(name, "%s Playback Switch", pfx); |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4320 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4321 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 4322 | if (err < 0) |
| 4323 | return err; |
| 4324 | return 0; |
| 4325 | } |
| 4326 | |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4327 | #define create_controls(codec, pfx, nid, chs) \ |
| 4328 | create_controls_idx(codec, pfx, 0, nid, chs) |
| 4329 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4330 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 4331 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4332 | if (spec->multiout.num_dacs > 4) { |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4333 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 4334 | return 1; |
| 4335 | } else { |
Takashi Iwai | dda1441 | 2011-05-02 11:29:30 +0200 | [diff] [blame] | 4336 | snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids); |
| 4337 | spec->dac_nids[spec->multiout.num_dacs] = nid; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4338 | spec->multiout.num_dacs++; |
| 4339 | } |
| 4340 | return 0; |
| 4341 | } |
| 4342 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4343 | 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] | 4344 | { |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 4345 | int i; |
| 4346 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 4347 | if (!spec->multiout.extra_out_nid[i]) { |
| 4348 | spec->multiout.extra_out_nid[i] = nid; |
| 4349 | return 0; |
| 4350 | } |
| 4351 | } |
| 4352 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); |
| 4353 | return 1; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 4354 | } |
| 4355 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4356 | /* Create output controls |
| 4357 | * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT) |
| 4358 | */ |
| 4359 | static int create_multi_out_ctls(struct hda_codec *codec, int num_outs, |
| 4360 | const hda_nid_t *pins, |
| 4361 | const hda_nid_t *dac_nids, |
| 4362 | int type) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4363 | { |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 4364 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4365 | static const char * const chname[4] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 4366 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 4367 | }; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4368 | hda_nid_t nid; |
Takashi Iwai | 9158923 | 2008-12-19 15:59:40 +0100 | [diff] [blame] | 4369 | int i, err; |
| 4370 | unsigned int wid_caps; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4371 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4372 | for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) { |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 4373 | if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) { |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 4374 | if (is_jack_detectable(codec, pins[i])) |
Takashi Iwai | ffd0e56 | 2009-04-16 12:20:24 +0200 | [diff] [blame] | 4375 | spec->hp_detect = 1; |
| 4376 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4377 | nid = dac_nids[i]; |
| 4378 | if (!nid) |
| 4379 | continue; |
| 4380 | if (type != AUTO_PIN_HP_OUT && i == 2) { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4381 | /* Center/LFE */ |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4382 | err = create_controls(codec, "Center", nid, 1); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4383 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4384 | return err; |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 4385 | err = create_controls(codec, "LFE", nid, 2); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4386 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4387 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 4388 | |
| 4389 | wid_caps = get_wcaps(codec, nid); |
| 4390 | |
| 4391 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 4392 | err = stac92xx_add_control(spec, |
| 4393 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 4394 | "Swap Center/LFE Playback Switch", nid); |
| 4395 | |
| 4396 | if (err < 0) |
| 4397 | return err; |
| 4398 | } |
| 4399 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4400 | } else { |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4401 | const char *name; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4402 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4403 | switch (type) { |
| 4404 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4405 | name = "Headphone"; |
| 4406 | idx = i; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4407 | break; |
| 4408 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 4409 | if (num_outs <= 2) { |
| 4410 | name = i ? "Bass Speaker" : "Speaker"; |
| 4411 | idx = 0; |
David Henningsson | 298efee | 2012-09-06 11:17:58 +0200 | [diff] [blame] | 4412 | break; |
| 4413 | } |
| 4414 | /* Fall through in case of multi speaker outs */ |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4415 | default: |
| 4416 | name = chname[i]; |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4417 | idx = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4418 | break; |
Takashi Iwai | 7662453 | 2008-12-19 10:09:47 +0100 | [diff] [blame] | 4419 | } |
Takashi Iwai | 668b965 | 2009-03-06 10:13:24 +0100 | [diff] [blame] | 4420 | err = create_controls_idx(codec, name, idx, nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4421 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4422 | return err; |
| 4423 | } |
| 4424 | } |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4425 | return 0; |
| 4426 | } |
| 4427 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4428 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
| 4429 | unsigned int dir_mask, unsigned int data); |
| 4430 | |
| 4431 | /* hook for controlling mic-mute LED GPIO */ |
| 4432 | static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol, |
| 4433 | struct snd_ctl_elem_value *ucontrol) |
| 4434 | { |
| 4435 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4436 | struct sigmatel_spec *spec = codec->spec; |
| 4437 | int err; |
| 4438 | bool mute; |
| 4439 | |
| 4440 | err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); |
| 4441 | if (err <= 0) |
| 4442 | return err; |
| 4443 | mute = !(ucontrol->value.integer.value[0] && |
| 4444 | ucontrol->value.integer.value[1]); |
| 4445 | if (spec->mic_mute_led_on != mute) { |
| 4446 | spec->mic_mute_led_on = mute; |
| 4447 | if (mute) |
| 4448 | spec->gpio_data |= spec->mic_mute_led_gpio; |
| 4449 | else |
| 4450 | spec->gpio_data &= ~spec->mic_mute_led_gpio; |
| 4451 | stac_gpio_set(codec, spec->gpio_mask, |
| 4452 | spec->gpio_dir, spec->gpio_data); |
| 4453 | } |
| 4454 | return err; |
| 4455 | } |
| 4456 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4457 | static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol, |
| 4458 | unsigned long sw, int idx) |
| 4459 | { |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4460 | struct sigmatel_spec *spec = codec->spec; |
| 4461 | struct snd_kcontrol_new *knew; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4462 | int err; |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4463 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4464 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, |
Takashi Iwai | bf677bd8 | 2009-07-30 09:24:29 +0200 | [diff] [blame] | 4465 | "Capture Volume", vol); |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4466 | if (err < 0) |
| 4467 | return err; |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 4468 | |
| 4469 | knew = add_control_temp(spec, |
| 4470 | &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE], |
| 4471 | idx, "Capture Switch", sw); |
| 4472 | if (!knew) |
| 4473 | return -ENOMEM; |
| 4474 | /* add a LED hook for some HP laptops */ |
| 4475 | if (spec->mic_mute_led_gpio) |
| 4476 | knew->put = stac92xx_capture_sw_put_led; |
| 4477 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 4478 | return 0; |
| 4479 | } |
| 4480 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4481 | /* add playback controls from the parsed DAC table */ |
| 4482 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
| 4483 | const struct auto_pin_cfg *cfg) |
| 4484 | { |
| 4485 | struct sigmatel_spec *spec = codec->spec; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4486 | hda_nid_t nid; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4487 | int err; |
Nickolas Lloyd | 7c922de | 2009-06-01 11:12:29 +0200 | [diff] [blame] | 4488 | int idx; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4489 | |
| 4490 | err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins, |
| 4491 | spec->multiout.dac_nids, |
| 4492 | cfg->line_out_type); |
| 4493 | if (err < 0) |
| 4494 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4495 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 4496 | 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] | 4497 | err = stac92xx_add_control(spec, |
| 4498 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4499 | "Headphone as Line Out Switch", |
| 4500 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4501 | if (err < 0) |
| 4502 | return err; |
| 4503 | } |
| 4504 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4505 | for (idx = 0; idx < cfg->num_inputs; idx++) { |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4506 | if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4507 | break; |
| 4508 | nid = cfg->inputs[idx].pin; |
| 4509 | err = stac92xx_add_jack_mode_control(codec, nid, idx); |
| 4510 | if (err < 0) |
| 4511 | return err; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 4512 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4513 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4514 | return 0; |
| 4515 | } |
| 4516 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4517 | /* add playback controls for Speaker and HP outputs */ |
| 4518 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 4519 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4520 | { |
| 4521 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4522 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4523 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 4524 | err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins, |
| 4525 | spec->hp_dacs, AUTO_PIN_HP_OUT); |
| 4526 | if (err < 0) |
| 4527 | return err; |
| 4528 | |
| 4529 | err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins, |
| 4530 | spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT); |
| 4531 | if (err < 0) |
| 4532 | return err; |
| 4533 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4534 | return 0; |
| 4535 | } |
| 4536 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4537 | /* labels for mono mux outputs */ |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4538 | static const char * const stac92xx_mono_labels[4] = { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4539 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4540 | }; |
| 4541 | |
| 4542 | /* create mono mux for mono out on capable codecs */ |
| 4543 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 4544 | { |
| 4545 | struct sigmatel_spec *spec = codec->spec; |
| 4546 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 4547 | int i, num_cons; |
| 4548 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 4549 | |
| 4550 | num_cons = snd_hda_get_connections(codec, |
| 4551 | spec->mono_nid, |
| 4552 | con_lst, |
| 4553 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 4554 | if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4555 | return -EINVAL; |
| 4556 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4557 | for (i = 0; i < num_cons; i++) |
| 4558 | snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i, |
| 4559 | NULL); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 4560 | |
| 4561 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 4562 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 4563 | } |
| 4564 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4565 | /* create PC beep volume controls */ |
| 4566 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 4567 | hda_nid_t nid) |
| 4568 | { |
| 4569 | struct sigmatel_spec *spec = codec->spec; |
| 4570 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4571 | int err, type = STAC_CTL_WIDGET_MUTE_BEEP; |
| 4572 | |
| 4573 | if (spec->anabeep_nid == nid) |
| 4574 | type = STAC_CTL_WIDGET_MUTE; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4575 | |
| 4576 | /* check for mute support for the the amp */ |
| 4577 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4578 | err = stac92xx_add_control(spec, type, |
Jaroslav Kysela | d355c82a | 2009-11-03 15:47:25 +0100 | [diff] [blame] | 4579 | "Beep Playback Switch", |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4580 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 4581 | if (err < 0) |
| 4582 | return err; |
| 4583 | } |
| 4584 | |
| 4585 | /* check to see if there is volume support for the amp */ |
| 4586 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 4587 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
Jaroslav Kysela | d355c82a | 2009-11-03 15:47:25 +0100 | [diff] [blame] | 4588 | "Beep Playback Volume", |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4589 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 4590 | if (err < 0) |
| 4591 | return err; |
| 4592 | } |
| 4593 | return 0; |
| 4594 | } |
| 4595 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4596 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4597 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 4598 | |
| 4599 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 4600 | struct snd_ctl_elem_value *ucontrol) |
| 4601 | { |
| 4602 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4603 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 4604 | return 0; |
| 4605 | } |
| 4606 | |
| 4607 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 4608 | struct snd_ctl_elem_value *ucontrol) |
| 4609 | { |
| 4610 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 4611 | return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]); |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4612 | } |
| 4613 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 4614 | static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4615 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4616 | .info = stac92xx_dig_beep_switch_info, |
| 4617 | .get = stac92xx_dig_beep_switch_get, |
| 4618 | .put = stac92xx_dig_beep_switch_put, |
| 4619 | }; |
| 4620 | |
| 4621 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 4622 | { |
| 4623 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
Jaroslav Kysela | d355c82a | 2009-11-03 15:47:25 +0100 | [diff] [blame] | 4624 | 0, "Beep Playback Switch", 0); |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 4625 | } |
| 4626 | #endif |
| 4627 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4628 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 4629 | { |
| 4630 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4631 | int i, j, err = 0; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4632 | |
| 4633 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4634 | hda_nid_t nid; |
| 4635 | unsigned int wcaps; |
| 4636 | unsigned long val; |
| 4637 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4638 | nid = spec->mux_nids[i]; |
| 4639 | wcaps = get_wcaps(codec, nid); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4640 | if (!(wcaps & AC_WCAP_OUT_AMP)) |
| 4641 | continue; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4642 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4643 | /* check whether already the same control was created as |
| 4644 | * normal Capture Volume. |
| 4645 | */ |
| 4646 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 4647 | for (j = 0; j < spec->num_caps; j++) { |
| 4648 | if (spec->capvols[j] == val) |
| 4649 | break; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4650 | } |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4651 | if (j < spec->num_caps) |
| 4652 | continue; |
| 4653 | |
| 4654 | err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i, |
| 4655 | "Mux Capture Volume", val); |
| 4656 | if (err < 0) |
| 4657 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 4658 | } |
| 4659 | return 0; |
| 4660 | }; |
| 4661 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4662 | static const char * const stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4663 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4664 | }; |
| 4665 | |
| 4666 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 4667 | { |
| 4668 | struct sigmatel_spec *spec = codec->spec; |
| 4669 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4670 | const char * const *labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4671 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4672 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4673 | |
| 4674 | num_cons = snd_hda_get_connections(codec, |
| 4675 | spec->smux_nids[0], |
| 4676 | con_lst, |
| 4677 | HDA_MAX_NUM_INPUTS); |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 4678 | if (num_cons <= 0) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4679 | return -EINVAL; |
| 4680 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 4681 | if (!labels) |
| 4682 | labels = stac92xx_spdif_labels; |
| 4683 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4684 | for (i = 0; i < num_cons; i++) |
| 4685 | snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4686 | |
| 4687 | return 0; |
| 4688 | } |
| 4689 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4690 | /* labels for dmic mux inputs */ |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 4691 | static const char * const stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4692 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 4693 | "Digital Mic 3", "Digital Mic 4" |
| 4694 | }; |
| 4695 | |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 4696 | static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux, |
| 4697 | int idx) |
| 4698 | { |
| 4699 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; |
| 4700 | int nums; |
| 4701 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); |
| 4702 | if (idx >= 0 && idx < nums) |
| 4703 | return conn[idx]; |
| 4704 | return 0; |
| 4705 | } |
| 4706 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 4707 | /* look for NID recursively */ |
| 4708 | #define get_connection_index(codec, mux, nid) \ |
| 4709 | snd_hda_get_conn_index(codec, mux, nid, 1) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4710 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4711 | /* create a volume assigned to the given pin (only if supported) */ |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4712 | /* return 1 if the volume control is created */ |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4713 | 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] | 4714 | const char *label, int idx, int direction) |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4715 | { |
| 4716 | unsigned int caps, nums; |
| 4717 | char name[32]; |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4718 | int err; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4719 | |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4720 | if (direction == HDA_OUTPUT) |
| 4721 | caps = AC_WCAP_OUT_AMP; |
| 4722 | else |
| 4723 | caps = AC_WCAP_IN_AMP; |
| 4724 | if (!(get_wcaps(codec, nid) & caps)) |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4725 | return 0; |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4726 | caps = query_amp_caps(codec, nid, direction); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4727 | nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; |
| 4728 | if (!nums) |
| 4729 | return 0; |
| 4730 | snprintf(name, sizeof(name), "%s Capture Volume", label); |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4731 | err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name, |
| 4732 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4733 | if (err < 0) |
| 4734 | return err; |
| 4735 | return 1; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4736 | } |
| 4737 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4738 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 4739 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 4740 | const struct auto_pin_cfg *cfg) |
| 4741 | { |
| 4742 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4743 | struct hda_input_mux *imux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4744 | struct hda_input_mux *dimux = &spec->private_dimux; |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 4745 | int err, i; |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4746 | unsigned int def_conf; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4747 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4748 | snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4749 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4750 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 4751 | hda_nid_t nid; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4752 | int index, type_idx; |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 4753 | char label[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4754 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4755 | nid = spec->dmic_nids[i]; |
| 4756 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 4757 | continue; |
| 4758 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4759 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 4760 | continue; |
| 4761 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4762 | index = get_connection_index(codec, spec->dmux_nids[0], nid); |
| 4763 | if (index < 0) |
| 4764 | continue; |
| 4765 | |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 4766 | snd_hda_get_pin_label(codec, nid, &spec->autocfg, |
| 4767 | label, sizeof(label), NULL); |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4768 | snd_hda_add_imux_item(dimux, label, index, &type_idx); |
Takashi Iwai | 2d7ec12 | 2010-12-23 10:16:05 +0100 | [diff] [blame] | 4769 | if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) |
| 4770 | snd_hda_add_imux_item(imux, label, index, &type_idx); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4771 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4772 | err = create_elem_capture_vol(codec, nid, label, type_idx, |
| 4773 | HDA_INPUT); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4774 | if (err < 0) |
| 4775 | return err; |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4776 | if (!err) { |
| 4777 | err = create_elem_capture_vol(codec, nid, label, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4778 | type_idx, HDA_OUTPUT); |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4779 | if (err < 0) |
| 4780 | return err; |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 4781 | if (!err) { |
| 4782 | nid = get_connected_node(codec, |
| 4783 | spec->dmux_nids[0], index); |
| 4784 | if (nid) |
| 4785 | err = create_elem_capture_vol(codec, |
| 4786 | nid, label, |
| 4787 | type_idx, HDA_INPUT); |
| 4788 | if (err < 0) |
| 4789 | return err; |
| 4790 | } |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4791 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4792 | } |
| 4793 | |
| 4794 | return 0; |
| 4795 | } |
| 4796 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4797 | 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] | 4798 | hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4799 | { |
| 4800 | unsigned int cfg; |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4801 | unsigned int type; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4802 | |
| 4803 | if (!nid) |
| 4804 | return 0; |
| 4805 | cfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4806 | type = get_defcfg_device(cfg); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4807 | switch (snd_hda_get_input_pin_attr(cfg)) { |
| 4808 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4809 | if (*fixed) |
| 4810 | return 1; /* already occupied */ |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4811 | if (type != AC_JACK_MIC_IN) |
| 4812 | return 1; /* invalid type */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4813 | *fixed = nid; |
| 4814 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4815 | case INPUT_PIN_ATTR_UNUSED: |
| 4816 | break; |
| 4817 | case INPUT_PIN_ATTR_DOCK: |
| 4818 | if (*dock) |
| 4819 | return 1; /* already occupied */ |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4820 | if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN) |
| 4821 | return 1; /* invalid type */ |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 4822 | *dock = nid; |
| 4823 | break; |
| 4824 | default: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4825 | if (*ext) |
| 4826 | return 1; /* already occupied */ |
Takashi Iwai | 1f83ac5 | 2011-05-17 12:29:09 +0200 | [diff] [blame] | 4827 | if (type != AC_JACK_MIC_IN) |
| 4828 | return 1; /* invalid type */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4829 | *ext = nid; |
| 4830 | break; |
| 4831 | } |
| 4832 | return 0; |
| 4833 | } |
| 4834 | |
| 4835 | static int set_mic_route(struct hda_codec *codec, |
| 4836 | struct sigmatel_mic_route *mic, |
| 4837 | hda_nid_t pin) |
| 4838 | { |
| 4839 | struct sigmatel_spec *spec = codec->spec; |
| 4840 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4841 | int i; |
| 4842 | |
| 4843 | mic->pin = pin; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4844 | if (pin == 0) |
| 4845 | return 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4846 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4847 | if (pin == cfg->inputs[i].pin) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4848 | break; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4849 | } |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 4850 | if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4851 | /* analog pin */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4852 | i = get_connection_index(codec, spec->mux_nids[0], pin); |
| 4853 | if (i < 0) |
| 4854 | return -1; |
| 4855 | mic->mux_idx = i; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 4856 | mic->dmux_idx = -1; |
| 4857 | if (spec->dmux_nids) |
| 4858 | mic->dmux_idx = get_connection_index(codec, |
| 4859 | spec->dmux_nids[0], |
| 4860 | spec->mux_nids[0]); |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 4861 | } else if (spec->dmux_nids) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4862 | /* digital pin */ |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4863 | i = get_connection_index(codec, spec->dmux_nids[0], pin); |
| 4864 | if (i < 0) |
| 4865 | return -1; |
| 4866 | mic->dmux_idx = i; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 4867 | mic->mux_idx = -1; |
| 4868 | if (spec->mux_nids) |
| 4869 | mic->mux_idx = get_connection_index(codec, |
| 4870 | spec->mux_nids[0], |
| 4871 | spec->dmux_nids[0]); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4872 | } |
| 4873 | return 0; |
| 4874 | } |
| 4875 | |
| 4876 | /* return non-zero if the device is for automatic mic switch */ |
| 4877 | static int stac_check_auto_mic(struct hda_codec *codec) |
| 4878 | { |
| 4879 | struct sigmatel_spec *spec = codec->spec; |
| 4880 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4881 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4882 | int i; |
| 4883 | |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4884 | fixed = ext = dock = 0; |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4885 | for (i = 0; i < cfg->num_inputs; i++) |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4886 | if (check_mic_pin(codec, cfg->inputs[i].pin, |
| 4887 | &fixed, &ext, &dock)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4888 | return 0; |
| 4889 | for (i = 0; i < spec->num_dmics; i++) |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4890 | if (check_mic_pin(codec, spec->dmic_nids[i], |
| 4891 | &fixed, &ext, &dock)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4892 | return 0; |
Takashi Iwai | 80c6785 | 2011-01-13 08:08:08 +0100 | [diff] [blame] | 4893 | if (!fixed || (!ext && !dock)) |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4894 | return 0; /* no input to switch */ |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 4895 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4896 | return 0; /* no unsol support */ |
| 4897 | if (set_mic_route(codec, &spec->ext_mic, ext) || |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 4898 | set_mic_route(codec, &spec->int_mic, fixed) || |
| 4899 | set_mic_route(codec, &spec->dock_mic, dock)) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 4900 | return 0; /* something is wrong */ |
| 4901 | return 1; |
| 4902 | } |
| 4903 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4904 | /* create playback/capture controls for input pins */ |
| 4905 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 4906 | { |
| 4907 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4908 | struct hda_input_mux *imux = &spec->private_imux; |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4909 | int i, j; |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 4910 | const char *label; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4911 | |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 4912 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4913 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4914 | int index, err, type_idx; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4915 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4916 | index = -1; |
| 4917 | for (j = 0; j < spec->num_muxes; j++) { |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4918 | index = get_connection_index(codec, spec->mux_nids[j], |
| 4919 | nid); |
| 4920 | if (index >= 0) |
| 4921 | break; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4922 | } |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4923 | if (index < 0) |
| 4924 | continue; |
| 4925 | |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 4926 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 4927 | snd_hda_add_imux_item(imux, label, index, &type_idx); |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 4928 | |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4929 | err = create_elem_capture_vol(codec, nid, |
Vitaliy Kulikov | 263d032 | 2010-09-08 08:56:03 +0200 | [diff] [blame] | 4930 | label, type_idx, |
Takashi Iwai | 96f845d | 2009-08-29 00:49:36 +0200 | [diff] [blame] | 4931 | HDA_INPUT); |
Takashi Iwai | 667067d | 2009-08-13 18:14:42 +0200 | [diff] [blame] | 4932 | if (err < 0) |
| 4933 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4934 | } |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 4935 | spec->num_analog_muxes = imux->num_items; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4936 | |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4937 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4938 | /* |
| 4939 | * Set the current input for the muxes. |
| 4940 | * The STAC9221 has two input muxes with identical source |
| 4941 | * NID lists. Hopefully this won't get confused. |
| 4942 | */ |
| 4943 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4944 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 4945 | AC_VERB_SET_CONNECT_SEL, |
| 4946 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4947 | } |
| 4948 | } |
| 4949 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4950 | return 0; |
| 4951 | } |
| 4952 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4953 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 4954 | { |
| 4955 | struct sigmatel_spec *spec = codec->spec; |
| 4956 | int i; |
| 4957 | |
| 4958 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 4959 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 4960 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 4961 | } |
| 4962 | } |
| 4963 | |
| 4964 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 4965 | { |
| 4966 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4967 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4968 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4969 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 4970 | hda_nid_t pin; |
| 4971 | pin = spec->autocfg.hp_pins[i]; |
| 4972 | if (pin) /* connect to front */ |
| 4973 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 4974 | } |
| 4975 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 4976 | hda_nid_t pin; |
| 4977 | pin = spec->autocfg.speaker_pins[i]; |
| 4978 | if (pin) /* connect to front */ |
| 4979 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 4980 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4981 | } |
| 4982 | |
Takashi Iwai | 8af3aeb | 2009-11-18 14:23:37 +0100 | [diff] [blame] | 4983 | static int is_dual_headphones(struct hda_codec *codec) |
| 4984 | { |
| 4985 | struct sigmatel_spec *spec = codec->spec; |
| 4986 | int i, valid_hps; |
| 4987 | |
| 4988 | if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT || |
| 4989 | spec->autocfg.hp_outs <= 1) |
| 4990 | return 0; |
| 4991 | valid_hps = 0; |
| 4992 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 4993 | hda_nid_t nid = spec->autocfg.hp_pins[i]; |
| 4994 | unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid); |
| 4995 | if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE) |
| 4996 | continue; |
| 4997 | valid_hps++; |
| 4998 | } |
| 4999 | return (valid_hps > 1); |
| 5000 | } |
| 5001 | |
| 5002 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 5003 | static int stac92xx_parse_auto_config(struct hda_codec *codec) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5004 | { |
| 5005 | struct sigmatel_spec *spec = codec->spec; |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 5006 | hda_nid_t dig_out = 0, dig_in = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5007 | int hp_swap = 0; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5008 | int i, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5009 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5010 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 5011 | &spec->autocfg, |
| 5012 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5013 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5014 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 5015 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5016 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5017 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 5018 | * be set up as multi-channel outputs. |
| 5019 | */ |
Takashi Iwai | 8af3aeb | 2009-11-18 14:23:37 +0100 | [diff] [blame] | 5020 | if (is_dual_headphones(codec)) { |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5021 | /* Copy hp_outs to line_outs, backup line_outs in |
| 5022 | * speaker_outs so that the following routines can handle |
| 5023 | * HP pins as primary outputs. |
| 5024 | */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5025 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5026 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 5027 | sizeof(spec->autocfg.line_out_pins)); |
| 5028 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 5029 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 5030 | sizeof(spec->autocfg.hp_pins)); |
| 5031 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5032 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 5033 | spec->autocfg.hp_outs = 0; |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5034 | hp_swap = 1; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5035 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5036 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5037 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 5038 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5039 | u32 caps = query_amp_caps(codec, |
| 5040 | spec->autocfg.mono_out_pin, dir); |
| 5041 | hda_nid_t conn_list[1]; |
| 5042 | |
| 5043 | /* get the mixer node and then the mono mux if it exists */ |
| 5044 | if (snd_hda_get_connections(codec, |
| 5045 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 5046 | snd_hda_get_connections(codec, conn_list[0], |
Jaroslav Kysela | 16a433d | 2009-07-22 16:20:40 +0200 | [diff] [blame] | 5047 | conn_list, 1) > 0) { |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5048 | |
| 5049 | int wcaps = get_wcaps(codec, conn_list[0]); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 5050 | int wid_type = get_wcaps_type(wcaps); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5051 | /* LR swap check, some stac925x have a mux that |
| 5052 | * changes the DACs output path instead of the |
| 5053 | * mono-mux path. |
| 5054 | */ |
| 5055 | if (wid_type == AC_WID_AUD_SEL && |
| 5056 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 5057 | spec->mono_nid = conn_list[0]; |
| 5058 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5059 | if (dir) { |
| 5060 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 5061 | |
| 5062 | /* most mono outs have a least a mute/unmute switch */ |
| 5063 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 5064 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 5065 | "Mono Playback Switch", |
| 5066 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5067 | if (err < 0) |
| 5068 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5069 | /* check for volume support for the amp */ |
| 5070 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 5071 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 5072 | err = stac92xx_add_control(spec, |
| 5073 | STAC_CTL_WIDGET_VOL, |
| 5074 | "Mono Playback Volume", |
| 5075 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 5076 | if (err < 0) |
| 5077 | return err; |
| 5078 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 5079 | } |
| 5080 | |
| 5081 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 5082 | AC_PINCTL_OUT_EN); |
| 5083 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 5084 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5085 | if (!spec->multiout.num_dacs) { |
| 5086 | err = stac92xx_auto_fill_dac_nids(codec); |
| 5087 | if (err < 0) |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5088 | return err; |
Takashi Iwai | c9280d6 | 2009-01-15 17:31:00 +0100 | [diff] [blame] | 5089 | err = stac92xx_auto_create_multi_out_ctls(codec, |
| 5090 | &spec->autocfg); |
| 5091 | if (err < 0) |
| 5092 | return err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5093 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5094 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5095 | /* setup analog beep controls */ |
| 5096 | if (spec->anabeep_nid > 0) { |
| 5097 | err = stac92xx_auto_create_beep_ctls(codec, |
| 5098 | spec->anabeep_nid); |
| 5099 | if (err < 0) |
| 5100 | return err; |
| 5101 | } |
| 5102 | |
| 5103 | /* setup digital beep controls and input device */ |
| 5104 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 5105 | if (spec->digbeep_nid > 0) { |
| 5106 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 5107 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5108 | |
| 5109 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 5110 | if (err < 0) |
| 5111 | return err; |
| 5112 | err = snd_hda_attach_beep_device(codec, nid); |
| 5113 | if (err < 0) |
| 5114 | return err; |
Takashi Iwai | d8d881d | 2009-12-22 07:52:49 +0100 | [diff] [blame] | 5115 | if (codec->beep) { |
| 5116 | /* IDT/STAC codecs have linear beep tone parameter */ |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 5117 | codec->beep->linear_tone = spec->linear_tone_beep; |
Takashi Iwai | d8d881d | 2009-12-22 07:52:49 +0100 | [diff] [blame] | 5118 | /* if no beep switch is available, make its own one */ |
| 5119 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 5120 | if (!(caps & AC_AMPCAP_MUTE)) { |
| 5121 | err = stac92xx_beep_switch_ctl(codec); |
| 5122 | if (err < 0) |
| 5123 | return err; |
| 5124 | } |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 5125 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5126 | } |
| 5127 | #endif |
| 5128 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5129 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5130 | if (err < 0) |
| 5131 | return err; |
| 5132 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5133 | /* All output parsing done, now restore the swapped hp pins */ |
| 5134 | if (hp_swap) { |
| 5135 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 5136 | sizeof(spec->autocfg.hp_pins)); |
| 5137 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 5138 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
| 5139 | spec->autocfg.line_outs = 0; |
| 5140 | } |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5141 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5142 | if (stac_check_auto_mic(codec)) { |
| 5143 | spec->auto_mic = 1; |
| 5144 | /* only one capture for auto-mic */ |
| 5145 | spec->num_adcs = 1; |
| 5146 | spec->num_caps = 1; |
| 5147 | spec->num_muxes = 1; |
| 5148 | } |
| 5149 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 5150 | for (i = 0; i < spec->num_caps; i++) { |
| 5151 | err = stac92xx_add_capvol_ctls(codec, spec->capvols[i], |
| 5152 | spec->capsws[i], i); |
| 5153 | if (err < 0) |
| 5154 | return err; |
| 5155 | } |
| 5156 | |
Takashi Iwai | dc04d1b | 2009-03-06 10:00:05 +0100 | [diff] [blame] | 5157 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 5158 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5159 | return err; |
| 5160 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 5161 | if (spec->mono_nid > 0) { |
| 5162 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 5163 | if (err < 0) |
| 5164 | return err; |
| 5165 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 5166 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5167 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 5168 | &spec->autocfg)) < 0) |
| 5169 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 5170 | if (spec->num_muxes > 0) { |
| 5171 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 5172 | if (err < 0) |
| 5173 | return err; |
| 5174 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5175 | if (spec->num_smuxes > 0) { |
| 5176 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 5177 | if (err < 0) |
| 5178 | return err; |
| 5179 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5180 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 5181 | err = stac92xx_add_input_source(spec); |
| 5182 | if (err < 0) |
| 5183 | return err; |
| 5184 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5185 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 5186 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5187 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5188 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 5189 | /* find digital out and in converters */ |
| 5190 | for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) { |
| 5191 | unsigned int wid_caps = get_wcaps(codec, i); |
| 5192 | if (wid_caps & AC_WCAP_DIGITAL) { |
| 5193 | switch (get_wcaps_type(wid_caps)) { |
| 5194 | case AC_WID_AUD_OUT: |
| 5195 | if (!dig_out) |
| 5196 | dig_out = i; |
| 5197 | break; |
| 5198 | case AC_WID_AUD_IN: |
| 5199 | if (!dig_in) |
| 5200 | dig_in = i; |
| 5201 | break; |
| 5202 | } |
| 5203 | } |
| 5204 | } |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 5205 | if (spec->autocfg.dig_outs) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5206 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5207 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5208 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5209 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 5210 | if (spec->kctls.list) |
| 5211 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5212 | |
| 5213 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | f8ccbf6 | 2008-12-20 17:36:28 -0500 | [diff] [blame] | 5214 | if (!spec->dinput_mux) |
| 5215 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5216 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 5217 | spec->mono_mux = &spec->private_mono_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5218 | return 1; |
| 5219 | } |
| 5220 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5221 | /* add playback controls for HP output */ |
| 5222 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 5223 | struct auto_pin_cfg *cfg) |
| 5224 | { |
| 5225 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5226 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5227 | |
| 5228 | if (! pin) |
| 5229 | return 0; |
| 5230 | |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 5231 | if (is_jack_detectable(codec, pin)) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5232 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5233 | |
| 5234 | return 0; |
| 5235 | } |
| 5236 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5237 | /* add playback controls for LFE output */ |
| 5238 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 5239 | struct auto_pin_cfg *cfg) |
| 5240 | { |
| 5241 | struct sigmatel_spec *spec = codec->spec; |
| 5242 | int err; |
| 5243 | hda_nid_t lfe_pin = 0x0; |
| 5244 | int i; |
| 5245 | |
| 5246 | /* |
| 5247 | * search speaker outs and line outs for a mono speaker pin |
| 5248 | * with an amp. If one is found, add LFE controls |
| 5249 | * for it. |
| 5250 | */ |
| 5251 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 5252 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 5253 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5254 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 5255 | if (wcaps == AC_WCAP_OUT_AMP) |
| 5256 | /* found a mono speaker with an amp, must be lfe */ |
| 5257 | lfe_pin = pin; |
| 5258 | } |
| 5259 | |
| 5260 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 5261 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 5262 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 5263 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 5264 | unsigned int defcfg; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 5265 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 5266 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 5267 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5268 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 5269 | if (wcaps == AC_WCAP_OUT_AMP) |
| 5270 | /* found a mono speaker with an amp, |
| 5271 | must be lfe */ |
| 5272 | lfe_pin = pin; |
| 5273 | } |
| 5274 | } |
| 5275 | } |
| 5276 | |
| 5277 | if (lfe_pin) { |
Takashi Iwai | 7c7767e | 2009-01-20 15:28:38 +0100 | [diff] [blame] | 5278 | err = create_controls(codec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5279 | if (err < 0) |
| 5280 | return err; |
| 5281 | } |
| 5282 | |
| 5283 | return 0; |
| 5284 | } |
| 5285 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5286 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 5287 | { |
| 5288 | struct sigmatel_spec *spec = codec->spec; |
| 5289 | int err; |
| 5290 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 5291 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5292 | return err; |
| 5293 | |
| 5294 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 5295 | return err; |
| 5296 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5297 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 5298 | return err; |
| 5299 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 5300 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 5301 | return err; |
| 5302 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 5303 | if (spec->num_muxes > 0) { |
| 5304 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 5305 | if (err < 0) |
| 5306 | return err; |
| 5307 | } |
| 5308 | |
Takashi Iwai | e3c7596 | 2009-01-23 11:57:22 +0100 | [diff] [blame] | 5309 | err = stac92xx_add_input_source(spec); |
| 5310 | if (err < 0) |
| 5311 | return err; |
| 5312 | |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 5313 | if (spec->autocfg.dig_outs) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5314 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5315 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5316 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5317 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 5318 | if (spec->kctls.list) |
| 5319 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5320 | |
| 5321 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5322 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5323 | |
| 5324 | return 1; |
| 5325 | } |
| 5326 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5327 | /* |
| 5328 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 5329 | * funky external mute control using GPIO pins. |
| 5330 | */ |
| 5331 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5332 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5333 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5334 | { |
| 5335 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5336 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5337 | snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data); |
| 5338 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5339 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5340 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5341 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5342 | |
| 5343 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5344 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5345 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5346 | |
| 5347 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5348 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5349 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5350 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5351 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5352 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 5353 | |
| 5354 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5355 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5356 | snd_hda_codec_read(codec, codec->afg, 0, |
| 5357 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5358 | |
| 5359 | msleep(1); |
| 5360 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 5361 | snd_hda_codec_read(codec, codec->afg, 0, |
| 5362 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5363 | } |
| 5364 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5365 | 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] | 5366 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5367 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5368 | struct hda_jack_tbl *event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5369 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5370 | event = snd_hda_jack_tbl_new(codec, nid); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5371 | if (!event) |
| 5372 | return -ENOMEM; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5373 | event->action = type; |
| 5374 | event->private_data = data; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5375 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5376 | return 0; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5377 | } |
| 5378 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5379 | static void handle_unsol_event(struct hda_codec *codec, |
| 5380 | struct hda_jack_tbl *event); |
| 5381 | |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5382 | /* check if given nid is a valid pin and no other events are assigned |
| 5383 | * to it. If OK, assign the event, set the unsol flag, and returns 1. |
| 5384 | * Otherwise, returns zero. |
| 5385 | */ |
| 5386 | static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
| 5387 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5388 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5389 | struct hda_jack_tbl *event; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5390 | |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 5391 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5392 | return 0; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5393 | event = snd_hda_jack_tbl_new(codec, nid); |
| 5394 | if (!event) |
| 5395 | return -ENOMEM; |
| 5396 | if (event->action && event->action != type) |
| 5397 | return 0; |
| 5398 | event->action = type; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 5399 | event->callback = handle_unsol_event; |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5400 | snd_hda_jack_detect_enable(codec, nid, 0); |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5401 | return 1; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5402 | } |
| 5403 | |
Takashi Iwai | b4ead01 | 2012-01-23 18:23:36 +0100 | [diff] [blame] | 5404 | 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] | 5405 | { |
| 5406 | int i; |
| 5407 | for (i = 0; i < cfg->hp_outs; i++) |
| 5408 | if (cfg->hp_pins[i] == nid) |
| 5409 | return 1; /* nid is a HP-Out */ |
Takashi Iwai | b4ead01 | 2012-01-23 18:23:36 +0100 | [diff] [blame] | 5410 | for (i = 0; i < cfg->line_outs; i++) |
| 5411 | if (cfg->line_out_pins[i] == nid) |
| 5412 | return 1; /* nid is a line-Out */ |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5413 | return 0; /* nid is not a HP-Out */ |
| 5414 | }; |
| 5415 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5416 | static void stac92xx_power_down(struct hda_codec *codec) |
| 5417 | { |
| 5418 | struct sigmatel_spec *spec = codec->spec; |
| 5419 | |
| 5420 | /* power down inactive DACs */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 5421 | const hda_nid_t *dac; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5422 | for (dac = spec->dac_list; *dac; dac++) |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5423 | if (!check_all_dac_nids(spec, *dac)) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5424 | snd_hda_codec_write(codec, *dac, 0, |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5425 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 5426 | } |
| 5427 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5428 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 5429 | int enable); |
| 5430 | |
Takashi Iwai | bc75972 | 2013-01-11 17:40:31 +0100 | [diff] [blame] | 5431 | static inline bool get_int_hint(struct hda_codec *codec, const char *key, |
| 5432 | int *valp) |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5433 | { |
Takashi Iwai | bc75972 | 2013-01-11 17:40:31 +0100 | [diff] [blame] | 5434 | return !snd_hda_get_int_hint(codec, key, valp); |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5435 | } |
| 5436 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5437 | /* override some hints from the hwdep entry */ |
| 5438 | static void stac_store_hints(struct hda_codec *codec) |
| 5439 | { |
| 5440 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5441 | int val; |
| 5442 | |
| 5443 | val = snd_hda_get_bool_hint(codec, "hp_detect"); |
| 5444 | if (val >= 0) |
| 5445 | spec->hp_detect = val; |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5446 | if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) { |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5447 | spec->eapd_mask = spec->gpio_dir = spec->gpio_data = |
| 5448 | spec->gpio_mask; |
| 5449 | } |
Takashi Iwai | 014c41f | 2009-12-27 13:53:24 +0100 | [diff] [blame] | 5450 | if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) |
| 5451 | spec->gpio_mask &= spec->gpio_mask; |
| 5452 | if (get_int_hint(codec, "gpio_data", &spec->gpio_data)) |
| 5453 | spec->gpio_dir &= spec->gpio_mask; |
| 5454 | if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) |
| 5455 | spec->eapd_mask &= spec->gpio_mask; |
| 5456 | if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) |
| 5457 | spec->gpio_mute &= spec->gpio_mask; |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5458 | val = snd_hda_get_bool_hint(codec, "eapd_switch"); |
| 5459 | if (val >= 0) |
| 5460 | spec->eapd_switch = val; |
| 5461 | } |
| 5462 | |
Takashi Iwai | f2cbba7 | 2012-01-11 12:34:11 +0100 | [diff] [blame] | 5463 | static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins, |
| 5464 | const hda_nid_t *pins) |
| 5465 | { |
| 5466 | while (num_pins--) |
| 5467 | stac_issue_unsol_event(codec, *pins++); |
| 5468 | } |
| 5469 | |
| 5470 | /* fake event to set up pins */ |
| 5471 | static void stac_fake_hp_events(struct hda_codec *codec) |
| 5472 | { |
| 5473 | struct sigmatel_spec *spec = codec->spec; |
| 5474 | |
| 5475 | if (spec->autocfg.hp_outs) |
| 5476 | stac_issue_unsol_events(codec, spec->autocfg.hp_outs, |
| 5477 | spec->autocfg.hp_pins); |
| 5478 | if (spec->autocfg.line_outs && |
| 5479 | spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0]) |
| 5480 | stac_issue_unsol_events(codec, spec->autocfg.line_outs, |
| 5481 | spec->autocfg.line_out_pins); |
| 5482 | } |
| 5483 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5484 | static int stac92xx_init(struct hda_codec *codec) |
| 5485 | { |
| 5486 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5487 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5488 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 5489 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5490 | |
David Henningsson | 5e68fb3 | 2012-08-16 14:11:09 +0200 | [diff] [blame] | 5491 | if (spec->init) |
| 5492 | snd_hda_sequence_write(codec, spec->init); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5493 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 5494 | snd_hda_apply_verbs(codec); |
| 5495 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5496 | /* power down adcs initially */ |
| 5497 | if (spec->powerdown_adcs) |
| 5498 | for (i = 0; i < spec->num_adcs; i++) |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 5499 | snd_hda_codec_write(codec, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 5500 | spec->adc_nids[i], 0, |
| 5501 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5502 | |
Takashi Iwai | 6565e4f | 2009-03-02 14:38:35 +0100 | [diff] [blame] | 5503 | /* override some hints */ |
| 5504 | stac_store_hints(codec); |
| 5505 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5506 | /* set up GPIO */ |
| 5507 | gpio = spec->gpio_data; |
| 5508 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 5509 | * otherwise, unsol event will turn it on/off dynamically |
| 5510 | */ |
| 5511 | if (!spec->eapd_switch) |
| 5512 | gpio |= spec->eapd_mask; |
| 5513 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 5514 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5515 | /* set up pins */ |
| 5516 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 5517 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5518 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5519 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5520 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5521 | } |
Takashi Iwai | 1c4bdf9 | 2009-08-13 08:23:24 +0200 | [diff] [blame] | 5522 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && |
| 5523 | cfg->speaker_outs > 0) { |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5524 | /* enable pin-detect for line-outs as well */ |
Takashi Iwai | 15cfa2b | 2009-08-03 14:23:33 +0200 | [diff] [blame] | 5525 | for (i = 0; i < cfg->line_outs; i++) { |
| 5526 | hda_nid_t nid = cfg->line_out_pins[i]; |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5527 | enable_pin_detect(codec, nid, STAC_LO_EVENT); |
| 5528 | } |
| 5529 | } |
| 5530 | |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 5531 | /* force to enable the first line-out; the others are set up |
| 5532 | * in unsol_event |
| 5533 | */ |
| 5534 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5535 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5536 | /* fake event to set up pins */ |
Takashi Iwai | f2cbba7 | 2012-01-11 12:34:11 +0100 | [diff] [blame] | 5537 | stac_fake_hp_events(codec); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5538 | } else { |
| 5539 | stac92xx_auto_init_multi_out(codec); |
| 5540 | stac92xx_auto_init_hp_out(codec); |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 5541 | for (i = 0; i < cfg->hp_outs; i++) |
| 5542 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5543 | } |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5544 | if (spec->auto_mic) { |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 5545 | /* initialize connection to analog input */ |
Takashi Iwai | da2a2aa | 2009-08-10 07:44:09 +0200 | [diff] [blame] | 5546 | if (spec->dmux_nids) |
| 5547 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
Takashi Iwai | 15b4f29 | 2009-07-29 16:32:55 +0200 | [diff] [blame] | 5548 | AC_VERB_SET_CONNECT_SEL, 0); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5549 | if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) |
| 5550 | stac_issue_unsol_event(codec, spec->ext_mic.pin); |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5551 | if (enable_pin_detect(codec, spec->dock_mic.pin, |
| 5552 | STAC_MIC_EVENT)) |
| 5553 | stac_issue_unsol_event(codec, spec->dock_mic.pin); |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5554 | } |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5555 | for (i = 0; i < cfg->num_inputs; i++) { |
| 5556 | hda_nid_t nid = cfg->inputs[i].pin; |
| 5557 | int type = cfg->inputs[i].type; |
| 5558 | unsigned int pinctl, conf; |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 5559 | if (type == AUTO_PIN_MIC) { |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5560 | /* for mic pins, force to initialize */ |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 5561 | pinctl = snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5562 | pinctl |= AC_PINCTL_IN_EN; |
| 5563 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 5564 | } else { |
| 5565 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 5566 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5567 | /* if PINCTL already set then skip */ |
| 5568 | /* Also, if both INPUT and OUTPUT are set, |
| 5569 | * it must be a BIOS bug; need to override, too |
| 5570 | */ |
| 5571 | if (!(pinctl & AC_PINCTL_IN_EN) || |
| 5572 | (pinctl & AC_PINCTL_OUT_EN)) { |
| 5573 | pinctl &= ~AC_PINCTL_OUT_EN; |
Takashi Iwai | 12dde4c | 2008-12-05 13:09:27 +0100 | [diff] [blame] | 5574 | pinctl |= AC_PINCTL_IN_EN; |
| 5575 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 5576 | } |
Takashi Iwai | eea7dc9 | 2010-08-30 13:06:15 +0200 | [diff] [blame] | 5577 | } |
| 5578 | conf = snd_hda_codec_get_pincfg(codec, nid); |
| 5579 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
| 5580 | if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT)) |
| 5581 | stac_issue_unsol_event(codec, nid); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 5582 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5583 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5584 | for (i = 0; i < spec->num_dmics; i++) |
| 5585 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 5586 | AC_PINCTL_IN_EN); |
Takashi Iwai | 0852d7a | 2009-02-11 11:35:15 +0100 | [diff] [blame] | 5587 | if (cfg->dig_out_pins[0]) |
| 5588 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0], |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5589 | AC_PINCTL_OUT_EN); |
| 5590 | if (cfg->dig_in_pin) |
| 5591 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 5592 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5593 | for (i = 0; i < spec->num_pwrs; i++) { |
| 5594 | hda_nid_t nid = spec->pwr_nids[i]; |
Takashi Iwai | 6e1c39c | 2012-06-26 17:35:10 +0200 | [diff] [blame] | 5595 | unsigned int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 5596 | |
Takashi Iwai | bfc89de | 2012-05-15 09:02:26 +0200 | [diff] [blame] | 5597 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 5598 | def_conf = get_defcfg_connect(def_conf); |
| 5599 | if (def_conf == AC_JACK_PORT_NONE) { |
| 5600 | /* power off unused ports */ |
| 5601 | stac_toggle_power_map(codec, nid, 0); |
| 5602 | continue; |
| 5603 | } |
Takashi Iwai | 6e1c39c | 2012-06-26 17:35:10 +0200 | [diff] [blame] | 5604 | if (def_conf == AC_JACK_PORT_FIXED) { |
| 5605 | /* no need for jack detection for fixed pins */ |
| 5606 | stac_toggle_power_map(codec, nid, 1); |
| 5607 | continue; |
| 5608 | } |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5609 | /* power on when no jack detection is available */ |
Takashi Iwai | 542c9a0 | 2011-11-29 13:01:30 +0100 | [diff] [blame] | 5610 | /* or when the VREF is used for controlling LED */ |
| 5611 | if (!spec->hp_detect || |
Takashi Iwai | bfc89de | 2012-05-15 09:02:26 +0200 | [diff] [blame] | 5612 | spec->vref_mute_led_nid == nid || |
| 5613 | !is_jack_detectable(codec, nid)) { |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5614 | stac_toggle_power_map(codec, nid, 1); |
| 5615 | continue; |
| 5616 | } |
| 5617 | |
Takashi Iwai | b4ead01 | 2012-01-23 18:23:36 +0100 | [diff] [blame] | 5618 | if (is_nid_out_jack_pin(cfg, nid)) |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5619 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 5620 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5621 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 5622 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5623 | /* outputs are only ports capable of power management |
| 5624 | * any attempts on powering down a input port cause the |
| 5625 | * referenced VREF to act quirky. |
| 5626 | */ |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5627 | if (pinctl & AC_PINCTL_IN_EN) { |
| 5628 | stac_toggle_power_map(codec, nid, 1); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5629 | continue; |
Takashi Iwai | eb63212 | 2008-12-19 16:39:48 +0100 | [diff] [blame] | 5630 | } |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 5631 | if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) { |
Takashi Iwai | 62558ce | 2009-07-29 14:23:09 +0200 | [diff] [blame] | 5632 | stac_issue_unsol_event(codec, nid); |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 5633 | continue; |
| 5634 | } |
| 5635 | /* none of the above, turn the port OFF */ |
| 5636 | stac_toggle_power_map(codec, nid, 0); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5637 | } |
Takashi Iwai | c21bd02 | 2010-02-08 15:16:08 +0100 | [diff] [blame] | 5638 | |
Takashi Iwai | c21bd02 | 2010-02-08 15:16:08 +0100 | [diff] [blame] | 5639 | /* sync mute LED */ |
Takashi Iwai | 1f43f6c | 2012-07-31 10:40:05 +0200 | [diff] [blame] | 5640 | if (spec->gpio_led) { |
| 5641 | if (spec->vmaster_mute.hook) |
| 5642 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 5643 | else /* the very first init call doesn't have vmaster yet */ |
| 5644 | stac92xx_update_led_status(codec, false); |
| 5645 | } |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 5646 | |
| 5647 | /* sync the power-map */ |
| 5648 | if (spec->num_pwrs) |
| 5649 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5650 | AC_VERB_IDT_SET_POWER_MAP, |
| 5651 | spec->power_map_bits); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5652 | if (spec->dac_list) |
| 5653 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5654 | return 0; |
| 5655 | } |
| 5656 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 5657 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 5658 | { |
| 5659 | struct sigmatel_spec *spec = codec->spec; |
| 5660 | |
| 5661 | if (spec->kctls.list) { |
| 5662 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 5663 | int i; |
| 5664 | for (i = 0; i < spec->kctls.used; i++) |
| 5665 | kfree(kctl[i].name); |
| 5666 | } |
| 5667 | snd_array_free(&spec->kctls); |
| 5668 | } |
| 5669 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5670 | static void stac92xx_shutup_pins(struct hda_codec *codec) |
| 5671 | { |
| 5672 | unsigned int i, def_conf; |
| 5673 | |
| 5674 | if (codec->bus->shutdown) |
| 5675 | return; |
| 5676 | for (i = 0; i < codec->init_pins.used; i++) { |
| 5677 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); |
| 5678 | def_conf = snd_hda_codec_get_pincfg(codec, pin->nid); |
| 5679 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5680 | snd_hda_set_pin_ctl(codec, pin->nid, 0); |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5681 | } |
| 5682 | } |
| 5683 | |
Takashi Iwai | 167eae5 | 2009-11-06 15:47:50 +0100 | [diff] [blame] | 5684 | static void stac92xx_shutup(struct hda_codec *codec) |
| 5685 | { |
| 5686 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 167eae5 | 2009-11-06 15:47:50 +0100 | [diff] [blame] | 5687 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 5688 | stac92xx_shutup_pins(codec); |
Takashi Iwai | 167eae5 | 2009-11-06 15:47:50 +0100 | [diff] [blame] | 5689 | |
| 5690 | if (spec->eapd_mask) |
| 5691 | stac_gpio_set(codec, spec->gpio_mask, |
| 5692 | spec->gpio_dir, spec->gpio_data & |
| 5693 | ~spec->eapd_mask); |
| 5694 | } |
| 5695 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5696 | static void stac92xx_free(struct hda_codec *codec) |
| 5697 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5698 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5699 | |
| 5700 | if (! spec) |
| 5701 | return; |
| 5702 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5703 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5704 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5705 | } |
| 5706 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5707 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 5708 | unsigned int flag) |
| 5709 | { |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5710 | unsigned int old_ctl, pin_ctl; |
| 5711 | |
| 5712 | pin_ctl = snd_hda_codec_read(codec, nid, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5713 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 5714 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 5715 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 5716 | /* |
| 5717 | * we need to check the current set-up direction of |
| 5718 | * shared input pins since they can be switched via |
| 5719 | * "xxx as Output" mixer switch |
| 5720 | */ |
| 5721 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5722 | if (nid == spec->line_switch || nid == spec->mic_switch) |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 5723 | return; |
| 5724 | } |
| 5725 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5726 | old_ctl = pin_ctl; |
Steve Longerbeam | 7b043899 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 5727 | /* if setting pin direction bits, clear the current |
| 5728 | direction bits first */ |
| 5729 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 5730 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 5731 | |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5732 | pin_ctl |= flag; |
| 5733 | if (old_ctl != pin_ctl) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5734 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5735 | } |
| 5736 | |
| 5737 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 5738 | unsigned int flag) |
| 5739 | { |
| 5740 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 5741 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 8ce8419 | 2009-01-22 16:59:20 +0100 | [diff] [blame] | 5742 | if (pin_ctl & flag) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5743 | snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5744 | } |
| 5745 | |
Takashi Iwai | d56757a | 2009-11-18 08:00:14 +0100 | [diff] [blame] | 5746 | 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] | 5747 | { |
| 5748 | if (!nid) |
| 5749 | return 0; |
Takashi Iwai | a252c81 | 2009-12-25 22:56:20 +0100 | [diff] [blame] | 5750 | return snd_hda_jack_detect(codec, nid); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5751 | } |
| 5752 | |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5753 | static void stac92xx_line_out_detect(struct hda_codec *codec, |
| 5754 | int presence) |
| 5755 | { |
| 5756 | struct sigmatel_spec *spec = codec->spec; |
| 5757 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 5758 | int i; |
| 5759 | |
David Henningsson | 042b92c | 2012-08-22 16:10:43 +0200 | [diff] [blame] | 5760 | if (cfg->speaker_outs == 0) |
| 5761 | return; |
| 5762 | |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5763 | for (i = 0; i < cfg->line_outs; i++) { |
| 5764 | if (presence) |
| 5765 | break; |
| 5766 | presence = get_pin_presence(codec, cfg->line_out_pins[i]); |
| 5767 | if (presence) { |
| 5768 | unsigned int pinctl; |
| 5769 | pinctl = snd_hda_codec_read(codec, |
| 5770 | cfg->line_out_pins[i], 0, |
| 5771 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5772 | if (pinctl & AC_PINCTL_IN_EN) |
| 5773 | presence = 0; /* mic- or line-input */ |
| 5774 | } |
| 5775 | } |
| 5776 | |
| 5777 | if (presence) { |
| 5778 | /* disable speakers */ |
| 5779 | for (i = 0; i < cfg->speaker_outs; i++) |
| 5780 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 5781 | AC_PINCTL_OUT_EN); |
| 5782 | if (spec->eapd_mask && spec->eapd_switch) |
| 5783 | stac_gpio_set(codec, spec->gpio_mask, |
| 5784 | spec->gpio_dir, spec->gpio_data & |
| 5785 | ~spec->eapd_mask); |
| 5786 | } else { |
| 5787 | /* enable speakers */ |
| 5788 | for (i = 0; i < cfg->speaker_outs; i++) |
| 5789 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 5790 | AC_PINCTL_OUT_EN); |
| 5791 | if (spec->eapd_mask && spec->eapd_switch) |
| 5792 | stac_gpio_set(codec, spec->gpio_mask, |
| 5793 | spec->gpio_dir, spec->gpio_data | |
| 5794 | spec->eapd_mask); |
| 5795 | } |
| 5796 | } |
| 5797 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5798 | /* return non-zero if the hp-pin of the given array index isn't |
| 5799 | * a jack-detection target |
| 5800 | */ |
| 5801 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 5802 | { |
| 5803 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 5804 | |
| 5805 | /* ignore sensing of shared line and mic jacks */ |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5806 | if (cfg->hp_pins[i] == spec->line_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5807 | return 1; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 5808 | if (cfg->hp_pins[i] == spec->mic_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5809 | return 1; |
| 5810 | /* ignore if the pin is set as line-out */ |
| 5811 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 5812 | return 1; |
| 5813 | return 0; |
| 5814 | } |
| 5815 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5816 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5817 | { |
| 5818 | struct sigmatel_spec *spec = codec->spec; |
| 5819 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 5820 | int i, presence; |
| 5821 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5822 | presence = 0; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5823 | if (spec->gpio_mute) |
| 5824 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 5825 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 5826 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5827 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5828 | if (presence) |
| 5829 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5830 | if (no_hp_sensing(spec, i)) |
| 5831 | continue; |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 5832 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
| 5833 | if (presence) { |
| 5834 | unsigned int pinctl; |
| 5835 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 5836 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5837 | if (pinctl & AC_PINCTL_IN_EN) |
| 5838 | presence = 0; /* mic- or line-input */ |
| 5839 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 5840 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5841 | |
| 5842 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5843 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 5844 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5845 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 5846 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5847 | for (i = 0; i < cfg->line_outs; i++) |
| 5848 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 5849 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5850 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5851 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 5852 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5853 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 5854 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5855 | for (i = 0; i < cfg->line_outs; i++) |
| 5856 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 5857 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5858 | } |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5859 | stac92xx_line_out_detect(codec, presence); |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5860 | /* toggle hp outs */ |
| 5861 | for (i = 0; i < cfg->hp_outs; i++) { |
| 5862 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 5863 | if (no_hp_sensing(spec, i)) |
| 5864 | continue; |
Takashi Iwai | 7bff172 | 2012-02-29 09:41:17 +0100 | [diff] [blame] | 5865 | if (1 /*presence*/) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5866 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 5867 | #if 0 /* FIXME */ |
| 5868 | /* Resetting the pinctl like below may lead to (a sort of) regressions |
| 5869 | * on some devices since they use the HP pin actually for line/speaker |
| 5870 | * outs although the default pin config shows a different pin (that is |
| 5871 | * wrong and useless). |
| 5872 | * |
| 5873 | * So, it's basically a problem of default pin configs, likely a BIOS issue. |
| 5874 | * But, disabling the code below just works around it, and I'm too tired of |
| 5875 | * bug reports with such devices... |
| 5876 | */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5877 | else |
| 5878 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
Takashi Iwai | 8317e0b | 2009-01-14 07:56:51 +0100 | [diff] [blame] | 5879 | #endif /* FIXME */ |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 5880 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 5881 | } |
| 5882 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5883 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 5884 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5885 | { |
| 5886 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5887 | unsigned int idx, val; |
| 5888 | |
| 5889 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 5890 | if (spec->pwr_nids[idx] == nid) |
| 5891 | break; |
| 5892 | } |
| 5893 | if (idx >= spec->num_pwrs) |
| 5894 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5895 | |
Charles Chin | afef2cf | 2011-11-11 08:05:28 +0100 | [diff] [blame] | 5896 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5897 | |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 5898 | val = spec->power_map_bits; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5899 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5900 | val &= ~idx; |
| 5901 | else |
| 5902 | val |= idx; |
| 5903 | |
| 5904 | /* power down unused output ports */ |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 5905 | if (val != spec->power_map_bits) { |
| 5906 | spec->power_map_bits = val; |
| 5907 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5908 | AC_VERB_IDT_SET_POWER_MAP, val); |
| 5909 | } |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5910 | } |
| 5911 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5912 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 5913 | { |
Takashi Iwai | e6e3ea2 | 2008-12-05 12:54:56 +0100 | [diff] [blame] | 5914 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 5915 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5916 | |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 5917 | /* get the pin connection (fixed, none, etc) */ |
| 5918 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) |
| 5919 | { |
| 5920 | struct sigmatel_spec *spec = codec->spec; |
| 5921 | unsigned int cfg; |
| 5922 | |
| 5923 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); |
| 5924 | return get_defcfg_connect(cfg); |
| 5925 | } |
| 5926 | |
| 5927 | static int stac92xx_connected_ports(struct hda_codec *codec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 5928 | const hda_nid_t *nids, int num_nids) |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 5929 | { |
| 5930 | struct sigmatel_spec *spec = codec->spec; |
| 5931 | int idx, num; |
| 5932 | unsigned int def_conf; |
| 5933 | |
| 5934 | for (num = 0; num < num_nids; num++) { |
| 5935 | for (idx = 0; idx < spec->num_pins; idx++) |
| 5936 | if (spec->pin_nids[idx] == nids[num]) |
| 5937 | break; |
| 5938 | if (idx >= spec->num_pins) |
| 5939 | break; |
| 5940 | def_conf = stac_get_defcfg_connect(codec, idx); |
| 5941 | if (def_conf == AC_JACK_PORT_NONE) |
| 5942 | break; |
| 5943 | } |
| 5944 | return num; |
| 5945 | } |
| 5946 | |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5947 | static void stac92xx_mic_detect(struct hda_codec *codec) |
| 5948 | { |
| 5949 | struct sigmatel_spec *spec = codec->spec; |
| 5950 | struct sigmatel_mic_route *mic; |
| 5951 | |
| 5952 | if (get_pin_presence(codec, spec->ext_mic.pin)) |
| 5953 | mic = &spec->ext_mic; |
Charles Chin | 9907790 | 2010-09-17 10:22:32 +0200 | [diff] [blame] | 5954 | else if (get_pin_presence(codec, spec->dock_mic.pin)) |
| 5955 | mic = &spec->dock_mic; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5956 | else |
| 5957 | mic = &spec->int_mic; |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 5958 | if (mic->dmux_idx >= 0) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5959 | snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0, |
| 5960 | AC_VERB_SET_CONNECT_SEL, |
| 5961 | mic->dmux_idx); |
Takashi Iwai | 02d3332 | 2009-10-01 16:38:11 +0200 | [diff] [blame] | 5962 | if (mic->mux_idx >= 0) |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5963 | snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0, |
| 5964 | AC_VERB_SET_CONNECT_SEL, |
| 5965 | mic->mux_idx); |
| 5966 | } |
| 5967 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 5968 | static void handle_unsol_event(struct hda_codec *codec, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5969 | struct hda_jack_tbl *event) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5970 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5971 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 5972 | int data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5973 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5974 | switch (event->action) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 5975 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5976 | case STAC_LO_EVENT: |
Takashi Iwai | 16ffe32 | 2009-08-04 13:40:54 +0200 | [diff] [blame] | 5977 | stac92xx_hp_detect(codec); |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5978 | break; |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5979 | case STAC_MIC_EVENT: |
| 5980 | stac92xx_mic_detect(codec); |
| 5981 | break; |
| 5982 | } |
| 5983 | |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 5984 | switch (event->action) { |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5985 | case STAC_HP_EVENT: |
Takashi Iwai | fefd67f | 2009-07-30 18:03:05 +0200 | [diff] [blame] | 5986 | case STAC_LO_EVENT: |
Takashi Iwai | 3d21d3f | 2009-07-29 14:32:56 +0200 | [diff] [blame] | 5987 | case STAC_MIC_EVENT: |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 5988 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5989 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5990 | if (spec->num_pwrs > 0) |
| 5991 | stac92xx_pin_sense(codec, event->nid); |
Matthew Ranostay | fd60cc8 | 2009-04-06 09:30:46 -0400 | [diff] [blame] | 5992 | |
| 5993 | switch (codec->subsystem_id) { |
| 5994 | case 0x103c308f: |
| 5995 | if (event->nid == 0xb) { |
| 5996 | int pin = AC_PINCTL_IN_EN; |
| 5997 | |
| 5998 | if (get_pin_presence(codec, 0xa) |
| 5999 | && get_pin_presence(codec, 0xb)) |
| 6000 | pin |= AC_PINCTL_VREF_80; |
| 6001 | if (!get_pin_presence(codec, 0xb)) |
| 6002 | pin |= AC_PINCTL_VREF_80; |
| 6003 | |
| 6004 | /* toggle VREF state based on mic + hp pin |
| 6005 | * status |
| 6006 | */ |
| 6007 | stac92xx_auto_set_pinctl(codec, 0x0a, pin); |
| 6008 | } |
| 6009 | } |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 6010 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 6011 | case STAC_VREF_EVENT: |
| 6012 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 6013 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 6014 | /* toggle VREF state based on GPIOx status */ |
| 6015 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6016 | !!(data & (1 << event->private_data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 6017 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 6018 | } |
| 6019 | } |
| 6020 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 6021 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) |
| 6022 | { |
Takashi Iwai | 3a93897 | 2011-10-28 01:16:55 +0200 | [diff] [blame] | 6023 | struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 6024 | if (!event) |
| 6025 | return; |
| 6026 | handle_unsol_event(codec, event); |
| 6027 | } |
| 6028 | |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6029 | static void set_hp_led_gpio(struct hda_codec *codec) |
| 6030 | { |
| 6031 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 07f8044 | 2010-02-08 15:06:13 +0100 | [diff] [blame] | 6032 | unsigned int gpio; |
| 6033 | |
Takashi Iwai | 26ebe0a | 2010-05-11 08:36:29 +0200 | [diff] [blame] | 6034 | if (spec->gpio_led) |
| 6035 | return; |
| 6036 | |
Takashi Iwai | 07f8044 | 2010-02-08 15:06:13 +0100 | [diff] [blame] | 6037 | gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); |
| 6038 | gpio &= AC_GPIO_IO_COUNT; |
| 6039 | if (gpio > 3) |
| 6040 | spec->gpio_led = 0x08; /* GPIO 3 */ |
| 6041 | else |
| 6042 | spec->gpio_led = 0x01; /* GPIO 0 */ |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6043 | } |
| 6044 | |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6045 | /* |
| 6046 | * This method searches for the mute LED GPIO configuration |
| 6047 | * provided as OEM string in SMBIOS. The format of that string |
| 6048 | * is HP_Mute_LED_P_G or HP_Mute_LED_P |
| 6049 | * where P can be 0 or 1 and defines mute LED GPIO control state (low/high) |
| 6050 | * that corresponds to the NOT muted state of the master volume |
| 6051 | * and G is the index of the GPIO to use as the mute LED control (0..9) |
| 6052 | * If _G portion is missing it is assigned based on the codec ID |
| 6053 | * |
| 6054 | * So, HP B-series like systems may have HP_Mute_LED_0 (current models) |
| 6055 | * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6056 | * |
| 6057 | * |
| 6058 | * The dv-series laptops don't seem to have the HP_Mute_LED* strings in |
| 6059 | * SMBIOS - at least the ones I have seen do not have them - which include |
| 6060 | * my own system (HP Pavilion dv6-1110ax) and my cousin's |
| 6061 | * HP Pavilion dv9500t CTO. |
| 6062 | * Need more information on whether it is true across the entire series. |
| 6063 | * -- kunal |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6064 | */ |
Vitaliy Kulikov | 6a557c9 | 2011-12-12 17:35:13 -0600 | [diff] [blame] | 6065 | 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] | 6066 | { |
| 6067 | struct sigmatel_spec *spec = codec->spec; |
| 6068 | const struct dmi_device *dev = NULL; |
| 6069 | |
Takashi Iwai | 7560931 | 2012-05-14 16:52:00 +0200 | [diff] [blame] | 6070 | if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) { |
| 6071 | get_int_hint(codec, "gpio_led_polarity", |
| 6072 | &spec->gpio_led_polarity); |
| 6073 | return 1; |
| 6074 | } |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6075 | |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6076 | if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) { |
| 6077 | while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, |
| 6078 | NULL, dev))) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6079 | if (sscanf(dev->name, "HP_Mute_LED_%d_%x", |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6080 | &spec->gpio_led_polarity, |
| 6081 | &spec->gpio_led) == 2) { |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6082 | unsigned int max_gpio; |
| 6083 | max_gpio = snd_hda_param_read(codec, codec->afg, |
| 6084 | AC_PAR_GPIO_CAP); |
| 6085 | max_gpio &= AC_GPIO_IO_COUNT; |
| 6086 | if (spec->gpio_led < max_gpio) |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6087 | spec->gpio_led = 1 << spec->gpio_led; |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6088 | else |
| 6089 | spec->vref_mute_led_nid = spec->gpio_led; |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6090 | return 1; |
| 6091 | } |
| 6092 | if (sscanf(dev->name, "HP_Mute_LED_%d", |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6093 | &spec->gpio_led_polarity) == 1) { |
| 6094 | set_hp_led_gpio(codec); |
| 6095 | return 1; |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6096 | } |
Gustavo Maciel Dias Vieira | e2ef36c | 2011-12-13 11:47:22 -0200 | [diff] [blame] | 6097 | /* BIOS bug: unfilled OEM string */ |
| 6098 | if (strstr(dev->name, "HP_Mute_LED_P_G")) { |
| 6099 | set_hp_led_gpio(codec); |
Gustavo Maciel Dias Vieira | a6a600d | 2012-01-24 13:27:56 -0200 | [diff] [blame] | 6100 | switch (codec->subsystem_id) { |
| 6101 | case 0x103c148a: |
| 6102 | spec->gpio_led_polarity = 0; |
| 6103 | break; |
| 6104 | default: |
| 6105 | spec->gpio_led_polarity = 1; |
| 6106 | break; |
| 6107 | } |
Gustavo Maciel Dias Vieira | e2ef36c | 2011-12-13 11:47:22 -0200 | [diff] [blame] | 6108 | return 1; |
| 6109 | } |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6110 | } |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6111 | |
| 6112 | /* |
| 6113 | * Fallback case - if we don't find the DMI strings, |
Vitaliy Kulikov | 6a557c9 | 2011-12-12 17:35:13 -0600 | [diff] [blame] | 6114 | * we statically set the GPIO - if not a B-series system |
| 6115 | * and default polarity is provided |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6116 | */ |
Vitaliy Kulikov | 6a557c9 | 2011-12-12 17:35:13 -0600 | [diff] [blame] | 6117 | if (!hp_blike_system(codec->subsystem_id) && |
| 6118 | (default_polarity == 0 || default_polarity == 1)) { |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6119 | set_hp_led_gpio(codec); |
Takashi Iwai | dce17d4 | 2010-02-09 09:25:26 +0100 | [diff] [blame] | 6120 | spec->gpio_led_polarity = default_polarity; |
Kunal Gangakhedkar | d38cce7 | 2010-01-15 21:01:47 +0530 | [diff] [blame] | 6121 | return 1; |
| 6122 | } |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6123 | } |
| 6124 | return 0; |
| 6125 | } |
| 6126 | |
| 6127 | static int hp_blike_system(u32 subsystem_id) |
Randy Dunlap | 78987bd | 2009-11-05 09:22:30 -0800 | [diff] [blame] | 6128 | { |
| 6129 | switch (subsystem_id) { |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6130 | case 0x103c1520: |
| 6131 | case 0x103c1521: |
| 6132 | case 0x103c1523: |
| 6133 | case 0x103c1524: |
| 6134 | case 0x103c1525: |
Randy Dunlap | 78987bd | 2009-11-05 09:22:30 -0800 | [diff] [blame] | 6135 | case 0x103c1722: |
| 6136 | case 0x103c1723: |
| 6137 | case 0x103c1724: |
| 6138 | case 0x103c1725: |
| 6139 | case 0x103c1726: |
| 6140 | case 0x103c1727: |
| 6141 | case 0x103c1728: |
| 6142 | case 0x103c1729: |
Vitaliy Kulikov | c357aab | 2009-12-11 07:51:54 +0100 | [diff] [blame] | 6143 | case 0x103c172a: |
| 6144 | case 0x103c172b: |
| 6145 | case 0x103c307e: |
| 6146 | case 0x103c307f: |
| 6147 | case 0x103c3080: |
| 6148 | case 0x103c3081: |
| 6149 | case 0x103c7007: |
| 6150 | case 0x103c7008: |
Randy Dunlap | 78987bd | 2009-11-05 09:22:30 -0800 | [diff] [blame] | 6151 | return 1; |
| 6152 | } |
| 6153 | return 0; |
| 6154 | } |
| 6155 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6156 | #ifdef CONFIG_PROC_FS |
| 6157 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, |
| 6158 | struct hda_codec *codec, hda_nid_t nid) |
| 6159 | { |
| 6160 | if (nid == codec->afg) |
| 6161 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", |
Takashi Iwai | c882246 | 2012-05-15 09:11:36 +0200 | [diff] [blame] | 6162 | snd_hda_codec_read(codec, nid, 0, |
| 6163 | AC_VERB_IDT_GET_POWER_MAP, 0)); |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6164 | } |
| 6165 | |
| 6166 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, |
| 6167 | struct hda_codec *codec, |
| 6168 | unsigned int verb) |
| 6169 | { |
| 6170 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", |
| 6171 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); |
| 6172 | } |
| 6173 | |
| 6174 | /* stac92hd71bxx, stac92hd73xx */ |
| 6175 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, |
| 6176 | struct hda_codec *codec, hda_nid_t nid) |
| 6177 | { |
| 6178 | stac92hd_proc_hook(buffer, codec, nid); |
| 6179 | if (nid == codec->afg) |
| 6180 | analog_loop_proc_hook(buffer, codec, 0xfa0); |
| 6181 | } |
| 6182 | |
| 6183 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, |
| 6184 | struct hda_codec *codec, hda_nid_t nid) |
| 6185 | { |
| 6186 | if (nid == codec->afg) |
| 6187 | analog_loop_proc_hook(buffer, codec, 0xfe0); |
| 6188 | } |
| 6189 | |
| 6190 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, |
| 6191 | struct hda_codec *codec, hda_nid_t nid) |
| 6192 | { |
| 6193 | if (nid == codec->afg) |
| 6194 | analog_loop_proc_hook(buffer, codec, 0xfeb); |
| 6195 | } |
| 6196 | #else |
| 6197 | #define stac92hd_proc_hook NULL |
| 6198 | #define stac92hd7x_proc_hook NULL |
| 6199 | #define stac9205_proc_hook NULL |
| 6200 | #define stac927x_proc_hook NULL |
| 6201 | #endif |
| 6202 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6203 | #ifdef CONFIG_PM |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 6204 | static int stac92xx_resume(struct hda_codec *codec) |
| 6205 | { |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 6206 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 6207 | snd_hda_codec_resume_amp(codec); |
| 6208 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 6209 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | f2cbba7 | 2012-01-11 12:34:11 +0100 | [diff] [blame] | 6210 | stac_fake_hp_events(codec); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 6211 | return 0; |
| 6212 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 6213 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 6214 | static int stac92xx_suspend(struct hda_codec *codec) |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6215 | { |
| 6216 | stac92xx_shutup(codec); |
| 6217 | return 0; |
| 6218 | } |
| 6219 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6220 | static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg, |
| 6221 | unsigned int power_state) |
| 6222 | { |
| 6223 | unsigned int afg_power_state = power_state; |
| 6224 | struct sigmatel_spec *spec = codec->spec; |
| 6225 | |
| 6226 | if (power_state == AC_PWRST_D3) { |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6227 | if (spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6228 | /* with vref-out pin used for mute led control |
| 6229 | * codec AFG is prevented from D3 state |
| 6230 | */ |
| 6231 | afg_power_state = AC_PWRST_D1; |
| 6232 | } |
| 6233 | /* this delay seems necessary to avoid click noise at power-down */ |
| 6234 | msleep(100); |
| 6235 | } |
| 6236 | snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, |
| 6237 | afg_power_state); |
| 6238 | snd_hda_codec_set_power_to_all(codec, fg, power_state, true); |
| 6239 | } |
Takashi Iwai | 350eba43 | 2012-03-16 16:09:03 +0100 | [diff] [blame] | 6240 | #else |
| 6241 | #define stac92xx_suspend NULL |
| 6242 | #define stac92xx_resume NULL |
Takashi Iwai | 350eba43 | 2012-03-16 16:09:03 +0100 | [diff] [blame] | 6243 | #define stac92xx_set_power_state NULL |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6244 | #endif /* CONFIG_PM */ |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6245 | |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6246 | /* update mute-LED accoring to the master switch */ |
| 6247 | static void stac92xx_update_led_status(struct hda_codec *codec, int enabled) |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 6248 | { |
| 6249 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6250 | int muted = !enabled; |
Takashi Iwai | 6fce61a | 2009-03-10 07:48:57 +0100 | [diff] [blame] | 6251 | |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6252 | if (!spec->gpio_led) |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6253 | return; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6254 | |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6255 | /* LED state is inverted on these systems */ |
| 6256 | if (spec->gpio_led_polarity) |
| 6257 | muted = !muted; |
| 6258 | |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6259 | if (!spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6260 | if (muted) |
Takashi Iwai | 3e84319 | 2012-04-19 12:04:03 +0200 | [diff] [blame] | 6261 | spec->gpio_data |= spec->gpio_led; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6262 | else |
Takashi Iwai | 3e84319 | 2012-04-19 12:04:03 +0200 | [diff] [blame] | 6263 | spec->gpio_data &= ~spec->gpio_led; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6264 | stac_gpio_set(codec, spec->gpio_mask, |
| 6265 | spec->gpio_dir, spec->gpio_data); |
| 6266 | } else { |
Takashi Iwai | 2faa3bf | 2012-03-12 12:30:22 +0100 | [diff] [blame] | 6267 | spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD; |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6268 | stac_vrefout_set(codec, spec->vref_mute_led_nid, |
| 6269 | spec->vref_led); |
Christoph Plattner | ae6241f | 2009-03-08 23:19:05 +0100 | [diff] [blame] | 6270 | } |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6271 | } |
Vitaliy Kulikov | 7df1ce1 | 2011-07-25 17:52:57 -0500 | [diff] [blame] | 6272 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6273 | static const struct hda_codec_ops stac92xx_patch_ops = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6274 | .build_controls = stac92xx_build_controls, |
| 6275 | .build_pcms = stac92xx_build_pcms, |
| 6276 | .init = stac92xx_init, |
| 6277 | .free = stac92xx_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 6278 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6279 | #ifdef CONFIG_PM |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 6280 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 6281 | .resume = stac92xx_resume, |
| 6282 | #endif |
Takashi Iwai | fb8d1a3 | 2009-11-10 16:02:29 +0100 | [diff] [blame] | 6283 | .reboot_notify = stac92xx_shutup, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6284 | }; |
| 6285 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6286 | static int alloc_stac_spec(struct hda_codec *codec, int num_pins, |
| 6287 | const hda_nid_t *pin_nids) |
| 6288 | { |
| 6289 | struct sigmatel_spec *spec; |
| 6290 | |
| 6291 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6292 | if (!spec) |
| 6293 | return -ENOMEM; |
| 6294 | codec->spec = spec; |
| 6295 | codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */ |
| 6296 | spec->num_pins = num_pins; |
| 6297 | spec->pin_nids = pin_nids; |
| 6298 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 6299 | return 0; |
| 6300 | } |
| 6301 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6302 | static int patch_stac9200(struct hda_codec *codec) |
| 6303 | { |
| 6304 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6305 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6306 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6307 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids), |
| 6308 | stac9200_pin_nids); |
| 6309 | if (err < 0) |
| 6310 | return err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6311 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6312 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6313 | spec->linear_tone_beep = 1; |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6314 | |
| 6315 | snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl, |
| 6316 | stac9200_fixups); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6317 | |
| 6318 | spec->multiout.max_channels = 2; |
| 6319 | spec->multiout.num_dacs = 1; |
| 6320 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 6321 | spec->adc_nids = stac9200_adc_nids; |
| 6322 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 6323 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 6324 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 6325 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6326 | spec->num_pwrs = 0; |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6327 | snd_hda_add_verbs(codec, stac9200_eapd_init); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6328 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6329 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6330 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6331 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 6332 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6333 | err = stac9200_parse_auto_config(codec); |
| 6334 | if (err < 0) { |
| 6335 | stac92xx_free(codec); |
| 6336 | return err; |
| 6337 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6338 | |
| 6339 | codec->patch_ops = stac92xx_patch_ops; |
| 6340 | |
Takashi Iwai | d39a3ae | 2013-01-14 14:06:26 +0100 | [diff] [blame] | 6341 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6342 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6343 | return 0; |
| 6344 | } |
| 6345 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6346 | static int patch_stac925x(struct hda_codec *codec) |
| 6347 | { |
| 6348 | struct sigmatel_spec *spec; |
| 6349 | int err; |
| 6350 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6351 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids), |
| 6352 | stac925x_pin_nids); |
| 6353 | if (err < 0) |
| 6354 | return err; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6355 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6356 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6357 | spec->linear_tone_beep = 1; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame] | 6358 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6359 | snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl, |
| 6360 | stac925x_fixups); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6361 | |
| 6362 | spec->multiout.max_channels = 2; |
| 6363 | spec->multiout.num_dacs = 1; |
| 6364 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 6365 | spec->adc_nids = stac925x_adc_nids; |
| 6366 | spec->mux_nids = stac925x_mux_nids; |
| 6367 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 6368 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6369 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 6370 | switch (codec->vendor_id) { |
| 6371 | case 0x83847632: /* STAC9202 */ |
| 6372 | case 0x83847633: /* STAC9202D */ |
| 6373 | case 0x83847636: /* STAC9251 */ |
| 6374 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 6375 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 6376 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 6377 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 6378 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 6379 | break; |
| 6380 | default: |
| 6381 | spec->num_dmics = 0; |
| 6382 | break; |
| 6383 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6384 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6385 | snd_hda_add_verbs(codec, stac925x_core_init); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6386 | spec->mixer = stac925x_mixer; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6387 | spec->num_caps = 1; |
| 6388 | spec->capvols = stac925x_capvols; |
| 6389 | spec->capsws = stac925x_capsws; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6390 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6391 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 6392 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6393 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6394 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 6395 | err = -EINVAL; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6396 | if (err < 0) { |
| 6397 | stac92xx_free(codec); |
| 6398 | return err; |
| 6399 | } |
| 6400 | |
| 6401 | codec->patch_ops = stac92xx_patch_ops; |
| 6402 | |
Takashi Iwai | d2077d4 | 2013-01-14 14:20:16 +0100 | [diff] [blame] | 6403 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6404 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 6405 | return 0; |
| 6406 | } |
| 6407 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6408 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 6409 | { |
| 6410 | struct sigmatel_spec *spec; |
| 6411 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6412 | int err; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6413 | int num_dacs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6414 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6415 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids), |
| 6416 | stac92hd73xx_pin_nids); |
| 6417 | if (err < 0) |
| 6418 | return err; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6419 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6420 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6421 | spec->linear_tone_beep = 0; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 6422 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6423 | |
| 6424 | snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl, |
| 6425 | stac92hd73xx_fixups); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6426 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6427 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6428 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 6429 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6430 | if (num_dacs < 3 || num_dacs > 5) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6431 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 6432 | "number of channels defaulting to DAC count\n"); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6433 | num_dacs = STAC92HD73_DAC_COUNT; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6434 | } |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6435 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6436 | switch (num_dacs) { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6437 | case 0x3: /* 6 Channel */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6438 | spec->aloopback_ctl = stac92hd73xx_6ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6439 | break; |
| 6440 | case 0x4: /* 8 Channel */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6441 | spec->aloopback_ctl = stac92hd73xx_8ch_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6442 | break; |
| 6443 | case 0x5: /* 10 Channel */ |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6444 | spec->aloopback_ctl = stac92hd73xx_10ch_loopback; |
| 6445 | break; |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6446 | } |
| 6447 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6448 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6449 | spec->aloopback_mask = 0x01; |
| 6450 | spec->aloopback_shift = 8; |
| 6451 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 6452 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6453 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 6454 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 6455 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 6456 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 6457 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6458 | |
| 6459 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 6460 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 6461 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 6462 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6463 | spec->num_caps = STAC92HD73XX_NUM_CAPS; |
| 6464 | spec->capvols = stac92hd73xx_capvols; |
| 6465 | spec->capsws = stac92hd73xx_capsws; |
| 6466 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6467 | /* GPIO0 High = Enable EAPD */ |
| 6468 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 6469 | spec->gpio_data = 0x01; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 6470 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6471 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
| 6472 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
| 6473 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 6474 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6475 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 6476 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 6477 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6478 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 6479 | |
| 6480 | if (!spec->volknob_init) |
| 6481 | snd_hda_add_verbs(codec, stac92hd73xx_core_init); |
| 6482 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6483 | err = stac92xx_parse_auto_config(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6484 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6485 | if (!err) |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6486 | err = -EINVAL; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6487 | if (err < 0) { |
| 6488 | stac92xx_free(codec); |
| 6489 | return err; |
| 6490 | } |
| 6491 | |
| 6492 | codec->patch_ops = stac92xx_patch_ops; |
| 6493 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6494 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 6495 | |
Takashi Iwai | 55e3014 | 2013-01-14 17:30:04 +0100 | [diff] [blame^] | 6496 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6497 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 6498 | return 0; |
| 6499 | } |
| 6500 | |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6501 | static int hp_bnb2011_with_dock(struct hda_codec *codec) |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6502 | { |
| 6503 | if (codec->vendor_id != 0x111d7605 && |
| 6504 | codec->vendor_id != 0x111d76d1) |
| 6505 | return 0; |
| 6506 | |
| 6507 | switch (codec->subsystem_id) { |
| 6508 | case 0x103c1618: |
| 6509 | case 0x103c1619: |
| 6510 | case 0x103c161a: |
| 6511 | case 0x103c161b: |
| 6512 | case 0x103c161c: |
| 6513 | case 0x103c161d: |
| 6514 | case 0x103c161e: |
| 6515 | case 0x103c161f: |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6516 | |
| 6517 | case 0x103c162a: |
| 6518 | case 0x103c162b: |
| 6519 | |
| 6520 | case 0x103c1630: |
| 6521 | case 0x103c1631: |
| 6522 | |
| 6523 | case 0x103c1633: |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6524 | case 0x103c1634: |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6525 | case 0x103c1635: |
| 6526 | |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6527 | case 0x103c3587: |
| 6528 | case 0x103c3588: |
| 6529 | case 0x103c3589: |
| 6530 | case 0x103c358a: |
| 6531 | |
| 6532 | case 0x103c3667: |
| 6533 | case 0x103c3668: |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6534 | case 0x103c3669: |
| 6535 | |
| 6536 | return 1; |
Vitaliy Kulikov | 335e3b8 | 2010-10-22 18:38:31 -0500 | [diff] [blame] | 6537 | } |
| 6538 | return 0; |
| 6539 | } |
| 6540 | |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 6541 | static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid) |
| 6542 | { |
| 6543 | struct sigmatel_spec *spec = codec->spec; |
| 6544 | unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| 6545 | int i; |
| 6546 | |
| 6547 | spec->auto_pin_nids[spec->auto_pin_cnt] = nid; |
| 6548 | spec->auto_pin_cnt++; |
| 6549 | |
| 6550 | if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN && |
| 6551 | get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) { |
| 6552 | for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) { |
| 6553 | if (nid == stac92hd83xxx_dmic_nids[i]) { |
| 6554 | spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid; |
| 6555 | spec->auto_dmic_cnt++; |
| 6556 | } |
| 6557 | } |
| 6558 | } |
| 6559 | } |
| 6560 | |
| 6561 | static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid) |
| 6562 | { |
| 6563 | struct sigmatel_spec *spec = codec->spec; |
| 6564 | |
| 6565 | spec->auto_adc_nids[spec->auto_adc_cnt] = nid; |
| 6566 | spec->auto_adc_cnt++; |
| 6567 | } |
| 6568 | |
| 6569 | static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid) |
| 6570 | { |
| 6571 | int i, j; |
| 6572 | struct sigmatel_spec *spec = codec->spec; |
| 6573 | |
| 6574 | for (i = 0; i < spec->auto_adc_cnt; i++) { |
| 6575 | if (get_connection_index(codec, |
| 6576 | spec->auto_adc_nids[i], nid) >= 0) { |
| 6577 | /* mux and volume for adc_nids[i] */ |
| 6578 | if (!spec->auto_mux_nids[i]) { |
| 6579 | spec->auto_mux_nids[i] = nid; |
| 6580 | /* 92hd codecs capture volume is in mux */ |
| 6581 | spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid, |
| 6582 | 3, 0, HDA_OUTPUT); |
| 6583 | } |
| 6584 | for (j = 0; j < spec->auto_dmic_cnt; j++) { |
| 6585 | if (get_connection_index(codec, nid, |
| 6586 | spec->auto_dmic_nids[j]) >= 0) { |
| 6587 | /* dmux for adc_nids[i] */ |
| 6588 | if (!spec->auto_dmux_nids[i]) |
| 6589 | spec->auto_dmux_nids[i] = nid; |
| 6590 | break; |
| 6591 | } |
| 6592 | } |
| 6593 | break; |
| 6594 | } |
| 6595 | } |
| 6596 | } |
| 6597 | |
| 6598 | static void stac92hd8x_fill_auto_spec(struct hda_codec *codec) |
| 6599 | { |
| 6600 | hda_nid_t nid, end_nid; |
| 6601 | unsigned int wid_caps, wid_type; |
| 6602 | struct sigmatel_spec *spec = codec->spec; |
| 6603 | |
| 6604 | end_nid = codec->start_nid + codec->num_nodes; |
| 6605 | |
| 6606 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 6607 | wid_caps = get_wcaps(codec, nid); |
| 6608 | wid_type = get_wcaps_type(wid_caps); |
| 6609 | |
| 6610 | if (wid_type == AC_WID_PIN) |
| 6611 | stac92hd8x_add_pin(codec, nid); |
| 6612 | |
| 6613 | if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL)) |
| 6614 | stac92hd8x_add_adc(codec, nid); |
| 6615 | } |
| 6616 | |
| 6617 | for (nid = codec->start_nid; nid < end_nid; nid++) { |
| 6618 | wid_caps = get_wcaps(codec, nid); |
| 6619 | wid_type = get_wcaps_type(wid_caps); |
| 6620 | |
| 6621 | if (wid_type == AC_WID_AUD_SEL) |
| 6622 | stac92hd8x_add_mux(codec, nid); |
| 6623 | } |
| 6624 | |
| 6625 | spec->pin_nids = spec->auto_pin_nids; |
| 6626 | spec->num_pins = spec->auto_pin_cnt; |
| 6627 | spec->adc_nids = spec->auto_adc_nids; |
| 6628 | spec->num_adcs = spec->auto_adc_cnt; |
| 6629 | spec->capvols = spec->auto_capvols; |
| 6630 | spec->capsws = spec->auto_capvols; |
| 6631 | spec->num_caps = spec->auto_adc_cnt; |
| 6632 | spec->mux_nids = spec->auto_mux_nids; |
| 6633 | spec->num_muxes = spec->auto_adc_cnt; |
| 6634 | spec->dmux_nids = spec->auto_dmux_nids; |
| 6635 | spec->num_dmuxes = spec->auto_adc_cnt; |
| 6636 | spec->dmic_nids = spec->auto_dmic_nids; |
| 6637 | spec->num_dmics = spec->auto_dmic_cnt; |
| 6638 | } |
| 6639 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6640 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 6641 | { |
| 6642 | struct sigmatel_spec *spec; |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 6643 | int default_polarity = -1; /* no default cfg */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6644 | int err; |
| 6645 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6646 | err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */ |
| 6647 | if (err < 0) |
| 6648 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6649 | |
Vitaliy Kulikov | cbbf50b | 2011-01-14 17:21:13 -0600 | [diff] [blame] | 6650 | if (hp_bnb2011_with_dock(codec)) { |
| 6651 | snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f); |
| 6652 | snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e); |
| 6653 | } |
| 6654 | |
Takashi Iwai | c36b5b0 | 2012-08-28 09:20:13 -0700 | [diff] [blame] | 6655 | codec->epss = 0; /* longer delay needed for D3 */ |
Vitaliy Kulikov | 699d899 | 2011-03-10 13:43:35 -0600 | [diff] [blame] | 6656 | stac92hd8x_fill_auto_spec(codec); |
| 6657 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6658 | spec = codec->spec; |
Takashi Iwai | 1db7ccdb | 2010-12-03 15:19:14 +0100 | [diff] [blame] | 6659 | spec->linear_tone_beep = 0; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 6660 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6661 | spec->digbeep_nid = 0x21; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6662 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6663 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6664 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6665 | spec->init = stac92hd83xxx_core_init; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6666 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6667 | spec->board_config = snd_hda_check_board_config(codec, |
| 6668 | STAC_92HD83XXX_MODELS, |
| 6669 | stac92hd83xxx_models, |
| 6670 | stac92hd83xxx_cfg_tbl); |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 6671 | /* check codec subsystem id if not found */ |
| 6672 | if (spec->board_config < 0) |
| 6673 | spec->board_config = |
| 6674 | snd_hda_check_board_codec_sid_config(codec, |
| 6675 | STAC_92HD83XXX_MODELS, stac92hd83xxx_models, |
| 6676 | stac92hd83xxx_codec_id_cfg_tbl); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6677 | again: |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6678 | if (spec->board_config < 0) |
Takashi Iwai | 9a11f1a | 2009-07-28 16:01:20 +0200 | [diff] [blame] | 6679 | snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", |
| 6680 | codec->chip_name); |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6681 | else |
| 6682 | stac92xx_set_config_regs(codec, |
Takashi Iwai | af9f341a | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 6683 | stac92hd83xxx_brd_tbl[spec->board_config]); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6684 | |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6685 | codec->patch_ops = stac92xx_patch_ops; |
| 6686 | |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 6687 | switch (spec->board_config) { |
| 6688 | case STAC_HP_ZEPHYR: |
| 6689 | spec->init = stac92hd83xxx_hp_zephyr_init; |
| 6690 | break; |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 6691 | case STAC_92HD83XXX_HP_LED: |
Takashi Iwai | ff8a1e2 | 2012-07-31 10:16:59 +0200 | [diff] [blame] | 6692 | default_polarity = 0; |
| 6693 | break; |
| 6694 | case STAC_92HD83XXX_HP_INV_LED: |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 6695 | default_polarity = 1; |
| 6696 | break; |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 6697 | case STAC_92HD83XXX_HP_MIC_LED: |
| 6698 | spec->mic_mute_led_gpio = 0x08; /* GPIO3 */ |
| 6699 | break; |
David Henningsson | 8d032a8 | 2012-10-09 12:48:40 +0200 | [diff] [blame] | 6700 | case STAC_92HD83XXX_HEADSET_JACK: |
| 6701 | spec->headset_jack = 1; |
| 6702 | break; |
Vitaliy Kulikov | 5556e14 | 2012-02-27 16:47:37 -0600 | [diff] [blame] | 6703 | } |
| 6704 | |
Takashi Iwai | a3e1997 | 2012-07-26 08:17:20 +0200 | [diff] [blame] | 6705 | if (find_mute_led_cfg(codec, default_polarity)) |
Vitaliy Kulikov | e108c7b | 2010-01-28 19:21:07 +0100 | [diff] [blame] | 6706 | snd_printd("mute LED gpio %d polarity %d\n", |
| 6707 | spec->gpio_led, |
| 6708 | spec->gpio_led_polarity); |
| 6709 | |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6710 | if (spec->gpio_led) { |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6711 | if (!spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6712 | spec->gpio_mask |= spec->gpio_led; |
| 6713 | spec->gpio_dir |= spec->gpio_led; |
| 6714 | spec->gpio_data |= spec->gpio_led; |
| 6715 | } else { |
| 6716 | codec->patch_ops.set_power_state = |
| 6717 | stac92xx_set_power_state; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6718 | } |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6719 | } |
Takashi Iwai | b4e8187 | 2009-11-18 17:20:24 +0100 | [diff] [blame] | 6720 | |
Takashi Iwai | 62cbde1 | 2012-09-14 11:58:54 +0200 | [diff] [blame] | 6721 | if (spec->mic_mute_led_gpio) { |
| 6722 | spec->gpio_mask |= spec->mic_mute_led_gpio; |
| 6723 | spec->gpio_dir |= spec->mic_mute_led_gpio; |
| 6724 | spec->mic_mute_led_on = true; |
| 6725 | spec->gpio_data |= spec->mic_mute_led_gpio; |
| 6726 | } |
| 6727 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6728 | err = stac92xx_parse_auto_config(codec); |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6729 | if (!err) { |
| 6730 | if (spec->board_config < 0) { |
| 6731 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 6732 | "available, default to model=ref\n"); |
| 6733 | spec->board_config = STAC_92HD83XXX_REF; |
| 6734 | goto again; |
| 6735 | } |
| 6736 | err = -EINVAL; |
| 6737 | } |
| 6738 | |
| 6739 | if (err < 0) { |
| 6740 | stac92xx_free(codec); |
| 6741 | return err; |
| 6742 | } |
| 6743 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6744 | codec->proc_widget_hook = stac92hd_proc_hook; |
| 6745 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 6746 | return 0; |
| 6747 | } |
| 6748 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6749 | static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, |
| 6750 | hda_nid_t dig0pin) |
| 6751 | { |
| 6752 | struct sigmatel_spec *spec = codec->spec; |
| 6753 | int idx; |
| 6754 | |
| 6755 | for (idx = 0; idx < spec->num_pins; idx++) |
| 6756 | if (spec->pin_nids[idx] == dig0pin) |
| 6757 | break; |
| 6758 | if ((idx + 2) >= spec->num_pins) |
| 6759 | return 0; |
| 6760 | |
| 6761 | /* dig1pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6762 | 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] | 6763 | return 2; |
| 6764 | |
| 6765 | /* dig0pin + dig2pin case */ |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6766 | 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] | 6767 | return 2; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6768 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6769 | return 1; |
| 6770 | else |
| 6771 | return 0; |
| 6772 | } |
| 6773 | |
Takashi Iwai | 75d1aeb | 2009-12-22 11:56:32 +0100 | [diff] [blame] | 6774 | /* HP dv7 bass switch - GPIO5 */ |
| 6775 | #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info |
| 6776 | static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol, |
| 6777 | struct snd_ctl_elem_value *ucontrol) |
| 6778 | { |
| 6779 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 6780 | struct sigmatel_spec *spec = codec->spec; |
| 6781 | ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20); |
| 6782 | return 0; |
| 6783 | } |
| 6784 | |
| 6785 | static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol, |
| 6786 | struct snd_ctl_elem_value *ucontrol) |
| 6787 | { |
| 6788 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 6789 | struct sigmatel_spec *spec = codec->spec; |
| 6790 | unsigned int gpio_data; |
| 6791 | |
| 6792 | gpio_data = (spec->gpio_data & ~0x20) | |
| 6793 | (ucontrol->value.integer.value[0] ? 0x20 : 0); |
| 6794 | if (gpio_data == spec->gpio_data) |
| 6795 | return 0; |
| 6796 | spec->gpio_data = gpio_data; |
| 6797 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); |
| 6798 | return 1; |
| 6799 | } |
| 6800 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6801 | static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = { |
Takashi Iwai | 75d1aeb | 2009-12-22 11:56:32 +0100 | [diff] [blame] | 6802 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 6803 | .info = stac_hp_bass_gpio_info, |
| 6804 | .get = stac_hp_bass_gpio_get, |
| 6805 | .put = stac_hp_bass_gpio_put, |
| 6806 | }; |
| 6807 | |
| 6808 | static int stac_add_hp_bass_switch(struct hda_codec *codec) |
| 6809 | { |
| 6810 | struct sigmatel_spec *spec = codec->spec; |
| 6811 | |
| 6812 | if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl, |
| 6813 | "Bass Speaker Playback Switch", 0)) |
| 6814 | return -ENOMEM; |
| 6815 | |
| 6816 | spec->gpio_mask |= 0x20; |
| 6817 | spec->gpio_dir |= 0x20; |
| 6818 | spec->gpio_data |= 0x20; |
| 6819 | return 0; |
| 6820 | } |
| 6821 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6822 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 6823 | { |
| 6824 | struct sigmatel_spec *spec; |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6825 | const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6826 | int err; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6827 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6828 | err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS, |
| 6829 | stac92hd71bxx_pin_nids_4port); |
| 6830 | if (err < 0) |
| 6831 | return err; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6832 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6833 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6834 | spec->linear_tone_beep = 0; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6835 | codec->patch_ops = stac92xx_patch_ops; |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 6836 | switch (codec->vendor_id) { |
| 6837 | case 0x111d76b6: |
| 6838 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 616f89e | 2009-02-04 11:23:19 -0500 | [diff] [blame] | 6839 | break; |
| 6840 | case 0x111d7603: |
| 6841 | case 0x111d7608: |
| 6842 | /* On 92HD75Bx 0x27 isn't a pin nid */ |
| 6843 | spec->num_pins--; |
| 6844 | /* fallthrough */ |
| 6845 | default: |
| 6846 | spec->pin_nids = stac92hd71bxx_pin_nids_6port; |
| 6847 | } |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6848 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6849 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6850 | snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl, |
| 6851 | stac92hd71bxx_fixups); |
| 6852 | |
| 6853 | /* GPIO0 = EAPD */ |
| 6854 | spec->gpio_mask = 0x01; |
| 6855 | spec->gpio_dir = 0x01; |
| 6856 | spec->gpio_data = 0x01; |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 6857 | |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6858 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
| 6859 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
| 6860 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6861 | spec->num_caps = STAC92HD71BXX_NUM_CAPS; |
| 6862 | spec->capvols = stac92hd71bxx_capvols; |
| 6863 | spec->capsws = stac92hd71bxx_capsws; |
| 6864 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6865 | switch (codec->vendor_id) { |
| 6866 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 6867 | case 0x111d76b7: |
Herton Ronaldo Krzesinski | 23c7b52 | 2009-02-08 19:51:28 -0200 | [diff] [blame] | 6868 | unmute_init++; |
| 6869 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6870 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 6871 | case 0x111d76b5: |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 6872 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6873 | spec->num_dmics = stac92xx_connected_ports(codec, |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6874 | stac92hd71bxx_dmic_nids, |
| 6875 | STAC92HD71BXX_NUM_DMICS); |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6876 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6877 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6878 | if ((codec->revision_id & 0xf) == 0 || |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 6879 | (codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6880 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6881 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6882 | /* disable VSW */ |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 6883 | unmute_init++; |
Takashi Iwai | 330ee99 | 2009-02-20 14:33:36 +0100 | [diff] [blame] | 6884 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
| 6885 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6886 | spec->dmic_nids = stac92hd71bxx_dmic_5port_nids; |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6887 | spec->num_dmics = stac92xx_connected_ports(codec, |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 6888 | stac92hd71bxx_dmic_5port_nids, |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6889 | STAC92HD71BXX_NUM_DMICS - 1); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6890 | break; |
| 6891 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Takashi Iwai | 8c2f767 | 2008-12-01 11:54:35 +0100 | [diff] [blame] | 6892 | if ((codec->revision_id & 0xf) == 1) |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6893 | spec->stream_delay = 40; /* 40 milliseconds */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6894 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6895 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6896 | default: |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 6897 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 6898 | spec->num_dmics = stac92xx_connected_ports(codec, |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6899 | stac92hd71bxx_dmic_nids, |
| 6900 | STAC92HD71BXX_NUM_DMICS); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 6901 | break; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6902 | } |
| 6903 | |
David Henningsson | 5e68fb3 | 2012-08-16 14:11:09 +0200 | [diff] [blame] | 6904 | if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB) |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6905 | snd_hda_add_verbs(codec, stac92hd71bxx_core_init); |
David Henningsson | 5e68fb3 | 2012-08-16 14:11:09 +0200 | [diff] [blame] | 6906 | |
Matthew Ranostay | ca8d33f | 2009-01-26 09:33:52 -0500 | [diff] [blame] | 6907 | if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) |
| 6908 | snd_hda_sequence_write_cache(codec, unmute_init); |
| 6909 | |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 6910 | spec->aloopback_ctl = stac92hd71bxx_loopback; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 6911 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 6912 | spec->aloopback_shift = 0; |
| 6913 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 6914 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 6915 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6916 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 6917 | spec->adc_nids = stac92hd71bxx_adc_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 6918 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 6919 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6920 | |
| 6921 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 6922 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Takashi Iwai | 5207e10 | 2009-07-30 13:09:08 +0200 | [diff] [blame] | 6923 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
Herton Ronaldo Krzesinski | 6df703a | 2009-02-04 11:34:22 -0500 | [diff] [blame] | 6924 | spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6925 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6926 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Vitaliy Kulikov | 5bdaaad | 2009-11-04 07:57:45 +0100 | [diff] [blame] | 6927 | |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 6928 | if (spec->gpio_led) { |
Takashi Iwai | f1a7374 | 2011-12-04 13:44:06 +0100 | [diff] [blame] | 6929 | if (!spec->vref_mute_led_nid) { |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6930 | spec->gpio_mask |= spec->gpio_led; |
| 6931 | spec->gpio_dir |= spec->gpio_led; |
| 6932 | spec->gpio_data |= spec->gpio_led; |
| 6933 | } else { |
| 6934 | codec->patch_ops.set_power_state = |
| 6935 | stac92xx_set_power_state; |
Vitaliy Kulikov | 45eebda | 2011-07-26 16:56:20 -0500 | [diff] [blame] | 6936 | } |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 6937 | } |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 6938 | |
Takashi Iwai | c21ca4a | 2008-12-19 09:26:08 +0100 | [diff] [blame] | 6939 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6940 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6941 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6942 | if (!err) |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6943 | err = -EINVAL; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6944 | if (err < 0) { |
| 6945 | stac92xx_free(codec); |
| 6946 | return err; |
| 6947 | } |
| 6948 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 6949 | codec->proc_widget_hook = stac92hd7x_proc_hook; |
| 6950 | |
Takashi Iwai | 0f6fcb7 | 2013-01-14 17:05:25 +0100 | [diff] [blame] | 6951 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 6952 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6953 | return 0; |
Takashi Iwai | 86d190e | 2009-05-26 15:18:58 +0200 | [diff] [blame] | 6954 | } |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 6955 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6956 | static int patch_stac922x(struct hda_codec *codec) |
| 6957 | { |
| 6958 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6959 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6960 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6961 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids), |
| 6962 | stac922x_pin_nids); |
| 6963 | if (err < 0) |
| 6964 | return err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6965 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 6966 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 6967 | spec->linear_tone_beep = 1; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 6968 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 6969 | snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl, |
| 6970 | stac922x_fixups); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6971 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 6972 | spec->adc_nids = stac922x_adc_nids; |
| 6973 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 6974 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 6975 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 6976 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 6977 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6978 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 6979 | spec->num_caps = STAC922X_NUM_CAPS; |
| 6980 | spec->capvols = stac922x_capvols; |
| 6981 | spec->capsws = stac922x_capsws; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 6982 | |
| 6983 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 6984 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 6985 | snd_hda_add_verbs(codec, stac922x_core_init); |
| 6986 | |
| 6987 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 6988 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 6989 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 6990 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 6991 | err = -EINVAL; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 6992 | if (err < 0) { |
| 6993 | stac92xx_free(codec); |
| 6994 | return err; |
| 6995 | } |
| 6996 | |
| 6997 | codec->patch_ops = stac92xx_patch_ops; |
| 6998 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 6999 | /* Fix Mux capture level; max to 2 */ |
| 7000 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 7001 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 7002 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 7003 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 7004 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 7005 | |
Takashi Iwai | 0a42784 | 2013-01-14 15:20:13 +0100 | [diff] [blame] | 7006 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7007 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7008 | return 0; |
| 7009 | } |
| 7010 | |
| 7011 | static int patch_stac927x(struct hda_codec *codec) |
| 7012 | { |
| 7013 | struct sigmatel_spec *spec; |
| 7014 | int err; |
| 7015 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7016 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids), |
| 7017 | stac927x_pin_nids); |
| 7018 | if (err < 0) |
| 7019 | return err; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7020 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7021 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7022 | spec->linear_tone_beep = 1; |
Matthew Ranostay | 45c1d85 | 2009-02-04 17:49:41 -0500 | [diff] [blame] | 7023 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7024 | |
| 7025 | snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl, |
| 7026 | stac927x_fixups); |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7027 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 7028 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 7029 | spec->adc_nids = stac927x_adc_nids; |
| 7030 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 7031 | spec->mux_nids = stac927x_mux_nids; |
| 7032 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 7033 | spec->smux_nids = stac927x_smux_nids; |
| 7034 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 7035 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 7036 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 7037 | spec->multiout.dac_nids = spec->dac_nids; |
| 7038 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7039 | /* GPIO0 High = Enable EAPD */ |
| 7040 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 7041 | spec->gpio_dir = spec->gpio_data = 0x01; |
Takashi Iwai | af6ee30 | 2009-09-14 15:03:12 +0200 | [diff] [blame] | 7042 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7043 | spec->num_dmics = 0; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7044 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7045 | spec->num_caps = STAC927X_NUM_CAPS; |
| 7046 | spec->capvols = stac927x_capvols; |
| 7047 | spec->capsws = stac927x_capsws; |
| 7048 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 7049 | spec->num_pwrs = 0; |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 7050 | spec->aloopback_ctl = stac927x_loopback; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7051 | spec->aloopback_mask = 0x40; |
| 7052 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 7053 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 7054 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7055 | if (!spec->volknob_init) |
| 7056 | snd_hda_add_verbs(codec, stac927x_core_init); |
| 7057 | |
| 7058 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
| 7059 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7060 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7061 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 7062 | err = -EINVAL; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 7063 | if (err < 0) { |
| 7064 | stac92xx_free(codec); |
| 7065 | return err; |
| 7066 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7067 | |
| 7068 | codec->patch_ops = stac92xx_patch_ops; |
| 7069 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 7070 | codec->proc_widget_hook = stac927x_proc_hook; |
| 7071 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 7072 | /* |
| 7073 | * !!FIXME!! |
| 7074 | * The STAC927x seem to require fairly long delays for certain |
| 7075 | * command sequences. With too short delays (even if the answer |
| 7076 | * is set to RIRB properly), it results in the silence output |
| 7077 | * on some hardwares like Dell. |
| 7078 | * |
| 7079 | * The below flag enables the longer delay (see get_response |
| 7080 | * in hda_intel.c). |
| 7081 | */ |
| 7082 | codec->bus->needs_damn_long_delay = 1; |
| 7083 | |
Takashi Iwai | 29ac836 | 2013-01-14 16:03:38 +0100 | [diff] [blame] | 7084 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
Takashi Iwai | e28d832 | 2008-12-17 13:48:29 +0100 | [diff] [blame] | 7085 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7086 | return 0; |
| 7087 | } |
| 7088 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7089 | static int patch_stac9205(struct hda_codec *codec) |
| 7090 | { |
| 7091 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 7092 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7093 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7094 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids), |
| 7095 | stac9205_pin_nids); |
| 7096 | if (err < 0) |
| 7097 | return err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7098 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7099 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7100 | spec->linear_tone_beep = 1; |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7101 | |
| 7102 | snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl, |
| 7103 | stac9205_fixups); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7104 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 7105 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7106 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 7107 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7108 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 7109 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 7110 | spec->smux_nids = stac9205_smux_nids; |
| 7111 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 7112 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 7113 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7114 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 7115 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 7116 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7117 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7118 | snd_hda_add_verbs(codec, stac9205_core_init); |
Takashi Iwai | d78d7a9 | 2009-03-02 14:26:25 +0100 | [diff] [blame] | 7119 | spec->aloopback_ctl = stac9205_loopback; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7120 | |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7121 | spec->num_caps = STAC9205_NUM_CAPS; |
| 7122 | spec->capvols = stac9205_capvols; |
| 7123 | spec->capsws = stac9205_capsws; |
| 7124 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7125 | spec->aloopback_mask = 0x40; |
| 7126 | spec->aloopback_shift = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7127 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 7128 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7129 | /* GPIO0 High = EAPD */ |
| 7130 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 7131 | spec->gpio_data = 0x01; |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 7132 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7133 | /* Turn on/off EAPD per HP plugging */ |
| 7134 | spec->eapd_switch = 1; |
Matthew Ranostay | 4fe5195c | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 7135 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7136 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 7137 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7138 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7139 | if (!err) |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 7140 | err = -EINVAL; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7141 | if (err < 0) { |
| 7142 | stac92xx_free(codec); |
| 7143 | return err; |
| 7144 | } |
| 7145 | |
| 7146 | codec->patch_ops = stac92xx_patch_ops; |
| 7147 | |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 7148 | codec->proc_widget_hook = stac9205_proc_hook; |
| 7149 | |
Takashi Iwai | fe6322c | 2013-01-14 14:46:51 +0100 | [diff] [blame] | 7150 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7151 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7152 | return 0; |
| 7153 | } |
| 7154 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7155 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 7156 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7157 | */ |
| 7158 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7159 | static const struct hda_verb stac9872_core_init[] = { |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 7160 | {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] | 7161 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 7162 | {} |
| 7163 | }; |
| 7164 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7165 | static const hda_nid_t stac9872_pin_nids[] = { |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7166 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 7167 | 0x11, 0x13, 0x14, |
| 7168 | }; |
| 7169 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7170 | static const hda_nid_t stac9872_adc_nids[] = { |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7171 | 0x8 /*,0x6*/ |
| 7172 | }; |
| 7173 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7174 | static const hda_nid_t stac9872_mux_nids[] = { |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7175 | 0x15 |
| 7176 | }; |
| 7177 | |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7178 | static const unsigned long stac9872_capvols[] = { |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7179 | HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT), |
| 7180 | }; |
| 7181 | #define stac9872_capsws stac9872_capvols |
| 7182 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7183 | static const struct hda_pintbl stac9872_vaio_pin_configs[] = { |
| 7184 | { 0x0a, 0x03211020 }, |
| 7185 | { 0x0b, 0x411111f0 }, |
| 7186 | { 0x0c, 0x411111f0 }, |
| 7187 | { 0x0d, 0x03a15030 }, |
| 7188 | { 0x0e, 0x411111f0 }, |
| 7189 | { 0x0f, 0x90170110 }, |
| 7190 | { 0x11, 0x411111f0 }, |
| 7191 | { 0x13, 0x411111f0 }, |
| 7192 | { 0x14, 0x90a7013e }, |
| 7193 | {} |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7194 | }; |
| 7195 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7196 | static const struct hda_model_fixup stac9872_models[] = { |
| 7197 | { .id = STAC_9872_VAIO, .name = "vaio" }, |
| 7198 | {} |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7199 | }; |
| 7200 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7201 | static const struct hda_fixup stac9872_fixups[] = { |
| 7202 | [STAC_9872_VAIO] = { |
| 7203 | .type = HDA_FIXUP_PINS, |
| 7204 | .v.pins = stac9872_vaio_pin_configs, |
| 7205 | }, |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7206 | }; |
| 7207 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7208 | static const struct snd_pci_quirk stac9872_fixup_tbl[] = { |
Takashi Iwai | b04add9 | 2009-07-20 08:01:36 +0200 | [diff] [blame] | 7209 | SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0, |
| 7210 | "Sony VAIO F/S", STAC_9872_VAIO), |
Takashi Iwai | 307282c | 2009-03-12 18:17:58 +0100 | [diff] [blame] | 7211 | {} /* terminator */ |
| 7212 | }; |
| 7213 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 7214 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7215 | { |
| 7216 | struct sigmatel_spec *spec; |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7217 | int err; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7218 | |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 7219 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids), |
| 7220 | stac9872_pin_nids); |
| 7221 | if (err < 0) |
| 7222 | return err; |
| 7223 | |
| 7224 | spec = codec->spec; |
Daniel J Blueman | 1b0e372 | 2010-08-03 11:09:13 +0100 | [diff] [blame] | 7225 | spec->linear_tone_beep = 1; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7226 | |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7227 | snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl, |
| 7228 | stac9872_fixups); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7229 | |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7230 | spec->multiout.dac_nids = spec->dac_nids; |
| 7231 | spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); |
| 7232 | spec->adc_nids = stac9872_adc_nids; |
| 7233 | spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); |
| 7234 | spec->mux_nids = stac9872_mux_nids; |
Takashi Iwai | 6479c63 | 2009-07-28 18:20:25 +0200 | [diff] [blame] | 7235 | spec->num_caps = 1; |
| 7236 | spec->capvols = stac9872_capvols; |
| 7237 | spec->capsws = stac9872_capsws; |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7238 | snd_hda_add_verbs(codec, stac9872_core_init); |
| 7239 | |
| 7240 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7241 | |
Charles Chin | 9009b0e | 2011-11-03 10:27:27 +0100 | [diff] [blame] | 7242 | err = stac92xx_parse_auto_config(codec); |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7243 | if (err < 0) { |
| 7244 | stac92xx_free(codec); |
| 7245 | return -EINVAL; |
Takashi Iwai | caa10b6 | 2009-01-20 17:19:01 +0100 | [diff] [blame] | 7246 | } |
Takashi Iwai | 1e137f9 | 2009-01-21 07:41:22 +0100 | [diff] [blame] | 7247 | spec->input_mux = &spec->private_imux; |
| 7248 | codec->patch_ops = stac92xx_patch_ops; |
Takashi Iwai | fc268c1 | 2013-01-14 14:29:36 +0100 | [diff] [blame] | 7249 | |
| 7250 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 7251 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 7252 | return 0; |
| 7253 | } |
| 7254 | |
| 7255 | |
| 7256 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7257 | * patch entries |
| 7258 | */ |
Takashi Iwai | 2b63536 | 2011-05-02 12:33:43 +0200 | [diff] [blame] | 7259 | static const struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7260 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 7261 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 7262 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 7263 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 7264 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 7265 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 7266 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 7267 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 7268 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 7269 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 7270 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 7271 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 7272 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 7273 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 7274 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 7275 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 7276 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 7277 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 7278 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 7279 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 7280 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 7281 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 7282 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 7283 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 7284 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 7285 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 7286 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 7287 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 7288 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 7289 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 7290 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 7291 | /* The following does not take into account .id=0x83847661 when subsys = |
| 7292 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 7293 | * currently not fully supported. |
| 7294 | */ |
| 7295 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 7296 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 7297 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Simos Xenitellis | a5c0f88 | 2009-06-10 16:33:31 +0100 | [diff] [blame] | 7298 | { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 7299 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 7300 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 7301 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 7302 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 7303 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 7304 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 7305 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 7306 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 7307 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 7308 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | a9694fa | 2010-02-04 08:58:23 +0100 | [diff] [blame] | 7309 | { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 7310 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | ff2e733 | 2009-04-01 14:49:48 -0400 | [diff] [blame] | 7311 | { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, |
Charles Chin | 8a345a0 | 2010-08-10 11:43:25 +0200 | [diff] [blame] | 7312 | { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx}, |
| 7313 | { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx}, |
Charles Chin | 3670600 | 2010-01-29 12:05:51 +0100 | [diff] [blame] | 7314 | { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx}, |
| 7315 | { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx}, |
| 7316 | { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx}, |
| 7317 | { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 7318 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 7319 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 7320 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 7321 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 7322 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 7323 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 7324 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 7325 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 7326 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 7327 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 7328 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 7329 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Charles Chin | 4d8ec5f | 2010-08-19 08:06:16 +0200 | [diff] [blame] | 7330 | { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx }, |
| 7331 | { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx }, |
| 7332 | { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx }, |
| 7333 | { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx }, |
| 7334 | { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx }, |
| 7335 | { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx }, |
| 7336 | { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx }, |
| 7337 | { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx }, |
| 7338 | { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx }, |
| 7339 | { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx }, |
| 7340 | { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx }, |
| 7341 | { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx }, |
| 7342 | { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx }, |
| 7343 | { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx }, |
| 7344 | { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx }, |
David Henningsson | 46724c2 | 2011-09-20 09:02:22 +0200 | [diff] [blame] | 7345 | { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 7346 | { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | 4dfb8a4 | 2011-02-22 17:32:19 -0600 | [diff] [blame] | 7347 | { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx}, |
| 7348 | { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx}, |
Vitaliy Kulikov | ab5a6eb | 2010-09-08 09:00:17 +0200 | [diff] [blame] | 7349 | { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx}, |
Charles Chin | ad5d875 | 2011-11-02 07:56:58 +0100 | [diff] [blame] | 7350 | { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx}, |
| 7351 | { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx}, |
| 7352 | { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx}, |
| 7353 | { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx}, |
| 7354 | { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx}, |
| 7355 | { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx}, |
| 7356 | { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx}, |
| 7357 | { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx}, |
| 7358 | { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx}, |
| 7359 | { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx}, |
| 7360 | { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx}, |
| 7361 | { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 7362 | {} /* terminator */ |
| 7363 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7364 | |
| 7365 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 7366 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 7367 | |
| 7368 | MODULE_LICENSE("GPL"); |
| 7369 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 7370 | |
| 7371 | static struct hda_codec_preset_list sigmatel_list = { |
| 7372 | .preset = snd_hda_preset_sigmatel, |
| 7373 | .owner = THIS_MODULE, |
| 7374 | }; |
| 7375 | |
| 7376 | static int __init patch_sigmatel_init(void) |
| 7377 | { |
| 7378 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 7379 | } |
| 7380 | |
| 7381 | static void __exit patch_sigmatel_exit(void) |
| 7382 | { |
| 7383 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 7384 | } |
| 7385 | |
| 7386 | module_init(patch_sigmatel_init) |
| 7387 | module_exit(patch_sigmatel_exit) |