hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/sound/pci/via82xx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA driver for VIA VT82xx (South Bridge)
34 *
....@@ -6,21 +7,6 @@
67 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
78 * Tjeerd.Mulder <Tjeerd.Mulder@fujitsu-siemens.com>
89 * 2002 Takashi Iwai <tiwai@suse.de>
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
- *
2410 */
2511
2612 /*
....@@ -428,12 +414,13 @@
428414 {
429415 unsigned int i, idx, ofs, rest;
430416 struct via82xx *chip = snd_pcm_substream_chip(substream);
417
+ __le32 *pgtbl;
431418
432419 if (dev->table.area == NULL) {
433420 /* the start of each lists must be aligned to 8 bytes,
434421 * but the kernel pages are much bigger, so we don't care
435422 */
436
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
423
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
437424 PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8),
438425 &dev->table) < 0)
439426 return -ENOMEM;
....@@ -449,6 +436,7 @@
449436 /* fill the entries */
450437 idx = 0;
451438 ofs = 0;
439
+ pgtbl = (__le32 *)dev->table.area;
452440 for (i = 0; i < periods; i++) {
453441 rest = fragsize;
454442 /* fill descriptors for a period.
....@@ -465,7 +453,7 @@
465453 return -EINVAL;
466454 }
467455 addr = snd_pcm_sgbuf_get_addr(substream, ofs);
468
- ((u32 *)dev->table.area)[idx << 1] = cpu_to_le32(addr);
456
+ pgtbl[idx << 1] = cpu_to_le32(addr);
469457 r = snd_pcm_sgbuf_get_chunk_size(substream, ofs, rest);
470458 rest -= r;
471459 if (! rest) {
....@@ -480,7 +468,7 @@
480468 "tbl %d: at %d size %d (rest %d)\n",
481469 idx, ofs, r, rest);
482470 */
483
- ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
471
+ pgtbl[(idx<<1) + 1] = cpu_to_le32(r | flag);
484472 dev->idx_table[idx].offset = ofs;
485473 dev->idx_table[idx].size = r;
486474 ofs += r;
....@@ -556,7 +544,7 @@
556544 static void snd_via82xx_codec_wait(struct snd_ac97 *ac97)
557545 {
558546 struct via82xx *chip = ac97->private_data;
559
- int err;
547
+ __always_unused int err;
560548 err = snd_via82xx_codec_ready(chip, ac97->num);
561549 /* here we need to wait fairly for long time.. */
562550 if (!nodelay)
....@@ -933,18 +921,10 @@
933921 {
934922 struct via82xx *chip = snd_pcm_substream_chip(substream);
935923 struct viadev *viadev = substream->runtime->private_data;
936
- int err;
937924
938
- err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
939
- if (err < 0)
940
- return err;
941
- err = build_via_table(viadev, substream, chip->pci,
942
- params_periods(hw_params),
943
- params_period_bytes(hw_params));
944
- if (err < 0)
945
- return err;
946
-
947
- return 0;
925
+ return build_via_table(viadev, substream, chip->pci,
926
+ params_periods(hw_params),
927
+ params_period_bytes(hw_params));
948928 }
949929
950930 /*
....@@ -957,7 +937,6 @@
957937 struct viadev *viadev = substream->runtime->private_data;
958938
959939 clean_via_table(viadev, substream, chip->pci);
960
- snd_pcm_lib_free_pages(substream);
961940 return 0;
962941 }
963942
....@@ -1371,65 +1350,55 @@
13711350 static const struct snd_pcm_ops snd_via686_playback_ops = {
13721351 .open = snd_via686_playback_open,
13731352 .close = snd_via82xx_pcm_close,
1374
- .ioctl = snd_pcm_lib_ioctl,
13751353 .hw_params = snd_via82xx_hw_params,
13761354 .hw_free = snd_via82xx_hw_free,
13771355 .prepare = snd_via686_playback_prepare,
13781356 .trigger = snd_via82xx_pcm_trigger,
13791357 .pointer = snd_via686_pcm_pointer,
1380
- .page = snd_pcm_sgbuf_ops_page,
13811358 };
13821359
13831360 /* via686 capture callbacks */
13841361 static const struct snd_pcm_ops snd_via686_capture_ops = {
13851362 .open = snd_via82xx_capture_open,
13861363 .close = snd_via82xx_pcm_close,
1387
- .ioctl = snd_pcm_lib_ioctl,
13881364 .hw_params = snd_via82xx_hw_params,
13891365 .hw_free = snd_via82xx_hw_free,
13901366 .prepare = snd_via686_capture_prepare,
13911367 .trigger = snd_via82xx_pcm_trigger,
13921368 .pointer = snd_via686_pcm_pointer,
1393
- .page = snd_pcm_sgbuf_ops_page,
13941369 };
13951370
13961371 /* via823x DSX playback callbacks */
13971372 static const struct snd_pcm_ops snd_via8233_playback_ops = {
13981373 .open = snd_via8233_playback_open,
13991374 .close = snd_via8233_playback_close,
1400
- .ioctl = snd_pcm_lib_ioctl,
14011375 .hw_params = snd_via82xx_hw_params,
14021376 .hw_free = snd_via82xx_hw_free,
14031377 .prepare = snd_via8233_playback_prepare,
14041378 .trigger = snd_via82xx_pcm_trigger,
14051379 .pointer = snd_via8233_pcm_pointer,
1406
- .page = snd_pcm_sgbuf_ops_page,
14071380 };
14081381
14091382 /* via823x multi-channel playback callbacks */
14101383 static const struct snd_pcm_ops snd_via8233_multi_ops = {
14111384 .open = snd_via8233_multi_open,
14121385 .close = snd_via82xx_pcm_close,
1413
- .ioctl = snd_pcm_lib_ioctl,
14141386 .hw_params = snd_via82xx_hw_params,
14151387 .hw_free = snd_via82xx_hw_free,
14161388 .prepare = snd_via8233_multi_prepare,
14171389 .trigger = snd_via82xx_pcm_trigger,
14181390 .pointer = snd_via8233_pcm_pointer,
1419
- .page = snd_pcm_sgbuf_ops_page,
14201391 };
14211392
14221393 /* via823x capture callbacks */
14231394 static const struct snd_pcm_ops snd_via8233_capture_ops = {
14241395 .open = snd_via82xx_capture_open,
14251396 .close = snd_via82xx_pcm_close,
1426
- .ioctl = snd_pcm_lib_ioctl,
14271397 .hw_params = snd_via82xx_hw_params,
14281398 .hw_free = snd_via82xx_hw_free,
14291399 .prepare = snd_via8233_capture_prepare,
14301400 .trigger = snd_via82xx_pcm_trigger,
14311401 .pointer = snd_via8233_pcm_pointer,
1432
- .page = snd_pcm_sgbuf_ops_page,
14331402 };
14341403
14351404
....@@ -1472,9 +1441,9 @@
14721441 /* capture */
14731442 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
14741443
1475
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1476
- snd_dma_pci_data(chip->pci),
1477
- 64*1024, VIA_MAX_BUFSIZE);
1444
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1445
+ &chip->pci->dev,
1446
+ 64*1024, VIA_MAX_BUFSIZE);
14781447
14791448 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
14801449 snd_pcm_std_chmaps, 2, 0,
....@@ -1496,9 +1465,9 @@
14961465 /* set up capture */
14971466 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1);
14981467
1499
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1500
- snd_dma_pci_data(chip->pci),
1501
- 64*1024, VIA_MAX_BUFSIZE);
1468
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1469
+ &chip->pci->dev,
1470
+ 64*1024, VIA_MAX_BUFSIZE);
15021471
15031472 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
15041473 snd_pcm_alt_chmaps, 6, 0,
....@@ -1539,9 +1508,9 @@
15391508 /* capture */
15401509 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1);
15411510
1542
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1543
- snd_dma_pci_data(chip->pci),
1544
- 64*1024, VIA_MAX_BUFSIZE);
1511
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1512
+ &chip->pci->dev,
1513
+ 64*1024, VIA_MAX_BUFSIZE);
15451514
15461515 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
15471516 snd_pcm_alt_chmaps, 6, 0,
....@@ -1565,9 +1534,9 @@
15651534 /* set up playback */
15661535 init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
15671536
1568
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1569
- snd_dma_pci_data(chip->pci),
1570
- 64*1024, VIA_MAX_BUFSIZE);
1537
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1538
+ &chip->pci->dev,
1539
+ 64*1024, VIA_MAX_BUFSIZE);
15711540 return 0;
15721541 }
15731542
....@@ -1595,9 +1564,9 @@
15951564 init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0);
15961565 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
15971566
1598
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1599
- snd_dma_pci_data(chip->pci),
1600
- 64*1024, VIA_MAX_BUFSIZE);
1567
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1568
+ &chip->pci->dev,
1569
+ 64*1024, VIA_MAX_BUFSIZE);
16011570 return 0;
16021571 }
16031572
....@@ -1901,7 +1870,7 @@
19011870 {
19021871 struct snd_ac97_template ac97;
19031872 int err;
1904
- static struct snd_ac97_bus_ops ops = {
1873
+ static const struct snd_ac97_bus_ops ops = {
19051874 .write = snd_via82xx_codec_write,
19061875 .read = snd_via82xx_codec_read,
19071876 .wait = snd_via82xx_codec_wait,
....@@ -2144,10 +2113,8 @@
21442113
21452114 static void snd_via82xx_proc_init(struct via82xx *chip)
21462115 {
2147
- struct snd_info_entry *entry;
2148
-
2149
- if (! snd_card_proc_new(chip->card, "via82xx", &entry))
2150
- snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read);
2116
+ snd_card_ro_proc_new(chip->card, "via82xx", chip,
2117
+ snd_via82xx_proc_read);
21512118 }
21522119
21532120 /*
....@@ -2278,11 +2245,8 @@
22782245 int i;
22792246
22802247 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2281
- for (i = 0; i < 2; i++)
2282
- snd_pcm_suspend_all(chip->pcms[i]);
22832248 for (i = 0; i < chip->num_devs; i++)
22842249 snd_via82xx_channel_reset(chip, &chip->devs[i]);
2285
- synchronize_irq(chip->irq);
22862250 snd_ac97_suspend(chip->ac97);
22872251
22882252 /* save misc values */
....@@ -2370,7 +2334,7 @@
23702334 {
23712335 struct via82xx *chip;
23722336 int err;
2373
- static struct snd_device_ops ops = {
2337
+ static const struct snd_device_ops ops = {
23742338 .dev_free = snd_via82xx_dev_free,
23752339 };
23762340
....@@ -2413,9 +2377,9 @@
24132377 return -EBUSY;
24142378 }
24152379 chip->irq = pci->irq;
2380
+ card->sync_irq = chip->irq;
24162381 if (ac97_clock >= 8000 && ac97_clock <= 48000)
24172382 chip->ac97_clock = ac97_clock;
2418
- synchronize_irq(chip->irq);
24192383
24202384 if ((err = snd_via82xx_chip_init(chip)) < 0) {
24212385 snd_via82xx_free(chip);
....@@ -2441,7 +2405,7 @@
24412405 char *name;
24422406 int type;
24432407 };
2444
-static struct via823x_info via823x_cards[] = {
2408
+static const struct via823x_info via823x_cards[] = {
24452409 { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 },
24462410 { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 },
24472411 { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 },
....@@ -2455,7 +2419,7 @@
24552419 * auto detection of DXS channel supports.
24562420 */
24572421
2458
-static struct snd_pci_quirk dxs_whitelist[] = {
2422
+static const struct snd_pci_quirk dxs_allowlist[] = {
24592423 SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE),
24602424 SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K),
24612425 SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA),
....@@ -2503,9 +2467,9 @@
25032467 {
25042468 const struct snd_pci_quirk *w;
25052469
2506
- w = snd_pci_quirk_lookup(pci, dxs_whitelist);
2470
+ w = snd_pci_quirk_lookup(pci, dxs_allowlist);
25072471 if (w) {
2508
- dev_dbg(&pci->dev, "DXS white list for %s found\n",
2472
+ dev_dbg(&pci->dev, "DXS allow list for %s found\n",
25092473 snd_pci_quirk_name(w));
25102474 return w->value;
25112475 }