hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/sound/pci/ali5451/ali5451.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Matt Wu <Matt_Wu@acersoftech.com.cn>
34 * Apr 26, 2001
....@@ -8,21 +9,6 @@
89 *
910 * TODO:
1011 * --
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public Lcodecnse as published by
14
- * the Free Software Foundation; either version 2 of the Lcodecnse, or
15
- * (at your option) any later version.
16
- *
17
- * This program 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 Lcodecnse for more details.
21
- *
22
- * You should have received a copy of the GNU General Public Lcodecnse
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
25
- *
2612 */
2713
2814 #include <linux/io.h>
....@@ -1084,7 +1070,7 @@
10841070 {
10851071 struct snd_ali *codec = snd_pcm_substream_chip(substream);
10861072 struct snd_pcm_substream *s;
1087
- unsigned int what, whati, capture_flag;
1073
+ unsigned int what, whati;
10881074 struct snd_ali_voice *pvoice, *evoice;
10891075 unsigned int val;
10901076 int do_start;
....@@ -1102,7 +1088,7 @@
11021088 return -EINVAL;
11031089 }
11041090
1105
- what = whati = capture_flag = 0;
1091
+ what = whati = 0;
11061092 snd_pcm_group_for_each_entry(s, substream) {
11071093 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
11081094 pvoice = s->runtime->private_data;
....@@ -1124,8 +1110,6 @@
11241110 evoice->running = 0;
11251111 }
11261112 snd_pcm_trigger_done(s, substream);
1127
- if (pvoice->mode)
1128
- capture_flag = 1;
11291113 }
11301114 }
11311115 spin_lock(&codec->reg_lock);
....@@ -1152,13 +1136,7 @@
11521136 struct snd_pcm_runtime *runtime = substream->runtime;
11531137 struct snd_ali_voice *pvoice = runtime->private_data;
11541138 struct snd_ali_voice *evoice = pvoice->extra;
1155
- int err;
11561139
1157
- err = snd_pcm_lib_malloc_pages(substream,
1158
- params_buffer_bytes(hw_params));
1159
- if (err < 0)
1160
- return err;
1161
-
11621140 /* voice management */
11631141
11641142 if (params_buffer_size(hw_params) / 2 !=
....@@ -1189,24 +1167,11 @@
11891167 struct snd_ali_voice *pvoice = runtime->private_data;
11901168 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
11911169
1192
- snd_pcm_lib_free_pages(substream);
11931170 if (evoice) {
11941171 snd_ali_free_voice(codec, evoice);
11951172 pvoice->extra = NULL;
11961173 }
11971174 return 0;
1198
-}
1199
-
1200
-static int snd_ali_hw_params(struct snd_pcm_substream *substream,
1201
- struct snd_pcm_hw_params *hw_params)
1202
-{
1203
- return snd_pcm_lib_malloc_pages(substream,
1204
- params_buffer_bytes(hw_params));
1205
-}
1206
-
1207
-static int snd_ali_hw_free(struct snd_pcm_substream *substream)
1208
-{
1209
- return snd_pcm_lib_free_pages(substream);
12101175 }
12111176
12121177 static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
....@@ -1433,7 +1398,7 @@
14331398 return cso;
14341399 }
14351400
1436
-static struct snd_pcm_hardware snd_ali_playback =
1401
+static const struct snd_pcm_hardware snd_ali_playback =
14371402 {
14381403 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
14391404 SNDRV_PCM_INFO_BLOCK_TRANSFER |
....@@ -1459,7 +1424,7 @@
14591424 * Capture support device description
14601425 */
14611426
1462
-static struct snd_pcm_hardware snd_ali_capture =
1427
+static const struct snd_pcm_hardware snd_ali_capture =
14631428 {
14641429 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
14651430 SNDRV_PCM_INFO_BLOCK_TRANSFER |
....@@ -1490,7 +1455,7 @@
14901455 }
14911456
14921457 static int snd_ali_open(struct snd_pcm_substream *substream, int rec,
1493
- int channel, struct snd_pcm_hardware *phw)
1458
+ int channel, const struct snd_pcm_hardware *phw)
14941459 {
14951460 struct snd_ali *codec = snd_pcm_substream_chip(substream);
14961461 struct snd_pcm_runtime *runtime = substream->runtime;
....@@ -1540,7 +1505,6 @@
15401505 static const struct snd_pcm_ops snd_ali_playback_ops = {
15411506 .open = snd_ali_playback_open,
15421507 .close = snd_ali_playback_close,
1543
- .ioctl = snd_pcm_lib_ioctl,
15441508 .hw_params = snd_ali_playback_hw_params,
15451509 .hw_free = snd_ali_playback_hw_free,
15461510 .prepare = snd_ali_playback_prepare,
....@@ -1551,9 +1515,6 @@
15511515 static const struct snd_pcm_ops snd_ali_capture_ops = {
15521516 .open = snd_ali_capture_open,
15531517 .close = snd_ali_close,
1554
- .ioctl = snd_pcm_lib_ioctl,
1555
- .hw_params = snd_ali_hw_params,
1556
- .hw_free = snd_ali_hw_free,
15571518 .prepare = snd_ali_prepare,
15581519 .trigger = snd_ali_trigger,
15591520 .pointer = snd_ali_pointer,
....@@ -1571,10 +1532,10 @@
15711532 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE,
15721533 params_rate(hw_params));
15731534 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0);
1574
- return snd_ali_hw_params(substream, hw_params);
1535
+ return 0;
15751536 }
15761537
1577
-static struct snd_pcm_hardware snd_ali_modem =
1538
+static const struct snd_pcm_hardware snd_ali_modem =
15781539 {
15791540 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
15801541 SNDRV_PCM_INFO_BLOCK_TRANSFER |
....@@ -1626,9 +1587,7 @@
16261587 static const struct snd_pcm_ops snd_ali_modem_playback_ops = {
16271588 .open = snd_ali_modem_playback_open,
16281589 .close = snd_ali_close,
1629
- .ioctl = snd_pcm_lib_ioctl,
16301590 .hw_params = snd_ali_modem_hw_params,
1631
- .hw_free = snd_ali_hw_free,
16321591 .prepare = snd_ali_prepare,
16331592 .trigger = snd_ali_trigger,
16341593 .pointer = snd_ali_pointer,
....@@ -1637,9 +1596,7 @@
16371596 static const struct snd_pcm_ops snd_ali_modem_capture_ops = {
16381597 .open = snd_ali_modem_capture_open,
16391598 .close = snd_ali_close,
1640
- .ioctl = snd_pcm_lib_ioctl,
16411599 .hw_params = snd_ali_modem_hw_params,
1642
- .hw_free = snd_ali_hw_free,
16431600 .prepare = snd_ali_prepare,
16441601 .trigger = snd_ali_trigger,
16451602 .pointer = snd_ali_pointer,
....@@ -1685,9 +1642,8 @@
16851642 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
16861643 desc->capture_ops);
16871644
1688
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1689
- snd_dma_pci_data(codec->pci),
1690
- 64*1024, 128*1024);
1645
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1646
+ &codec->pci->dev, 64*1024, 128*1024);
16911647
16921648 pcm->info_flags = 0;
16931649 pcm->dev_class = desc->class;
....@@ -1818,7 +1774,7 @@
18181774 return change;
18191775 }
18201776
1821
-static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] = {
1777
+static const struct snd_kcontrol_new snd_ali5451_mixer_spdif[] = {
18221778 /* spdif aplayback switch */
18231779 /* FIXME: "IEC958 Playback Switch" may conflict with one on ac97_codec */
18241780 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), 0, 0),
....@@ -1833,7 +1789,7 @@
18331789 struct snd_ac97_template ac97;
18341790 unsigned int idx;
18351791 int i, err;
1836
- static struct snd_ac97_bus_ops ops = {
1792
+ static const struct snd_ac97_bus_ops ops = {
18371793 .write = snd_ali_codec_write,
18381794 .read = snd_ali_codec_read,
18391795 };
....@@ -1882,10 +1838,8 @@
18821838 return 0;
18831839
18841840 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1885
- for (i = 0; i < chip->num_of_codecs; i++) {
1886
- snd_pcm_suspend_all(chip->pcm[i]);
1841
+ for (i = 0; i < chip->num_of_codecs; i++)
18871842 snd_ac97_suspend(chip->ac97[i]);
1888
- }
18891843
18901844 spin_lock_irq(&chip->reg_lock);
18911845
....@@ -2051,9 +2005,7 @@
20512005
20522006 static void snd_ali_proc_init(struct snd_ali *codec)
20532007 {
2054
- struct snd_info_entry *entry;
2055
- if (!snd_card_proc_new(codec->card, "ali5451", &entry))
2056
- snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
2008
+ snd_card_ro_proc_new(codec->card, "ali5451", codec, snd_ali_proc_read);
20572009 }
20582010
20592011 static int snd_ali_resources(struct snd_ali *codec)
....@@ -2072,6 +2024,7 @@
20722024 return -EBUSY;
20732025 }
20742026 codec->irq = codec->pci->irq;
2027
+ codec->card->sync_irq = codec->irq;
20752028 dev_dbg(codec->card->dev, "resources allocated.\n");
20762029 return 0;
20772030 }
....@@ -2091,7 +2044,7 @@
20912044 struct snd_ali *codec;
20922045 int i, err;
20932046 unsigned short cmdw;
2094
- static struct snd_device_ops ops = {
2047
+ static const struct snd_device_ops ops = {
20952048 .dev_free = snd_ali_dev_free,
20962049 };
20972050
....@@ -2144,8 +2097,6 @@
21442097 snd_ali_free(codec);
21452098 return -EBUSY;
21462099 }
2147
-
2148
- synchronize_irq(pci->irq);
21492100
21502101 codec->synth.chmap = 0;
21512102 codec->synth.chcnt = 0;