| 1 | // SPDX-License-Identifier: GPL-2.0-or-later
|
|---|
| 2 | /*
|
|---|
| 3 | * HD audio interface patch for Cirrus Logic CS420x chip
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 2009 Takashi Iwai <tiwai@suse.de>
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include <linux/init.h>
|
|---|
| 9 | #include <linux/slab.h>
|
|---|
| 10 | #include <linux/module.h>
|
|---|
| 11 | #include <sound/core.h>
|
|---|
| 12 | #include <linux/pci.h>
|
|---|
| 13 | #include <sound/tlv.h>
|
|---|
| 14 | #include <sound/hda_codec.h>
|
|---|
| 15 | #include "hda_local.h"
|
|---|
| 16 | #include "hda_auto_parser.h"
|
|---|
| 17 | #include "hda_jack.h"
|
|---|
| 18 | #include "hda_generic.h"
|
|---|
| 19 |
|
|---|
| 20 | #ifdef TARGET_OS2
|
|---|
| 21 | #define KBUILD_MODNAME "patch_cirrus"
|
|---|
| 22 | #endif
|
|---|
| 23 |
|
|---|
| 24 | /*
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | struct cs_spec {
|
|---|
| 28 | struct hda_gen_spec gen;
|
|---|
| 29 |
|
|---|
| 30 | unsigned int gpio_mask;
|
|---|
| 31 | unsigned int gpio_dir;
|
|---|
| 32 | unsigned int gpio_data;
|
|---|
| 33 | unsigned int gpio_eapd_hp; /* EAPD GPIO bit for headphones */
|
|---|
| 34 | unsigned int gpio_eapd_speaker; /* EAPD GPIO bit for speakers */
|
|---|
| 35 |
|
|---|
| 36 | /* CS421x */
|
|---|
| 37 | unsigned int spdif_detect:1;
|
|---|
| 38 | unsigned int spdif_present:1;
|
|---|
| 39 | unsigned int sense_b:1;
|
|---|
| 40 | hda_nid_t vendor_nid;
|
|---|
| 41 |
|
|---|
| 42 | /* for MBP SPDIF control */
|
|---|
| 43 | int (*spdif_sw_put)(struct snd_kcontrol *kcontrol,
|
|---|
| 44 | struct snd_ctl_elem_value *ucontrol);
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 | /* available models with CS420x */
|
|---|
| 48 | enum {
|
|---|
| 49 | CS420X_MBP53,
|
|---|
| 50 | CS420X_MBP55,
|
|---|
| 51 | CS420X_IMAC27,
|
|---|
| 52 | CS420X_GPIO_13,
|
|---|
| 53 | CS420X_GPIO_23,
|
|---|
| 54 | CS420X_MBP101,
|
|---|
| 55 | CS420X_MBP81,
|
|---|
| 56 | CS420X_MBA42,
|
|---|
| 57 | CS420X_AUTO,
|
|---|
| 58 | /* aliases */
|
|---|
| 59 | CS420X_IMAC27_122 = CS420X_GPIO_23,
|
|---|
| 60 | CS420X_APPLE = CS420X_GPIO_13,
|
|---|
| 61 | };
|
|---|
| 62 |
|
|---|
| 63 | /* CS421x boards */
|
|---|
| 64 | enum {
|
|---|
| 65 | CS421X_CDB4210,
|
|---|
| 66 | CS421X_SENSE_B,
|
|---|
| 67 | CS421X_STUMPY,
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 | /* Vendor-specific processing widget */
|
|---|
| 71 | #define CS420X_VENDOR_NID 0x11
|
|---|
| 72 | #define CS_DIG_OUT1_PIN_NID 0x10
|
|---|
| 73 | #define CS_DIG_OUT2_PIN_NID 0x15
|
|---|
| 74 | #define CS_DMIC1_PIN_NID 0x0e
|
|---|
| 75 | #define CS_DMIC2_PIN_NID 0x12
|
|---|
| 76 |
|
|---|
| 77 | /* coef indices */
|
|---|
| 78 | #define IDX_SPDIF_STAT 0x0000
|
|---|
| 79 | #define IDX_SPDIF_CTL 0x0001
|
|---|
| 80 | #define IDX_ADC_CFG 0x0002
|
|---|
| 81 | /* SZC bitmask, 4 modes below:
|
|---|
| 82 | * 0 = immediate,
|
|---|
| 83 | * 1 = digital immediate, analog zero-cross
|
|---|
| 84 | * 2 = digtail & analog soft-ramp
|
|---|
| 85 | * 3 = digital soft-ramp, analog zero-cross
|
|---|
| 86 | */
|
|---|
| 87 | #define CS_COEF_ADC_SZC_MASK (3 << 0)
|
|---|
| 88 | #define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */
|
|---|
| 89 | #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */
|
|---|
| 90 | /* PGA mode: 0 = differential, 1 = signle-ended */
|
|---|
| 91 | #define CS_COEF_ADC_MIC_PGA_MODE (1 << 5) /* PGA setup for mic */
|
|---|
| 92 | #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */
|
|---|
| 93 | #define IDX_DAC_CFG 0x0003
|
|---|
| 94 | /* SZC bitmask, 4 modes below:
|
|---|
| 95 | * 0 = Immediate
|
|---|
| 96 | * 1 = zero-cross
|
|---|
| 97 | * 2 = soft-ramp
|
|---|
| 98 | * 3 = soft-ramp on zero-cross
|
|---|
| 99 | */
|
|---|
| 100 | #define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */
|
|---|
| 101 | #define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */
|
|---|
| 102 | #define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */
|
|---|
| 103 |
|
|---|
| 104 | #define IDX_BEEP_CFG 0x0004
|
|---|
| 105 | /* 0x0008 - test reg key */
|
|---|
| 106 | /* 0x0009 - 0x0014 -> 12 test regs */
|
|---|
| 107 | /* 0x0015 - visibility reg */
|
|---|
| 108 |
|
|---|
| 109 | /* Cirrus Logic CS4208 */
|
|---|
| 110 | #define CS4208_VENDOR_NID 0x24
|
|---|
| 111 |
|
|---|
| 112 | /*
|
|---|
| 113 | * Cirrus Logic CS4210
|
|---|
| 114 | *
|
|---|
| 115 | * 1 DAC => HP(sense) / Speakers,
|
|---|
| 116 | * 1 ADC <= LineIn(sense) / MicIn / DMicIn,
|
|---|
| 117 | * 1 SPDIF OUT => SPDIF Trasmitter(sense)
|
|---|
| 118 | */
|
|---|
| 119 | #define CS4210_DAC_NID 0x02
|
|---|
| 120 | #define CS4210_ADC_NID 0x03
|
|---|
| 121 | #define CS4210_VENDOR_NID 0x0B
|
|---|
| 122 | #define CS421X_DMIC_PIN_NID 0x09 /* Port E */
|
|---|
| 123 | #define CS421X_SPDIF_PIN_NID 0x0A /* Port H */
|
|---|
| 124 |
|
|---|
| 125 | #define CS421X_IDX_DEV_CFG 0x01
|
|---|
| 126 | #define CS421X_IDX_ADC_CFG 0x02
|
|---|
| 127 | #define CS421X_IDX_DAC_CFG 0x03
|
|---|
| 128 | #define CS421X_IDX_SPK_CTL 0x04
|
|---|
| 129 |
|
|---|
| 130 | /* Cirrus Logic CS4213 is like CS4210 but does not have SPDIF input/output */
|
|---|
| 131 | #define CS4213_VENDOR_NID 0x09
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
|
|---|
| 135 | {
|
|---|
| 136 | struct cs_spec *spec = codec->spec;
|
|---|
| 137 |
|
|---|
| 138 | snd_hda_codec_write(codec, spec->vendor_nid, 0,
|
|---|
| 139 | AC_VERB_SET_COEF_INDEX, idx);
|
|---|
| 140 | return snd_hda_codec_read(codec, spec->vendor_nid, 0,
|
|---|
| 141 | AC_VERB_GET_PROC_COEF, 0);
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx,
|
|---|
| 145 | unsigned int coef)
|
|---|
| 146 | {
|
|---|
| 147 | struct cs_spec *spec = codec->spec;
|
|---|
| 148 |
|
|---|
| 149 | snd_hda_codec_write(codec, spec->vendor_nid, 0,
|
|---|
| 150 | AC_VERB_SET_COEF_INDEX, idx);
|
|---|
| 151 | snd_hda_codec_write(codec, spec->vendor_nid, 0,
|
|---|
| 152 | AC_VERB_SET_PROC_COEF, coef);
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | /*
|
|---|
| 156 | * auto-mute and auto-mic switching
|
|---|
| 157 | * CS421x auto-output redirecting
|
|---|
| 158 | * HP/SPK/SPDIF
|
|---|
| 159 | */
|
|---|
| 160 |
|
|---|
| 161 | static void cs_automute(struct hda_codec *codec)
|
|---|
| 162 | {
|
|---|
| 163 | struct cs_spec *spec = codec->spec;
|
|---|
| 164 |
|
|---|
| 165 | /* mute HPs if spdif jack (SENSE_B) is present */
|
|---|
| 166 | spec->gen.master_mute = !!(spec->spdif_present && spec->sense_b);
|
|---|
| 167 |
|
|---|
| 168 | snd_hda_gen_update_outputs(codec);
|
|---|
| 169 |
|
|---|
| 170 | if (spec->gpio_eapd_hp || spec->gpio_eapd_speaker) {
|
|---|
| 171 | if (spec->gen.automute_speaker)
|
|---|
| 172 | spec->gpio_data = spec->gen.hp_jack_present ?
|
|---|
| 173 | spec->gpio_eapd_hp : spec->gpio_eapd_speaker;
|
|---|
| 174 | else
|
|---|
| 175 | spec->gpio_data =
|
|---|
| 176 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
|
|---|
| 177 | snd_hda_codec_write(codec, 0x01, 0,
|
|---|
| 178 | AC_VERB_SET_GPIO_DATA, spec->gpio_data);
|
|---|
| 179 | }
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | static bool is_active_pin(struct hda_codec *codec, hda_nid_t nid)
|
|---|
| 183 | {
|
|---|
| 184 | unsigned int val;
|
|---|
| 185 |
|
|---|
| 186 | val = snd_hda_codec_get_pincfg(codec, nid);
|
|---|
| 187 | return (get_defcfg_connect(val) != AC_JACK_PORT_NONE);
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | static void init_input_coef(struct hda_codec *codec)
|
|---|
| 191 | {
|
|---|
| 192 | struct cs_spec *spec = codec->spec;
|
|---|
| 193 | unsigned int coef;
|
|---|
| 194 |
|
|---|
| 195 | /* CS420x has multiple ADC, CS421x has single ADC */
|
|---|
| 196 | if (spec->vendor_nid == CS420X_VENDOR_NID) {
|
|---|
| 197 | coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG);
|
|---|
| 198 | if (is_active_pin(codec, CS_DMIC2_PIN_NID))
|
|---|
| 199 | coef |= 1 << 4; /* DMIC2 2 chan on, GPIO1 off */
|
|---|
| 200 | if (is_active_pin(codec, CS_DMIC1_PIN_NID))
|
|---|
| 201 | coef |= 1 << 3; /* DMIC1 2 chan on, GPIO0 off
|
|---|
| 202 | * No effect if SPDIF_OUT2 is
|
|---|
| 203 | * selected in IDX_SPDIF_CTL.
|
|---|
| 204 | */
|
|---|
| 205 |
|
|---|
| 206 | cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef);
|
|---|
| 207 | }
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | static const struct hda_verb cs_coef_init_verbs[] = {
|
|---|
| 211 | {0x11, AC_VERB_SET_PROC_STATE, 1},
|
|---|
| 212 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG},
|
|---|
| 213 | {0x11, AC_VERB_SET_PROC_COEF,
|
|---|
| 214 | (0x002a /* DAC1/2/3 SZCMode Soft Ramp */
|
|---|
| 215 | | 0x0040 /* Mute DACs on FIFO error */
|
|---|
| 216 | | 0x1000 /* Enable DACs High Pass Filter */
|
|---|
| 217 | | 0x0400 /* Disable Coefficient Auto increment */
|
|---|
| 218 | )},
|
|---|
| 219 | /* ADC1/2 - Digital and Analog Soft Ramp */
|
|---|
| 220 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_ADC_CFG},
|
|---|
| 221 | {0x11, AC_VERB_SET_PROC_COEF, 0x000a},
|
|---|
| 222 | /* Beep */
|
|---|
| 223 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_BEEP_CFG},
|
|---|
| 224 | {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */
|
|---|
| 225 |
|
|---|
| 226 | {0} /* terminator */
|
|---|
| 227 | };
|
|---|
| 228 |
|
|---|
| 229 | static const struct hda_verb cs4208_coef_init_verbs[] = {
|
|---|
| 230 | {0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */
|
|---|
| 231 | {0x24, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
|
|---|
| 232 | {0x24, AC_VERB_SET_COEF_INDEX, 0x0033},
|
|---|
| 233 | {0x24, AC_VERB_SET_PROC_COEF, 0x0001}, /* A1 ICS */
|
|---|
| 234 | {0x24, AC_VERB_SET_COEF_INDEX, 0x0034},
|
|---|
| 235 | {0x24, AC_VERB_SET_PROC_COEF, 0x1C01}, /* A1 Enable, A Thresh = 300mV */
|
|---|
| 236 | {0} /* terminator */
|
|---|
| 237 | };
|
|---|
| 238 |
|
|---|
| 239 | /* Errata: CS4207 rev C0/C1/C2 Silicon
|
|---|
| 240 | *
|
|---|
| 241 | * http://www.cirrus.com/en/pubs/errata/ER880C3.pdf
|
|---|
| 242 | *
|
|---|
| 243 | * 6. At high temperature (TA > +85°C), the digital supply current (IVD)
|
|---|
| 244 | * may be excessive (up to an additional 200 ÎŒA), which is most easily
|
|---|
| 245 | * observed while the part is being held in reset (RESET# active low).
|
|---|
| 246 | *
|
|---|
| 247 | * Root Cause: At initial powerup of the device, the logic that drives
|
|---|
| 248 | * the clock and write enable to the S/PDIF SRC RAMs is not properly
|
|---|
| 249 | * initialized.
|
|---|
| 250 | * Certain random patterns will cause a steady leakage current in those
|
|---|
| 251 | * RAM cells. The issue will resolve once the SRCs are used (turned on).
|
|---|
| 252 | *
|
|---|
| 253 | * Workaround: The following verb sequence briefly turns on the S/PDIF SRC
|
|---|
| 254 | * blocks, which will alleviate the issue.
|
|---|
| 255 | */
|
|---|
| 256 |
|
|---|
| 257 | static const struct hda_verb cs_errata_init_verbs[] = {
|
|---|
| 258 | {0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */
|
|---|
| 259 | {0x11, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
|
|---|
| 260 |
|
|---|
| 261 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0008},
|
|---|
| 262 | {0x11, AC_VERB_SET_PROC_COEF, 0x9999},
|
|---|
| 263 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0017},
|
|---|
| 264 | {0x11, AC_VERB_SET_PROC_COEF, 0xa412},
|
|---|
| 265 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0001},
|
|---|
| 266 | {0x11, AC_VERB_SET_PROC_COEF, 0x0009},
|
|---|
| 267 |
|
|---|
| 268 | {0x07, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Rx: D0 */
|
|---|
| 269 | {0x08, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Tx: D0 */
|
|---|
| 270 |
|
|---|
| 271 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0017},
|
|---|
| 272 | {0x11, AC_VERB_SET_PROC_COEF, 0x2412},
|
|---|
| 273 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0008},
|
|---|
| 274 | {0x11, AC_VERB_SET_PROC_COEF, 0x0000},
|
|---|
| 275 | {0x11, AC_VERB_SET_COEF_INDEX, 0x0001},
|
|---|
| 276 | {0x11, AC_VERB_SET_PROC_COEF, 0x0008},
|
|---|
| 277 | {0x11, AC_VERB_SET_PROC_STATE, 0x00},
|
|---|
| 278 | {0} /* terminator */
|
|---|
| 279 | };
|
|---|
| 280 |
|
|---|
| 281 | /* SPDIF setup */
|
|---|
| 282 | static void init_digital_coef(struct hda_codec *codec)
|
|---|
| 283 | {
|
|---|
| 284 | unsigned int coef;
|
|---|
| 285 |
|
|---|
| 286 | coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */
|
|---|
| 287 | coef |= 0x0008; /* Replace with mute on error */
|
|---|
| 288 | if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID))
|
|---|
| 289 | coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2
|
|---|
| 290 | * SPDIF_OUT2 is shared with GPIO1 and
|
|---|
| 291 | * DMIC_SDA2.
|
|---|
| 292 | */
|
|---|
| 293 | cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef);
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | static int cs_init(struct hda_codec *codec)
|
|---|
| 297 | {
|
|---|
| 298 | struct cs_spec *spec = codec->spec;
|
|---|
| 299 |
|
|---|
| 300 | if (spec->vendor_nid == CS420X_VENDOR_NID) {
|
|---|
| 301 | /* init_verb sequence for C0/C1/C2 errata*/
|
|---|
| 302 | snd_hda_sequence_write(codec, cs_errata_init_verbs);
|
|---|
| 303 | snd_hda_sequence_write(codec, cs_coef_init_verbs);
|
|---|
| 304 | } else if (spec->vendor_nid == CS4208_VENDOR_NID) {
|
|---|
| 305 | snd_hda_sequence_write(codec, cs4208_coef_init_verbs);
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | snd_hda_gen_init(codec);
|
|---|
| 309 |
|
|---|
| 310 | if (spec->gpio_mask) {
|
|---|
| 311 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
|
|---|
| 312 | spec->gpio_mask);
|
|---|
| 313 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
|
|---|
| 314 | spec->gpio_dir);
|
|---|
| 315 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
|
|---|
| 316 | spec->gpio_data);
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | if (spec->vendor_nid == CS420X_VENDOR_NID) {
|
|---|
| 320 | init_input_coef(codec);
|
|---|
| 321 | init_digital_coef(codec);
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | return 0;
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | static int cs_build_controls(struct hda_codec *codec)
|
|---|
| 328 | {
|
|---|
| 329 | int err;
|
|---|
| 330 |
|
|---|
| 331 | err = snd_hda_gen_build_controls(codec);
|
|---|
| 332 | if (err < 0)
|
|---|
| 333 | return err;
|
|---|
| 334 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
|
|---|
| 335 | return 0;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | #define cs_free snd_hda_gen_free
|
|---|
| 339 |
|
|---|
| 340 | static const struct hda_codec_ops cs_patch_ops = {
|
|---|
| 341 | .build_controls = cs_build_controls,
|
|---|
| 342 | .build_pcms = snd_hda_gen_build_pcms,
|
|---|
| 343 | .init = cs_init,
|
|---|
| 344 | .free = cs_free,
|
|---|
| 345 | .unsol_event = snd_hda_jack_unsol_event,
|
|---|
| 346 | };
|
|---|
| 347 |
|
|---|
| 348 | static int cs_parse_auto_config(struct hda_codec *codec)
|
|---|
| 349 | {
|
|---|
| 350 | struct cs_spec *spec = codec->spec;
|
|---|
| 351 | int err;
|
|---|
| 352 | int i;
|
|---|
| 353 |
|
|---|
| 354 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
|
|---|
| 355 | if (err < 0)
|
|---|
| 356 | return err;
|
|---|
| 357 |
|
|---|
| 358 | err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
|
|---|
| 359 | if (err < 0)
|
|---|
| 360 | return err;
|
|---|
| 361 |
|
|---|
| 362 | /* keep the ADCs powered up when it's dynamically switchable */
|
|---|
| 363 | if (spec->gen.dyn_adc_switch) {
|
|---|
| 364 | unsigned int done = 0;
|
|---|
| 365 |
|
|---|
| 366 | for (i = 0; i < spec->gen.input_mux.num_items; i++) {
|
|---|
| 367 | int idx = spec->gen.dyn_adc_idx[i];
|
|---|
| 368 |
|
|---|
| 369 | if (done & (1 << idx))
|
|---|
| 370 | continue;
|
|---|
| 371 | snd_hda_gen_fix_pin_power(codec,
|
|---|
| 372 | spec->gen.adc_nids[idx]);
|
|---|
| 373 | done |= 1 << idx;
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | return 0;
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | static const struct hda_model_fixup cs420x_models[] = {
|
|---|
| 381 | { .id = CS420X_MBP53, .name = "mbp53" },
|
|---|
| 382 | { .id = CS420X_MBP55, .name = "mbp55" },
|
|---|
| 383 | { .id = CS420X_IMAC27, .name = "imac27" },
|
|---|
| 384 | { .id = CS420X_IMAC27_122, .name = "imac27_122" },
|
|---|
| 385 | { .id = CS420X_APPLE, .name = "apple" },
|
|---|
| 386 | { .id = CS420X_MBP101, .name = "mbp101" },
|
|---|
| 387 | { .id = CS420X_MBP81, .name = "mbp81" },
|
|---|
| 388 | { .id = CS420X_MBA42, .name = "mba42" },
|
|---|
| 389 | {0}
|
|---|
| 390 | };
|
|---|
| 391 |
|
|---|
| 392 | static const struct hda_quirk cs420x_fixup_tbl[] = {
|
|---|
| 393 | SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53),
|
|---|
| 394 | SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55),
|
|---|
| 395 | SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55),
|
|---|
| 396 | SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55),
|
|---|
| 397 | /* this conflicts with too many other models */
|
|---|
| 398 | /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
|
|---|
| 399 |
|
|---|
| 400 | /* codec SSID */
|
|---|
| 401 | SND_PCI_QUIRK(0x106b, 0x0600, "iMac 14,1", CS420X_IMAC27_122),
|
|---|
| 402 | SND_PCI_QUIRK(0x106b, 0x0900, "iMac 12,1", CS420X_IMAC27_122),
|
|---|
| 403 | SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
|
|---|
| 404 | SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
|
|---|
| 405 | SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
|
|---|
| 406 | SND_PCI_QUIRK(0x106b, 0x5600, "MacBookAir 5,2", CS420X_MBP81),
|
|---|
| 407 | SND_PCI_QUIRK(0x106b, 0x5b00, "MacBookAir 4,2", CS420X_MBA42),
|
|---|
| 408 | SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
|
|---|
| 409 | {0} /* terminator */
|
|---|
| 410 | };
|
|---|
| 411 |
|
|---|
| 412 | static const struct hda_pintbl mbp53_pincfgs[] = {
|
|---|
| 413 | { 0x09, 0x012b4050 },
|
|---|
| 414 | { 0x0a, 0x90100141 },
|
|---|
| 415 | { 0x0b, 0x90100140 },
|
|---|
| 416 | { 0x0c, 0x018b3020 },
|
|---|
| 417 | { 0x0d, 0x90a00110 },
|
|---|
| 418 | { 0x0e, 0x400000f0 },
|
|---|
| 419 | { 0x0f, 0x01cbe030 },
|
|---|
| 420 | { 0x10, 0x014be060 },
|
|---|
| 421 | { 0x12, 0x400000f0 },
|
|---|
| 422 | { 0x15, 0x400000f0 },
|
|---|
| 423 | {0} /* terminator */
|
|---|
| 424 | };
|
|---|
| 425 |
|
|---|
| 426 | static const struct hda_pintbl mbp55_pincfgs[] = {
|
|---|
| 427 | { 0x09, 0x012b4030 },
|
|---|
| 428 | { 0x0a, 0x90100121 },
|
|---|
| 429 | { 0x0b, 0x90100120 },
|
|---|
| 430 | { 0x0c, 0x400000f0 },
|
|---|
| 431 | { 0x0d, 0x90a00110 },
|
|---|
| 432 | { 0x0e, 0x400000f0 },
|
|---|
| 433 | { 0x0f, 0x400000f0 },
|
|---|
| 434 | { 0x10, 0x014be040 },
|
|---|
| 435 | { 0x12, 0x400000f0 },
|
|---|
| 436 | { 0x15, 0x400000f0 },
|
|---|
| 437 | {0} /* terminator */
|
|---|
| 438 | };
|
|---|
| 439 |
|
|---|
| 440 | static const struct hda_pintbl imac27_pincfgs[] = {
|
|---|
| 441 | { 0x09, 0x012b4050 },
|
|---|
| 442 | { 0x0a, 0x90100140 },
|
|---|
| 443 | { 0x0b, 0x90100142 },
|
|---|
| 444 | { 0x0c, 0x018b3020 },
|
|---|
| 445 | { 0x0d, 0x90a00110 },
|
|---|
| 446 | { 0x0e, 0x400000f0 },
|
|---|
| 447 | { 0x0f, 0x01cbe030 },
|
|---|
| 448 | { 0x10, 0x014be060 },
|
|---|
| 449 | { 0x12, 0x01ab9070 },
|
|---|
| 450 | { 0x15, 0x400000f0 },
|
|---|
| 451 | {0} /* terminator */
|
|---|
| 452 | };
|
|---|
| 453 |
|
|---|
| 454 | static const struct hda_pintbl mbp101_pincfgs[] = {
|
|---|
| 455 | { 0x0d, 0x40ab90f0 },
|
|---|
| 456 | { 0x0e, 0x90a600f0 },
|
|---|
| 457 | { 0x12, 0x50a600f0 },
|
|---|
| 458 | {0} /* terminator */
|
|---|
| 459 | };
|
|---|
| 460 |
|
|---|
| 461 | static const struct hda_pintbl mba42_pincfgs[] = {
|
|---|
| 462 | { 0x09, 0x012b4030 }, /* HP */
|
|---|
| 463 | { 0x0a, 0x400000f0 },
|
|---|
| 464 | { 0x0b, 0x90100120 }, /* speaker */
|
|---|
| 465 | { 0x0c, 0x400000f0 },
|
|---|
| 466 | { 0x0d, 0x90a00110 }, /* mic */
|
|---|
| 467 | { 0x0e, 0x400000f0 },
|
|---|
| 468 | { 0x0f, 0x400000f0 },
|
|---|
| 469 | { 0x10, 0x400000f0 },
|
|---|
| 470 | { 0x12, 0x400000f0 },
|
|---|
| 471 | { 0x15, 0x400000f0 },
|
|---|
| 472 | {0} /* terminator */
|
|---|
| 473 | };
|
|---|
| 474 |
|
|---|
| 475 | static const struct hda_pintbl mba6_pincfgs[] = {
|
|---|
| 476 | { 0x10, 0x032120f0 }, /* HP */
|
|---|
| 477 | { 0x11, 0x500000f0 },
|
|---|
| 478 | { 0x12, 0x90100010 }, /* Speaker */
|
|---|
| 479 | { 0x13, 0x500000f0 },
|
|---|
| 480 | { 0x14, 0x500000f0 },
|
|---|
| 481 | { 0x15, 0x770000f0 },
|
|---|
| 482 | { 0x16, 0x770000f0 },
|
|---|
| 483 | { 0x17, 0x430000f0 },
|
|---|
| 484 | { 0x18, 0x43ab9030 }, /* Mic */
|
|---|
| 485 | { 0x19, 0x770000f0 },
|
|---|
| 486 | { 0x1a, 0x770000f0 },
|
|---|
| 487 | { 0x1b, 0x770000f0 },
|
|---|
| 488 | { 0x1c, 0x90a00090 },
|
|---|
| 489 | { 0x1d, 0x500000f0 },
|
|---|
| 490 | { 0x1e, 0x500000f0 },
|
|---|
| 491 | { 0x1f, 0x500000f0 },
|
|---|
| 492 | { 0x20, 0x500000f0 },
|
|---|
| 493 | { 0x21, 0x430000f0 },
|
|---|
| 494 | { 0x22, 0x430000f0 },
|
|---|
| 495 | {0} /* terminator */
|
|---|
| 496 | };
|
|---|
| 497 |
|
|---|
| 498 | static void cs420x_fixup_gpio_13(struct hda_codec *codec,
|
|---|
| 499 | const struct hda_fixup *fix, int action)
|
|---|
| 500 | {
|
|---|
| 501 | if (action == HDA_FIXUP_ACT_PRE_PROBE) {
|
|---|
| 502 | struct cs_spec *spec = codec->spec;
|
|---|
| 503 |
|
|---|
| 504 | spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */
|
|---|
| 505 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
|
|---|
| 506 | spec->gpio_mask = spec->gpio_dir =
|
|---|
| 507 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | static void cs420x_fixup_gpio_23(struct hda_codec *codec,
|
|---|
| 512 | const struct hda_fixup *fix, int action)
|
|---|
| 513 | {
|
|---|
| 514 | if (action == HDA_FIXUP_ACT_PRE_PROBE) {
|
|---|
| 515 | struct cs_spec *spec = codec->spec;
|
|---|
| 516 |
|
|---|
| 517 | spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */
|
|---|
| 518 | spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */
|
|---|
| 519 | spec->gpio_mask = spec->gpio_dir =
|
|---|
| 520 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
|
|---|
| 521 | }
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 | static const struct hda_fixup cs420x_fixups[] = {
|
|---|
| 525 | [CS420X_MBP53] = {
|
|---|
| 526 | .type = HDA_FIXUP_PINS,
|
|---|
| 527 | .v.pins = mbp53_pincfgs,
|
|---|
| 528 | .chained = true,
|
|---|
| 529 | .chain_id = CS420X_APPLE,
|
|---|
| 530 | },
|
|---|
| 531 | [CS420X_MBP55] = {
|
|---|
| 532 | .type = HDA_FIXUP_PINS,
|
|---|
| 533 | .v.pins = mbp55_pincfgs,
|
|---|
| 534 | .chained = true,
|
|---|
| 535 | .chain_id = CS420X_GPIO_13,
|
|---|
| 536 | },
|
|---|
| 537 | [CS420X_IMAC27] = {
|
|---|
| 538 | .type = HDA_FIXUP_PINS,
|
|---|
| 539 | .v.pins = imac27_pincfgs,
|
|---|
| 540 | .chained = true,
|
|---|
| 541 | .chain_id = CS420X_GPIO_13,
|
|---|
| 542 | },
|
|---|
| 543 | [CS420X_GPIO_13] = {
|
|---|
| 544 | .type = HDA_FIXUP_FUNC,
|
|---|
| 545 | .v.func = cs420x_fixup_gpio_13,
|
|---|
| 546 | },
|
|---|
| 547 | [CS420X_GPIO_23] = {
|
|---|
| 548 | .type = HDA_FIXUP_FUNC,
|
|---|
| 549 | .v.func = cs420x_fixup_gpio_23,
|
|---|
| 550 | },
|
|---|
| 551 | [CS420X_MBP101] = {
|
|---|
| 552 | .type = HDA_FIXUP_PINS,
|
|---|
| 553 | .v.pins = mbp101_pincfgs,
|
|---|
| 554 | .chained = true,
|
|---|
| 555 | .chain_id = CS420X_GPIO_13,
|
|---|
| 556 | },
|
|---|
| 557 | #ifndef TARGET_OS2
|
|---|
| 558 | [CS420X_MBP81] = {
|
|---|
| 559 | .type = HDA_FIXUP_VERBS,
|
|---|
| 560 | .v.verbs = (const struct hda_verb[]) {
|
|---|
| 561 | /* internal mic ADC2: right only, single ended */
|
|---|
| 562 | {0x11, AC_VERB_SET_COEF_INDEX, IDX_ADC_CFG},
|
|---|
| 563 | {0x11, AC_VERB_SET_PROC_COEF, 0x102a},
|
|---|
| 564 | {0}
|
|---|
| 565 | },
|
|---|
| 566 | .chained = true,
|
|---|
| 567 | .chain_id = CS420X_GPIO_13,
|
|---|
| 568 | },
|
|---|
| 569 | #endif
|
|---|
| 570 | [CS420X_MBA42] = {
|
|---|
| 571 | .type = HDA_FIXUP_PINS,
|
|---|
| 572 | .v.pins = mba42_pincfgs,
|
|---|
| 573 | .chained = true,
|
|---|
| 574 | .chain_id = CS420X_GPIO_13,
|
|---|
| 575 | },
|
|---|
| 576 | };
|
|---|
| 577 |
|
|---|
| 578 | static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid)
|
|---|
| 579 | {
|
|---|
| 580 | struct cs_spec *spec;
|
|---|
| 581 |
|
|---|
| 582 | spec = kzalloc(sizeof(*spec), GFP_KERNEL);
|
|---|
| 583 | if (!spec)
|
|---|
| 584 | return NULL;
|
|---|
| 585 | codec->spec = spec;
|
|---|
| 586 | spec->vendor_nid = vendor_nid;
|
|---|
| 587 | codec->power_save_node = 1;
|
|---|
| 588 | snd_hda_gen_spec_init(&spec->gen);
|
|---|
| 589 |
|
|---|
| 590 | return spec;
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | static int patch_cs420x(struct hda_codec *codec)
|
|---|
| 594 | {
|
|---|
| 595 | struct cs_spec *spec;
|
|---|
| 596 | int err;
|
|---|
| 597 |
|
|---|
| 598 | spec = cs_alloc_spec(codec, CS420X_VENDOR_NID);
|
|---|
| 599 | if (!spec)
|
|---|
| 600 | return -ENOMEM;
|
|---|
| 601 |
|
|---|
| 602 | codec->patch_ops = cs_patch_ops;
|
|---|
| 603 | spec->gen.automute_hook = cs_automute;
|
|---|
| 604 | codec->single_adc_amp = 1;
|
|---|
| 605 |
|
|---|
| 606 | snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl,
|
|---|
| 607 | cs420x_fixups);
|
|---|
| 608 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
|
|---|
| 609 |
|
|---|
| 610 | err = cs_parse_auto_config(codec);
|
|---|
| 611 | if (err < 0)
|
|---|
| 612 | goto error;
|
|---|
| 613 |
|
|---|
| 614 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
|
|---|
| 615 |
|
|---|
| 616 | return 0;
|
|---|
| 617 |
|
|---|
| 618 | error:
|
|---|
| 619 | cs_free(codec);
|
|---|
| 620 | return err;
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 | /*
|
|---|
| 624 | * CS4208 support:
|
|---|
| 625 | * Its layout is no longer compatible with CS4206/CS4207
|
|---|
| 626 | */
|
|---|
| 627 | enum {
|
|---|
| 628 | CS4208_MAC_AUTO,
|
|---|
| 629 | CS4208_MBA6,
|
|---|
| 630 | CS4208_MBP11,
|
|---|
| 631 | CS4208_MACMINI,
|
|---|
| 632 | CS4208_GPIO0,
|
|---|
| 633 | };
|
|---|
| 634 |
|
|---|
| 635 | static const struct hda_model_fixup cs4208_models[] = {
|
|---|
| 636 | { .id = CS4208_GPIO0, .name = "gpio0" },
|
|---|
| 637 | { .id = CS4208_MBA6, .name = "mba6" },
|
|---|
| 638 | { .id = CS4208_MBP11, .name = "mbp11" },
|
|---|
| 639 | { .id = CS4208_MACMINI, .name = "macmini" },
|
|---|
| 640 | {0}
|
|---|
| 641 | };
|
|---|
| 642 |
|
|---|
| 643 | static const struct hda_quirk cs4208_fixup_tbl[] = {
|
|---|
| 644 | SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS4208_MAC_AUTO),
|
|---|
| 645 | {0} /* terminator */
|
|---|
| 646 | };
|
|---|
| 647 |
|
|---|
| 648 | /* codec SSID matching */
|
|---|
| 649 | static const struct hda_quirk cs4208_mac_fixup_tbl[] = {
|
|---|
| 650 | SND_PCI_QUIRK(0x106b, 0x5e00, "MacBookPro 11,2", CS4208_MBP11),
|
|---|
| 651 | SND_PCI_QUIRK(0x106b, 0x6c00, "MacMini 7,1", CS4208_MACMINI),
|
|---|
| 652 | SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6),
|
|---|
| 653 | SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6),
|
|---|
| 654 | SND_PCI_QUIRK(0x106b, 0x7b00, "MacBookPro 12,1", CS4208_MBP11),
|
|---|
| 655 | {0} /* terminator */
|
|---|
| 656 | };
|
|---|
| 657 |
|
|---|
| 658 | static void cs4208_fixup_gpio0(struct hda_codec *codec,
|
|---|
| 659 | const struct hda_fixup *fix, int action)
|
|---|
| 660 | {
|
|---|
| 661 | if (action == HDA_FIXUP_ACT_PRE_PROBE) {
|
|---|
| 662 | struct cs_spec *spec = codec->spec;
|
|---|
| 663 |
|
|---|
| 664 | spec->gpio_eapd_hp = 0;
|
|---|
| 665 | spec->gpio_eapd_speaker = 1;
|
|---|
| 666 | spec->gpio_mask = spec->gpio_dir =
|
|---|
| 667 | spec->gpio_eapd_hp | spec->gpio_eapd_speaker;
|
|---|
| 668 | }
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | static const struct hda_fixup cs4208_fixups[];
|
|---|
| 672 |
|
|---|
| 673 | /* remap the fixup from codec SSID and apply it */
|
|---|
| 674 | static void cs4208_fixup_mac(struct hda_codec *codec,
|
|---|
| 675 | const struct hda_fixup *fix, int action)
|
|---|
| 676 | {
|
|---|
| 677 | if (action != HDA_FIXUP_ACT_PRE_PROBE)
|
|---|
| 678 | return;
|
|---|
| 679 |
|
|---|
| 680 | codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
|
|---|
| 681 | snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups);
|
|---|
| 682 | if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET)
|
|---|
| 683 | codec->fixup_id = CS4208_GPIO0; /* default fixup */
|
|---|
| 684 | snd_hda_apply_fixup(codec, action);
|
|---|
| 685 | }
|
|---|
| 686 |
|
|---|
| 687 | /* MacMini 7,1 has the inverted jack detection */
|
|---|
| 688 | static void cs4208_fixup_macmini(struct hda_codec *codec,
|
|---|
| 689 | const struct hda_fixup *fix, int action)
|
|---|
| 690 | {
|
|---|
| 691 | static const struct hda_pintbl pincfgs[] = {
|
|---|
| 692 | { 0x18, 0x00ab9150 }, /* mic (audio-in) jack: disable detect */
|
|---|
| 693 | { 0x21, 0x004be140 }, /* SPDIF: disable detect */
|
|---|
| 694 | {0}
|
|---|
| 695 | };
|
|---|
| 696 |
|
|---|
| 697 | if (action == HDA_FIXUP_ACT_PRE_PROBE) {
|
|---|
| 698 | /* HP pin (0x10) has an inverted detection */
|
|---|
| 699 | codec->inv_jack_detect = 1;
|
|---|
| 700 | /* disable the bogus Mic and SPDIF jack detections */
|
|---|
| 701 | snd_hda_apply_pincfgs(codec, pincfgs);
|
|---|
| 702 | }
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 | static int cs4208_spdif_sw_put(struct snd_kcontrol *kcontrol,
|
|---|
| 706 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 707 | {
|
|---|
| 708 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 709 | struct cs_spec *spec = codec->spec;
|
|---|
| 710 | hda_nid_t pin = spec->gen.autocfg.dig_out_pins[0];
|
|---|
| 711 | int pinctl = ucontrol->value.integer.value[0] ? PIN_OUT : 0;
|
|---|
| 712 |
|
|---|
| 713 | snd_hda_set_pin_ctl_cache(codec, pin, pinctl);
|
|---|
| 714 | return spec->spdif_sw_put(kcontrol, ucontrol);
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | /* hook the SPDIF switch */
|
|---|
| 718 | static void cs4208_fixup_spdif_switch(struct hda_codec *codec,
|
|---|
| 719 | const struct hda_fixup *fix, int action)
|
|---|
| 720 | {
|
|---|
| 721 | if (action == HDA_FIXUP_ACT_BUILD) {
|
|---|
| 722 | struct cs_spec *spec = codec->spec;
|
|---|
| 723 | struct snd_kcontrol *kctl;
|
|---|
| 724 |
|
|---|
| 725 | if (!spec->gen.autocfg.dig_out_pins[0])
|
|---|
| 726 | return;
|
|---|
| 727 | kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch");
|
|---|
| 728 | if (!kctl)
|
|---|
| 729 | return;
|
|---|
| 730 | spec->spdif_sw_put = kctl->put;
|
|---|
| 731 | kctl->put = cs4208_spdif_sw_put;
|
|---|
| 732 | }
|
|---|
| 733 | }
|
|---|
| 734 |
|
|---|
| 735 | static const struct hda_fixup cs4208_fixups[] = {
|
|---|
| 736 | [CS4208_MBA6] = {
|
|---|
| 737 | .type = HDA_FIXUP_PINS,
|
|---|
| 738 | .v.pins = mba6_pincfgs,
|
|---|
| 739 | .chained = true,
|
|---|
| 740 | .chain_id = CS4208_GPIO0,
|
|---|
| 741 | },
|
|---|
| 742 | [CS4208_MBP11] = {
|
|---|
| 743 | .type = HDA_FIXUP_FUNC,
|
|---|
| 744 | .v.func = cs4208_fixup_spdif_switch,
|
|---|
| 745 | .chained = true,
|
|---|
| 746 | .chain_id = CS4208_GPIO0,
|
|---|
| 747 | },
|
|---|
| 748 | [CS4208_MACMINI] = {
|
|---|
| 749 | .type = HDA_FIXUP_FUNC,
|
|---|
| 750 | .v.func = cs4208_fixup_macmini,
|
|---|
| 751 | .chained = true,
|
|---|
| 752 | .chain_id = CS4208_GPIO0,
|
|---|
| 753 | },
|
|---|
| 754 | [CS4208_GPIO0] = {
|
|---|
| 755 | .type = HDA_FIXUP_FUNC,
|
|---|
| 756 | .v.func = cs4208_fixup_gpio0,
|
|---|
| 757 | },
|
|---|
| 758 | [CS4208_MAC_AUTO] = {
|
|---|
| 759 | .type = HDA_FIXUP_FUNC,
|
|---|
| 760 | .v.func = cs4208_fixup_mac,
|
|---|
| 761 | },
|
|---|
| 762 | };
|
|---|
| 763 |
|
|---|
| 764 | /* correct the 0dB offset of input pins */
|
|---|
| 765 | static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc)
|
|---|
| 766 | {
|
|---|
| 767 | unsigned int caps;
|
|---|
| 768 |
|
|---|
| 769 | caps = query_amp_caps(codec, adc, HDA_INPUT);
|
|---|
| 770 | caps &= ~(AC_AMPCAP_OFFSET);
|
|---|
| 771 | caps |= 0x02;
|
|---|
| 772 | snd_hda_override_amp_caps(codec, adc, HDA_INPUT, caps);
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 | static int patch_cs4208(struct hda_codec *codec)
|
|---|
| 776 | {
|
|---|
| 777 | struct cs_spec *spec;
|
|---|
| 778 | int err;
|
|---|
| 779 |
|
|---|
| 780 | spec = cs_alloc_spec(codec, CS4208_VENDOR_NID);
|
|---|
| 781 | if (!spec)
|
|---|
| 782 | return -ENOMEM;
|
|---|
| 783 |
|
|---|
| 784 | codec->patch_ops = cs_patch_ops;
|
|---|
| 785 | spec->gen.automute_hook = cs_automute;
|
|---|
| 786 | /* exclude NID 0x10 (HP) from output volumes due to different steps */
|
|---|
| 787 | spec->gen.out_vol_mask = 1ULL << 0x10;
|
|---|
| 788 |
|
|---|
| 789 | snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl,
|
|---|
| 790 | cs4208_fixups);
|
|---|
| 791 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
|
|---|
| 792 |
|
|---|
| 793 | snd_hda_override_wcaps(codec, 0x18,
|
|---|
| 794 | get_wcaps(codec, 0x18) | AC_WCAP_STEREO);
|
|---|
| 795 | cs4208_fix_amp_caps(codec, 0x18);
|
|---|
| 796 | cs4208_fix_amp_caps(codec, 0x1b);
|
|---|
| 797 | cs4208_fix_amp_caps(codec, 0x1c);
|
|---|
| 798 |
|
|---|
| 799 | err = cs_parse_auto_config(codec);
|
|---|
| 800 | if (err < 0)
|
|---|
| 801 | goto error;
|
|---|
| 802 |
|
|---|
| 803 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
|
|---|
| 804 |
|
|---|
| 805 | return 0;
|
|---|
| 806 |
|
|---|
| 807 | error:
|
|---|
| 808 | cs_free(codec);
|
|---|
| 809 | return err;
|
|---|
| 810 | }
|
|---|
| 811 |
|
|---|
| 812 | /*
|
|---|
| 813 | * Cirrus Logic CS4210
|
|---|
| 814 | *
|
|---|
| 815 | * 1 DAC => HP(sense) / Speakers,
|
|---|
| 816 | * 1 ADC <= LineIn(sense) / MicIn / DMicIn,
|
|---|
| 817 | * 1 SPDIF OUT => SPDIF Trasmitter(sense)
|
|---|
| 818 | */
|
|---|
| 819 |
|
|---|
| 820 | /* CS4210 board names */
|
|---|
| 821 | static const struct hda_model_fixup cs421x_models[] = {
|
|---|
| 822 | { .id = CS421X_CDB4210, .name = "cdb4210" },
|
|---|
| 823 | { .id = CS421X_STUMPY, .name = "stumpy" },
|
|---|
| 824 | {0}
|
|---|
| 825 | };
|
|---|
| 826 |
|
|---|
| 827 | static const struct hda_quirk cs421x_fixup_tbl[] = {
|
|---|
| 828 | /* Test Intel board + CDB2410 */
|
|---|
| 829 | SND_PCI_QUIRK(0x8086, 0x5001, "DP45SG/CDB4210", CS421X_CDB4210),
|
|---|
| 830 | {0} /* terminator */
|
|---|
| 831 | };
|
|---|
| 832 |
|
|---|
| 833 | /* CS4210 board pinconfigs */
|
|---|
| 834 | /* Default CS4210 (CDB4210)*/
|
|---|
| 835 | static const struct hda_pintbl cdb4210_pincfgs[] = {
|
|---|
| 836 | { 0x05, 0x0321401f },
|
|---|
| 837 | { 0x06, 0x90170010 },
|
|---|
| 838 | { 0x07, 0x03813031 },
|
|---|
| 839 | { 0x08, 0xb7a70037 },
|
|---|
| 840 | { 0x09, 0xb7a6003e },
|
|---|
| 841 | { 0x0a, 0x034510f0 },
|
|---|
| 842 | {0} /* terminator */
|
|---|
| 843 | };
|
|---|
| 844 |
|
|---|
| 845 | /* Stumpy ChromeBox */
|
|---|
| 846 | static const struct hda_pintbl stumpy_pincfgs[] = {
|
|---|
| 847 | { 0x05, 0x022120f0 },
|
|---|
| 848 | { 0x06, 0x901700f0 },
|
|---|
| 849 | { 0x07, 0x02a120f0 },
|
|---|
| 850 | { 0x08, 0x77a70037 },
|
|---|
| 851 | { 0x09, 0x77a6003e },
|
|---|
| 852 | { 0x0a, 0x434510f0 },
|
|---|
| 853 | {0} /* terminator */
|
|---|
| 854 | };
|
|---|
| 855 |
|
|---|
| 856 | /* Setup GPIO/SENSE for each board (if used) */
|
|---|
| 857 | static void cs421x_fixup_sense_b(struct hda_codec *codec,
|
|---|
| 858 | const struct hda_fixup *fix, int action)
|
|---|
| 859 | {
|
|---|
| 860 | struct cs_spec *spec = codec->spec;
|
|---|
| 861 |
|
|---|
| 862 | if (action == HDA_FIXUP_ACT_PRE_PROBE)
|
|---|
| 863 | spec->sense_b = 1;
|
|---|
| 864 | }
|
|---|
| 865 |
|
|---|
| 866 | static const struct hda_fixup cs421x_fixups[] = {
|
|---|
| 867 | [CS421X_CDB4210] = {
|
|---|
| 868 | .type = HDA_FIXUP_PINS,
|
|---|
| 869 | .v.pins = cdb4210_pincfgs,
|
|---|
| 870 | .chained = true,
|
|---|
| 871 | .chain_id = CS421X_SENSE_B,
|
|---|
| 872 | },
|
|---|
| 873 | [CS421X_SENSE_B] = {
|
|---|
| 874 | .type = HDA_FIXUP_FUNC,
|
|---|
| 875 | .v.func = cs421x_fixup_sense_b,
|
|---|
| 876 | },
|
|---|
| 877 | [CS421X_STUMPY] = {
|
|---|
| 878 | .type = HDA_FIXUP_PINS,
|
|---|
| 879 | .v.pins = stumpy_pincfgs,
|
|---|
| 880 | },
|
|---|
| 881 | };
|
|---|
| 882 |
|
|---|
| 883 | static const struct hda_verb cs421x_coef_init_verbs[] = {
|
|---|
| 884 | {0x0B, AC_VERB_SET_PROC_STATE, 1},
|
|---|
| 885 | {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DEV_CFG},
|
|---|
| 886 | /*
|
|---|
| 887 | * Disable Coefficient Index Auto-Increment(DAI)=1,
|
|---|
| 888 | * PDREF=0
|
|---|
| 889 | */
|
|---|
| 890 | {0x0B, AC_VERB_SET_PROC_COEF, 0x0001 },
|
|---|
| 891 |
|
|---|
| 892 | {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_ADC_CFG},
|
|---|
| 893 | /* ADC SZCMode = Digital Soft Ramp */
|
|---|
| 894 | {0x0B, AC_VERB_SET_PROC_COEF, 0x0002 },
|
|---|
| 895 |
|
|---|
| 896 | {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DAC_CFG},
|
|---|
| 897 | {0x0B, AC_VERB_SET_PROC_COEF,
|
|---|
| 898 | (0x0002 /* DAC SZCMode = Digital Soft Ramp */
|
|---|
| 899 | | 0x0004 /* Mute DAC on FIFO error */
|
|---|
| 900 | | 0x0008 /* Enable DAC High Pass Filter */
|
|---|
| 901 | )},
|
|---|
| 902 | {0} /* terminator */
|
|---|
| 903 | };
|
|---|
| 904 |
|
|---|
| 905 | /* Errata: CS4210 rev A1 Silicon
|
|---|
| 906 | *
|
|---|
| 907 | * http://www.cirrus.com/en/pubs/errata/
|
|---|
| 908 | *
|
|---|
| 909 | * Description:
|
|---|
| 910 | * 1. Performance degredation is present in the ADC.
|
|---|
| 911 | * 2. Speaker output is not completely muted upon HP detect.
|
|---|
| 912 | * 3. Noise is present when clipping occurs on the amplified
|
|---|
| 913 | * speaker outputs.
|
|---|
| 914 | *
|
|---|
| 915 | * Workaround:
|
|---|
| 916 | * The following verb sequence written to the registers during
|
|---|
| 917 | * initialization will correct the issues listed above.
|
|---|
| 918 | */
|
|---|
| 919 |
|
|---|
| 920 | static const struct hda_verb cs421x_coef_init_verbs_A1_silicon_fixes[] = {
|
|---|
| 921 | {0x0B, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
|
|---|
| 922 |
|
|---|
| 923 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x0006},
|
|---|
| 924 | {0x0B, AC_VERB_SET_PROC_COEF, 0x9999}, /* Test mode: on */
|
|---|
| 925 |
|
|---|
| 926 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x000A},
|
|---|
| 927 | {0x0B, AC_VERB_SET_PROC_COEF, 0x14CB}, /* Chop double */
|
|---|
| 928 |
|
|---|
| 929 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x0011},
|
|---|
| 930 | {0x0B, AC_VERB_SET_PROC_COEF, 0xA2D0}, /* Increase ADC current */
|
|---|
| 931 |
|
|---|
| 932 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x001A},
|
|---|
| 933 | {0x0B, AC_VERB_SET_PROC_COEF, 0x02A9}, /* Mute speaker */
|
|---|
| 934 |
|
|---|
| 935 | {0x0B, AC_VERB_SET_COEF_INDEX, 0x001B},
|
|---|
| 936 | {0x0B, AC_VERB_SET_PROC_COEF, 0X1006}, /* Remove noise */
|
|---|
| 937 |
|
|---|
| 938 | {0} /* terminator */
|
|---|
| 939 | };
|
|---|
| 940 |
|
|---|
| 941 | /* Speaker Amp Gain is controlled by the vendor widget's coef 4 */
|
|---|
| 942 | static const DECLARE_TLV_DB_SCALE(cs421x_speaker_boost_db_scale, 900, 300, 0);
|
|---|
| 943 |
|
|---|
| 944 | static int cs421x_boost_vol_info(struct snd_kcontrol *kcontrol,
|
|---|
| 945 | struct snd_ctl_elem_info *uinfo)
|
|---|
| 946 | {
|
|---|
| 947 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|---|
| 948 | uinfo->count = 1;
|
|---|
| 949 | uinfo->value.integer.min = 0;
|
|---|
| 950 | uinfo->value.integer.max = 3;
|
|---|
| 951 | return 0;
|
|---|
| 952 | }
|
|---|
| 953 |
|
|---|
| 954 | static int cs421x_boost_vol_get(struct snd_kcontrol *kcontrol,
|
|---|
| 955 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 956 | {
|
|---|
| 957 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 958 |
|
|---|
| 959 | ucontrol->value.integer.value[0] =
|
|---|
| 960 | cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL) & 0x0003;
|
|---|
| 961 | return 0;
|
|---|
| 962 | }
|
|---|
| 963 |
|
|---|
| 964 | static int cs421x_boost_vol_put(struct snd_kcontrol *kcontrol,
|
|---|
| 965 | struct snd_ctl_elem_value *ucontrol)
|
|---|
| 966 | {
|
|---|
| 967 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
|
|---|
| 968 |
|
|---|
| 969 | unsigned int vol = ucontrol->value.integer.value[0];
|
|---|
| 970 | unsigned int coef =
|
|---|
| 971 | cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL);
|
|---|
| 972 | unsigned int original_coef = coef;
|
|---|
| 973 |
|
|---|
| 974 | coef &= ~0x0003;
|
|---|
| 975 | coef |= (vol & 0x0003);
|
|---|
| 976 | if (original_coef != coef) {
|
|---|
| 977 | cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef);
|
|---|
| 978 | return 1;
|
|---|
| 979 | }
|
|---|
| 980 |
|
|---|
| 981 | return 0;
|
|---|
| 982 | }
|
|---|
| 983 |
|
|---|
| 984 | static const struct snd_kcontrol_new cs421x_speaker_boost_ctl = {
|
|---|
| 985 |
|
|---|
| 986 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|---|
| 987 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|---|
| 988 | SNDRV_CTL_ELEM_ACCESS_TLV_READ),
|
|---|
| 989 | .name = "Speaker Boost Playback Volume",
|
|---|
| 990 | .info = cs421x_boost_vol_info,
|
|---|
| 991 | .get = cs421x_boost_vol_get,
|
|---|
| 992 | .put = cs421x_boost_vol_put,
|
|---|
| 993 | .tlv = { .p = cs421x_speaker_boost_db_scale },
|
|---|
| 994 | };
|
|---|
| 995 |
|
|---|
| 996 | static void cs4210_pinmux_init(struct hda_codec *codec)
|
|---|
| 997 | {
|
|---|
| 998 | struct cs_spec *spec = codec->spec;
|
|---|
| 999 | unsigned int def_conf, coef;
|
|---|
| 1000 |
|
|---|
| 1001 | /* GPIO, DMIC_SCL, DMIC_SDA and SENSE_B are multiplexed */
|
|---|
| 1002 | coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
|
|---|
| 1003 |
|
|---|
| 1004 | if (spec->gpio_mask)
|
|---|
| 1005 | coef |= 0x0008; /* B1,B2 are GPIOs */
|
|---|
| 1006 | else
|
|---|
| 1007 | coef &= ~0x0008;
|
|---|
| 1008 |
|
|---|
| 1009 | if (spec->sense_b)
|
|---|
| 1010 | coef |= 0x0010; /* B2 is SENSE_B, not inverted */
|
|---|
| 1011 | else
|
|---|
| 1012 | coef &= ~0x0010;
|
|---|
| 1013 |
|
|---|
| 1014 | cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
|
|---|
| 1015 |
|
|---|
| 1016 | if ((spec->gpio_mask || spec->sense_b) &&
|
|---|
| 1017 | is_active_pin(codec, CS421X_DMIC_PIN_NID)) {
|
|---|
| 1018 |
|
|---|
| 1019 | /*
|
|---|
| 1020 | * GPIO or SENSE_B forced - disconnect the DMIC pin.
|
|---|
| 1021 | */
|
|---|
| 1022 | def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID);
|
|---|
| 1023 | def_conf &= ~AC_DEFCFG_PORT_CONN;
|
|---|
| 1024 | def_conf |= (AC_JACK_PORT_NONE << AC_DEFCFG_PORT_CONN_SHIFT);
|
|---|
| 1025 | snd_hda_codec_set_pincfg(codec, CS421X_DMIC_PIN_NID, def_conf);
|
|---|
| 1026 | }
|
|---|
| 1027 | }
|
|---|
| 1028 |
|
|---|
| 1029 | static void cs4210_spdif_automute(struct hda_codec *codec,
|
|---|
| 1030 | struct hda_jack_callback *tbl)
|
|---|
| 1031 | {
|
|---|
| 1032 | struct cs_spec *spec = codec->spec;
|
|---|
| 1033 | bool spdif_present = false;
|
|---|
| 1034 | hda_nid_t spdif_pin = spec->gen.autocfg.dig_out_pins[0];
|
|---|
| 1035 |
|
|---|
| 1036 | /* detect on spdif is specific to CS4210 */
|
|---|
| 1037 | if (!spec->spdif_detect ||
|
|---|
| 1038 | spec->vendor_nid != CS4210_VENDOR_NID)
|
|---|
| 1039 | return;
|
|---|
| 1040 |
|
|---|
| 1041 | spdif_present = snd_hda_jack_detect(codec, spdif_pin);
|
|---|
| 1042 | if (spdif_present == spec->spdif_present)
|
|---|
| 1043 | return;
|
|---|
| 1044 |
|
|---|
| 1045 | spec->spdif_present = spdif_present;
|
|---|
| 1046 | /* SPDIF TX on/off */
|
|---|
| 1047 | snd_hda_set_pin_ctl(codec, spdif_pin, spdif_present ? PIN_OUT : 0);
|
|---|
| 1048 |
|
|---|
| 1049 | cs_automute(codec);
|
|---|
| 1050 | }
|
|---|
| 1051 |
|
|---|
| 1052 | static void parse_cs421x_digital(struct hda_codec *codec)
|
|---|
| 1053 | {
|
|---|
| 1054 | struct cs_spec *spec = codec->spec;
|
|---|
| 1055 | struct auto_pin_cfg *cfg = &spec->gen.autocfg;
|
|---|
| 1056 | int i;
|
|---|
| 1057 |
|
|---|
| 1058 | for (i = 0; i < cfg->dig_outs; i++) {
|
|---|
| 1059 | hda_nid_t nid = cfg->dig_out_pins[i];
|
|---|
| 1060 |
|
|---|
| 1061 | if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
|
|---|
| 1062 | spec->spdif_detect = 1;
|
|---|
| 1063 | snd_hda_jack_detect_enable_callback(codec, nid,
|
|---|
| 1064 | cs4210_spdif_automute);
|
|---|
| 1065 | }
|
|---|
| 1066 | }
|
|---|
| 1067 | }
|
|---|
| 1068 |
|
|---|
| 1069 | static int cs421x_init(struct hda_codec *codec)
|
|---|
| 1070 | {
|
|---|
| 1071 | struct cs_spec *spec = codec->spec;
|
|---|
| 1072 |
|
|---|
| 1073 | if (spec->vendor_nid == CS4210_VENDOR_NID) {
|
|---|
| 1074 | snd_hda_sequence_write(codec, cs421x_coef_init_verbs);
|
|---|
| 1075 | snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes);
|
|---|
| 1076 | cs4210_pinmux_init(codec);
|
|---|
| 1077 | }
|
|---|
| 1078 |
|
|---|
| 1079 | snd_hda_gen_init(codec);
|
|---|
| 1080 |
|
|---|
| 1081 | if (spec->gpio_mask) {
|
|---|
| 1082 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
|
|---|
| 1083 | spec->gpio_mask);
|
|---|
| 1084 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
|
|---|
| 1085 | spec->gpio_dir);
|
|---|
| 1086 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
|
|---|
| 1087 | spec->gpio_data);
|
|---|
| 1088 | }
|
|---|
| 1089 |
|
|---|
| 1090 | init_input_coef(codec);
|
|---|
| 1091 |
|
|---|
| 1092 | cs4210_spdif_automute(codec, NULL);
|
|---|
| 1093 |
|
|---|
| 1094 | return 0;
|
|---|
| 1095 | }
|
|---|
| 1096 |
|
|---|
| 1097 | static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
|
|---|
| 1098 | {
|
|---|
| 1099 | unsigned int caps;
|
|---|
| 1100 |
|
|---|
| 1101 | /* set the upper-limit for mixer amp to 0dB */
|
|---|
| 1102 | caps = query_amp_caps(codec, dac, HDA_OUTPUT);
|
|---|
| 1103 | caps &= ~(0x7f << AC_AMPCAP_NUM_STEPS_SHIFT);
|
|---|
| 1104 | caps |= ((caps >> AC_AMPCAP_OFFSET_SHIFT) & 0x7f)
|
|---|
| 1105 | << AC_AMPCAP_NUM_STEPS_SHIFT;
|
|---|
| 1106 | snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps);
|
|---|
| 1107 | }
|
|---|
| 1108 |
|
|---|
| 1109 | static int cs421x_parse_auto_config(struct hda_codec *codec)
|
|---|
| 1110 | {
|
|---|
| 1111 | struct cs_spec *spec = codec->spec;
|
|---|
| 1112 | hda_nid_t dac = CS4210_DAC_NID;
|
|---|
| 1113 | int err;
|
|---|
| 1114 |
|
|---|
| 1115 | fix_volume_caps(codec, dac);
|
|---|
| 1116 |
|
|---|
| 1117 | err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0);
|
|---|
| 1118 | if (err < 0)
|
|---|
| 1119 | return err;
|
|---|
| 1120 |
|
|---|
| 1121 | err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
|
|---|
| 1122 | if (err < 0)
|
|---|
| 1123 | return err;
|
|---|
| 1124 |
|
|---|
| 1125 | parse_cs421x_digital(codec);
|
|---|
| 1126 |
|
|---|
| 1127 | if (spec->gen.autocfg.speaker_outs &&
|
|---|
| 1128 | spec->vendor_nid == CS4210_VENDOR_NID) {
|
|---|
| 1129 | if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
|
|---|
| 1130 | &cs421x_speaker_boost_ctl))
|
|---|
| 1131 | return -ENOMEM;
|
|---|
| 1132 | }
|
|---|
| 1133 |
|
|---|
| 1134 | return 0;
|
|---|
| 1135 | }
|
|---|
| 1136 |
|
|---|
| 1137 | /*
|
|---|
| 1138 | * Manage PDREF, when transitioning to D3hot
|
|---|
| 1139 | * (DAC,ADC) -> D3, PDREF=1, AFG->D3
|
|---|
| 1140 | */
|
|---|
| 1141 | static int cs421x_suspend(struct hda_codec *codec)
|
|---|
| 1142 | {
|
|---|
| 1143 | struct cs_spec *spec = codec->spec;
|
|---|
| 1144 | unsigned int coef;
|
|---|
| 1145 |
|
|---|
| 1146 | snd_hda_shutup_pins(codec);
|
|---|
| 1147 |
|
|---|
| 1148 | snd_hda_codec_write(codec, CS4210_DAC_NID, 0,
|
|---|
| 1149 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
|
|---|
| 1150 | snd_hda_codec_write(codec, CS4210_ADC_NID, 0,
|
|---|
| 1151 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
|
|---|
| 1152 |
|
|---|
| 1153 | if (spec->vendor_nid == CS4210_VENDOR_NID) {
|
|---|
| 1154 | coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG);
|
|---|
| 1155 | coef |= 0x0004; /* PDREF */
|
|---|
| 1156 | cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef);
|
|---|
| 1157 | }
|
|---|
| 1158 |
|
|---|
| 1159 | return 0;
|
|---|
| 1160 | }
|
|---|
| 1161 |
|
|---|
| 1162 | static const struct hda_codec_ops cs421x_patch_ops = {
|
|---|
| 1163 | .build_controls = snd_hda_gen_build_controls,
|
|---|
| 1164 | .build_pcms = snd_hda_gen_build_pcms,
|
|---|
| 1165 | .init = cs421x_init,
|
|---|
| 1166 | .free = cs_free,
|
|---|
| 1167 | .unsol_event = snd_hda_jack_unsol_event,
|
|---|
| 1168 | .suspend = cs421x_suspend,
|
|---|
| 1169 | };
|
|---|
| 1170 |
|
|---|
| 1171 | static int patch_cs4210(struct hda_codec *codec)
|
|---|
| 1172 | {
|
|---|
| 1173 | struct cs_spec *spec;
|
|---|
| 1174 | int err;
|
|---|
| 1175 |
|
|---|
| 1176 | spec = cs_alloc_spec(codec, CS4210_VENDOR_NID);
|
|---|
| 1177 | if (!spec)
|
|---|
| 1178 | return -ENOMEM;
|
|---|
| 1179 |
|
|---|
| 1180 | codec->patch_ops = cs421x_patch_ops;
|
|---|
| 1181 | spec->gen.automute_hook = cs_automute;
|
|---|
| 1182 |
|
|---|
| 1183 | snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl,
|
|---|
| 1184 | cs421x_fixups);
|
|---|
| 1185 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
|
|---|
| 1186 |
|
|---|
| 1187 | /*
|
|---|
| 1188 | * Update the GPIO/DMIC/SENSE_B pinmux before the configuration
|
|---|
| 1189 | * is auto-parsed. If GPIO or SENSE_B is forced, DMIC input
|
|---|
| 1190 | * is disabled.
|
|---|
| 1191 | */
|
|---|
| 1192 | cs4210_pinmux_init(codec);
|
|---|
| 1193 |
|
|---|
| 1194 | err = cs421x_parse_auto_config(codec);
|
|---|
| 1195 | if (err < 0)
|
|---|
| 1196 | goto error;
|
|---|
| 1197 |
|
|---|
| 1198 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
|
|---|
| 1199 |
|
|---|
| 1200 | return 0;
|
|---|
| 1201 |
|
|---|
| 1202 | error:
|
|---|
| 1203 | cs_free(codec);
|
|---|
| 1204 | return err;
|
|---|
| 1205 | }
|
|---|
| 1206 |
|
|---|
| 1207 | static int patch_cs4213(struct hda_codec *codec)
|
|---|
| 1208 | {
|
|---|
| 1209 | struct cs_spec *spec;
|
|---|
| 1210 | int err;
|
|---|
| 1211 |
|
|---|
| 1212 | spec = cs_alloc_spec(codec, CS4213_VENDOR_NID);
|
|---|
| 1213 | if (!spec)
|
|---|
| 1214 | return -ENOMEM;
|
|---|
| 1215 |
|
|---|
| 1216 | codec->patch_ops = cs421x_patch_ops;
|
|---|
| 1217 |
|
|---|
| 1218 | err = cs421x_parse_auto_config(codec);
|
|---|
| 1219 | if (err < 0)
|
|---|
| 1220 | goto error;
|
|---|
| 1221 |
|
|---|
| 1222 | return 0;
|
|---|
| 1223 |
|
|---|
| 1224 | error:
|
|---|
| 1225 | cs_free(codec);
|
|---|
| 1226 | return err;
|
|---|
| 1227 | }
|
|---|
| 1228 |
|
|---|
| 1229 | /*
|
|---|
| 1230 | * patch entries
|
|---|
| 1231 | */
|
|---|
| 1232 | static const struct hda_device_id snd_hda_id_cirrus[] = {
|
|---|
| 1233 | HDA_CODEC_ENTRY(0x10134206, "CS4206", patch_cs420x),
|
|---|
| 1234 | HDA_CODEC_ENTRY(0x10134207, "CS4207", patch_cs420x),
|
|---|
| 1235 | HDA_CODEC_ENTRY(0x10134208, "CS4208", patch_cs4208),
|
|---|
| 1236 | HDA_CODEC_ENTRY(0x10134210, "CS4210", patch_cs4210),
|
|---|
| 1237 | HDA_CODEC_ENTRY(0x10134213, "CS4213", patch_cs4213),
|
|---|
| 1238 | {0} /* terminator */
|
|---|
| 1239 | };
|
|---|
| 1240 | MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_cirrus);
|
|---|
| 1241 |
|
|---|
| 1242 | MODULE_LICENSE("GPL");
|
|---|
| 1243 | MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");
|
|---|
| 1244 |
|
|---|
| 1245 | static struct hda_codec_driver cirrus_driver = {
|
|---|
| 1246 | .id = snd_hda_id_cirrus,
|
|---|
| 1247 | };
|
|---|
| 1248 |
|
|---|
| 1249 | module_hda_codec_driver(cirrus_driver);
|
|---|