forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/isa/es18xx.c
....@@ -1,23 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for generic ESS AudioDrive ES18xx soundcards
34 * Copyright (c) by Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>
45 * Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
5
- *
6
- *
7
- * This program 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 program 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
20
- *
216 */
227 /* GENERAL NOTES:
238 *
....@@ -449,7 +434,7 @@
449434 struct snd_pcm_hw_params *hw_params)
450435 {
451436 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
452
- int shift, err;
437
+ int shift;
453438
454439 shift = 0;
455440 if (params_channels(hw_params) == 2)
....@@ -468,14 +453,7 @@
468453 } else {
469454 chip->dma1_shift = shift;
470455 }
471
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
472
- return err;
473456 return 0;
474
-}
475
-
476
-static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream)
477
-{
478
- return snd_pcm_lib_free_pages(substream);
479457 }
480458
481459 static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip,
....@@ -558,7 +536,7 @@
558536 struct snd_pcm_hw_params *hw_params)
559537 {
560538 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
561
- int shift, err;
539
+ int shift;
562540
563541 shift = 0;
564542 if ((chip->caps & ES18XX_DUPLEX_MONO) &&
....@@ -572,8 +550,6 @@
572550 if (snd_pcm_format_width(params_format(hw_params)) == 16)
573551 shift++;
574552 chip->dma1_shift = shift;
575
- if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
576
- return err;
577553 return 0;
578554 }
579555
....@@ -930,7 +906,6 @@
930906 else
931907 chip->playback_b_substream = NULL;
932908
933
- snd_pcm_lib_free_pages(substream);
934909 return 0;
935910 }
936911
....@@ -939,7 +914,6 @@
939914 struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
940915
941916 chip->capture_a_substream = NULL;
942
- snd_pcm_lib_free_pages(substream);
943917 return 0;
944918 }
945919
....@@ -981,7 +955,7 @@
981955 case 0x1887:
982956 case 0x1888:
983957 return snd_ctl_enum_info(uinfo, 1, 5, texts5Source);
984
- case 0x1869: /* DS somewhat contradictory for 1869: could be be 5 or 8 */
958
+ case 0x1869: /* DS somewhat contradictory for 1869: could be 5 or 8 */
985959 case 0x1879:
986960 return snd_ctl_enum_info(uinfo, 1, 8, texts8Source);
987961 default:
....@@ -991,7 +965,7 @@
991965
992966 static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
993967 {
994
- static unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3};
968
+ static const unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3};
995969 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
996970 int muxSource = snd_es18xx_mixer_read(chip, 0x1c) & 0x07;
997971 if (!(chip->version == 0x1869 || chip->version == 0x1879)) {
....@@ -1008,7 +982,7 @@
1008982
1009983 static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1010984 {
1011
- static unsigned char map4Source[4] = {0, 2, 6, 7};
985
+ static const unsigned char map4Source[4] = {0, 2, 6, 7};
1012986 struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
1013987 unsigned char val = ucontrol->value.enumerated.item[0];
1014988 unsigned char retVal = 0;
....@@ -1024,7 +998,7 @@
1024998 val = 3;
1025999 } else
10261000 retVal = snd_es18xx_mixer_bits(chip, 0x7a, 0x08, 0x00) != 0x00;
1027
- /* fall through */
1001
+ fallthrough;
10281002 /* 4 source chips */
10291003 case 0x1868:
10301004 case 0x1878:
....@@ -1272,7 +1246,7 @@
12721246 * The controls that are universal to all chipsets are fully initialized
12731247 * here.
12741248 */
1275
-static struct snd_kcontrol_new snd_es18xx_base_controls[] = {
1249
+static const struct snd_kcontrol_new snd_es18xx_base_controls[] = {
12761250 ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0),
12771251 ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1),
12781252 ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0),
....@@ -1291,7 +1265,7 @@
12911265 }
12921266 };
12931267
1294
-static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = {
1268
+static const struct snd_kcontrol_new snd_es18xx_recmix_controls[] = {
12951269 ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0),
12961270 ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0),
12971271 ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0),
....@@ -1303,35 +1277,35 @@
13031277 /*
13041278 * The chipset specific mixer controls
13051279 */
1306
-static struct snd_kcontrol_new snd_es18xx_opt_speaker =
1280
+static const struct snd_kcontrol_new snd_es18xx_opt_speaker =
13071281 ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0);
13081282
1309
-static struct snd_kcontrol_new snd_es18xx_opt_1869[] = {
1283
+static const struct snd_kcontrol_new snd_es18xx_opt_1869[] = {
13101284 ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, ES18XX_FL_INVERT),
13111285 ES18XX_SINGLE("Video Playback Switch", 0, 0x7f, 0, 1, 0),
13121286 ES18XX_DOUBLE("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0),
13131287 ES18XX_DOUBLE("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0)
13141288 };
13151289
1316
-static struct snd_kcontrol_new snd_es18xx_opt_1878 =
1290
+static const struct snd_kcontrol_new snd_es18xx_opt_1878 =
13171291 ES18XX_DOUBLE("Video Playback Volume", 0, 0x68, 0x68, 4, 0, 15, 0);
13181292
1319
-static struct snd_kcontrol_new snd_es18xx_opt_1879[] = {
1293
+static const struct snd_kcontrol_new snd_es18xx_opt_1879[] = {
13201294 ES18XX_SINGLE("Video Playback Switch", 0, 0x71, 6, 1, 0),
13211295 ES18XX_DOUBLE("Video Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0),
13221296 ES18XX_DOUBLE("Video Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0)
13231297 };
13241298
1325
-static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = {
1299
+static const struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = {
13261300 ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0),
13271301 };
13281302
1329
-static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = {
1303
+static const struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = {
13301304 ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0),
13311305 ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0)
13321306 };
13331307
1334
-static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = {
1308
+static const struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = {
13351309 ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0),
13361310 {
13371311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
....@@ -1342,13 +1316,13 @@
13421316 }
13431317 };
13441318
1345
-static struct snd_kcontrol_new snd_es18xx_micpre1_control =
1319
+static const struct snd_kcontrol_new snd_es18xx_micpre1_control =
13461320 ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0);
13471321
1348
-static struct snd_kcontrol_new snd_es18xx_micpre2_control =
1322
+static const struct snd_kcontrol_new snd_es18xx_micpre2_control =
13491323 ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0);
13501324
1351
-static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = {
1325
+static const struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = {
13521326 {
13531327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13541328 .name = "Hardware Master Playback Volume",
....@@ -1366,7 +1340,7 @@
13661340 ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0),
13671341 };
13681342
1369
-static struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = {
1343
+static const struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = {
13701344 ES18XX_SINGLE("GPO0 Switch", 0, ES18XX_PM, 0, 1, ES18XX_FL_PMPORT),
13711345 ES18XX_SINGLE("GPO1 Switch", 0, ES18XX_PM, 1, 1, ES18XX_FL_PMPORT),
13721346 };
....@@ -1669,9 +1643,7 @@
16691643 static const struct snd_pcm_ops snd_es18xx_playback_ops = {
16701644 .open = snd_es18xx_playback_open,
16711645 .close = snd_es18xx_playback_close,
1672
- .ioctl = snd_pcm_lib_ioctl,
16731646 .hw_params = snd_es18xx_playback_hw_params,
1674
- .hw_free = snd_es18xx_pcm_hw_free,
16751647 .prepare = snd_es18xx_playback_prepare,
16761648 .trigger = snd_es18xx_playback_trigger,
16771649 .pointer = snd_es18xx_playback_pointer,
....@@ -1680,9 +1652,7 @@
16801652 static const struct snd_pcm_ops snd_es18xx_capture_ops = {
16811653 .open = snd_es18xx_capture_open,
16821654 .close = snd_es18xx_capture_close,
1683
- .ioctl = snd_pcm_lib_ioctl,
16841655 .hw_params = snd_es18xx_capture_hw_params,
1685
- .hw_free = snd_es18xx_pcm_hw_free,
16861656 .prepare = snd_es18xx_capture_prepare,
16871657 .trigger = snd_es18xx_capture_trigger,
16881658 .pointer = snd_es18xx_capture_pointer,
....@@ -1716,10 +1686,9 @@
17161686 sprintf(pcm->name, "ESS AudioDrive ES%x", chip->version);
17171687 chip->pcm = pcm;
17181688
1719
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1720
- snd_dma_isa_data(),
1721
- 64*1024,
1722
- chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
1689
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev,
1690
+ 64*1024,
1691
+ chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
17231692 return 0;
17241693 }
17251694
....@@ -1730,8 +1699,6 @@
17301699 struct snd_es18xx *chip = card->private_data;
17311700
17321701 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1733
-
1734
- snd_pcm_suspend_all(chip->pcm);
17351702
17361703 /* power down */
17371704 chip->pm_reg = (unsigned char)snd_es18xx_read(chip, ES18XX_PM);
....@@ -1786,7 +1753,7 @@
17861753 int irq, int dma1, int dma2)
17871754 {
17881755 struct snd_es18xx *chip = card->private_data;
1789
- static struct snd_device_ops ops = {
1756
+ static const struct snd_device_ops ops = {
17901757 .dev_free = snd_es18xx_dev_free,
17911758 };
17921759 int err;
....@@ -1814,6 +1781,7 @@
18141781 return -EBUSY;
18151782 }
18161783 chip->irq = irq;
1784
+ card->sync_irq = chip->irq;
18171785
18181786 if (request_dma(dma1, "ES18xx DMA 1")) {
18191787 snd_es18xx_free(card);
....@@ -2205,8 +2173,8 @@
22052173 static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)
22062174 {
22072175 int err;
2208
- static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
2209
- static int possible_dmas[] = {1, 0, 3, 5, -1};
2176
+ static const int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
2177
+ static const int possible_dmas[] = {1, 0, 3, 5, -1};
22102178
22112179 if (irq[dev] == SNDRV_AUTO_IRQ) {
22122180 if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) {
....@@ -2230,7 +2198,7 @@
22302198 if (port[dev] != SNDRV_AUTO_PORT) {
22312199 return snd_es18xx_isa_probe1(dev, pdev);
22322200 } else {
2233
- static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
2201
+ static const unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
22342202 int i;
22352203 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
22362204 port[dev] = possible_ports[i];