forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/pci/hda/hda_auto_parser.c
....@@ -1,19 +1,15 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * BIOS auto-parser helper functions for HD-audio
34 *
45 * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de>
5
- *
6
- * This driver is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/slab.h>
139 #include <linux/export.h>
1410 #include <linux/sort.h>
1511 #include <sound/core.h>
16
-#include "hda_codec.h"
12
+#include <sound/hda_codec.h>
1713 #include "hda_local.h"
1814 #include "hda_auto_parser.h"
1915
....@@ -354,7 +350,7 @@
354350 */
355351 if (!cfg->line_outs && cfg->hp_outs > 1 &&
356352 !(cond_flags & HDA_PINCFG_NO_HP_FIXUP)) {
357
- int i = 0;
353
+ i = 0;
358354 while (i < cfg->hp_outs) {
359355 /* The real HPs should have the sequence 0x0f */
360356 if ((hp_out[i].seq & 0x0f) == 0x0f) {
....@@ -827,7 +823,7 @@
827823 snd_hda_set_pin_ctl_cache(codec, cfg->nid, cfg->val);
828824 }
829825
830
-static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
826
+void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth)
831827 {
832828 const char *modelname = codec->fixup_name;
833829
....@@ -837,7 +833,7 @@
837833 if (++depth > 10)
838834 break;
839835 if (fix->chained_before)
840
- apply_fixup(codec, fix->chain_id, action, depth + 1);
836
+ __snd_hda_apply_fixup(codec, fix->chain_id, action, depth + 1);
841837
842838 switch (fix->type) {
843839 case HDA_FIXUP_PINS:
....@@ -878,6 +874,7 @@
878874 id = fix->chain_id;
879875 }
880876 }
877
+EXPORT_SYMBOL_GPL(__snd_hda_apply_fixup);
881878
882879 /**
883880 * snd_hda_apply_fixup - Apply the fixup chain with the given action
....@@ -887,14 +884,15 @@
887884 void snd_hda_apply_fixup(struct hda_codec *codec, int action)
888885 {
889886 if (codec->fixup_list)
890
- apply_fixup(codec, codec->fixup_id, action, 0);
887
+ __snd_hda_apply_fixup(codec, codec->fixup_id, action, 0);
891888 }
892889 EXPORT_SYMBOL_GPL(snd_hda_apply_fixup);
893890
894891 #define IGNORE_SEQ_ASSOC (~(AC_DEFCFG_SEQUENCE | AC_DEFCFG_DEF_ASSOC))
895892
896893 static bool pin_config_match(struct hda_codec *codec,
897
- const struct hda_pintbl *pins)
894
+ const struct hda_pintbl *pins,
895
+ bool match_all_pins)
898896 {
899897 const struct hda_pincfg *pin;
900898 int i;
....@@ -918,7 +916,8 @@
918916 return false;
919917 }
920918 }
921
- if (!found && (cfg & 0xf0000000) != 0x40000000)
919
+ if (match_all_pins &&
920
+ !found && (cfg & 0xf0000000) != 0x40000000)
922921 return false;
923922 }
924923
....@@ -930,10 +929,12 @@
930929 * @codec: the HDA codec
931930 * @pin_quirk: zero-terminated pin quirk list
932931 * @fixlist: the fixup list
932
+ * @match_all_pins: all valid pins must match with the table entries
933933 */
934934 void snd_hda_pick_pin_fixup(struct hda_codec *codec,
935935 const struct snd_hda_pin_quirk *pin_quirk,
936
- const struct hda_fixup *fixlist)
936
+ const struct hda_fixup *fixlist,
937
+ bool match_all_pins)
937938 {
938939 const struct snd_hda_pin_quirk *pq;
939940
....@@ -945,7 +946,7 @@
945946 continue;
946947 if (codec->core.vendor_id != pq->codec)
947948 continue;
948
- if (pin_config_match(codec, pq->pins)) {
949
+ if (pin_config_match(codec, pq->pins, match_all_pins)) {
949950 codec->fixup_id = pq->value;
950951 #ifdef CONFIG_SND_DEBUG_VERBOSE
951952 codec->fixup_name = pq->name;