.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * ALSA driver for VIA VT82xx (South Bridge) |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> |
---|
7 | 8 | * Tjeerd.Mulder <Tjeerd.Mulder@fujitsu-siemens.com> |
---|
8 | 9 | * 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 | | - * |
---|
24 | 10 | */ |
---|
25 | 11 | |
---|
26 | 12 | /* |
---|
.. | .. |
---|
428 | 414 | { |
---|
429 | 415 | unsigned int i, idx, ofs, rest; |
---|
430 | 416 | struct via82xx *chip = snd_pcm_substream_chip(substream); |
---|
| 417 | + __le32 *pgtbl; |
---|
431 | 418 | |
---|
432 | 419 | if (dev->table.area == NULL) { |
---|
433 | 420 | /* the start of each lists must be aligned to 8 bytes, |
---|
434 | 421 | * but the kernel pages are much bigger, so we don't care |
---|
435 | 422 | */ |
---|
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, |
---|
437 | 424 | PAGE_ALIGN(VIA_TABLE_SIZE * 2 * 8), |
---|
438 | 425 | &dev->table) < 0) |
---|
439 | 426 | return -ENOMEM; |
---|
.. | .. |
---|
449 | 436 | /* fill the entries */ |
---|
450 | 437 | idx = 0; |
---|
451 | 438 | ofs = 0; |
---|
| 439 | + pgtbl = (__le32 *)dev->table.area; |
---|
452 | 440 | for (i = 0; i < periods; i++) { |
---|
453 | 441 | rest = fragsize; |
---|
454 | 442 | /* fill descriptors for a period. |
---|
.. | .. |
---|
465 | 453 | return -EINVAL; |
---|
466 | 454 | } |
---|
467 | 455 | 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); |
---|
469 | 457 | r = snd_pcm_sgbuf_get_chunk_size(substream, ofs, rest); |
---|
470 | 458 | rest -= r; |
---|
471 | 459 | if (! rest) { |
---|
.. | .. |
---|
480 | 468 | "tbl %d: at %d size %d (rest %d)\n", |
---|
481 | 469 | idx, ofs, r, rest); |
---|
482 | 470 | */ |
---|
483 | | - ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); |
---|
| 471 | + pgtbl[(idx<<1) + 1] = cpu_to_le32(r | flag); |
---|
484 | 472 | dev->idx_table[idx].offset = ofs; |
---|
485 | 473 | dev->idx_table[idx].size = r; |
---|
486 | 474 | ofs += r; |
---|
.. | .. |
---|
556 | 544 | static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) |
---|
557 | 545 | { |
---|
558 | 546 | struct via82xx *chip = ac97->private_data; |
---|
559 | | - int err; |
---|
| 547 | + __always_unused int err; |
---|
560 | 548 | err = snd_via82xx_codec_ready(chip, ac97->num); |
---|
561 | 549 | /* here we need to wait fairly for long time.. */ |
---|
562 | 550 | if (!nodelay) |
---|
.. | .. |
---|
933 | 921 | { |
---|
934 | 922 | struct via82xx *chip = snd_pcm_substream_chip(substream); |
---|
935 | 923 | struct viadev *viadev = substream->runtime->private_data; |
---|
936 | | - int err; |
---|
937 | 924 | |
---|
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)); |
---|
948 | 928 | } |
---|
949 | 929 | |
---|
950 | 930 | /* |
---|
.. | .. |
---|
957 | 937 | struct viadev *viadev = substream->runtime->private_data; |
---|
958 | 938 | |
---|
959 | 939 | clean_via_table(viadev, substream, chip->pci); |
---|
960 | | - snd_pcm_lib_free_pages(substream); |
---|
961 | 940 | return 0; |
---|
962 | 941 | } |
---|
963 | 942 | |
---|
.. | .. |
---|
1371 | 1350 | static const struct snd_pcm_ops snd_via686_playback_ops = { |
---|
1372 | 1351 | .open = snd_via686_playback_open, |
---|
1373 | 1352 | .close = snd_via82xx_pcm_close, |
---|
1374 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1375 | 1353 | .hw_params = snd_via82xx_hw_params, |
---|
1376 | 1354 | .hw_free = snd_via82xx_hw_free, |
---|
1377 | 1355 | .prepare = snd_via686_playback_prepare, |
---|
1378 | 1356 | .trigger = snd_via82xx_pcm_trigger, |
---|
1379 | 1357 | .pointer = snd_via686_pcm_pointer, |
---|
1380 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1381 | 1358 | }; |
---|
1382 | 1359 | |
---|
1383 | 1360 | /* via686 capture callbacks */ |
---|
1384 | 1361 | static const struct snd_pcm_ops snd_via686_capture_ops = { |
---|
1385 | 1362 | .open = snd_via82xx_capture_open, |
---|
1386 | 1363 | .close = snd_via82xx_pcm_close, |
---|
1387 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1388 | 1364 | .hw_params = snd_via82xx_hw_params, |
---|
1389 | 1365 | .hw_free = snd_via82xx_hw_free, |
---|
1390 | 1366 | .prepare = snd_via686_capture_prepare, |
---|
1391 | 1367 | .trigger = snd_via82xx_pcm_trigger, |
---|
1392 | 1368 | .pointer = snd_via686_pcm_pointer, |
---|
1393 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1394 | 1369 | }; |
---|
1395 | 1370 | |
---|
1396 | 1371 | /* via823x DSX playback callbacks */ |
---|
1397 | 1372 | static const struct snd_pcm_ops snd_via8233_playback_ops = { |
---|
1398 | 1373 | .open = snd_via8233_playback_open, |
---|
1399 | 1374 | .close = snd_via8233_playback_close, |
---|
1400 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1401 | 1375 | .hw_params = snd_via82xx_hw_params, |
---|
1402 | 1376 | .hw_free = snd_via82xx_hw_free, |
---|
1403 | 1377 | .prepare = snd_via8233_playback_prepare, |
---|
1404 | 1378 | .trigger = snd_via82xx_pcm_trigger, |
---|
1405 | 1379 | .pointer = snd_via8233_pcm_pointer, |
---|
1406 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1407 | 1380 | }; |
---|
1408 | 1381 | |
---|
1409 | 1382 | /* via823x multi-channel playback callbacks */ |
---|
1410 | 1383 | static const struct snd_pcm_ops snd_via8233_multi_ops = { |
---|
1411 | 1384 | .open = snd_via8233_multi_open, |
---|
1412 | 1385 | .close = snd_via82xx_pcm_close, |
---|
1413 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1414 | 1386 | .hw_params = snd_via82xx_hw_params, |
---|
1415 | 1387 | .hw_free = snd_via82xx_hw_free, |
---|
1416 | 1388 | .prepare = snd_via8233_multi_prepare, |
---|
1417 | 1389 | .trigger = snd_via82xx_pcm_trigger, |
---|
1418 | 1390 | .pointer = snd_via8233_pcm_pointer, |
---|
1419 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1420 | 1391 | }; |
---|
1421 | 1392 | |
---|
1422 | 1393 | /* via823x capture callbacks */ |
---|
1423 | 1394 | static const struct snd_pcm_ops snd_via8233_capture_ops = { |
---|
1424 | 1395 | .open = snd_via82xx_capture_open, |
---|
1425 | 1396 | .close = snd_via82xx_pcm_close, |
---|
1426 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1427 | 1397 | .hw_params = snd_via82xx_hw_params, |
---|
1428 | 1398 | .hw_free = snd_via82xx_hw_free, |
---|
1429 | 1399 | .prepare = snd_via8233_capture_prepare, |
---|
1430 | 1400 | .trigger = snd_via82xx_pcm_trigger, |
---|
1431 | 1401 | .pointer = snd_via8233_pcm_pointer, |
---|
1432 | | - .page = snd_pcm_sgbuf_ops_page, |
---|
1433 | 1402 | }; |
---|
1434 | 1403 | |
---|
1435 | 1404 | |
---|
.. | .. |
---|
1472 | 1441 | /* capture */ |
---|
1473 | 1442 | init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); |
---|
1474 | 1443 | |
---|
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); |
---|
1478 | 1447 | |
---|
1479 | 1448 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
1480 | 1449 | snd_pcm_std_chmaps, 2, 0, |
---|
.. | .. |
---|
1496 | 1465 | /* set up capture */ |
---|
1497 | 1466 | init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); |
---|
1498 | 1467 | |
---|
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); |
---|
1502 | 1471 | |
---|
1503 | 1472 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
1504 | 1473 | snd_pcm_alt_chmaps, 6, 0, |
---|
.. | .. |
---|
1539 | 1508 | /* capture */ |
---|
1540 | 1509 | init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); |
---|
1541 | 1510 | |
---|
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); |
---|
1545 | 1514 | |
---|
1546 | 1515 | err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
1547 | 1516 | snd_pcm_alt_chmaps, 6, 0, |
---|
.. | .. |
---|
1565 | 1534 | /* set up playback */ |
---|
1566 | 1535 | init_viadev(chip, chip->playback_devno, 0x30, 3, 0); |
---|
1567 | 1536 | |
---|
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); |
---|
1571 | 1540 | return 0; |
---|
1572 | 1541 | } |
---|
1573 | 1542 | |
---|
.. | .. |
---|
1595 | 1564 | init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); |
---|
1596 | 1565 | init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); |
---|
1597 | 1566 | |
---|
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); |
---|
1601 | 1570 | return 0; |
---|
1602 | 1571 | } |
---|
1603 | 1572 | |
---|
.. | .. |
---|
1901 | 1870 | { |
---|
1902 | 1871 | struct snd_ac97_template ac97; |
---|
1903 | 1872 | int err; |
---|
1904 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 1873 | + static const struct snd_ac97_bus_ops ops = { |
---|
1905 | 1874 | .write = snd_via82xx_codec_write, |
---|
1906 | 1875 | .read = snd_via82xx_codec_read, |
---|
1907 | 1876 | .wait = snd_via82xx_codec_wait, |
---|
.. | .. |
---|
2144 | 2113 | |
---|
2145 | 2114 | static void snd_via82xx_proc_init(struct via82xx *chip) |
---|
2146 | 2115 | { |
---|
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); |
---|
2151 | 2118 | } |
---|
2152 | 2119 | |
---|
2153 | 2120 | /* |
---|
.. | .. |
---|
2278 | 2245 | int i; |
---|
2279 | 2246 | |
---|
2280 | 2247 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
2281 | | - for (i = 0; i < 2; i++) |
---|
2282 | | - snd_pcm_suspend_all(chip->pcms[i]); |
---|
2283 | 2248 | for (i = 0; i < chip->num_devs; i++) |
---|
2284 | 2249 | snd_via82xx_channel_reset(chip, &chip->devs[i]); |
---|
2285 | | - synchronize_irq(chip->irq); |
---|
2286 | 2250 | snd_ac97_suspend(chip->ac97); |
---|
2287 | 2251 | |
---|
2288 | 2252 | /* save misc values */ |
---|
.. | .. |
---|
2370 | 2334 | { |
---|
2371 | 2335 | struct via82xx *chip; |
---|
2372 | 2336 | int err; |
---|
2373 | | - static struct snd_device_ops ops = { |
---|
| 2337 | + static const struct snd_device_ops ops = { |
---|
2374 | 2338 | .dev_free = snd_via82xx_dev_free, |
---|
2375 | 2339 | }; |
---|
2376 | 2340 | |
---|
.. | .. |
---|
2413 | 2377 | return -EBUSY; |
---|
2414 | 2378 | } |
---|
2415 | 2379 | chip->irq = pci->irq; |
---|
| 2380 | + card->sync_irq = chip->irq; |
---|
2416 | 2381 | if (ac97_clock >= 8000 && ac97_clock <= 48000) |
---|
2417 | 2382 | chip->ac97_clock = ac97_clock; |
---|
2418 | | - synchronize_irq(chip->irq); |
---|
2419 | 2383 | |
---|
2420 | 2384 | if ((err = snd_via82xx_chip_init(chip)) < 0) { |
---|
2421 | 2385 | snd_via82xx_free(chip); |
---|
.. | .. |
---|
2441 | 2405 | char *name; |
---|
2442 | 2406 | int type; |
---|
2443 | 2407 | }; |
---|
2444 | | -static struct via823x_info via823x_cards[] = { |
---|
| 2408 | +static const struct via823x_info via823x_cards[] = { |
---|
2445 | 2409 | { VIA_REV_PRE_8233, "VIA 8233-Pre", TYPE_VIA8233 }, |
---|
2446 | 2410 | { VIA_REV_8233C, "VIA 8233C", TYPE_VIA8233 }, |
---|
2447 | 2411 | { VIA_REV_8233, "VIA 8233", TYPE_VIA8233 }, |
---|
.. | .. |
---|
2455 | 2419 | * auto detection of DXS channel supports. |
---|
2456 | 2420 | */ |
---|
2457 | 2421 | |
---|
2458 | | -static struct snd_pci_quirk dxs_whitelist[] = { |
---|
| 2422 | +static const struct snd_pci_quirk dxs_allowlist[] = { |
---|
2459 | 2423 | SND_PCI_QUIRK(0x1005, 0x4710, "Avance Logic Mobo", VIA_DXS_ENABLE), |
---|
2460 | 2424 | SND_PCI_QUIRK(0x1019, 0x0996, "ESC Mobo", VIA_DXS_48K), |
---|
2461 | 2425 | SND_PCI_QUIRK(0x1019, 0x0a81, "ECS K7VTA3 v8.0", VIA_DXS_NO_VRA), |
---|
.. | .. |
---|
2503 | 2467 | { |
---|
2504 | 2468 | const struct snd_pci_quirk *w; |
---|
2505 | 2469 | |
---|
2506 | | - w = snd_pci_quirk_lookup(pci, dxs_whitelist); |
---|
| 2470 | + w = snd_pci_quirk_lookup(pci, dxs_allowlist); |
---|
2507 | 2471 | 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", |
---|
2509 | 2473 | snd_pci_quirk_name(w)); |
---|
2510 | 2474 | return w->value; |
---|
2511 | 2475 | } |
---|