hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/sound/pci/hda/patch_analog.c
....@@ -1,22 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
34 * AD1986A, AD1988
45 *
56 * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
6
- *
7
- * This driver is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This driver is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
207 */
218
229 #include <linux/init.h>
....@@ -24,7 +11,7 @@
2411 #include <linux/module.h>
2512
2613 #include <sound/core.h>
27
-#include "hda_codec.h"
14
+#include <sound/hda_codec.h>
2815 #include "hda_local.h"
2916 #include "hda_auto_parser.h"
3017 #include "hda_beep.h"
....@@ -41,6 +28,7 @@
4128 hda_nid_t eapd_nid;
4229
4330 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
31
+ int num_smux_conns;
4432 };
4533
4634
....@@ -402,7 +390,7 @@
402390 {
403391 int err;
404392 struct ad198x_spec *spec;
405
- static hda_nid_t preferred_pairs[] = {
393
+ static const hda_nid_t preferred_pairs[] = {
406394 0x1a, 0x03,
407395 0x1b, 0x03,
408396 0x1c, 0x04,
....@@ -466,8 +454,7 @@
466454 struct ad198x_spec *spec = codec->spec;
467455 static const char * const texts2[] = { "PCM", "ADC" };
468456 static const char * const texts3[] = { "PCM", "ADC1", "ADC2" };
469
- hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
470
- int num_conns = snd_hda_get_num_conns(codec, dig_out);
457
+ int num_conns = spec->num_smux_conns;
471458
472459 if (num_conns == 2)
473460 return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2);
....@@ -494,7 +481,7 @@
494481 struct ad198x_spec *spec = codec->spec;
495482 unsigned int val = ucontrol->value.enumerated.item[0];
496483 hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
497
- int num_conns = snd_hda_get_num_conns(codec, dig_out);
484
+ int num_conns = spec->num_smux_conns;
498485
499486 if (val >= num_conns)
500487 return -EINVAL;
....@@ -525,6 +512,7 @@
525512 num_conns = snd_hda_get_num_conns(codec, dig_out);
526513 if (num_conns != 2 && num_conns != 3)
527514 return 0;
515
+ spec->num_smux_conns = num_conns;
528516 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer))
529517 return -ENOMEM;
530518 return 0;
....@@ -532,9 +520,9 @@
532520
533521 static int patch_ad1983(struct hda_codec *codec)
534522 {
523
+ static const hda_nid_t conn_0c[] = { 0x08 };
524
+ static const hda_nid_t conn_0d[] = { 0x09 };
535525 struct ad198x_spec *spec;
536
- static hda_nid_t conn_0c[] = { 0x08 };
537
- static hda_nid_t conn_0d[] = { 0x09 };
538526 int err;
539527
540528 err = alloc_ad_spec(codec);
....@@ -743,10 +731,12 @@
743731 struct snd_ctl_elem_info *uinfo)
744732 {
745733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
734
+ struct ad198x_spec *spec = codec->spec;
746735 static const char * const texts[] = {
747736 "PCM", "ADC1", "ADC2", "ADC3",
748737 };
749
- int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
738
+ int num_conns = spec->num_smux_conns;
739
+
750740 if (num_conns > 4)
751741 num_conns = 4;
752742 return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts);
....@@ -769,7 +759,7 @@
769759 struct ad198x_spec *spec = codec->spec;
770760 unsigned int val = ucontrol->value.enumerated.item[0];
771761 struct nid_path *path;
772
- int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
762
+ int num_conns = spec->num_smux_conns;
773763
774764 if (val >= num_conns)
775765 return -EINVAL;
....@@ -825,7 +815,7 @@
825815 /* we create four static faked paths, since AD codecs have odd
826816 * widget connections regarding the SPDIF out source
827817 */
828
- static struct nid_path fake_paths[4] = {
818
+ static const struct nid_path fake_paths[4] = {
829819 {
830820 .depth = 3,
831821 .path = { 0x02, 0x1d, 0x1b },
....@@ -860,6 +850,7 @@
860850 num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
861851 if (num_conns != 3 && num_conns != 4)
862852 return 0;
853
+ spec->num_smux_conns = num_conns;
863854
864855 for (i = 0; i < num_conns; i++) {
865856 struct nid_path *path = snd_array_new(&spec->gen.paths);