forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/pci/hda/patch_sigmatel.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Universal Interface for Intel High Definition Audio Codec
34 *
....@@ -8,20 +9,6 @@
89 *
910 * Based on patch_cmedia.c and patch_realtek.c
1011 * 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
2512 */
2613
2714 #include <linux/init.h>
....@@ -32,7 +19,7 @@
3219 #include <linux/module.h>
3320 #include <sound/core.h>
3421 #include <sound/jack.h>
35
-#include "hda_codec.h"
22
+#include <sound/hda_codec.h>
3623 #include "hda_local.h"
3724 #include "hda_auto_parser.h"
3825 #include "hda_beep.h"
....@@ -222,6 +209,7 @@
222209
223210 /* beep widgets */
224211 hda_nid_t anabeep_nid;
212
+ bool beep_power_on;
225213
226214 /* SPDIF-out mux */
227215 const char * const *spdif_labels;
....@@ -333,15 +321,18 @@
333321 }
334322
335323 /* 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)
337326 {
327
+ struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
338328 struct sigmatel_spec *spec = codec->spec;
339329
340
- if (spec->gen.micmute_led.led_value)
330
+ if (brightness)
341331 spec->gpio_data |= spec->mic_mute_led_gpio;
342332 else
343333 spec->gpio_data &= ~spec->mic_mute_led_gpio;
344334 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
335
+ return 0;
345336 }
346337
347338 static int stac_vrefout_set(struct hda_codec *codec,
....@@ -379,10 +370,9 @@
379370 }
380371
381372 /* 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)
383374 {
384375 struct sigmatel_spec *spec = codec->spec;
385
- int muted = !enabled;
386376
387377 if (!spec->gpio_led)
388378 return;
....@@ -406,9 +396,13 @@
406396 }
407397
408398 /* 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)
410401 {
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;
412406 }
413407
414408 /* automute hook to handle GPIO mute and EAPD updates */
....@@ -808,7 +802,7 @@
808802 static bool has_builtin_speaker(struct hda_codec *codec)
809803 {
810804 struct sigmatel_spec *spec = codec->spec;
811
- hda_nid_t *nid_pin;
805
+ const hda_nid_t *nid_pin;
812806 int nids, i;
813807
814808 if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) {
....@@ -838,11 +832,11 @@
838832 struct sigmatel_spec *spec = codec->spec;
839833 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
840834 struct snd_kcontrol_new *knew;
841
- static struct snd_kcontrol_new abeep_mute_ctl =
835
+ static const struct snd_kcontrol_new abeep_mute_ctl =
842836 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 =
844838 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 =
846840 HDA_CODEC_VOLUME(NULL, 0, 0, 0);
847841
848842 /* check for mute support for the amp */
....@@ -987,15 +981,6 @@
987981
988982 return 0;
989983 }
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
-};
999984
1000985 static const struct hda_verb stac9200_eapd_init[] = {
1001986 /* set dac0mux for dac converter */
....@@ -2204,7 +2189,7 @@
22042189 int action)
22052190 {
22062191 struct sigmatel_spec *spec = codec->spec;
2207
- static hda_nid_t preferred_pairs[] = {
2192
+ static const hda_nid_t preferred_pairs[] = {
22082193 0xd, 0x13,
22092194 0
22102195 };
....@@ -3151,7 +3136,7 @@
31513136 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, pin);
31523137
31533138 /* 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
31553140 */
31563141 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) |
31573142 (AC_JACK_HP_OUT << AC_DEFCFG_DEVICE_SHIFT);
....@@ -4323,6 +4308,8 @@
43234308 if (codec->beep) {
43244309 /* IDT/STAC codecs have linear beep tone parameter */
43254310 codec->beep->linear_tone = spec->linear_tone_beep;
4311
+ /* keep power up while beep is enabled */
4312
+ codec->beep->keep_power_at_enable = 1;
43264313 /* if no beep switch is available, make its own one */
43274314 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
43284315 if (!(caps & AC_AMPCAP_MUTE)) {
....@@ -4335,7 +4322,7 @@
43354322 #endif
43364323
43374324 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);
43394326
43404327 if (spec->aloopback_ctl &&
43414328 snd_hda_get_bool_hint(codec, "loopback") == 1) {
....@@ -4658,7 +4645,7 @@
46584645 spec->gpio_dir |= spec->mic_mute_led_gpio;
46594646 spec->mic_enabled = 0;
46604647 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);
46624649 }
46634650 }
46644651
....@@ -4930,7 +4917,7 @@
49304917 * The below flag enables the longer delay (see get_response
49314918 * in hda_intel.c).
49324919 */
4933
- codec->bus->needs_damn_long_delay = 1;
4920
+ codec->bus->core.needs_damn_long_delay = 1;
49344921
49354922 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
49364923