.. | .. |
---|
| 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 */ |
---|
.. | .. |
---|
2204 | 2189 | int action) |
---|
2205 | 2190 | { |
---|
2206 | 2191 | struct sigmatel_spec *spec = codec->spec; |
---|
2207 | | - static hda_nid_t preferred_pairs[] = { |
---|
| 2192 | + static const hda_nid_t preferred_pairs[] = { |
---|
2208 | 2193 | 0xd, 0x13, |
---|
2209 | 2194 | 0 |
---|
2210 | 2195 | }; |
---|
.. | .. |
---|
3151 | 3136 | unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, pin); |
---|
3152 | 3137 | |
---|
3153 | 3138 | /* It was changed in the BIOS to just satisfy MS DTM. |
---|
3154 | | - * Lets turn it back into slaved HP |
---|
| 3139 | + * Lets turn it back into follower HP |
---|
3155 | 3140 | */ |
---|
3156 | 3141 | pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) | |
---|
3157 | 3142 | (AC_JACK_HP_OUT << AC_DEFCFG_DEVICE_SHIFT); |
---|
.. | .. |
---|
4323 | 4308 | if (codec->beep) { |
---|
4324 | 4309 | /* IDT/STAC codecs have linear beep tone parameter */ |
---|
4325 | 4310 | codec->beep->linear_tone = spec->linear_tone_beep; |
---|
| 4311 | + /* keep power up while beep is enabled */ |
---|
| 4312 | + codec->beep->keep_power_at_enable = 1; |
---|
4326 | 4313 | /* if no beep switch is available, make its own one */ |
---|
4327 | 4314 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
---|
4328 | 4315 | if (!(caps & AC_AMPCAP_MUTE)) { |
---|
.. | .. |
---|
4335 | 4322 | #endif |
---|
4336 | 4323 | |
---|
4337 | 4324 | if (spec->gpio_led) |
---|
4338 | | - spec->gen.vmaster_mute.hook = stac_vmaster_hook; |
---|
| 4325 | + snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook); |
---|
4339 | 4326 | |
---|
4340 | 4327 | if (spec->aloopback_ctl && |
---|
4341 | 4328 | snd_hda_get_bool_hint(codec, "loopback") == 1) { |
---|
.. | .. |
---|
4658 | 4645 | spec->gpio_dir |= spec->mic_mute_led_gpio; |
---|
4659 | 4646 | spec->mic_enabled = 0; |
---|
4660 | 4647 | spec->gpio_data |= spec->mic_mute_led_gpio; |
---|
4661 | | - snd_hda_gen_add_micmute_led(codec, stac_capture_led_update); |
---|
| 4648 | + snd_hda_gen_add_micmute_led_cdev(codec, stac_capture_led_update); |
---|
4662 | 4649 | } |
---|
4663 | 4650 | } |
---|
4664 | 4651 | |
---|
.. | .. |
---|
4930 | 4917 | * The below flag enables the longer delay (see get_response |
---|
4931 | 4918 | * in hda_intel.c). |
---|
4932 | 4919 | */ |
---|
4933 | | - codec->bus->needs_damn_long_delay = 1; |
---|
| 4920 | + codec->bus->core.needs_damn_long_delay = 1; |
---|
4934 | 4921 | |
---|
4935 | 4922 | snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); |
---|
4936 | 4923 | |
---|