forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/pci/ac97/ac97_patch.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
34 * Universal interface for Audio Codec '97
....@@ -5,22 +6,6 @@
56 * For more details look to AC '97 component specification revision 2.2
67 * by Intel Corporation (http://developer.intel.com) and to datasheets
78 * for specific codecs.
8
- *
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
- *
249 */
2510
2611 #include "ac97_local.h"
....@@ -34,7 +19,7 @@
3419 const char *name);
3520 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3621 const unsigned int *tlv,
37
- const char * const *slaves);
22
+ const char * const *followers);
3823
3924 /*
4025 * Chip specific initialization
....@@ -1226,25 +1211,25 @@
12261211
12271212 static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
12281213 {
1229
- static unsigned short regs[4] = {
1214
+ static const unsigned short regs[4] = {
12301215 AC97_SIGMATEL_OUTSEL,
12311216 AC97_SIGMATEL_IOMISC,
12321217 AC97_SIGMATEL_INSEL,
12331218 AC97_SIGMATEL_VARIOUS
12341219 };
1235
- static unsigned short def_regs[4] = {
1220
+ static const unsigned short def_regs[4] = {
12361221 /* OUTSEL */ 0xd794, /* CL:CL, SR:SR, LO:MX, LI:DS, MI:DS */
12371222 /* IOMISC */ 0x2001,
12381223 /* INSEL */ 0x0201, /* LI:LI, MI:M1 */
12391224 /* VARIOUS */ 0x0040
12401225 };
1241
- static unsigned short m675_regs[4] = {
1226
+ static const unsigned short m675_regs[4] = {
12421227 /* OUTSEL */ 0xfc70, /* CL:MX, SR:MX, LO:DS, LI:MX, MI:DS */
12431228 /* IOMISC */ 0x2102, /* HP amp on */
12441229 /* INSEL */ 0x0203, /* LI:LI, MI:FR */
12451230 /* VARIOUS */ 0x0041 /* stereo mic */
12461231 };
1247
- unsigned short *pregs = def_regs;
1232
+ const unsigned short *pregs = def_regs;
12481233 int i;
12491234
12501235 /* Gateway M675 notebook */
....@@ -1371,12 +1356,12 @@
13711356 }
13721357
13731358 /*
1374
- * Analog Device AD18xx, AD19xx codecs
1359
+ * Analog Devices AD18xx, AD19xx codecs
13751360 */
13761361 #ifdef CONFIG_PM
13771362 static void ad18xx_resume(struct snd_ac97 *ac97)
13781363 {
1379
- static unsigned short setup_regs[] = {
1364
+ static const unsigned short setup_regs[] = {
13801365 AC97_AD_MISC, AC97_AD_SERIAL_CFG, AC97_AD_JACK_SPDIF,
13811366 };
13821367 int i, codec;
....@@ -1485,7 +1470,7 @@
14851470
14861471 static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits)
14871472 {
1488
- static int cfg_bits[3] = { 1<<12, 1<<14, 1<<13 };
1473
+ static const int cfg_bits[3] = { 1<<12, 1<<14, 1<<13 };
14891474 unsigned short val;
14901475
14911476 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]);
....@@ -1806,10 +1791,10 @@
18061791 AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0),
18071792 };
18081793
1809
-/* black list to avoid HP/Line jack-sense controls
1794
+/* deny list to avoid HP/Line jack-sense controls
18101795 * (SS vendor << 16 | device)
18111796 */
1812
-static unsigned int ad1981_jacks_blacklist[] = {
1797
+static const unsigned int ad1981_jacks_denylist[] = {
18131798 0x10140523, /* Thinkpad R40 */
18141799 0x10140534, /* Thinkpad X31 */
18151800 0x10140537, /* Thinkpad T41p */
....@@ -1836,7 +1821,7 @@
18361821
18371822 static int patch_ad1981a_specific(struct snd_ac97 * ac97)
18381823 {
1839
- if (check_list(ac97, ad1981_jacks_blacklist))
1824
+ if (check_list(ac97, ad1981_jacks_denylist))
18401825 return 0;
18411826 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
18421827 ARRAY_SIZE(snd_ac97_ad1981x_jack_sense));
....@@ -1850,10 +1835,10 @@
18501835 #endif
18511836 };
18521837
1853
-/* white list to enable HP jack-sense bits
1838
+/* allow list to enable HP jack-sense bits
18541839 * (SS vendor << 16 | device)
18551840 */
1856
-static unsigned int ad1981_jacks_whitelist[] = {
1841
+static const unsigned int ad1981_jacks_allowlist[] = {
18571842 0x0e11005a, /* HP nc4000/4010 */
18581843 0x103c0890, /* HP nc6000 */
18591844 0x103c0938, /* HP nc4220 */
....@@ -1868,7 +1853,7 @@
18681853
18691854 static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
18701855 {
1871
- if (check_list(ac97, ad1981_jacks_whitelist))
1856
+ if (check_list(ac97, ad1981_jacks_allowlist))
18721857 /* enable headphone jack sense */
18731858 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
18741859 }
....@@ -1892,7 +1877,7 @@
18921877
18931878 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
18941879 return err;
1895
- if (check_list(ac97, ad1981_jacks_blacklist))
1880
+ if (check_list(ac97, ad1981_jacks_denylist))
18961881 return 0;
18971882 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
18981883 ARRAY_SIZE(snd_ac97_ad1981x_jack_sense));
....@@ -3131,22 +3116,22 @@
31313116 /* FIXME: check the bits for each model
31323117 * model 83 is confirmed to work
31333118 */
3134
- static unsigned short surr_on[3][2] = {
3119
+ static const unsigned short surr_on[3][2] = {
31353120 { 0x0008, 0x0000 }, /* 9761-78 & 82 */
31363121 { 0x0000, 0x0008 }, /* 9761-82 rev.B */
31373122 { 0x0000, 0x0008 }, /* 9761-83 */
31383123 };
3139
- static unsigned short clfe_on[3][2] = {
3124
+ static const unsigned short clfe_on[3][2] = {
31403125 { 0x0000, 0x1000 }, /* 9761-78 & 82 */
31413126 { 0x1000, 0x0000 }, /* 9761-82 rev.B */
31423127 { 0x0000, 0x1000 }, /* 9761-83 */
31433128 };
3144
- static unsigned short surr_shared[3][2] = {
3129
+ static const unsigned short surr_shared[3][2] = {
31453130 { 0x0000, 0x0400 }, /* 9761-78 & 82 */
31463131 { 0x0000, 0x0400 }, /* 9761-82 rev.B */
31473132 { 0x0000, 0x0400 }, /* 9761-83 */
31483133 };
3149
- static unsigned short clfe_shared[3][2] = {
3134
+ static const unsigned short clfe_shared[3][2] = {
31503135 { 0x2000, 0x0880 }, /* 9761-78 & 82 */
31513136 { 0x0000, 0x2880 }, /* 9761-82 rev.B */
31523137 { 0x2000, 0x0800 }, /* 9761-83 */
....@@ -3388,7 +3373,7 @@
33883373 AC97_SINGLE("Downmix Surround to Front", 0x5a, 11, 1, 0),
33893374 };
33903375
3391
-static const char * const slave_vols_vt1616[] = {
3376
+static const char * const follower_vols_vt1616[] = {
33923377 "Front Playback Volume",
33933378 "Surround Playback Volume",
33943379 "Center Playback Volume",
....@@ -3396,7 +3381,7 @@
33963381 NULL
33973382 };
33983383
3399
-static const char * const slave_sws_vt1616[] = {
3384
+static const char * const follower_sws_vt1616[] = {
34003385 "Front Playback Switch",
34013386 "Surround Playback Switch",
34023387 "Center Playback Switch",
....@@ -3415,10 +3400,10 @@
34153400 return snd_ctl_find_id(ac97->bus->card, &id);
34163401 }
34173402
3418
-/* create a virtual master control and add slaves */
3403
+/* create a virtual master control and add followers */
34193404 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
34203405 const unsigned int *tlv,
3421
- const char * const *slaves)
3406
+ const char * const *followers)
34223407 {
34233408 struct snd_kcontrol *kctl;
34243409 const char * const *s;
....@@ -3431,16 +3416,16 @@
34313416 if (err < 0)
34323417 return err;
34333418
3434
- for (s = slaves; *s; s++) {
3419
+ for (s = followers; *s; s++) {
34353420 struct snd_kcontrol *sctl;
34363421
34373422 sctl = snd_ac97_find_mixer_ctl(ac97, *s);
34383423 if (!sctl) {
34393424 dev_dbg(ac97->bus->card->dev,
3440
- "Cannot find slave %s, skipped\n", *s);
3425
+ "Cannot find follower %s, skipped\n", *s);
34413426 continue;
34423427 }
3443
- err = snd_ctl_add_slave(kctl, sctl);
3428
+ err = snd_ctl_add_follower(kctl, sctl);
34443429 if (err < 0)
34453430 return err;
34463431 }
....@@ -3466,12 +3451,12 @@
34663451 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
34673452
34683453 err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
3469
- kctl->tlv.p, slave_vols_vt1616);
3454
+ kctl->tlv.p, follower_vols_vt1616);
34703455 if (err < 0)
34713456 return err;
34723457
34733458 err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
3474
- NULL, slave_sws_vt1616);
3459
+ NULL, follower_sws_vt1616);
34753460 if (err < 0)
34763461 return err;
34773462
....@@ -3650,7 +3635,7 @@
36503635
36513636 /* This list reflects the vt1618 docs for Vendor Defined Register 0x60. */
36523637
3653
-static struct vt1618_uaj_item vt1618_uaj[3] = {
3638
+static const struct vt1618_uaj_item vt1618_uaj[3] = {
36543639 {
36553640 /* speaker jack */
36563641 .mask = 0x03,
....@@ -3886,7 +3871,7 @@
38863871 * check_volume_resolution().
38873872 */
38883873
3889
-static struct snd_ac97_res_table lm4550_restbl[] = {
3874
+static const struct snd_ac97_res_table lm4550_restbl[] = {
38903875 { AC97_MASTER, 0x1f1f },
38913876 { AC97_HEADPHONE, 0x1f1f },
38923877 { AC97_MASTER_MONO, 0x001f },