| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Universal Interface for Intel High Definition Audio Codec |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * Based on patch_cmedia.c and patch_realtek.c |
|---|
| 10 | 11 | * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> |
|---|
| 11 | | - * |
|---|
| 12 | | - * This driver is free software; you can redistribute it and/or modify |
|---|
| 13 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 14 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 15 | | - * (at your option) any later version. |
|---|
| 16 | | - * |
|---|
| 17 | | - * This driver is distributed in the hope that it will be useful, |
|---|
| 18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | | - * GNU General Public License for more details. |
|---|
| 21 | | - * |
|---|
| 22 | | - * You should have received a copy of the GNU General Public License |
|---|
| 23 | | - * along with this program; if not, write to the Free Software |
|---|
| 24 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 25 | 12 | */ |
|---|
| 26 | 13 | |
|---|
| 27 | 14 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 32 | 19 | #include <linux/module.h> |
|---|
| 33 | 20 | #include <sound/core.h> |
|---|
| 34 | 21 | #include <sound/jack.h> |
|---|
| 35 | | -#include "hda_codec.h" |
|---|
| 22 | +#include <sound/hda_codec.h> |
|---|
| 36 | 23 | #include "hda_local.h" |
|---|
| 37 | 24 | #include "hda_auto_parser.h" |
|---|
| 38 | 25 | #include "hda_beep.h" |
|---|
| .. | .. |
|---|
| 222 | 209 | |
|---|
| 223 | 210 | /* beep widgets */ |
|---|
| 224 | 211 | hda_nid_t anabeep_nid; |
|---|
| 212 | + bool beep_power_on; |
|---|
| 225 | 213 | |
|---|
| 226 | 214 | /* SPDIF-out mux */ |
|---|
| 227 | 215 | const char * const *spdif_labels; |
|---|
| .. | .. |
|---|
| 333 | 321 | } |
|---|
| 334 | 322 | |
|---|
| 335 | 323 | /* hook for controlling mic-mute LED GPIO */ |
|---|
| 336 | | -static void stac_capture_led_update(struct hda_codec *codec) |
|---|
| 324 | +static int stac_capture_led_update(struct led_classdev *led_cdev, |
|---|
| 325 | + enum led_brightness brightness) |
|---|
| 337 | 326 | { |
|---|
| 327 | + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); |
|---|
| 338 | 328 | struct sigmatel_spec *spec = codec->spec; |
|---|
| 339 | 329 | |
|---|
| 340 | | - if (spec->gen.micmute_led.led_value) |
|---|
| 330 | + if (brightness) |
|---|
| 341 | 331 | spec->gpio_data |= spec->mic_mute_led_gpio; |
|---|
| 342 | 332 | else |
|---|
| 343 | 333 | spec->gpio_data &= ~spec->mic_mute_led_gpio; |
|---|
| 344 | 334 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data); |
|---|
| 335 | + return 0; |
|---|
| 345 | 336 | } |
|---|
| 346 | 337 | |
|---|
| 347 | 338 | static int stac_vrefout_set(struct hda_codec *codec, |
|---|
| .. | .. |
|---|
| 379 | 370 | } |
|---|
| 380 | 371 | |
|---|
| 381 | 372 | /* update mute-LED accoring to the master switch */ |
|---|
| 382 | | -static void stac_update_led_status(struct hda_codec *codec, int enabled) |
|---|
| 373 | +static void stac_update_led_status(struct hda_codec *codec, bool muted) |
|---|
| 383 | 374 | { |
|---|
| 384 | 375 | struct sigmatel_spec *spec = codec->spec; |
|---|
| 385 | | - int muted = !enabled; |
|---|
| 386 | 376 | |
|---|
| 387 | 377 | if (!spec->gpio_led) |
|---|
| 388 | 378 | return; |
|---|
| .. | .. |
|---|
| 406 | 396 | } |
|---|
| 407 | 397 | |
|---|
| 408 | 398 | /* vmaster hook to update mute LED */ |
|---|
| 409 | | -static void stac_vmaster_hook(void *private_data, int val) |
|---|
| 399 | +static int stac_vmaster_hook(struct led_classdev *led_cdev, |
|---|
| 400 | + enum led_brightness brightness) |
|---|
| 410 | 401 | { |
|---|
| 411 | | - stac_update_led_status(private_data, val); |
|---|
| 402 | + struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent); |
|---|
| 403 | + |
|---|
| 404 | + stac_update_led_status(codec, brightness); |
|---|
| 405 | + return 0; |
|---|
| 412 | 406 | } |
|---|
| 413 | 407 | |
|---|
| 414 | 408 | /* automute hook to handle GPIO mute and EAPD updates */ |
|---|
| .. | .. |
|---|
| 808 | 802 | static bool has_builtin_speaker(struct hda_codec *codec) |
|---|
| 809 | 803 | { |
|---|
| 810 | 804 | struct sigmatel_spec *spec = codec->spec; |
|---|
| 811 | | - hda_nid_t *nid_pin; |
|---|
| 805 | + const hda_nid_t *nid_pin; |
|---|
| 812 | 806 | int nids, i; |
|---|
| 813 | 807 | |
|---|
| 814 | 808 | if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) { |
|---|
| .. | .. |
|---|
| 838 | 832 | struct sigmatel_spec *spec = codec->spec; |
|---|
| 839 | 833 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
|---|
| 840 | 834 | struct snd_kcontrol_new *knew; |
|---|
| 841 | | - static struct snd_kcontrol_new abeep_mute_ctl = |
|---|
| 835 | + static const struct snd_kcontrol_new abeep_mute_ctl = |
|---|
| 842 | 836 | HDA_CODEC_MUTE(NULL, 0, 0, 0); |
|---|
| 843 | | - static struct snd_kcontrol_new dbeep_mute_ctl = |
|---|
| 837 | + static const struct snd_kcontrol_new dbeep_mute_ctl = |
|---|
| 844 | 838 | HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0); |
|---|
| 845 | | - static struct snd_kcontrol_new beep_vol_ctl = |
|---|
| 839 | + static const struct snd_kcontrol_new beep_vol_ctl = |
|---|
| 846 | 840 | HDA_CODEC_VOLUME(NULL, 0, 0, 0); |
|---|
| 847 | 841 | |
|---|
| 848 | 842 | /* check for mute support for the amp */ |
|---|
| .. | .. |
|---|
| 987 | 981 | |
|---|
| 988 | 982 | return 0; |
|---|
| 989 | 983 | } |
|---|
| 990 | | - |
|---|
| 991 | | -/* |
|---|
| 992 | | - */ |
|---|
| 993 | | - |
|---|
| 994 | | -static const struct hda_verb stac9200_core_init[] = { |
|---|
| 995 | | - /* set dac0mux for dac converter */ |
|---|
| 996 | | - { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
|---|
| 997 | | - {} |
|---|
| 998 | | -}; |
|---|
| 999 | 984 | |
|---|
| 1000 | 985 | static const struct hda_verb stac9200_eapd_init[] = { |
|---|
| 1001 | 986 | /* set dac0mux for dac converter */ |
|---|
| .. | .. |
|---|
| 1722 | 1707 | }; |
|---|
| 1723 | 1708 | |
|---|
| 1724 | 1709 | static const struct hda_pintbl ref92hd73xx_pin_configs[] = { |
|---|
| 1710 | + // Port A-H |
|---|
| 1725 | 1711 | { 0x0a, 0x02214030 }, |
|---|
| 1726 | 1712 | { 0x0b, 0x02a19040 }, |
|---|
| 1727 | 1713 | { 0x0c, 0x01a19020 }, |
|---|
| .. | .. |
|---|
| 1730 | 1716 | { 0x0f, 0x01014010 }, |
|---|
| 1731 | 1717 | { 0x10, 0x01014020 }, |
|---|
| 1732 | 1718 | { 0x11, 0x01014030 }, |
|---|
| 1719 | + // CD in |
|---|
| 1733 | 1720 | { 0x12, 0x02319040 }, |
|---|
| 1721 | + // Digial Mic ins |
|---|
| 1734 | 1722 | { 0x13, 0x90a000f0 }, |
|---|
| 1735 | 1723 | { 0x14, 0x90a000f0 }, |
|---|
| 1724 | + // Digital outs |
|---|
| 1736 | 1725 | { 0x22, 0x01452050 }, |
|---|
| 1737 | 1726 | { 0x23, 0x01452050 }, |
|---|
| 1738 | 1727 | {} |
|---|
| .. | .. |
|---|
| 1773 | 1762 | }; |
|---|
| 1774 | 1763 | |
|---|
| 1775 | 1764 | static const struct hda_pintbl intel_dg45id_pin_configs[] = { |
|---|
| 1765 | + // Analog outputs |
|---|
| 1776 | 1766 | { 0x0a, 0x02214230 }, |
|---|
| 1777 | 1767 | { 0x0b, 0x02A19240 }, |
|---|
| 1778 | 1768 | { 0x0c, 0x01013214 }, |
|---|
| .. | .. |
|---|
| 1780 | 1770 | { 0x0e, 0x01A19250 }, |
|---|
| 1781 | 1771 | { 0x0f, 0x01011212 }, |
|---|
| 1782 | 1772 | { 0x10, 0x01016211 }, |
|---|
| 1773 | + // Digital output |
|---|
| 1774 | + { 0x22, 0x01451380 }, |
|---|
| 1775 | + { 0x23, 0x40f000f0 }, |
|---|
| 1783 | 1776 | {} |
|---|
| 1784 | 1777 | }; |
|---|
| 1785 | 1778 | |
|---|
| .. | .. |
|---|
| 1970 | 1963 | "DFI LanParty", STAC_92HD73XX_REF), |
|---|
| 1971 | 1964 | SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, |
|---|
| 1972 | 1965 | "DFI LanParty", STAC_92HD73XX_REF), |
|---|
| 1966 | + SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5001, |
|---|
| 1967 | + "Intel DP45SG", STAC_92HD73XX_INTEL), |
|---|
| 1973 | 1968 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002, |
|---|
| 1974 | 1969 | "Intel DG45ID", STAC_92HD73XX_INTEL), |
|---|
| 1975 | 1970 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003, |
|---|
| .. | .. |
|---|
| 2204 | 2199 | int action) |
|---|
| 2205 | 2200 | { |
|---|
| 2206 | 2201 | struct sigmatel_spec *spec = codec->spec; |
|---|
| 2207 | | - static hda_nid_t preferred_pairs[] = { |
|---|
| 2202 | + static const hda_nid_t preferred_pairs[] = { |
|---|
| 2208 | 2203 | 0xd, 0x13, |
|---|
| 2209 | 2204 | 0 |
|---|
| 2210 | 2205 | }; |
|---|
| .. | .. |
|---|
| 3151 | 3146 | unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, pin); |
|---|
| 3152 | 3147 | |
|---|
| 3153 | 3148 | /* It was changed in the BIOS to just satisfy MS DTM. |
|---|
| 3154 | | - * Lets turn it back into slaved HP |
|---|
| 3149 | + * Lets turn it back into follower HP |
|---|
| 3155 | 3150 | */ |
|---|
| 3156 | 3151 | pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) | |
|---|
| 3157 | 3152 | (AC_JACK_HP_OUT << AC_DEFCFG_DEVICE_SHIFT); |
|---|
| .. | .. |
|---|
| 4323 | 4318 | if (codec->beep) { |
|---|
| 4324 | 4319 | /* IDT/STAC codecs have linear beep tone parameter */ |
|---|
| 4325 | 4320 | codec->beep->linear_tone = spec->linear_tone_beep; |
|---|
| 4321 | + /* keep power up while beep is enabled */ |
|---|
| 4322 | + codec->beep->keep_power_at_enable = 1; |
|---|
| 4326 | 4323 | /* if no beep switch is available, make its own one */ |
|---|
| 4327 | 4324 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
|---|
| 4328 | 4325 | if (!(caps & AC_AMPCAP_MUTE)) { |
|---|
| .. | .. |
|---|
| 4335 | 4332 | #endif |
|---|
| 4336 | 4333 | |
|---|
| 4337 | 4334 | if (spec->gpio_led) |
|---|
| 4338 | | - spec->gen.vmaster_mute.hook = stac_vmaster_hook; |
|---|
| 4335 | + snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook); |
|---|
| 4339 | 4336 | |
|---|
| 4340 | 4337 | if (spec->aloopback_ctl && |
|---|
| 4341 | 4338 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
|---|
| .. | .. |
|---|
| 4658 | 4655 | spec->gpio_dir |= spec->mic_mute_led_gpio; |
|---|
| 4659 | 4656 | spec->mic_enabled = 0; |
|---|
| 4660 | 4657 | spec->gpio_data |= spec->mic_mute_led_gpio; |
|---|
| 4661 | | - snd_hda_gen_add_micmute_led(codec, stac_capture_led_update); |
|---|
| 4658 | + snd_hda_gen_add_micmute_led_cdev(codec, stac_capture_led_update); |
|---|
| 4662 | 4659 | } |
|---|
| 4663 | 4660 | } |
|---|
| 4664 | 4661 | |
|---|
| .. | .. |
|---|
| 4930 | 4927 | * The below flag enables the longer delay (see get_response |
|---|
| 4931 | 4928 | * in hda_intel.c). |
|---|
| 4932 | 4929 | */ |
|---|
| 4933 | | - codec->bus->needs_damn_long_delay = 1; |
|---|
| 4930 | + codec->bus->core.needs_damn_long_delay = 1; |
|---|
| 4934 | 4931 | |
|---|
| 4935 | 4932 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
|---|
| 4936 | 4933 | |
|---|