forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
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 */
....@@ -1722,6 +1707,7 @@
17221707 };
17231708
17241709 static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
1710
+ // Port A-H
17251711 { 0x0a, 0x02214030 },
17261712 { 0x0b, 0x02a19040 },
17271713 { 0x0c, 0x01a19020 },
....@@ -1730,9 +1716,12 @@
17301716 { 0x0f, 0x01014010 },
17311717 { 0x10, 0x01014020 },
17321718 { 0x11, 0x01014030 },
1719
+ // CD in
17331720 { 0x12, 0x02319040 },
1721
+ // Digial Mic ins
17341722 { 0x13, 0x90a000f0 },
17351723 { 0x14, 0x90a000f0 },
1724
+ // Digital outs
17361725 { 0x22, 0x01452050 },
17371726 { 0x23, 0x01452050 },
17381727 {}
....@@ -1773,6 +1762,7 @@
17731762 };
17741763
17751764 static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1765
+ // Analog outputs
17761766 { 0x0a, 0x02214230 },
17771767 { 0x0b, 0x02A19240 },
17781768 { 0x0c, 0x01013214 },
....@@ -1780,6 +1770,9 @@
17801770 { 0x0e, 0x01A19250 },
17811771 { 0x0f, 0x01011212 },
17821772 { 0x10, 0x01016211 },
1773
+ // Digital output
1774
+ { 0x22, 0x01451380 },
1775
+ { 0x23, 0x40f000f0 },
17831776 {}
17841777 };
17851778
....@@ -1970,6 +1963,8 @@
19701963 "DFI LanParty", STAC_92HD73XX_REF),
19711964 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
19721965 "DFI LanParty", STAC_92HD73XX_REF),
1966
+ SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5001,
1967
+ "Intel DP45SG", STAC_92HD73XX_INTEL),
19731968 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
19741969 "Intel DG45ID", STAC_92HD73XX_INTEL),
19751970 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
....@@ -2204,7 +2199,7 @@
22042199 int action)
22052200 {
22062201 struct sigmatel_spec *spec = codec->spec;
2207
- static hda_nid_t preferred_pairs[] = {
2202
+ static const hda_nid_t preferred_pairs[] = {
22082203 0xd, 0x13,
22092204 0
22102205 };
....@@ -3151,7 +3146,7 @@
31513146 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, pin);
31523147
31533148 /* 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
31553150 */
31563151 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE)) |
31573152 (AC_JACK_HP_OUT << AC_DEFCFG_DEVICE_SHIFT);
....@@ -4323,6 +4318,8 @@
43234318 if (codec->beep) {
43244319 /* IDT/STAC codecs have linear beep tone parameter */
43254320 codec->beep->linear_tone = spec->linear_tone_beep;
4321
+ /* keep power up while beep is enabled */
4322
+ codec->beep->keep_power_at_enable = 1;
43264323 /* if no beep switch is available, make its own one */
43274324 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
43284325 if (!(caps & AC_AMPCAP_MUTE)) {
....@@ -4335,7 +4332,7 @@
43354332 #endif
43364333
43374334 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);
43394336
43404337 if (spec->aloopback_ctl &&
43414338 snd_hda_get_bool_hint(codec, "loopback") == 1) {
....@@ -4658,7 +4655,7 @@
46584655 spec->gpio_dir |= spec->mic_mute_led_gpio;
46594656 spec->mic_enabled = 0;
46604657 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);
46624659 }
46634660 }
46644661
....@@ -4930,7 +4927,7 @@
49304927 * The below flag enables the longer delay (see get_response
49314928 * in hda_intel.c).
49324929 */
4933
- codec->bus->needs_damn_long_delay = 1;
4930
+ codec->bus->core.needs_damn_long_delay = 1;
49344931
49354932 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
49364933