Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | * HD audio interface patch for Cirrus Logic CS420x chip |
| 3 | * |
| 4 | * Copyright (c) 2009 Takashi Iwai <tiwai@suse.de> |
| 5 | * |
| 6 | * This driver is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This driver is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/delay.h> |
| 23 | #include <linux/slab.h> |
| 24 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 25 | #include <linux/module.h> |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 26 | #include <sound/core.h> |
| 27 | #include "hda_codec.h" |
| 28 | #include "hda_local.h" |
Takashi Iwai | 128bc4b | 2012-05-07 17:42:31 +0200 | [diff] [blame] | 29 | #include "hda_auto_parser.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 30 | #include "hda_jack.h" |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 31 | #include <sound/tlv.h> |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 32 | |
| 33 | /* |
| 34 | */ |
| 35 | |
| 36 | struct cs_spec { |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 37 | struct hda_gen_spec gen; |
| 38 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 39 | struct auto_pin_cfg autocfg; |
| 40 | struct hda_multi_out multiout; |
| 41 | struct snd_kcontrol *vmaster_sw; |
| 42 | struct snd_kcontrol *vmaster_vol; |
| 43 | |
| 44 | hda_nid_t dac_nid[AUTO_CFG_MAX_OUTS]; |
| 45 | hda_nid_t slave_dig_outs[2]; |
| 46 | |
| 47 | unsigned int input_idx[AUTO_PIN_LAST]; |
| 48 | unsigned int capsrc_idx[AUTO_PIN_LAST]; |
| 49 | hda_nid_t adc_nid[AUTO_PIN_LAST]; |
| 50 | unsigned int adc_idx[AUTO_PIN_LAST]; |
| 51 | unsigned int num_inputs; |
| 52 | unsigned int cur_input; |
| 53 | unsigned int automic_idx; |
| 54 | hda_nid_t cur_adc; |
| 55 | unsigned int cur_adc_stream_tag; |
| 56 | unsigned int cur_adc_format; |
| 57 | hda_nid_t dig_in; |
| 58 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 59 | const struct hda_bind_ctls *capture_bind[2]; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 60 | |
Takashi Iwai | ed20825 | 2009-07-07 09:04:26 +0200 | [diff] [blame] | 61 | unsigned int gpio_mask; |
| 62 | unsigned int gpio_dir; |
| 63 | unsigned int gpio_data; |
Takashi Iwai | 6dfeb703 | 2011-11-22 20:00:31 +0100 | [diff] [blame] | 64 | unsigned int gpio_eapd_hp; /* EAPD GPIO bit for headphones */ |
| 65 | unsigned int gpio_eapd_speaker; /* EAPD GPIO bit for speakers */ |
Takashi Iwai | ed20825 | 2009-07-07 09:04:26 +0200 | [diff] [blame] | 66 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 67 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 68 | |
| 69 | unsigned int hp_detect:1; |
| 70 | unsigned int mic_detect:1; |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 71 | unsigned int speaker_2_1:1; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 72 | /* CS421x */ |
| 73 | unsigned int spdif_detect:1; |
| 74 | unsigned int sense_b:1; |
| 75 | hda_nid_t vendor_nid; |
| 76 | struct hda_input_mux input_mux; |
| 77 | unsigned int last_input; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 78 | }; |
| 79 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 80 | /* available models with CS420x */ |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 81 | enum { |
Vince Weaver | 4e7d7c6 | 2010-09-22 17:31:37 -0400 | [diff] [blame] | 82 | CS420X_MBP53, |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 83 | CS420X_MBP55, |
Rafael Avila de Espindola | 1a5ba2e | 2009-12-22 07:59:37 +0100 | [diff] [blame] | 84 | CS420X_IMAC27, |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 85 | CS420X_GPIO_13, |
| 86 | CS420X_GPIO_23, |
Takashi Iwai | ef596a5 | 2012-09-11 16:53:08 +0200 | [diff] [blame] | 87 | CS420X_MBP101, |
| 88 | CS420X_MBP101_COEF, |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 89 | CS420X_AUTO, |
Takashi Iwai | 03efce7 | 2012-09-13 09:56:57 +0200 | [diff] [blame] | 90 | /* aliases */ |
| 91 | CS420X_IMAC27_122 = CS420X_GPIO_23, |
| 92 | CS420X_APPLE = CS420X_GPIO_13, |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 93 | }; |
| 94 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 95 | /* CS421x boards */ |
| 96 | enum { |
| 97 | CS421X_CDB4210, |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 98 | CS421X_SENSE_B, |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 99 | }; |
| 100 | |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 101 | /* Vendor-specific processing widget */ |
| 102 | #define CS420X_VENDOR_NID 0x11 |
| 103 | #define CS_DIG_OUT1_PIN_NID 0x10 |
| 104 | #define CS_DIG_OUT2_PIN_NID 0x15 |
Daniel J Blueman | 16337e0 | 2012-11-04 13:19:03 +0800 | [diff] [blame] | 105 | #define CS_DMIC1_PIN_NID 0x0e |
| 106 | #define CS_DMIC2_PIN_NID 0x12 |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 107 | |
| 108 | /* coef indices */ |
| 109 | #define IDX_SPDIF_STAT 0x0000 |
| 110 | #define IDX_SPDIF_CTL 0x0001 |
| 111 | #define IDX_ADC_CFG 0x0002 |
| 112 | /* SZC bitmask, 4 modes below: |
| 113 | * 0 = immediate, |
| 114 | * 1 = digital immediate, analog zero-cross |
| 115 | * 2 = digtail & analog soft-ramp |
| 116 | * 3 = digital soft-ramp, analog zero-cross |
| 117 | */ |
| 118 | #define CS_COEF_ADC_SZC_MASK (3 << 0) |
| 119 | #define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */ |
| 120 | #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */ |
| 121 | /* PGA mode: 0 = differential, 1 = signle-ended */ |
| 122 | #define CS_COEF_ADC_MIC_PGA_MODE (1 << 5) /* PGA setup for mic */ |
| 123 | #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */ |
| 124 | #define IDX_DAC_CFG 0x0003 |
| 125 | /* SZC bitmask, 4 modes below: |
| 126 | * 0 = Immediate |
| 127 | * 1 = zero-cross |
| 128 | * 2 = soft-ramp |
| 129 | * 3 = soft-ramp on zero-cross |
| 130 | */ |
| 131 | #define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */ |
| 132 | #define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */ |
| 133 | #define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */ |
| 134 | |
| 135 | #define IDX_BEEP_CFG 0x0004 |
| 136 | /* 0x0008 - test reg key */ |
| 137 | /* 0x0009 - 0x0014 -> 12 test regs */ |
| 138 | /* 0x0015 - visibility reg */ |
| 139 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 140 | /* |
| 141 | * Cirrus Logic CS4210 |
| 142 | * |
| 143 | * 1 DAC => HP(sense) / Speakers, |
| 144 | * 1 ADC <= LineIn(sense) / MicIn / DMicIn, |
| 145 | * 1 SPDIF OUT => SPDIF Trasmitter(sense) |
| 146 | */ |
| 147 | #define CS4210_DAC_NID 0x02 |
| 148 | #define CS4210_ADC_NID 0x03 |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 149 | #define CS4210_VENDOR_NID 0x0B |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 150 | #define CS421X_DMIC_PIN_NID 0x09 /* Port E */ |
| 151 | #define CS421X_SPDIF_PIN_NID 0x0A /* Port H */ |
| 152 | |
| 153 | #define CS421X_IDX_DEV_CFG 0x01 |
| 154 | #define CS421X_IDX_ADC_CFG 0x02 |
| 155 | #define CS421X_IDX_DAC_CFG 0x03 |
| 156 | #define CS421X_IDX_SPK_CTL 0x04 |
| 157 | |
| 158 | #define SPDIF_EVENT 0x04 |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 159 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 160 | /* Cirrus Logic CS4213 is like CS4210 but does not have SPDIF input/output */ |
| 161 | #define CS4213_VENDOR_NID 0x09 |
| 162 | |
| 163 | |
Takashi Iwai | 277a57c | 2009-07-08 12:42:08 +0200 | [diff] [blame] | 164 | static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx) |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 165 | { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 166 | struct cs_spec *spec = codec->spec; |
| 167 | snd_hda_codec_write(codec, spec->vendor_nid, 0, |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 168 | AC_VERB_SET_COEF_INDEX, idx); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 169 | return snd_hda_codec_read(codec, spec->vendor_nid, 0, |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 170 | AC_VERB_GET_PROC_COEF, 0); |
| 171 | } |
| 172 | |
Takashi Iwai | 277a57c | 2009-07-08 12:42:08 +0200 | [diff] [blame] | 173 | static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, |
| 174 | unsigned int coef) |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 175 | { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 176 | struct cs_spec *spec = codec->spec; |
| 177 | snd_hda_codec_write(codec, spec->vendor_nid, 0, |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 178 | AC_VERB_SET_COEF_INDEX, idx); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 179 | snd_hda_codec_write(codec, spec->vendor_nid, 0, |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 180 | AC_VERB_SET_PROC_COEF, coef); |
| 181 | } |
| 182 | |
| 183 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 184 | #define HP_EVENT 1 |
| 185 | #define MIC_EVENT 2 |
| 186 | |
| 187 | /* |
| 188 | * PCM callbacks |
| 189 | */ |
| 190 | static int cs_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 191 | struct hda_codec *codec, |
| 192 | struct snd_pcm_substream *substream) |
| 193 | { |
| 194 | struct cs_spec *spec = codec->spec; |
| 195 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 196 | hinfo); |
| 197 | } |
| 198 | |
| 199 | static int cs_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 200 | struct hda_codec *codec, |
| 201 | unsigned int stream_tag, |
| 202 | unsigned int format, |
| 203 | struct snd_pcm_substream *substream) |
| 204 | { |
| 205 | struct cs_spec *spec = codec->spec; |
| 206 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 207 | stream_tag, format, substream); |
| 208 | } |
| 209 | |
| 210 | static int cs_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 211 | struct hda_codec *codec, |
| 212 | struct snd_pcm_substream *substream) |
| 213 | { |
| 214 | struct cs_spec *spec = codec->spec; |
| 215 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * Digital out |
| 220 | */ |
| 221 | static int cs_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 222 | struct hda_codec *codec, |
| 223 | struct snd_pcm_substream *substream) |
| 224 | { |
| 225 | struct cs_spec *spec = codec->spec; |
| 226 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 227 | } |
| 228 | |
| 229 | static int cs_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 230 | struct hda_codec *codec, |
| 231 | struct snd_pcm_substream *substream) |
| 232 | { |
| 233 | struct cs_spec *spec = codec->spec; |
| 234 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 235 | } |
| 236 | |
| 237 | static int cs_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 238 | struct hda_codec *codec, |
| 239 | unsigned int stream_tag, |
| 240 | unsigned int format, |
| 241 | struct snd_pcm_substream *substream) |
| 242 | { |
| 243 | struct cs_spec *spec = codec->spec; |
| 244 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, |
| 245 | format, substream); |
| 246 | } |
| 247 | |
| 248 | static int cs_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 249 | struct hda_codec *codec, |
| 250 | struct snd_pcm_substream *substream) |
| 251 | { |
| 252 | struct cs_spec *spec = codec->spec; |
| 253 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 254 | } |
| 255 | |
Takashi Iwai | 05ee796 | 2011-11-16 18:05:11 +0100 | [diff] [blame] | 256 | static void cs_update_input_select(struct hda_codec *codec) |
| 257 | { |
| 258 | struct cs_spec *spec = codec->spec; |
| 259 | if (spec->cur_adc) |
| 260 | snd_hda_codec_write(codec, spec->cur_adc, 0, |
| 261 | AC_VERB_SET_CONNECT_SEL, |
| 262 | spec->adc_idx[spec->cur_input]); |
| 263 | } |
| 264 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 265 | /* |
| 266 | * Analog capture |
| 267 | */ |
| 268 | static int cs_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 269 | struct hda_codec *codec, |
| 270 | unsigned int stream_tag, |
| 271 | unsigned int format, |
| 272 | struct snd_pcm_substream *substream) |
| 273 | { |
| 274 | struct cs_spec *spec = codec->spec; |
| 275 | spec->cur_adc = spec->adc_nid[spec->cur_input]; |
| 276 | spec->cur_adc_stream_tag = stream_tag; |
| 277 | spec->cur_adc_format = format; |
Takashi Iwai | 05ee796 | 2011-11-16 18:05:11 +0100 | [diff] [blame] | 278 | cs_update_input_select(codec); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 279 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | static int cs_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 284 | struct hda_codec *codec, |
| 285 | struct snd_pcm_substream *substream) |
| 286 | { |
| 287 | struct cs_spec *spec = codec->spec; |
| 288 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 289 | spec->cur_adc = 0; |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | /* |
| 294 | */ |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 295 | static const struct hda_pcm_stream cs_pcm_analog_playback = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 296 | .substreams = 1, |
| 297 | .channels_min = 2, |
| 298 | .channels_max = 2, |
| 299 | .ops = { |
| 300 | .open = cs_playback_pcm_open, |
| 301 | .prepare = cs_playback_pcm_prepare, |
| 302 | .cleanup = cs_playback_pcm_cleanup |
| 303 | }, |
| 304 | }; |
| 305 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 306 | static const struct hda_pcm_stream cs_pcm_analog_capture = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 307 | .substreams = 1, |
| 308 | .channels_min = 2, |
| 309 | .channels_max = 2, |
| 310 | .ops = { |
| 311 | .prepare = cs_capture_pcm_prepare, |
| 312 | .cleanup = cs_capture_pcm_cleanup |
| 313 | }, |
| 314 | }; |
| 315 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 316 | static const struct hda_pcm_stream cs_pcm_digital_playback = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 317 | .substreams = 1, |
| 318 | .channels_min = 2, |
| 319 | .channels_max = 2, |
| 320 | .ops = { |
| 321 | .open = cs_dig_playback_pcm_open, |
| 322 | .close = cs_dig_playback_pcm_close, |
| 323 | .prepare = cs_dig_playback_pcm_prepare, |
| 324 | .cleanup = cs_dig_playback_pcm_cleanup |
| 325 | }, |
| 326 | }; |
| 327 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 328 | static const struct hda_pcm_stream cs_pcm_digital_capture = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 329 | .substreams = 1, |
| 330 | .channels_min = 2, |
| 331 | .channels_max = 2, |
| 332 | }; |
| 333 | |
| 334 | static int cs_build_pcms(struct hda_codec *codec) |
| 335 | { |
| 336 | struct cs_spec *spec = codec->spec; |
| 337 | struct hda_pcm *info = spec->pcm_rec; |
| 338 | |
| 339 | codec->pcm_info = info; |
| 340 | codec->num_pcms = 0; |
| 341 | |
| 342 | info->name = "Cirrus Analog"; |
| 343 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cs_pcm_analog_playback; |
| 344 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dac_nid[0]; |
| 345 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 346 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame^] | 347 | if (spec->speaker_2_1) |
| 348 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 349 | snd_pcm_2_1_chmaps; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 350 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = cs_pcm_analog_capture; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 351 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 352 | spec->adc_nid[spec->cur_input]; |
| 353 | codec->num_pcms++; |
| 354 | |
| 355 | if (!spec->multiout.dig_out_nid && !spec->dig_in) |
| 356 | return 0; |
| 357 | |
| 358 | info++; |
| 359 | info->name = "Cirrus Digital"; |
| 360 | info->pcm_type = spec->autocfg.dig_out_type[0]; |
| 361 | if (!info->pcm_type) |
| 362 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
| 363 | if (spec->multiout.dig_out_nid) { |
| 364 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 365 | cs_pcm_digital_playback; |
| 366 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 367 | spec->multiout.dig_out_nid; |
| 368 | } |
| 369 | if (spec->dig_in) { |
| 370 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 371 | cs_pcm_digital_capture; |
| 372 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in; |
| 373 | } |
| 374 | codec->num_pcms++; |
| 375 | |
| 376 | return 0; |
| 377 | } |
| 378 | |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 379 | /* |
| 380 | * parse codec topology |
| 381 | */ |
| 382 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 383 | static hda_nid_t get_dac(struct hda_codec *codec, hda_nid_t pin) |
| 384 | { |
| 385 | hda_nid_t dac; |
| 386 | if (!pin) |
| 387 | return 0; |
| 388 | if (snd_hda_get_connections(codec, pin, &dac, 1) != 1) |
| 389 | return 0; |
| 390 | return dac; |
| 391 | } |
| 392 | |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 393 | static int is_ext_mic(struct hda_codec *codec, unsigned int idx) |
| 394 | { |
| 395 | struct cs_spec *spec = codec->spec; |
| 396 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 397 | hda_nid_t pin = cfg->inputs[idx].pin; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 398 | unsigned int val; |
| 399 | if (!is_jack_detectable(codec, pin)) |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 400 | return 0; |
| 401 | val = snd_hda_codec_get_pincfg(codec, pin); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 402 | return (snd_hda_get_input_pin_attr(val) != INPUT_PIN_ATTR_INT); |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, |
| 406 | unsigned int *idxp) |
| 407 | { |
Takashi Iwai | 1b004d0 | 2011-08-20 09:19:59 +0200 | [diff] [blame] | 408 | int i, idx; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 409 | hda_nid_t nid; |
| 410 | |
| 411 | nid = codec->start_nid; |
| 412 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 413 | unsigned int type; |
Takashi Iwai | 1682c81 | 2011-05-17 10:02:27 +0200 | [diff] [blame] | 414 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 415 | if (type != AC_WID_AUD_IN) |
| 416 | continue; |
Takashi Iwai | 1b004d0 | 2011-08-20 09:19:59 +0200 | [diff] [blame] | 417 | idx = snd_hda_get_conn_index(codec, nid, pin, false); |
| 418 | if (idx >= 0) { |
| 419 | *idxp = idx; |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 420 | return nid; |
Takashi Iwai | 1b004d0 | 2011-08-20 09:19:59 +0200 | [diff] [blame] | 421 | } |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 422 | } |
| 423 | return 0; |
| 424 | } |
| 425 | |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 426 | static int is_active_pin(struct hda_codec *codec, hda_nid_t nid) |
| 427 | { |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 428 | unsigned int val; |
| 429 | val = snd_hda_codec_get_pincfg(codec, nid); |
| 430 | return (get_defcfg_connect(val) != AC_JACK_PORT_NONE); |
| 431 | } |
| 432 | |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 433 | static int parse_output(struct hda_codec *codec) |
| 434 | { |
| 435 | struct cs_spec *spec = codec->spec; |
| 436 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 277a57c | 2009-07-08 12:42:08 +0200 | [diff] [blame] | 437 | int i, extra_nids; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 438 | hda_nid_t dac; |
| 439 | |
| 440 | for (i = 0; i < cfg->line_outs; i++) { |
| 441 | dac = get_dac(codec, cfg->line_out_pins[i]); |
| 442 | if (!dac) |
| 443 | break; |
| 444 | spec->dac_nid[i] = dac; |
| 445 | } |
| 446 | spec->multiout.num_dacs = i; |
| 447 | spec->multiout.dac_nids = spec->dac_nid; |
| 448 | spec->multiout.max_channels = i * 2; |
| 449 | |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 450 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && i == 2) |
| 451 | spec->speaker_2_1 = 1; /* assume 2.1 speakers */ |
| 452 | |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 453 | /* add HP and speakers */ |
| 454 | extra_nids = 0; |
| 455 | for (i = 0; i < cfg->hp_outs; i++) { |
| 456 | dac = get_dac(codec, cfg->hp_pins[i]); |
| 457 | if (!dac) |
| 458 | break; |
| 459 | if (!i) |
| 460 | spec->multiout.hp_nid = dac; |
| 461 | else |
| 462 | spec->multiout.extra_out_nid[extra_nids++] = dac; |
| 463 | } |
| 464 | for (i = 0; i < cfg->speaker_outs; i++) { |
| 465 | dac = get_dac(codec, cfg->speaker_pins[i]); |
| 466 | if (!dac) |
| 467 | break; |
| 468 | spec->multiout.extra_out_nid[extra_nids++] = dac; |
| 469 | } |
| 470 | |
| 471 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 472 | cfg->speaker_outs = cfg->line_outs; |
| 473 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 474 | sizeof(cfg->speaker_pins)); |
| 475 | cfg->line_outs = 0; |
| 476 | } |
| 477 | |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | static int parse_input(struct hda_codec *codec) |
| 482 | { |
| 483 | struct cs_spec *spec = codec->spec; |
| 484 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 277a57c | 2009-07-08 12:42:08 +0200 | [diff] [blame] | 485 | int i; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 486 | |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 487 | for (i = 0; i < cfg->num_inputs; i++) { |
| 488 | hda_nid_t pin = cfg->inputs[i].pin; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 489 | spec->input_idx[spec->num_inputs] = i; |
| 490 | spec->capsrc_idx[i] = spec->num_inputs++; |
| 491 | spec->cur_input = i; |
| 492 | spec->adc_nid[i] = get_adc(codec, pin, &spec->adc_idx[i]); |
| 493 | } |
| 494 | if (!spec->num_inputs) |
| 495 | return 0; |
| 496 | |
| 497 | /* check whether the automatic mic switch is available */ |
| 498 | if (spec->num_inputs == 2 && |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 499 | cfg->inputs[0].type == AUTO_PIN_MIC && |
| 500 | cfg->inputs[1].type == AUTO_PIN_MIC) { |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 501 | if (is_ext_mic(codec, cfg->inputs[0].pin)) { |
| 502 | if (!is_ext_mic(codec, cfg->inputs[1].pin)) { |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 503 | spec->mic_detect = 1; |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 504 | spec->automic_idx = 0; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 505 | } |
| 506 | } else { |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 507 | if (is_ext_mic(codec, cfg->inputs[1].pin)) { |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 508 | spec->mic_detect = 1; |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 509 | spec->automic_idx = 1; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 510 | } |
| 511 | } |
| 512 | } |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | |
| 517 | static int parse_digital_output(struct hda_codec *codec) |
| 518 | { |
| 519 | struct cs_spec *spec = codec->spec; |
| 520 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 521 | hda_nid_t nid; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 522 | |
| 523 | if (!cfg->dig_outs) |
| 524 | return 0; |
| 525 | if (snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) < 1) |
| 526 | return 0; |
| 527 | spec->multiout.dig_out_nid = nid; |
| 528 | spec->multiout.share_spdif = 1; |
| 529 | if (cfg->dig_outs > 1 && |
| 530 | snd_hda_get_connections(codec, cfg->dig_out_pins[1], &nid, 1) > 0) { |
| 531 | spec->slave_dig_outs[0] = nid; |
| 532 | codec->slave_dig_outs = spec->slave_dig_outs; |
| 533 | } |
| 534 | return 0; |
| 535 | } |
| 536 | |
| 537 | static int parse_digital_input(struct hda_codec *codec) |
| 538 | { |
| 539 | struct cs_spec *spec = codec->spec; |
| 540 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 541 | int idx; |
| 542 | |
Takashi Iwai | 60e5388 | 2009-07-06 15:01:09 +0200 | [diff] [blame] | 543 | if (cfg->dig_in_pin) |
| 544 | spec->dig_in = get_adc(codec, cfg->dig_in_pin, &idx); |
| 545 | return 0; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | /* |
| 549 | * create mixer controls |
| 550 | */ |
| 551 | |
Takashi Iwai | ea73496 | 2011-01-17 11:29:34 +0100 | [diff] [blame] | 552 | static const char * const dir_sfx[2] = { "Playback", "Capture" }; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 553 | |
| 554 | static int add_mute(struct hda_codec *codec, const char *name, int index, |
| 555 | unsigned int pval, int dir, struct snd_kcontrol **kctlp) |
| 556 | { |
Takashi Iwai | b4dabfc | 2009-07-07 09:05:07 +0200 | [diff] [blame] | 557 | char tmp[44]; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 558 | struct snd_kcontrol_new knew = |
| 559 | HDA_CODEC_MUTE_IDX(tmp, index, 0, 0, HDA_OUTPUT); |
| 560 | knew.private_value = pval; |
| 561 | snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]); |
| 562 | *kctlp = snd_ctl_new1(&knew, codec); |
Jaroslav Kysela | 9e3fd87 | 2009-12-08 17:45:25 +0100 | [diff] [blame] | 563 | (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 564 | return snd_hda_ctl_add(codec, 0, *kctlp); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | static int add_volume(struct hda_codec *codec, const char *name, |
| 568 | int index, unsigned int pval, int dir, |
| 569 | struct snd_kcontrol **kctlp) |
| 570 | { |
David Henningsson | 2e1210b | 2011-09-14 13:22:54 +0200 | [diff] [blame] | 571 | char tmp[44]; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 572 | struct snd_kcontrol_new knew = |
| 573 | HDA_CODEC_VOLUME_IDX(tmp, index, 0, 0, HDA_OUTPUT); |
| 574 | knew.private_value = pval; |
| 575 | snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]); |
| 576 | *kctlp = snd_ctl_new1(&knew, codec); |
Jaroslav Kysela | 9e3fd87 | 2009-12-08 17:45:25 +0100 | [diff] [blame] | 577 | (*kctlp)->id.subdevice = HDA_SUBDEV_AMP_FLAG; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 578 | return snd_hda_ctl_add(codec, 0, *kctlp); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) |
| 582 | { |
| 583 | unsigned int caps; |
| 584 | |
| 585 | /* set the upper-limit for mixer amp to 0dB */ |
| 586 | caps = query_amp_caps(codec, dac, HDA_OUTPUT); |
| 587 | caps &= ~(0x7f << AC_AMPCAP_NUM_STEPS_SHIFT); |
| 588 | caps |= ((caps >> AC_AMPCAP_OFFSET_SHIFT) & 0x7f) |
| 589 | << AC_AMPCAP_NUM_STEPS_SHIFT; |
| 590 | snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps); |
| 591 | } |
| 592 | |
| 593 | static int add_vmaster(struct hda_codec *codec, hda_nid_t dac) |
| 594 | { |
| 595 | struct cs_spec *spec = codec->spec; |
| 596 | unsigned int tlv[4]; |
| 597 | int err; |
| 598 | |
| 599 | spec->vmaster_sw = |
| 600 | snd_ctl_make_virtual_master("Master Playback Switch", NULL); |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 601 | err = snd_hda_ctl_add(codec, dac, spec->vmaster_sw); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 602 | if (err < 0) |
| 603 | return err; |
| 604 | |
| 605 | snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv); |
| 606 | spec->vmaster_vol = |
| 607 | snd_ctl_make_virtual_master("Master Playback Volume", tlv); |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 608 | err = snd_hda_ctl_add(codec, dac, spec->vmaster_vol); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 609 | if (err < 0) |
| 610 | return err; |
| 611 | return 0; |
| 612 | } |
| 613 | |
| 614 | static int add_output(struct hda_codec *codec, hda_nid_t dac, int idx, |
| 615 | int num_ctls, int type) |
| 616 | { |
| 617 | struct cs_spec *spec = codec->spec; |
| 618 | const char *name; |
| 619 | int err, index; |
| 620 | struct snd_kcontrol *kctl; |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 621 | static const char * const speakers[] = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 622 | "Front Speaker", "Surround Speaker", "Bass Speaker" |
| 623 | }; |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 624 | static const char * const line_outs[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 625 | "Front Line Out", "Surround Line Out", "Bass Line Out" |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 626 | }; |
| 627 | |
| 628 | fix_volume_caps(codec, dac); |
| 629 | if (!spec->vmaster_sw) { |
| 630 | err = add_vmaster(codec, dac); |
| 631 | if (err < 0) |
| 632 | return err; |
| 633 | } |
| 634 | |
| 635 | index = 0; |
| 636 | switch (type) { |
| 637 | case AUTO_PIN_HP_OUT: |
| 638 | name = "Headphone"; |
| 639 | index = idx; |
| 640 | break; |
| 641 | case AUTO_PIN_SPEAKER_OUT: |
Takashi Iwai | f37bc7a | 2012-11-08 15:59:23 +0100 | [diff] [blame] | 642 | if (spec->speaker_2_1) |
| 643 | name = idx ? "Bass Speaker" : "Speaker"; |
| 644 | else if (num_ctls > 1) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 645 | name = speakers[idx]; |
| 646 | else |
| 647 | name = "Speaker"; |
| 648 | break; |
| 649 | default: |
| 650 | if (num_ctls > 1) |
| 651 | name = line_outs[idx]; |
| 652 | else |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 653 | name = "Line Out"; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 654 | break; |
| 655 | } |
| 656 | |
| 657 | err = add_mute(codec, name, index, |
| 658 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); |
| 659 | if (err < 0) |
| 660 | return err; |
| 661 | err = snd_ctl_add_slave(spec->vmaster_sw, kctl); |
| 662 | if (err < 0) |
| 663 | return err; |
| 664 | |
| 665 | err = add_volume(codec, name, index, |
| 666 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); |
| 667 | if (err < 0) |
| 668 | return err; |
| 669 | err = snd_ctl_add_slave(spec->vmaster_vol, kctl); |
| 670 | if (err < 0) |
| 671 | return err; |
| 672 | |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 676 | static int build_output(struct hda_codec *codec) |
| 677 | { |
| 678 | struct cs_spec *spec = codec->spec; |
| 679 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 680 | int i, err; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 681 | |
| 682 | for (i = 0; i < cfg->line_outs; i++) { |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 683 | err = add_output(codec, get_dac(codec, cfg->line_out_pins[i]), |
| 684 | i, cfg->line_outs, cfg->line_out_type); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 685 | if (err < 0) |
| 686 | return err; |
| 687 | } |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 688 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 689 | err = add_output(codec, get_dac(codec, cfg->hp_pins[i]), |
| 690 | i, cfg->hp_outs, AUTO_PIN_HP_OUT); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 691 | if (err < 0) |
| 692 | return err; |
| 693 | } |
| 694 | for (i = 0; i < cfg->speaker_outs; i++) { |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 695 | err = add_output(codec, get_dac(codec, cfg->speaker_pins[i]), |
| 696 | i, cfg->speaker_outs, AUTO_PIN_SPEAKER_OUT); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 697 | if (err < 0) |
| 698 | return err; |
| 699 | } |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | /* |
| 704 | */ |
| 705 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 706 | static const struct snd_kcontrol_new cs_capture_ctls[] = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 707 | HDA_BIND_SW("Capture Switch", 0), |
| 708 | HDA_BIND_VOL("Capture Volume", 0), |
| 709 | }; |
| 710 | |
Takashi Iwai | ea35929 | 2009-07-06 12:58:59 +0200 | [diff] [blame] | 711 | static int change_cur_input(struct hda_codec *codec, unsigned int idx, |
| 712 | int force) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 713 | { |
| 714 | struct cs_spec *spec = codec->spec; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 715 | |
Takashi Iwai | ea35929 | 2009-07-06 12:58:59 +0200 | [diff] [blame] | 716 | if (spec->cur_input == idx && !force) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 717 | return 0; |
| 718 | if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { |
| 719 | /* stream is running, let's swap the current ADC */ |
Takashi Iwai | f0cea79 | 2010-08-13 11:56:53 +0200 | [diff] [blame] | 720 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 721 | spec->cur_adc = spec->adc_nid[idx]; |
| 722 | snd_hda_codec_setup_stream(codec, spec->cur_adc, |
| 723 | spec->cur_adc_stream_tag, 0, |
| 724 | spec->cur_adc_format); |
| 725 | } |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 726 | spec->cur_input = idx; |
Takashi Iwai | 05ee796 | 2011-11-16 18:05:11 +0100 | [diff] [blame] | 727 | cs_update_input_select(codec); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 728 | return 1; |
| 729 | } |
| 730 | |
| 731 | static int cs_capture_source_info(struct snd_kcontrol *kcontrol, |
| 732 | struct snd_ctl_elem_info *uinfo) |
| 733 | { |
| 734 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 735 | struct cs_spec *spec = codec->spec; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 736 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 737 | unsigned int idx; |
| 738 | |
| 739 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 740 | uinfo->count = 1; |
| 741 | uinfo->value.enumerated.items = spec->num_inputs; |
| 742 | if (uinfo->value.enumerated.item >= spec->num_inputs) |
| 743 | uinfo->value.enumerated.item = spec->num_inputs - 1; |
| 744 | idx = spec->input_idx[uinfo->value.enumerated.item]; |
Takashi Iwai | 201e06f | 2011-11-16 15:33:26 +0100 | [diff] [blame] | 745 | snd_hda_get_pin_label(codec, cfg->inputs[idx].pin, cfg, |
| 746 | uinfo->value.enumerated.name, |
| 747 | sizeof(uinfo->value.enumerated.name), NULL); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 748 | return 0; |
| 749 | } |
| 750 | |
| 751 | static int cs_capture_source_get(struct snd_kcontrol *kcontrol, |
| 752 | struct snd_ctl_elem_value *ucontrol) |
| 753 | { |
| 754 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 755 | struct cs_spec *spec = codec->spec; |
| 756 | ucontrol->value.enumerated.item[0] = spec->capsrc_idx[spec->cur_input]; |
| 757 | return 0; |
| 758 | } |
| 759 | |
| 760 | static int cs_capture_source_put(struct snd_kcontrol *kcontrol, |
| 761 | struct snd_ctl_elem_value *ucontrol) |
| 762 | { |
| 763 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 764 | struct cs_spec *spec = codec->spec; |
| 765 | unsigned int idx = ucontrol->value.enumerated.item[0]; |
| 766 | |
| 767 | if (idx >= spec->num_inputs) |
| 768 | return -EINVAL; |
| 769 | idx = spec->input_idx[idx]; |
Takashi Iwai | ea35929 | 2009-07-06 12:58:59 +0200 | [diff] [blame] | 770 | return change_cur_input(codec, idx, 0); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 771 | } |
| 772 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 773 | static const struct snd_kcontrol_new cs_capture_source = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 774 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 775 | .name = "Capture Source", |
| 776 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, |
| 777 | .info = cs_capture_source_info, |
| 778 | .get = cs_capture_source_get, |
| 779 | .put = cs_capture_source_put, |
| 780 | }; |
| 781 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 782 | static const struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec, |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 783 | struct hda_ctl_ops *ops) |
| 784 | { |
| 785 | struct cs_spec *spec = codec->spec; |
| 786 | struct hda_bind_ctls *bind; |
| 787 | int i, n; |
| 788 | |
| 789 | bind = kzalloc(sizeof(*bind) + sizeof(long) * (spec->num_inputs + 1), |
| 790 | GFP_KERNEL); |
| 791 | if (!bind) |
| 792 | return NULL; |
| 793 | bind->ops = ops; |
| 794 | n = 0; |
| 795 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 796 | if (!spec->adc_nid[i]) |
| 797 | continue; |
| 798 | bind->values[n++] = |
| 799 | HDA_COMPOSE_AMP_VAL(spec->adc_nid[i], 3, |
| 800 | spec->adc_idx[i], HDA_INPUT); |
| 801 | } |
| 802 | return bind; |
| 803 | } |
| 804 | |
Takashi Iwai | 6a92934 | 2010-10-11 15:16:20 +0200 | [diff] [blame] | 805 | /* add a (input-boost) volume control to the given input pin */ |
| 806 | static int add_input_volume_control(struct hda_codec *codec, |
| 807 | struct auto_pin_cfg *cfg, |
| 808 | int item) |
| 809 | { |
| 810 | hda_nid_t pin = cfg->inputs[item].pin; |
| 811 | u32 caps; |
| 812 | const char *label; |
| 813 | struct snd_kcontrol *kctl; |
| 814 | |
| 815 | if (!(get_wcaps(codec, pin) & AC_WCAP_IN_AMP)) |
| 816 | return 0; |
| 817 | caps = query_amp_caps(codec, pin, HDA_INPUT); |
| 818 | caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; |
| 819 | if (caps <= 1) |
| 820 | return 0; |
| 821 | label = hda_get_autocfg_input_label(codec, cfg, item); |
| 822 | return add_volume(codec, label, 0, |
| 823 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_INPUT), 1, &kctl); |
| 824 | } |
| 825 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 826 | static int build_input(struct hda_codec *codec) |
| 827 | { |
| 828 | struct cs_spec *spec = codec->spec; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 829 | int i, err; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 830 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 831 | if (!spec->num_inputs) |
| 832 | return 0; |
| 833 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 834 | /* make bind-capture */ |
| 835 | spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw); |
| 836 | spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); |
| 837 | for (i = 0; i < 2; i++) { |
| 838 | struct snd_kcontrol *kctl; |
Takashi Iwai | 21949f0 | 2009-12-23 08:31:59 +0100 | [diff] [blame] | 839 | int n; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 840 | if (!spec->capture_bind[i]) |
| 841 | return -ENOMEM; |
| 842 | kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); |
| 843 | if (!kctl) |
| 844 | return -ENOMEM; |
| 845 | kctl->private_value = (long)spec->capture_bind[i]; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 846 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 847 | if (err < 0) |
| 848 | return err; |
Takashi Iwai | 21949f0 | 2009-12-23 08:31:59 +0100 | [diff] [blame] | 849 | for (n = 0; n < AUTO_PIN_LAST; n++) { |
| 850 | if (!spec->adc_nid[n]) |
| 851 | continue; |
Brian J. Tarricone | 8dd34ab | 2010-05-02 17:32:10 -0700 | [diff] [blame] | 852 | err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[n]); |
Takashi Iwai | 21949f0 | 2009-12-23 08:31:59 +0100 | [diff] [blame] | 853 | if (err < 0) |
| 854 | return err; |
| 855 | } |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | if (spec->num_inputs > 1 && !spec->mic_detect) { |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 859 | err = snd_hda_ctl_add(codec, 0, |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 860 | snd_ctl_new1(&cs_capture_source, codec)); |
| 861 | if (err < 0) |
| 862 | return err; |
| 863 | } |
| 864 | |
Takashi Iwai | 6a92934 | 2010-10-11 15:16:20 +0200 | [diff] [blame] | 865 | for (i = 0; i < spec->num_inputs; i++) { |
| 866 | err = add_input_volume_control(codec, &spec->autocfg, i); |
| 867 | if (err < 0) |
| 868 | return err; |
| 869 | } |
| 870 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 871 | return 0; |
| 872 | } |
| 873 | |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 874 | /* |
| 875 | */ |
| 876 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 877 | static int build_digital_output(struct hda_codec *codec) |
| 878 | { |
| 879 | struct cs_spec *spec = codec->spec; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 880 | int err; |
| 881 | |
Takashi Iwai | 63b2413 | 2009-07-09 11:45:59 +0200 | [diff] [blame] | 882 | if (!spec->multiout.dig_out_nid) |
| 883 | return 0; |
| 884 | |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 885 | err = snd_hda_create_dig_out_ctls(codec, spec->multiout.dig_out_nid, |
| 886 | spec->multiout.dig_out_nid, |
| 887 | spec->pcm_rec[1].pcm_type); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 888 | if (err < 0) |
| 889 | return err; |
| 890 | err = snd_hda_create_spdif_share_sw(codec, &spec->multiout); |
| 891 | if (err < 0) |
| 892 | return err; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | static int build_digital_input(struct hda_codec *codec) |
| 897 | { |
| 898 | struct cs_spec *spec = codec->spec; |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 899 | if (spec->dig_in) |
| 900 | return snd_hda_create_spdif_in_ctls(codec, spec->dig_in); |
| 901 | return 0; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 902 | } |
| 903 | |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 904 | /* |
| 905 | * auto-mute and auto-mic switching |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 906 | * CS421x auto-output redirecting |
| 907 | * HP/SPK/SPDIF |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 908 | */ |
| 909 | |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 910 | static void cs_automute(struct hda_codec *codec, struct hda_jack_tbl *tbl) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 911 | { |
| 912 | struct cs_spec *spec = codec->spec; |
| 913 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 914 | unsigned int hp_present; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 915 | unsigned int spdif_present; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 916 | hda_nid_t nid; |
| 917 | int i; |
| 918 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 919 | spdif_present = 0; |
| 920 | if (cfg->dig_outs) { |
| 921 | nid = cfg->dig_out_pins[0]; |
| 922 | if (is_jack_detectable(codec, nid)) { |
| 923 | /* |
| 924 | TODO: SPDIF output redirect when SENSE_B is enabled. |
| 925 | Shared (SENSE_A) jack (e.g HP/mini-TOSLINK) |
| 926 | assumed. |
| 927 | */ |
| 928 | if (snd_hda_jack_detect(codec, nid) |
| 929 | /* && spec->sense_b */) |
| 930 | spdif_present = 1; |
| 931 | } |
| 932 | } |
| 933 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 934 | hp_present = 0; |
| 935 | for (i = 0; i < cfg->hp_outs; i++) { |
| 936 | nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 937 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 938 | continue; |
Wu Fengguang | 864f92b | 2009-11-18 12:38:02 +0800 | [diff] [blame] | 939 | hp_present = snd_hda_jack_detect(codec, nid); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 940 | if (hp_present) |
| 941 | break; |
| 942 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 943 | |
| 944 | /* mute speakers if spdif or hp jack is plugged in */ |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 945 | for (i = 0; i < cfg->speaker_outs; i++) { |
David Henningsson | 78e2a92 | 2012-01-02 12:40:16 +0100 | [diff] [blame] | 946 | int pin_ctl = hp_present ? 0 : PIN_OUT; |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 947 | /* detect on spdif is specific to CS4210 */ |
| 948 | if (spdif_present && (spec->vendor_nid == CS4210_VENDOR_NID)) |
David Henningsson | 78e2a92 | 2012-01-02 12:40:16 +0100 | [diff] [blame] | 949 | pin_ctl = 0; |
| 950 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 951 | nid = cfg->speaker_pins[i]; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 952 | snd_hda_set_pin_ctl(codec, nid, pin_ctl); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 953 | } |
Takashi Iwai | 6dfeb703 | 2011-11-22 20:00:31 +0100 | [diff] [blame] | 954 | if (spec->gpio_eapd_hp) { |
| 955 | unsigned int gpio = hp_present ? |
| 956 | spec->gpio_eapd_hp : spec->gpio_eapd_speaker; |
Stelian Pop | 3a38516 | 2009-07-30 14:44:27 +0200 | [diff] [blame] | 957 | snd_hda_codec_write(codec, 0x01, 0, |
| 958 | AC_VERB_SET_GPIO_DATA, gpio); |
| 959 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 960 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 961 | /* specific to CS4210 */ |
| 962 | if (spec->vendor_nid == CS4210_VENDOR_NID) { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 963 | /* mute HPs if spdif jack (SENSE_B) is present */ |
| 964 | for (i = 0; i < cfg->hp_outs; i++) { |
| 965 | nid = cfg->hp_pins[i]; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 966 | snd_hda_set_pin_ctl(codec, nid, |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 967 | (spdif_present && spec->sense_b) ? 0 : PIN_HP); |
| 968 | } |
| 969 | |
| 970 | /* SPDIF TX on/off */ |
| 971 | if (cfg->dig_outs) { |
| 972 | nid = cfg->dig_out_pins[0]; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 973 | snd_hda_set_pin_ctl(codec, nid, |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 974 | spdif_present ? PIN_OUT : 0); |
| 975 | |
| 976 | } |
| 977 | /* Update board GPIOs if neccessary ... */ |
| 978 | } |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 979 | } |
| 980 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 981 | /* |
| 982 | * Auto-input redirect for CS421x |
| 983 | * Switch max 3 inputs of a single ADC (nid 3) |
| 984 | */ |
| 985 | |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 986 | static void cs_automic(struct hda_codec *codec, struct hda_jack_tbl *tbl) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 987 | { |
| 988 | struct cs_spec *spec = codec->spec; |
| 989 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 990 | hda_nid_t nid; |
Wu Fengguang | 864f92b | 2009-11-18 12:38:02 +0800 | [diff] [blame] | 991 | unsigned int present; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 992 | |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 993 | nid = cfg->inputs[spec->automic_idx].pin; |
Wu Fengguang | 864f92b | 2009-11-18 12:38:02 +0800 | [diff] [blame] | 994 | present = snd_hda_jack_detect(codec, nid); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 995 | |
| 996 | /* specific to CS421x, single ADC */ |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 997 | if (spec->vendor_nid == CS420X_VENDOR_NID) { |
| 998 | if (present) |
| 999 | change_cur_input(codec, spec->automic_idx, 0); |
| 1000 | else |
| 1001 | change_cur_input(codec, !spec->automic_idx, 0); |
| 1002 | } else { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1003 | if (present) { |
Dylan Reid | f70eecd | 2012-01-31 13:04:41 -0800 | [diff] [blame] | 1004 | if (spec->cur_input != spec->automic_idx) { |
| 1005 | spec->last_input = spec->cur_input; |
| 1006 | spec->cur_input = spec->automic_idx; |
| 1007 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1008 | } else { |
| 1009 | spec->cur_input = spec->last_input; |
| 1010 | } |
Takashi Iwai | 05ee796 | 2011-11-16 18:05:11 +0100 | [diff] [blame] | 1011 | cs_update_input_select(codec); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1012 | } |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | */ |
| 1017 | |
| 1018 | static void init_output(struct hda_codec *codec) |
| 1019 | { |
| 1020 | struct cs_spec *spec = codec->spec; |
| 1021 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1022 | int i; |
| 1023 | |
| 1024 | /* mute first */ |
| 1025 | for (i = 0; i < spec->multiout.num_dacs; i++) |
| 1026 | snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0, |
| 1027 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); |
| 1028 | if (spec->multiout.hp_nid) |
| 1029 | snd_hda_codec_write(codec, spec->multiout.hp_nid, 0, |
| 1030 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); |
| 1031 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
| 1032 | if (!spec->multiout.extra_out_nid[i]) |
| 1033 | break; |
| 1034 | snd_hda_codec_write(codec, spec->multiout.extra_out_nid[i], 0, |
| 1035 | AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); |
| 1036 | } |
| 1037 | |
| 1038 | /* set appropriate pin controls */ |
| 1039 | for (i = 0; i < cfg->line_outs; i++) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1040 | snd_hda_set_pin_ctl(codec, cfg->line_out_pins[i], PIN_OUT); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1041 | /* HP */ |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1042 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1043 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1044 | snd_hda_set_pin_ctl(codec, nid, PIN_HP); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1045 | if (!cfg->speaker_outs) |
| 1046 | continue; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1047 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1048 | snd_hda_jack_detect_enable_callback(codec, nid, HP_EVENT, cs_automute); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1049 | spec->hp_detect = 1; |
| 1050 | } |
| 1051 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1052 | |
| 1053 | /* Speaker */ |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1054 | for (i = 0; i < cfg->speaker_outs; i++) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1055 | snd_hda_set_pin_ctl(codec, cfg->speaker_pins[i], PIN_OUT); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1056 | |
| 1057 | /* SPDIF is enabled on presence detect for CS421x */ |
| 1058 | if (spec->hp_detect || spec->spdif_detect) |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1059 | cs_automute(codec, NULL); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | static void init_input(struct hda_codec *codec) |
| 1063 | { |
| 1064 | struct cs_spec *spec = codec->spec; |
| 1065 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1066 | unsigned int coef; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1067 | int i; |
| 1068 | |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 1069 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1070 | unsigned int ctl; |
Takashi Iwai | c1e0bb9 | 2010-08-30 13:05:30 +0200 | [diff] [blame] | 1071 | hda_nid_t pin = cfg->inputs[i].pin; |
| 1072 | if (!spec->adc_nid[i]) |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1073 | continue; |
| 1074 | /* set appropriate pin control and mute first */ |
| 1075 | ctl = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 1076 | if (cfg->inputs[i].type == AUTO_PIN_MIC) |
| 1077 | ctl |= snd_hda_get_default_vref(codec, pin); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1078 | snd_hda_set_pin_ctl(codec, pin, ctl); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1079 | snd_hda_codec_write(codec, spec->adc_nid[i], 0, |
| 1080 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1081 | AMP_IN_MUTE(spec->adc_idx[i])); |
| 1082 | if (spec->mic_detect && spec->automic_idx == i) |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1083 | snd_hda_jack_detect_enable_callback(codec, pin, MIC_EVENT, cs_automic); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1084 | } |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1085 | /* CS420x has multiple ADC, CS421x has single ADC */ |
| 1086 | if (spec->vendor_nid == CS420X_VENDOR_NID) { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1087 | change_cur_input(codec, spec->cur_input, 1); |
| 1088 | if (spec->mic_detect) |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1089 | cs_automic(codec, NULL); |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1090 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1091 | coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ |
Daniel J Blueman | 16337e0 | 2012-11-04 13:19:03 +0800 | [diff] [blame] | 1092 | cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); |
| 1093 | |
| 1094 | coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1095 | if (is_active_pin(codec, CS_DMIC2_PIN_NID)) |
Daniel J Blueman | 16337e0 | 2012-11-04 13:19:03 +0800 | [diff] [blame] | 1096 | coef |= 1 << 4; /* DMIC2 2 chan on, GPIO1 off */ |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1097 | if (is_active_pin(codec, CS_DMIC1_PIN_NID)) |
Daniel J Blueman | 16337e0 | 2012-11-04 13:19:03 +0800 | [diff] [blame] | 1098 | coef |= 1 << 3; /* DMIC1 2 chan on, GPIO0 off |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1099 | * No effect if SPDIF_OUT2 is |
| 1100 | * selected in IDX_SPDIF_CTL. |
| 1101 | */ |
Daniel J Blueman | 16337e0 | 2012-11-04 13:19:03 +0800 | [diff] [blame] | 1102 | |
| 1103 | cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef); |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1104 | } else { |
| 1105 | if (spec->mic_detect) |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1106 | cs_automic(codec, NULL); |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1107 | else { |
| 1108 | spec->cur_adc = spec->adc_nid[spec->cur_input]; |
| 1109 | cs_update_input_select(codec); |
| 1110 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1111 | } |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1112 | } |
| 1113 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 1114 | static const struct hda_verb cs_coef_init_verbs[] = { |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1115 | {0x11, AC_VERB_SET_PROC_STATE, 1}, |
| 1116 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG}, |
| 1117 | {0x11, AC_VERB_SET_PROC_COEF, |
| 1118 | (0x002a /* DAC1/2/3 SZCMode Soft Ramp */ |
| 1119 | | 0x0040 /* Mute DACs on FIFO error */ |
| 1120 | | 0x1000 /* Enable DACs High Pass Filter */ |
| 1121 | | 0x0400 /* Disable Coefficient Auto increment */ |
| 1122 | )}, |
| 1123 | /* Beep */ |
Alexander Stein | 5a83b4b | 2012-11-01 13:42:37 +0100 | [diff] [blame] | 1124 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_BEEP_CFG}, |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1125 | {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */ |
| 1126 | |
| 1127 | {} /* terminator */ |
| 1128 | }; |
| 1129 | |
Brian Austin | a769cbc | 2010-09-07 14:36:22 -0500 | [diff] [blame] | 1130 | /* Errata: CS4207 rev C0/C1/C2 Silicon |
| 1131 | * |
| 1132 | * http://www.cirrus.com/en/pubs/errata/ER880C3.pdf |
| 1133 | * |
| 1134 | * 6. At high temperature (TA > +85°C), the digital supply current (IVD) |
| 1135 | * may be excessive (up to an additional 200 μA), which is most easily |
| 1136 | * observed while the part is being held in reset (RESET# active low). |
| 1137 | * |
| 1138 | * Root Cause: At initial powerup of the device, the logic that drives |
| 1139 | * the clock and write enable to the S/PDIF SRC RAMs is not properly |
| 1140 | * initialized. |
| 1141 | * Certain random patterns will cause a steady leakage current in those |
| 1142 | * RAM cells. The issue will resolve once the SRCs are used (turned on). |
| 1143 | * |
| 1144 | * Workaround: The following verb sequence briefly turns on the S/PDIF SRC |
| 1145 | * blocks, which will alleviate the issue. |
| 1146 | */ |
| 1147 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 1148 | static const struct hda_verb cs_errata_init_verbs[] = { |
Brian Austin | a769cbc | 2010-09-07 14:36:22 -0500 | [diff] [blame] | 1149 | {0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */ |
| 1150 | {0x11, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */ |
| 1151 | |
| 1152 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0008}, |
| 1153 | {0x11, AC_VERB_SET_PROC_COEF, 0x9999}, |
| 1154 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0017}, |
| 1155 | {0x11, AC_VERB_SET_PROC_COEF, 0xa412}, |
| 1156 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0001}, |
| 1157 | {0x11, AC_VERB_SET_PROC_COEF, 0x0009}, |
| 1158 | |
| 1159 | {0x07, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Rx: D0 */ |
| 1160 | {0x08, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Tx: D0 */ |
| 1161 | |
| 1162 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0017}, |
| 1163 | {0x11, AC_VERB_SET_PROC_COEF, 0x2412}, |
| 1164 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0008}, |
| 1165 | {0x11, AC_VERB_SET_PROC_COEF, 0x0000}, |
| 1166 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0001}, |
| 1167 | {0x11, AC_VERB_SET_PROC_COEF, 0x0008}, |
| 1168 | {0x11, AC_VERB_SET_PROC_STATE, 0x00}, |
| 1169 | |
Takashi Iwai | 38c0764 | 2011-03-03 14:54:19 +0100 | [diff] [blame] | 1170 | #if 0 /* Don't to set to D3 as we are in power-up sequence */ |
Brian Austin | a769cbc | 2010-09-07 14:36:22 -0500 | [diff] [blame] | 1171 | {0x07, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Rx: D3 */ |
| 1172 | {0x08, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Tx: D3 */ |
| 1173 | /*{0x01, AC_VERB_SET_POWER_STATE, 0x03},*/ /* AFG: D3 This is already handled */ |
Takashi Iwai | 38c0764 | 2011-03-03 14:54:19 +0100 | [diff] [blame] | 1174 | #endif |
Brian Austin | a769cbc | 2010-09-07 14:36:22 -0500 | [diff] [blame] | 1175 | |
| 1176 | {} /* terminator */ |
| 1177 | }; |
| 1178 | |
Takashi Iwai | ef596a5 | 2012-09-11 16:53:08 +0200 | [diff] [blame] | 1179 | static const struct hda_verb mbp101_init_verbs[] = { |
| 1180 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0002}, |
| 1181 | {0x11, AC_VERB_SET_PROC_COEF, 0x100a}, |
| 1182 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0004}, |
| 1183 | {0x11, AC_VERB_SET_PROC_COEF, 0x000f}, |
| 1184 | {} |
| 1185 | }; |
| 1186 | |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1187 | /* SPDIF setup */ |
| 1188 | static void init_digital(struct hda_codec *codec) |
| 1189 | { |
| 1190 | unsigned int coef; |
| 1191 | |
| 1192 | coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */ |
| 1193 | coef |= 0x0008; /* Replace with mute on error */ |
| 1194 | if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID)) |
| 1195 | coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2 |
| 1196 | * SPDIF_OUT2 is shared with GPIO1 and |
| 1197 | * DMIC_SDA2. |
| 1198 | */ |
| 1199 | cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1200 | } |
| 1201 | |
| 1202 | static int cs_init(struct hda_codec *codec) |
| 1203 | { |
| 1204 | struct cs_spec *spec = codec->spec; |
| 1205 | |
Brian Austin | a769cbc | 2010-09-07 14:36:22 -0500 | [diff] [blame] | 1206 | /* init_verb sequence for C0/C1/C2 errata*/ |
| 1207 | snd_hda_sequence_write(codec, cs_errata_init_verbs); |
| 1208 | |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1209 | snd_hda_sequence_write(codec, cs_coef_init_verbs); |
Takashi Iwai | ed20825 | 2009-07-07 09:04:26 +0200 | [diff] [blame] | 1210 | |
| 1211 | if (spec->gpio_mask) { |
| 1212 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, |
| 1213 | spec->gpio_mask); |
| 1214 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, |
| 1215 | spec->gpio_dir); |
| 1216 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 1217 | spec->gpio_data); |
| 1218 | } |
| 1219 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1220 | init_output(codec); |
| 1221 | init_input(codec); |
Takashi Iwai | 40c20fa | 2009-07-06 13:00:57 +0200 | [diff] [blame] | 1222 | init_digital(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1223 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1224 | return 0; |
| 1225 | } |
| 1226 | |
| 1227 | static int cs_build_controls(struct hda_codec *codec) |
| 1228 | { |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1229 | struct cs_spec *spec = codec->spec; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1230 | int err; |
| 1231 | |
| 1232 | err = build_output(codec); |
| 1233 | if (err < 0) |
| 1234 | return err; |
| 1235 | err = build_input(codec); |
| 1236 | if (err < 0) |
| 1237 | return err; |
| 1238 | err = build_digital_output(codec); |
| 1239 | if (err < 0) |
| 1240 | return err; |
| 1241 | err = build_digital_input(codec); |
| 1242 | if (err < 0) |
| 1243 | return err; |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1244 | err = cs_init(codec); |
| 1245 | if (err < 0) |
| 1246 | return err; |
| 1247 | |
| 1248 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1249 | if (err < 0) |
| 1250 | return err; |
| 1251 | |
| 1252 | return 0; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | static void cs_free(struct hda_codec *codec) |
| 1256 | { |
| 1257 | struct cs_spec *spec = codec->spec; |
| 1258 | kfree(spec->capture_bind[0]); |
| 1259 | kfree(spec->capture_bind[1]); |
Takashi Iwai | b2cbf3b | 2012-10-10 08:53:06 +0200 | [diff] [blame] | 1260 | snd_hda_gen_free(&spec->gen); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1261 | kfree(codec->spec); |
| 1262 | } |
| 1263 | |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 1264 | static const struct hda_codec_ops cs_patch_ops = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1265 | .build_controls = cs_build_controls, |
| 1266 | .build_pcms = cs_build_pcms, |
| 1267 | .init = cs_init, |
| 1268 | .free = cs_free, |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1269 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1270 | }; |
| 1271 | |
| 1272 | static int cs_parse_auto_config(struct hda_codec *codec) |
| 1273 | { |
| 1274 | struct cs_spec *spec = codec->spec; |
| 1275 | int err; |
| 1276 | |
| 1277 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
| 1278 | if (err < 0) |
| 1279 | return err; |
Takashi Iwai | ed20825 | 2009-07-07 09:04:26 +0200 | [diff] [blame] | 1280 | |
| 1281 | err = parse_output(codec); |
| 1282 | if (err < 0) |
| 1283 | return err; |
| 1284 | err = parse_input(codec); |
| 1285 | if (err < 0) |
| 1286 | return err; |
| 1287 | err = parse_digital_output(codec); |
| 1288 | if (err < 0) |
| 1289 | return err; |
| 1290 | err = parse_digital_input(codec); |
| 1291 | if (err < 0) |
| 1292 | return err; |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1293 | return 0; |
| 1294 | } |
| 1295 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1296 | static const struct hda_model_fixup cs420x_models[] = { |
| 1297 | { .id = CS420X_MBP53, .name = "mbp53" }, |
| 1298 | { .id = CS420X_MBP55, .name = "mbp55" }, |
| 1299 | { .id = CS420X_IMAC27, .name = "imac27" }, |
| 1300 | { .id = CS420X_IMAC27_122, .name = "imac27_122" }, |
| 1301 | { .id = CS420X_APPLE, .name = "apple" }, |
Takashi Iwai | ef596a5 | 2012-09-11 16:53:08 +0200 | [diff] [blame] | 1302 | { .id = CS420X_MBP101, .name = "mbp101" }, |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1303 | {} |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 1304 | }; |
| 1305 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1306 | static const struct snd_pci_quirk cs420x_fixup_tbl[] = { |
Vince Weaver | 4e7d7c6 | 2010-09-22 17:31:37 -0400 | [diff] [blame] | 1307 | SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), |
Edgar (gimli) Hucek | 87232dd | 2010-11-03 08:14:10 +0100 | [diff] [blame] | 1308 | SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55), |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 1309 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), |
Takashi Iwai | f46119b | 2010-10-11 14:46:35 +0200 | [diff] [blame] | 1310 | SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), |
Takashi Iwai | 6dfeb703 | 2011-11-22 20:00:31 +0100 | [diff] [blame] | 1311 | /* this conflicts with too many other models */ |
| 1312 | /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/ |
Takashi Iwai | 6dfeb703 | 2011-11-22 20:00:31 +0100 | [diff] [blame] | 1313 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1314 | /* codec SSID */ |
Jérémy Lal | 7e5bea1 | 2012-01-09 17:19:45 +0100 | [diff] [blame] | 1315 | SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122), |
Takashi Iwai | ef596a5 | 2012-09-11 16:53:08 +0200 | [diff] [blame] | 1316 | SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101), |
Takashi Iwai | 6dfeb703 | 2011-11-22 20:00:31 +0100 | [diff] [blame] | 1317 | SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE), |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 1318 | {} /* terminator */ |
| 1319 | }; |
| 1320 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1321 | static const struct hda_pintbl mbp53_pincfgs[] = { |
Vince Weaver | 4e7d7c6 | 2010-09-22 17:31:37 -0400 | [diff] [blame] | 1322 | { 0x09, 0x012b4050 }, |
| 1323 | { 0x0a, 0x90100141 }, |
| 1324 | { 0x0b, 0x90100140 }, |
| 1325 | { 0x0c, 0x018b3020 }, |
| 1326 | { 0x0d, 0x90a00110 }, |
| 1327 | { 0x0e, 0x400000f0 }, |
| 1328 | { 0x0f, 0x01cbe030 }, |
| 1329 | { 0x10, 0x014be060 }, |
| 1330 | { 0x12, 0x400000f0 }, |
| 1331 | { 0x15, 0x400000f0 }, |
| 1332 | {} /* terminator */ |
| 1333 | }; |
| 1334 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1335 | static const struct hda_pintbl mbp55_pincfgs[] = { |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 1336 | { 0x09, 0x012b4030 }, |
| 1337 | { 0x0a, 0x90100121 }, |
| 1338 | { 0x0b, 0x90100120 }, |
| 1339 | { 0x0c, 0x400000f0 }, |
| 1340 | { 0x0d, 0x90a00110 }, |
| 1341 | { 0x0e, 0x400000f0 }, |
| 1342 | { 0x0f, 0x400000f0 }, |
| 1343 | { 0x10, 0x014be040 }, |
| 1344 | { 0x12, 0x400000f0 }, |
| 1345 | { 0x15, 0x400000f0 }, |
| 1346 | {} /* terminator */ |
| 1347 | }; |
| 1348 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1349 | static const struct hda_pintbl imac27_pincfgs[] = { |
Rafael Avila de Espindola | 1a5ba2e | 2009-12-22 07:59:37 +0100 | [diff] [blame] | 1350 | { 0x09, 0x012b4050 }, |
| 1351 | { 0x0a, 0x90100140 }, |
| 1352 | { 0x0b, 0x90100142 }, |
| 1353 | { 0x0c, 0x018b3020 }, |
| 1354 | { 0x0d, 0x90a00110 }, |
| 1355 | { 0x0e, 0x400000f0 }, |
| 1356 | { 0x0f, 0x01cbe030 }, |
| 1357 | { 0x10, 0x014be060 }, |
| 1358 | { 0x12, 0x01ab9070 }, |
| 1359 | { 0x15, 0x400000f0 }, |
| 1360 | {} /* terminator */ |
| 1361 | }; |
| 1362 | |
Takashi Iwai | ef596a5 | 2012-09-11 16:53:08 +0200 | [diff] [blame] | 1363 | static const struct hda_pintbl mbp101_pincfgs[] = { |
| 1364 | { 0x0d, 0x40ab90f0 }, |
| 1365 | { 0x0e, 0x90a600f0 }, |
| 1366 | { 0x12, 0x50a600f0 }, |
| 1367 | {} /* terminator */ |
| 1368 | }; |
| 1369 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1370 | static void cs420x_fixup_gpio_13(struct hda_codec *codec, |
| 1371 | const struct hda_fixup *fix, int action) |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 1372 | { |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1373 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1374 | struct cs_spec *spec = codec->spec; |
| 1375 | spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ |
| 1376 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ |
| 1377 | spec->gpio_mask = spec->gpio_dir = |
| 1378 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker; |
| 1379 | } |
Takashi Iwai | a6bae20 | 2009-07-06 15:15:22 +0200 | [diff] [blame] | 1380 | } |
| 1381 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1382 | static void cs420x_fixup_gpio_23(struct hda_codec *codec, |
| 1383 | const struct hda_fixup *fix, int action) |
| 1384 | { |
| 1385 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1386 | struct cs_spec *spec = codec->spec; |
| 1387 | spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ |
| 1388 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ |
| 1389 | spec->gpio_mask = spec->gpio_dir = |
| 1390 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker; |
| 1391 | } |
| 1392 | } |
| 1393 | |
| 1394 | static const struct hda_fixup cs420x_fixups[] = { |
| 1395 | [CS420X_MBP53] = { |
| 1396 | .type = HDA_FIXUP_PINS, |
| 1397 | .v.pins = mbp53_pincfgs, |
| 1398 | .chained = true, |
| 1399 | .chain_id = CS420X_APPLE, |
| 1400 | }, |
| 1401 | [CS420X_MBP55] = { |
| 1402 | .type = HDA_FIXUP_PINS, |
| 1403 | .v.pins = mbp55_pincfgs, |
| 1404 | .chained = true, |
| 1405 | .chain_id = CS420X_GPIO_13, |
| 1406 | }, |
| 1407 | [CS420X_IMAC27] = { |
| 1408 | .type = HDA_FIXUP_PINS, |
| 1409 | .v.pins = imac27_pincfgs, |
| 1410 | .chained = true, |
| 1411 | .chain_id = CS420X_GPIO_13, |
| 1412 | }, |
| 1413 | [CS420X_GPIO_13] = { |
| 1414 | .type = HDA_FIXUP_FUNC, |
| 1415 | .v.func = cs420x_fixup_gpio_13, |
| 1416 | }, |
| 1417 | [CS420X_GPIO_23] = { |
| 1418 | .type = HDA_FIXUP_FUNC, |
| 1419 | .v.func = cs420x_fixup_gpio_23, |
| 1420 | }, |
Takashi Iwai | ef596a5 | 2012-09-11 16:53:08 +0200 | [diff] [blame] | 1421 | [CS420X_MBP101] = { |
| 1422 | .type = HDA_FIXUP_PINS, |
| 1423 | .v.pins = mbp101_pincfgs, |
| 1424 | .chained = true, |
| 1425 | .chain_id = CS420X_MBP101_COEF, |
| 1426 | }, |
| 1427 | [CS420X_MBP101_COEF] = { |
| 1428 | .type = HDA_FIXUP_VERBS, |
| 1429 | .v.verbs = mbp101_init_verbs, |
| 1430 | .chained = true, |
| 1431 | .chain_id = CS420X_GPIO_13, |
| 1432 | }, |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1433 | }; |
| 1434 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1435 | static int patch_cs420x(struct hda_codec *codec) |
| 1436 | { |
| 1437 | struct cs_spec *spec; |
| 1438 | int err; |
| 1439 | |
| 1440 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1441 | if (!spec) |
| 1442 | return -ENOMEM; |
| 1443 | codec->spec = spec; |
Takashi Iwai | b2cbf3b | 2012-10-10 08:53:06 +0200 | [diff] [blame] | 1444 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1445 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1446 | spec->vendor_nid = CS420X_VENDOR_NID; |
| 1447 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1448 | snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl, |
| 1449 | cs420x_fixups); |
| 1450 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1451 | |
Takashi Iwai | ed20825 | 2009-07-07 09:04:26 +0200 | [diff] [blame] | 1452 | err = cs_parse_auto_config(codec); |
Takashi Iwai | 21a4dc4 | 2009-07-06 12:55:46 +0200 | [diff] [blame] | 1453 | if (err < 0) |
| 1454 | goto error; |
| 1455 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1456 | codec->patch_ops = cs_patch_ops; |
| 1457 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1458 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 1459 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1460 | return 0; |
| 1461 | |
| 1462 | error: |
Takashi Iwai | c5e0b6d | 2012-10-10 08:50:35 +0200 | [diff] [blame] | 1463 | cs_free(codec); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 1464 | codec->spec = NULL; |
| 1465 | return err; |
| 1466 | } |
| 1467 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1468 | /* |
| 1469 | * Cirrus Logic CS4210 |
| 1470 | * |
| 1471 | * 1 DAC => HP(sense) / Speakers, |
| 1472 | * 1 ADC <= LineIn(sense) / MicIn / DMicIn, |
| 1473 | * 1 SPDIF OUT => SPDIF Trasmitter(sense) |
| 1474 | */ |
| 1475 | |
| 1476 | /* CS4210 board names */ |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1477 | static const struct hda_model_fixup cs421x_models[] = { |
| 1478 | { .id = CS421X_CDB4210, .name = "cdb4210" }, |
| 1479 | {} |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1480 | }; |
| 1481 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1482 | static const struct snd_pci_quirk cs421x_fixup_tbl[] = { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1483 | /* Test Intel board + CDB2410 */ |
| 1484 | SND_PCI_QUIRK(0x8086, 0x5001, "DP45SG/CDB4210", CS421X_CDB4210), |
| 1485 | {} /* terminator */ |
| 1486 | }; |
| 1487 | |
| 1488 | /* CS4210 board pinconfigs */ |
| 1489 | /* Default CS4210 (CDB4210)*/ |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1490 | static const struct hda_pintbl cdb4210_pincfgs[] = { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1491 | { 0x05, 0x0321401f }, |
| 1492 | { 0x06, 0x90170010 }, |
| 1493 | { 0x07, 0x03813031 }, |
| 1494 | { 0x08, 0xb7a70037 }, |
| 1495 | { 0x09, 0xb7a6003e }, |
| 1496 | { 0x0a, 0x034510f0 }, |
| 1497 | {} /* terminator */ |
| 1498 | }; |
| 1499 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1500 | /* Setup GPIO/SENSE for each board (if used) */ |
| 1501 | static void cs421x_fixup_sense_b(struct hda_codec *codec, |
| 1502 | const struct hda_fixup *fix, int action) |
| 1503 | { |
| 1504 | struct cs_spec *spec = codec->spec; |
| 1505 | if (action == HDA_FIXUP_ACT_PRE_PROBE) |
| 1506 | spec->sense_b = 1; |
| 1507 | } |
| 1508 | |
| 1509 | static const struct hda_fixup cs421x_fixups[] = { |
| 1510 | [CS421X_CDB4210] = { |
| 1511 | .type = HDA_FIXUP_PINS, |
| 1512 | .v.pins = cdb4210_pincfgs, |
| 1513 | .chained = true, |
| 1514 | .chain_id = CS421X_SENSE_B, |
| 1515 | }, |
| 1516 | [CS421X_SENSE_B] = { |
| 1517 | .type = HDA_FIXUP_FUNC, |
| 1518 | .v.func = cs421x_fixup_sense_b, |
| 1519 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1520 | }; |
| 1521 | |
| 1522 | static const struct hda_verb cs421x_coef_init_verbs[] = { |
| 1523 | {0x0B, AC_VERB_SET_PROC_STATE, 1}, |
| 1524 | {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DEV_CFG}, |
| 1525 | /* |
| 1526 | Disable Coefficient Index Auto-Increment(DAI)=1, |
| 1527 | PDREF=0 |
| 1528 | */ |
| 1529 | {0x0B, AC_VERB_SET_PROC_COEF, 0x0001 }, |
| 1530 | |
| 1531 | {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_ADC_CFG}, |
| 1532 | /* ADC SZCMode = Digital Soft Ramp */ |
| 1533 | {0x0B, AC_VERB_SET_PROC_COEF, 0x0002 }, |
| 1534 | |
| 1535 | {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DAC_CFG}, |
| 1536 | {0x0B, AC_VERB_SET_PROC_COEF, |
| 1537 | (0x0002 /* DAC SZCMode = Digital Soft Ramp */ |
| 1538 | | 0x0004 /* Mute DAC on FIFO error */ |
| 1539 | | 0x0008 /* Enable DAC High Pass Filter */ |
| 1540 | )}, |
| 1541 | {} /* terminator */ |
| 1542 | }; |
| 1543 | |
| 1544 | /* Errata: CS4210 rev A1 Silicon |
| 1545 | * |
| 1546 | * http://www.cirrus.com/en/pubs/errata/ |
| 1547 | * |
| 1548 | * Description: |
| 1549 | * 1. Performance degredation is present in the ADC. |
| 1550 | * 2. Speaker output is not completely muted upon HP detect. |
| 1551 | * 3. Noise is present when clipping occurs on the amplified |
| 1552 | * speaker outputs. |
| 1553 | * |
| 1554 | * Workaround: |
| 1555 | * The following verb sequence written to the registers during |
| 1556 | * initialization will correct the issues listed above. |
| 1557 | */ |
| 1558 | |
| 1559 | static const struct hda_verb cs421x_coef_init_verbs_A1_silicon_fixes[] = { |
| 1560 | {0x0B, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */ |
| 1561 | |
| 1562 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x0006}, |
| 1563 | {0x0B, AC_VERB_SET_PROC_COEF, 0x9999}, /* Test mode: on */ |
| 1564 | |
| 1565 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x000A}, |
| 1566 | {0x0B, AC_VERB_SET_PROC_COEF, 0x14CB}, /* Chop double */ |
| 1567 | |
| 1568 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x0011}, |
| 1569 | {0x0B, AC_VERB_SET_PROC_COEF, 0xA2D0}, /* Increase ADC current */ |
| 1570 | |
| 1571 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x001A}, |
| 1572 | {0x0B, AC_VERB_SET_PROC_COEF, 0x02A9}, /* Mute speaker */ |
| 1573 | |
| 1574 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x001B}, |
| 1575 | {0x0B, AC_VERB_SET_PROC_COEF, 0X1006}, /* Remove noise */ |
| 1576 | |
| 1577 | {} /* terminator */ |
| 1578 | }; |
| 1579 | |
| 1580 | /* Speaker Amp Gain is controlled by the vendor widget's coef 4 */ |
| 1581 | static const DECLARE_TLV_DB_SCALE(cs421x_speaker_boost_db_scale, 900, 300, 0); |
| 1582 | |
| 1583 | static int cs421x_boost_vol_info(struct snd_kcontrol *kcontrol, |
| 1584 | struct snd_ctl_elem_info *uinfo) |
| 1585 | { |
| 1586 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 1587 | uinfo->count = 1; |
| 1588 | uinfo->value.integer.min = 0; |
| 1589 | uinfo->value.integer.max = 3; |
| 1590 | return 0; |
| 1591 | } |
| 1592 | |
| 1593 | static int cs421x_boost_vol_get(struct snd_kcontrol *kcontrol, |
| 1594 | struct snd_ctl_elem_value *ucontrol) |
| 1595 | { |
| 1596 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1597 | |
| 1598 | ucontrol->value.integer.value[0] = |
| 1599 | cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL) & 0x0003; |
| 1600 | return 0; |
| 1601 | } |
| 1602 | |
| 1603 | static int cs421x_boost_vol_put(struct snd_kcontrol *kcontrol, |
| 1604 | struct snd_ctl_elem_value *ucontrol) |
| 1605 | { |
| 1606 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1607 | |
| 1608 | unsigned int vol = ucontrol->value.integer.value[0]; |
| 1609 | unsigned int coef = |
| 1610 | cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL); |
| 1611 | unsigned int original_coef = coef; |
| 1612 | |
| 1613 | coef &= ~0x0003; |
| 1614 | coef |= (vol & 0x0003); |
| 1615 | if (original_coef == coef) |
| 1616 | return 0; |
| 1617 | else { |
| 1618 | cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef); |
| 1619 | return 1; |
| 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | static const struct snd_kcontrol_new cs421x_speaker_bost_ctl = { |
| 1624 | |
| 1625 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1626 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 1627 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), |
| 1628 | .name = "Speaker Boost Playback Volume", |
| 1629 | .info = cs421x_boost_vol_info, |
| 1630 | .get = cs421x_boost_vol_get, |
| 1631 | .put = cs421x_boost_vol_put, |
| 1632 | .tlv = { .p = cs421x_speaker_boost_db_scale }, |
| 1633 | }; |
| 1634 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1635 | static void cs4210_pinmux_init(struct hda_codec *codec) |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1636 | { |
| 1637 | struct cs_spec *spec = codec->spec; |
| 1638 | unsigned int def_conf, coef; |
| 1639 | |
| 1640 | /* GPIO, DMIC_SCL, DMIC_SDA and SENSE_B are multiplexed */ |
| 1641 | coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); |
| 1642 | |
| 1643 | if (spec->gpio_mask) |
| 1644 | coef |= 0x0008; /* B1,B2 are GPIOs */ |
| 1645 | else |
| 1646 | coef &= ~0x0008; |
| 1647 | |
| 1648 | if (spec->sense_b) |
| 1649 | coef |= 0x0010; /* B2 is SENSE_B, not inverted */ |
| 1650 | else |
| 1651 | coef &= ~0x0010; |
| 1652 | |
| 1653 | cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); |
| 1654 | |
| 1655 | if ((spec->gpio_mask || spec->sense_b) && |
| 1656 | is_active_pin(codec, CS421X_DMIC_PIN_NID)) { |
| 1657 | |
| 1658 | /* |
| 1659 | GPIO or SENSE_B forced - disconnect the DMIC pin. |
| 1660 | */ |
| 1661 | def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID); |
| 1662 | def_conf &= ~AC_DEFCFG_PORT_CONN; |
| 1663 | def_conf |= (AC_JACK_PORT_NONE << AC_DEFCFG_PORT_CONN_SHIFT); |
| 1664 | snd_hda_codec_set_pincfg(codec, CS421X_DMIC_PIN_NID, def_conf); |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | static void init_cs421x_digital(struct hda_codec *codec) |
| 1669 | { |
| 1670 | struct cs_spec *spec = codec->spec; |
| 1671 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1672 | int i; |
| 1673 | |
| 1674 | |
| 1675 | for (i = 0; i < cfg->dig_outs; i++) { |
| 1676 | hda_nid_t nid = cfg->dig_out_pins[i]; |
| 1677 | if (!cfg->speaker_outs) |
| 1678 | continue; |
| 1679 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1680 | snd_hda_jack_detect_enable_callback(codec, nid, SPDIF_EVENT, cs_automute); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1681 | spec->spdif_detect = 1; |
| 1682 | } |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | static int cs421x_init(struct hda_codec *codec) |
| 1687 | { |
| 1688 | struct cs_spec *spec = codec->spec; |
| 1689 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1690 | if (spec->vendor_nid == CS4210_VENDOR_NID) { |
| 1691 | snd_hda_sequence_write(codec, cs421x_coef_init_verbs); |
| 1692 | snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes); |
| 1693 | cs4210_pinmux_init(codec); |
| 1694 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1695 | |
| 1696 | if (spec->gpio_mask) { |
| 1697 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, |
| 1698 | spec->gpio_mask); |
| 1699 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, |
| 1700 | spec->gpio_dir); |
| 1701 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 1702 | spec->gpio_data); |
| 1703 | } |
| 1704 | |
| 1705 | init_output(codec); |
| 1706 | init_input(codec); |
| 1707 | init_cs421x_digital(codec); |
| 1708 | |
| 1709 | return 0; |
| 1710 | } |
| 1711 | |
| 1712 | /* |
| 1713 | * CS4210 Input MUX (1 ADC) |
| 1714 | */ |
| 1715 | static int cs421x_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 1716 | struct snd_ctl_elem_info *uinfo) |
| 1717 | { |
| 1718 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1719 | struct cs_spec *spec = codec->spec; |
| 1720 | |
| 1721 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); |
| 1722 | } |
| 1723 | |
| 1724 | static int cs421x_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 1725 | struct snd_ctl_elem_value *ucontrol) |
| 1726 | { |
| 1727 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1728 | struct cs_spec *spec = codec->spec; |
| 1729 | |
| 1730 | ucontrol->value.enumerated.item[0] = spec->cur_input; |
| 1731 | return 0; |
| 1732 | } |
| 1733 | |
| 1734 | static int cs421x_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 1735 | struct snd_ctl_elem_value *ucontrol) |
| 1736 | { |
| 1737 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1738 | struct cs_spec *spec = codec->spec; |
| 1739 | |
| 1740 | return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol, |
| 1741 | spec->adc_nid[0], &spec->cur_input); |
| 1742 | |
| 1743 | } |
| 1744 | |
Daniel J Blueman | 00e17f7 | 2012-11-04 13:19:04 +0800 | [diff] [blame] | 1745 | static const struct snd_kcontrol_new cs421x_capture_source = { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1746 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1747 | .name = "Capture Source", |
| 1748 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, |
| 1749 | .info = cs421x_mux_enum_info, |
| 1750 | .get = cs421x_mux_enum_get, |
| 1751 | .put = cs421x_mux_enum_put, |
| 1752 | }; |
| 1753 | |
| 1754 | static int cs421x_add_input_volume_control(struct hda_codec *codec, int item) |
| 1755 | { |
| 1756 | struct cs_spec *spec = codec->spec; |
| 1757 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1758 | const struct hda_input_mux *imux = &spec->input_mux; |
| 1759 | hda_nid_t pin = cfg->inputs[item].pin; |
| 1760 | struct snd_kcontrol *kctl; |
| 1761 | u32 caps; |
| 1762 | |
| 1763 | if (!(get_wcaps(codec, pin) & AC_WCAP_IN_AMP)) |
| 1764 | return 0; |
| 1765 | |
| 1766 | caps = query_amp_caps(codec, pin, HDA_INPUT); |
| 1767 | caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; |
| 1768 | if (caps <= 1) |
| 1769 | return 0; |
| 1770 | |
| 1771 | return add_volume(codec, imux->items[item].label, 0, |
| 1772 | HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_INPUT), 1, &kctl); |
| 1773 | } |
| 1774 | |
| 1775 | /* add a (input-boost) volume control to the given input pin */ |
| 1776 | static int build_cs421x_input(struct hda_codec *codec) |
| 1777 | { |
| 1778 | struct cs_spec *spec = codec->spec; |
| 1779 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1780 | struct hda_input_mux *imux = &spec->input_mux; |
| 1781 | int i, err, type_idx; |
| 1782 | const char *label; |
| 1783 | |
| 1784 | if (!spec->num_inputs) |
| 1785 | return 0; |
| 1786 | |
| 1787 | /* make bind-capture */ |
| 1788 | spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw); |
| 1789 | spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol); |
| 1790 | for (i = 0; i < 2; i++) { |
| 1791 | struct snd_kcontrol *kctl; |
| 1792 | int n; |
| 1793 | if (!spec->capture_bind[i]) |
| 1794 | return -ENOMEM; |
| 1795 | kctl = snd_ctl_new1(&cs_capture_ctls[i], codec); |
| 1796 | if (!kctl) |
| 1797 | return -ENOMEM; |
| 1798 | kctl->private_value = (long)spec->capture_bind[i]; |
| 1799 | err = snd_hda_ctl_add(codec, 0, kctl); |
| 1800 | if (err < 0) |
| 1801 | return err; |
| 1802 | for (n = 0; n < AUTO_PIN_LAST; n++) { |
| 1803 | if (!spec->adc_nid[n]) |
| 1804 | continue; |
| 1805 | err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[n]); |
| 1806 | if (err < 0) |
| 1807 | return err; |
| 1808 | } |
| 1809 | } |
| 1810 | |
| 1811 | /* Add Input MUX Items + Capture Volume/Switch */ |
| 1812 | for (i = 0; i < spec->num_inputs; i++) { |
| 1813 | label = hda_get_autocfg_input_label(codec, cfg, i); |
| 1814 | snd_hda_add_imux_item(imux, label, spec->adc_idx[i], &type_idx); |
| 1815 | |
| 1816 | err = cs421x_add_input_volume_control(codec, i); |
| 1817 | if (err < 0) |
| 1818 | return err; |
| 1819 | } |
| 1820 | |
| 1821 | /* |
| 1822 | Add 'Capture Source' Switch if |
| 1823 | * 2 inputs and no mic detec |
| 1824 | * 3 inputs |
| 1825 | */ |
| 1826 | if ((spec->num_inputs == 2 && !spec->mic_detect) || |
| 1827 | (spec->num_inputs == 3)) { |
| 1828 | |
| 1829 | err = snd_hda_ctl_add(codec, spec->adc_nid[0], |
| 1830 | snd_ctl_new1(&cs421x_capture_source, codec)); |
| 1831 | if (err < 0) |
| 1832 | return err; |
| 1833 | } |
| 1834 | |
| 1835 | return 0; |
| 1836 | } |
| 1837 | |
| 1838 | /* Single DAC (Mute/Gain) */ |
| 1839 | static int build_cs421x_output(struct hda_codec *codec) |
| 1840 | { |
| 1841 | hda_nid_t dac = CS4210_DAC_NID; |
| 1842 | struct cs_spec *spec = codec->spec; |
| 1843 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1844 | struct snd_kcontrol *kctl; |
| 1845 | int err; |
David Henningsson | 40d03e6 | 2012-01-02 12:40:15 +0100 | [diff] [blame] | 1846 | char *name = "Master"; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1847 | |
| 1848 | fix_volume_caps(codec, dac); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1849 | |
| 1850 | err = add_mute(codec, name, 0, |
| 1851 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); |
| 1852 | if (err < 0) |
| 1853 | return err; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1854 | |
| 1855 | err = add_volume(codec, name, 0, |
| 1856 | HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl); |
| 1857 | if (err < 0) |
| 1858 | return err; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1859 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1860 | if (cfg->speaker_outs && (spec->vendor_nid == CS4210_VENDOR_NID)) { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1861 | err = snd_hda_ctl_add(codec, 0, |
| 1862 | snd_ctl_new1(&cs421x_speaker_bost_ctl, codec)); |
| 1863 | if (err < 0) |
| 1864 | return err; |
| 1865 | } |
| 1866 | return err; |
| 1867 | } |
| 1868 | |
| 1869 | static int cs421x_build_controls(struct hda_codec *codec) |
| 1870 | { |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1871 | struct cs_spec *spec = codec->spec; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1872 | int err; |
| 1873 | |
| 1874 | err = build_cs421x_output(codec); |
| 1875 | if (err < 0) |
| 1876 | return err; |
| 1877 | err = build_cs421x_input(codec); |
| 1878 | if (err < 0) |
| 1879 | return err; |
| 1880 | err = build_digital_output(codec); |
| 1881 | if (err < 0) |
| 1882 | return err; |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1883 | err = cs421x_init(codec); |
| 1884 | if (err < 0) |
| 1885 | return err; |
| 1886 | |
| 1887 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1888 | if (err < 0) |
| 1889 | return err; |
| 1890 | |
| 1891 | return 0; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1892 | } |
| 1893 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1894 | static int parse_cs421x_input(struct hda_codec *codec) |
| 1895 | { |
| 1896 | struct cs_spec *spec = codec->spec; |
| 1897 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1898 | int i; |
| 1899 | |
| 1900 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1901 | hda_nid_t pin = cfg->inputs[i].pin; |
| 1902 | spec->adc_nid[i] = get_adc(codec, pin, &spec->adc_idx[i]); |
| 1903 | spec->cur_input = spec->last_input = i; |
| 1904 | spec->num_inputs++; |
| 1905 | |
| 1906 | /* check whether the automatic mic switch is available */ |
| 1907 | if (is_ext_mic(codec, i) && cfg->num_inputs >= 2) { |
| 1908 | spec->mic_detect = 1; |
| 1909 | spec->automic_idx = i; |
| 1910 | } |
| 1911 | } |
| 1912 | return 0; |
| 1913 | } |
| 1914 | |
| 1915 | static int cs421x_parse_auto_config(struct hda_codec *codec) |
| 1916 | { |
| 1917 | struct cs_spec *spec = codec->spec; |
| 1918 | int err; |
| 1919 | |
| 1920 | err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); |
| 1921 | if (err < 0) |
| 1922 | return err; |
| 1923 | err = parse_output(codec); |
| 1924 | if (err < 0) |
| 1925 | return err; |
| 1926 | err = parse_cs421x_input(codec); |
| 1927 | if (err < 0) |
| 1928 | return err; |
| 1929 | err = parse_digital_output(codec); |
| 1930 | if (err < 0) |
| 1931 | return err; |
| 1932 | return 0; |
| 1933 | } |
| 1934 | |
| 1935 | #ifdef CONFIG_PM |
| 1936 | /* |
| 1937 | Manage PDREF, when transitioning to D3hot |
| 1938 | (DAC,ADC) -> D3, PDREF=1, AFG->D3 |
| 1939 | */ |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 1940 | static int cs421x_suspend(struct hda_codec *codec) |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1941 | { |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1942 | struct cs_spec *spec = codec->spec; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1943 | unsigned int coef; |
| 1944 | |
| 1945 | snd_hda_shutup_pins(codec); |
| 1946 | |
| 1947 | snd_hda_codec_write(codec, CS4210_DAC_NID, 0, |
| 1948 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 1949 | snd_hda_codec_write(codec, CS4210_ADC_NID, 0, |
| 1950 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 1951 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1952 | if (spec->vendor_nid == CS4210_VENDOR_NID) { |
| 1953 | coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); |
| 1954 | coef |= 0x0004; /* PDREF */ |
| 1955 | cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); |
| 1956 | } |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1957 | |
| 1958 | return 0; |
| 1959 | } |
| 1960 | #endif |
| 1961 | |
Daniel J Blueman | 00e17f7 | 2012-11-04 13:19:04 +0800 | [diff] [blame] | 1962 | static const struct hda_codec_ops cs421x_patch_ops = { |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1963 | .build_controls = cs421x_build_controls, |
| 1964 | .build_pcms = cs_build_pcms, |
| 1965 | .init = cs421x_init, |
| 1966 | .free = cs_free, |
David Henningsson | 5c2e4e0 | 2012-10-08 15:44:15 +0200 | [diff] [blame] | 1967 | .unsol_event = snd_hda_jack_unsol_event, |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1968 | #ifdef CONFIG_PM |
| 1969 | .suspend = cs421x_suspend, |
| 1970 | #endif |
| 1971 | }; |
| 1972 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1973 | static int patch_cs4210(struct hda_codec *codec) |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1974 | { |
| 1975 | struct cs_spec *spec; |
| 1976 | int err; |
| 1977 | |
| 1978 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 1979 | if (!spec) |
| 1980 | return -ENOMEM; |
| 1981 | codec->spec = spec; |
Takashi Iwai | b2cbf3b | 2012-10-10 08:53:06 +0200 | [diff] [blame] | 1982 | snd_hda_gen_init(&spec->gen); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1983 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1984 | spec->vendor_nid = CS4210_VENDOR_NID; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1985 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 1986 | snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl, |
| 1987 | cs421x_fixups); |
| 1988 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1989 | |
| 1990 | /* |
| 1991 | Update the GPIO/DMIC/SENSE_B pinmux before the configuration |
| 1992 | is auto-parsed. If GPIO or SENSE_B is forced, DMIC input |
| 1993 | is disabled. |
| 1994 | */ |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 1995 | cs4210_pinmux_init(codec); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 1996 | |
| 1997 | err = cs421x_parse_auto_config(codec); |
| 1998 | if (err < 0) |
| 1999 | goto error; |
| 2000 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 2001 | codec->patch_ops = cs421x_patch_ops; |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 2002 | |
Takashi Iwai | b35aabd | 2012-08-24 19:09:45 +0200 | [diff] [blame] | 2003 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
| 2004 | |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 2005 | return 0; |
| 2006 | |
| 2007 | error: |
Takashi Iwai | c5e0b6d | 2012-10-10 08:50:35 +0200 | [diff] [blame] | 2008 | cs_free(codec); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 2009 | codec->spec = NULL; |
| 2010 | return err; |
| 2011 | } |
| 2012 | |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 2013 | static int patch_cs4213(struct hda_codec *codec) |
| 2014 | { |
| 2015 | struct cs_spec *spec; |
| 2016 | int err; |
| 2017 | |
| 2018 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 2019 | if (!spec) |
| 2020 | return -ENOMEM; |
| 2021 | codec->spec = spec; |
Takashi Iwai | b2cbf3b | 2012-10-10 08:53:06 +0200 | [diff] [blame] | 2022 | snd_hda_gen_init(&spec->gen); |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 2023 | |
| 2024 | spec->vendor_nid = CS4213_VENDOR_NID; |
| 2025 | |
| 2026 | err = cs421x_parse_auto_config(codec); |
| 2027 | if (err < 0) |
| 2028 | goto error; |
| 2029 | |
| 2030 | codec->patch_ops = cs421x_patch_ops; |
| 2031 | return 0; |
| 2032 | |
| 2033 | error: |
Takashi Iwai | c5e0b6d | 2012-10-10 08:50:35 +0200 | [diff] [blame] | 2034 | cs_free(codec); |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 2035 | codec->spec = NULL; |
| 2036 | return err; |
| 2037 | } |
| 2038 | |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 2039 | |
| 2040 | /* |
| 2041 | * patch entries |
| 2042 | */ |
Takashi Iwai | c42d478 | 2011-05-02 11:36:09 +0200 | [diff] [blame] | 2043 | static const struct hda_codec_preset snd_hda_preset_cirrus[] = { |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 2044 | { .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x }, |
| 2045 | { .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x }, |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 2046 | { .id = 0x10134210, .name = "CS4210", .patch = patch_cs4210 }, |
| 2047 | { .id = 0x10134213, .name = "CS4213", .patch = patch_cs4213 }, |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 2048 | {} /* terminator */ |
| 2049 | }; |
| 2050 | |
| 2051 | MODULE_ALIAS("snd-hda-codec-id:10134206"); |
| 2052 | MODULE_ALIAS("snd-hda-codec-id:10134207"); |
Tim Howe | 56487c2 | 2011-07-22 16:41:00 -0500 | [diff] [blame] | 2053 | MODULE_ALIAS("snd-hda-codec-id:10134210"); |
David Henningsson | 5660ffd | 2012-01-02 12:40:17 +0100 | [diff] [blame] | 2054 | MODULE_ALIAS("snd-hda-codec-id:10134213"); |
Takashi Iwai | e5f1424 | 2009-07-01 18:11:44 +0200 | [diff] [blame] | 2055 | |
| 2056 | MODULE_LICENSE("GPL"); |
| 2057 | MODULE_DESCRIPTION("Cirrus Logic HD-audio codec"); |
| 2058 | |
| 2059 | static struct hda_codec_preset_list cirrus_list = { |
| 2060 | .preset = snd_hda_preset_cirrus, |
| 2061 | .owner = THIS_MODULE, |
| 2062 | }; |
| 2063 | |
| 2064 | static int __init patch_cirrus_init(void) |
| 2065 | { |
| 2066 | return snd_hda_add_codec_preset(&cirrus_list); |
| 2067 | } |
| 2068 | |
| 2069 | static void __exit patch_cirrus_exit(void) |
| 2070 | { |
| 2071 | snd_hda_delete_codec_preset(&cirrus_list); |
| 2072 | } |
| 2073 | |
| 2074 | module_init(patch_cirrus_init) |
| 2075 | module_exit(patch_cirrus_exit) |