| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ALSA driver for VT1724 ICEnsemble ICE1724 / VIA VT1724 (Envy24HT) |
|---|
| 3 | 4 | * VIA VT1720 (Envy24PT) |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz> |
|---|
| 6 | 7 | * 2002 James Stafford <jstafford@ampltd.com> |
|---|
| 7 | 8 | * 2003 Takashi Iwai <tiwai@suse.de> |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program; if not, write to the Free Software |
|---|
| 21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 22 | | - * |
|---|
| 23 | 9 | */ |
|---|
| 24 | 10 | |
|---|
| 25 | 11 | #include <linux/delay.h> |
|---|
| .. | .. |
|---|
| 721 | 707 | struct snd_pcm_hw_params *hw_params) |
|---|
| 722 | 708 | { |
|---|
| 723 | 709 | struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); |
|---|
| 724 | | - int i, chs, err; |
|---|
| 710 | + int i, chs; |
|---|
| 725 | 711 | |
|---|
| 726 | 712 | chs = params_channels(hw_params); |
|---|
| 727 | 713 | mutex_lock(&ice->open_mutex); |
|---|
| .. | .. |
|---|
| 757 | 743 | } |
|---|
| 758 | 744 | mutex_unlock(&ice->open_mutex); |
|---|
| 759 | 745 | |
|---|
| 760 | | - err = snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); |
|---|
| 761 | | - if (err < 0) |
|---|
| 762 | | - return err; |
|---|
| 763 | | - |
|---|
| 764 | | - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
|---|
| 746 | + return snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); |
|---|
| 765 | 747 | } |
|---|
| 766 | 748 | |
|---|
| 767 | 749 | static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream) |
|---|
| .. | .. |
|---|
| 775 | 757 | if (ice->pcm_reserved[i] == substream) |
|---|
| 776 | 758 | ice->pcm_reserved[i] = NULL; |
|---|
| 777 | 759 | mutex_unlock(&ice->open_mutex); |
|---|
| 778 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 760 | + return 0; |
|---|
| 779 | 761 | } |
|---|
| 780 | 762 | |
|---|
| 781 | 763 | static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream) |
|---|
| .. | .. |
|---|
| 1117 | 1099 | static const struct snd_pcm_ops snd_vt1724_playback_pro_ops = { |
|---|
| 1118 | 1100 | .open = snd_vt1724_playback_pro_open, |
|---|
| 1119 | 1101 | .close = snd_vt1724_playback_pro_close, |
|---|
| 1120 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1121 | 1102 | .hw_params = snd_vt1724_pcm_hw_params, |
|---|
| 1122 | 1103 | .hw_free = snd_vt1724_pcm_hw_free, |
|---|
| 1123 | 1104 | .prepare = snd_vt1724_playback_pro_prepare, |
|---|
| .. | .. |
|---|
| 1128 | 1109 | static const struct snd_pcm_ops snd_vt1724_capture_pro_ops = { |
|---|
| 1129 | 1110 | .open = snd_vt1724_capture_pro_open, |
|---|
| 1130 | 1111 | .close = snd_vt1724_capture_pro_close, |
|---|
| 1131 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1132 | 1112 | .hw_params = snd_vt1724_pcm_hw_params, |
|---|
| 1133 | 1113 | .hw_free = snd_vt1724_pcm_hw_free, |
|---|
| 1134 | 1114 | .prepare = snd_vt1724_pcm_prepare, |
|---|
| .. | .. |
|---|
| 1159 | 1139 | pcm->info_flags = 0; |
|---|
| 1160 | 1140 | strcpy(pcm->name, "ICE1724"); |
|---|
| 1161 | 1141 | |
|---|
| 1162 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1163 | | - snd_dma_pci_data(ice->pci), |
|---|
| 1164 | | - 256*1024, 256*1024); |
|---|
| 1142 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1143 | + &ice->pci->dev, 256*1024, 256*1024); |
|---|
| 1165 | 1144 | |
|---|
| 1166 | 1145 | ice->pcm_pro = pcm; |
|---|
| 1167 | 1146 | |
|---|
| .. | .. |
|---|
| 1296 | 1275 | static const struct snd_pcm_ops snd_vt1724_playback_spdif_ops = { |
|---|
| 1297 | 1276 | .open = snd_vt1724_playback_spdif_open, |
|---|
| 1298 | 1277 | .close = snd_vt1724_playback_spdif_close, |
|---|
| 1299 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1300 | 1278 | .hw_params = snd_vt1724_pcm_hw_params, |
|---|
| 1301 | 1279 | .hw_free = snd_vt1724_pcm_hw_free, |
|---|
| 1302 | 1280 | .prepare = snd_vt1724_playback_spdif_prepare, |
|---|
| .. | .. |
|---|
| 1307 | 1285 | static const struct snd_pcm_ops snd_vt1724_capture_spdif_ops = { |
|---|
| 1308 | 1286 | .open = snd_vt1724_capture_spdif_open, |
|---|
| 1309 | 1287 | .close = snd_vt1724_capture_spdif_close, |
|---|
| 1310 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1311 | 1288 | .hw_params = snd_vt1724_pcm_hw_params, |
|---|
| 1312 | 1289 | .hw_free = snd_vt1724_pcm_hw_free, |
|---|
| 1313 | 1290 | .prepare = snd_vt1724_pcm_prepare, |
|---|
| .. | .. |
|---|
| 1357 | 1334 | pcm->info_flags = 0; |
|---|
| 1358 | 1335 | strcpy(pcm->name, name); |
|---|
| 1359 | 1336 | |
|---|
| 1360 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1361 | | - snd_dma_pci_data(ice->pci), |
|---|
| 1362 | | - 256*1024, 256*1024); |
|---|
| 1337 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1338 | + &ice->pci->dev, 256*1024, 256*1024); |
|---|
| 1363 | 1339 | |
|---|
| 1364 | 1340 | ice->pcm = pcm; |
|---|
| 1365 | 1341 | |
|---|
| .. | .. |
|---|
| 1441 | 1417 | static const struct snd_pcm_ops snd_vt1724_playback_indep_ops = { |
|---|
| 1442 | 1418 | .open = snd_vt1724_playback_indep_open, |
|---|
| 1443 | 1419 | .close = snd_vt1724_playback_indep_close, |
|---|
| 1444 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1445 | 1420 | .hw_params = snd_vt1724_pcm_hw_params, |
|---|
| 1446 | 1421 | .hw_free = snd_vt1724_pcm_hw_free, |
|---|
| 1447 | 1422 | .prepare = snd_vt1724_playback_indep_prepare, |
|---|
| .. | .. |
|---|
| 1471 | 1446 | pcm->info_flags = 0; |
|---|
| 1472 | 1447 | strcpy(pcm->name, "ICE1724 Surround PCM"); |
|---|
| 1473 | 1448 | |
|---|
| 1474 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1475 | | - snd_dma_pci_data(ice->pci), |
|---|
| 1476 | | - 256*1024, 256*1024); |
|---|
| 1449 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1450 | + &ice->pci->dev, 256*1024, 256*1024); |
|---|
| 1477 | 1451 | |
|---|
| 1478 | 1452 | ice->pcm_ds = pcm; |
|---|
| 1479 | 1453 | |
|---|
| .. | .. |
|---|
| 1492 | 1466 | if (!(ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) { |
|---|
| 1493 | 1467 | struct snd_ac97_bus *pbus; |
|---|
| 1494 | 1468 | struct snd_ac97_template ac97; |
|---|
| 1495 | | - static struct snd_ac97_bus_ops ops = { |
|---|
| 1469 | + static const struct snd_ac97_bus_ops ops = { |
|---|
| 1496 | 1470 | .write = snd_vt1724_ac97_write, |
|---|
| 1497 | 1471 | .read = snd_vt1724_ac97_read, |
|---|
| 1498 | 1472 | }; |
|---|
| .. | .. |
|---|
| 1574 | 1548 | |
|---|
| 1575 | 1549 | static void snd_vt1724_proc_init(struct snd_ice1712 *ice) |
|---|
| 1576 | 1550 | { |
|---|
| 1577 | | - struct snd_info_entry *entry; |
|---|
| 1578 | | - |
|---|
| 1579 | | - if (!snd_card_proc_new(ice->card, "ice1724", &entry)) |
|---|
| 1580 | | - snd_info_set_text_ops(entry, ice, snd_vt1724_proc_read); |
|---|
| 1551 | + snd_card_ro_proc_new(ice->card, "ice1724", ice, snd_vt1724_proc_read); |
|---|
| 1581 | 1552 | } |
|---|
| 1582 | 1553 | |
|---|
| 1583 | 1554 | /* |
|---|
| .. | .. |
|---|
| 2202 | 2173 | * |
|---|
| 2203 | 2174 | */ |
|---|
| 2204 | 2175 | |
|---|
| 2205 | | -static struct snd_ice1712_card_info no_matched; |
|---|
| 2176 | +static const struct snd_ice1712_card_info no_matched; |
|---|
| 2206 | 2177 | |
|---|
| 2207 | 2178 | |
|---|
| 2208 | 2179 | /* |
|---|
| 2209 | 2180 | ooAoo cards with no controls |
|---|
| 2210 | 2181 | */ |
|---|
| 2211 | | -static unsigned char ooaoo_sq210_eeprom[] = { |
|---|
| 2182 | +static const unsigned char ooaoo_sq210_eeprom[] = { |
|---|
| 2212 | 2183 | [ICE_EEP2_SYSCONF] = 0x4c, /* 49MHz crystal, no mpu401, no ADC, |
|---|
| 2213 | 2184 | 1xDACs */ |
|---|
| 2214 | 2185 | [ICE_EEP2_ACLINK] = 0x80, /* I2S */ |
|---|
| .. | .. |
|---|
| 2228 | 2199 | }; |
|---|
| 2229 | 2200 | |
|---|
| 2230 | 2201 | |
|---|
| 2231 | | -static struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = { |
|---|
| 2202 | +static const struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] = { |
|---|
| 2232 | 2203 | { |
|---|
| 2233 | 2204 | .name = "ooAoo SQ210a", |
|---|
| 2234 | 2205 | .model = "sq210a", |
|---|
| .. | .. |
|---|
| 2238 | 2209 | { } /* terminator */ |
|---|
| 2239 | 2210 | }; |
|---|
| 2240 | 2211 | |
|---|
| 2241 | | -static struct snd_ice1712_card_info *card_tables[] = { |
|---|
| 2212 | +static const struct snd_ice1712_card_info *card_tables[] = { |
|---|
| 2242 | 2213 | snd_vt1724_revo_cards, |
|---|
| 2243 | 2214 | snd_vt1724_amp_cards, |
|---|
| 2244 | 2215 | snd_vt1724_aureon_cards, |
|---|
| .. | .. |
|---|
| 2308 | 2279 | { |
|---|
| 2309 | 2280 | const int dev = 0xa0; /* EEPROM device address */ |
|---|
| 2310 | 2281 | unsigned int i, size; |
|---|
| 2311 | | - struct snd_ice1712_card_info * const *tbl, *c; |
|---|
| 2282 | + const struct snd_ice1712_card_info * const *tbl, *c; |
|---|
| 2312 | 2283 | |
|---|
| 2313 | 2284 | if (!modelname || !*modelname) { |
|---|
| 2314 | 2285 | ice->eeprom.subvendor = 0; |
|---|
| .. | .. |
|---|
| 2534 | 2505 | { |
|---|
| 2535 | 2506 | struct snd_ice1712 *ice; |
|---|
| 2536 | 2507 | int err; |
|---|
| 2537 | | - static struct snd_device_ops ops = { |
|---|
| 2508 | + static const struct snd_device_ops ops = { |
|---|
| 2538 | 2509 | .dev_free = snd_vt1724_dev_free, |
|---|
| 2539 | 2510 | }; |
|---|
| 2540 | 2511 | |
|---|
| .. | .. |
|---|
| 2566 | 2537 | ice->irq = -1; |
|---|
| 2567 | 2538 | pci_set_master(pci); |
|---|
| 2568 | 2539 | snd_vt1724_proc_init(ice); |
|---|
| 2569 | | - synchronize_irq(pci->irq); |
|---|
| 2570 | 2540 | |
|---|
| 2571 | 2541 | card->private_data = ice; |
|---|
| 2572 | 2542 | |
|---|
| .. | .. |
|---|
| 2587 | 2557 | } |
|---|
| 2588 | 2558 | |
|---|
| 2589 | 2559 | ice->irq = pci->irq; |
|---|
| 2560 | + card->sync_irq = ice->irq; |
|---|
| 2590 | 2561 | |
|---|
| 2591 | 2562 | snd_vt1724_chip_reset(ice); |
|---|
| 2592 | 2563 | if (snd_vt1724_read_eeprom(ice, modelname) < 0) { |
|---|
| .. | .. |
|---|
| 2622 | 2593 | struct snd_card *card; |
|---|
| 2623 | 2594 | struct snd_ice1712 *ice; |
|---|
| 2624 | 2595 | int pcm_dev = 0, err; |
|---|
| 2625 | | - struct snd_ice1712_card_info * const *tbl, *c; |
|---|
| 2596 | + const struct snd_ice1712_card_info * const *tbl, *c; |
|---|
| 2626 | 2597 | |
|---|
| 2627 | 2598 | if (dev >= SNDRV_CARDS) |
|---|
| 2628 | 2599 | return -ENODEV; |
|---|
| .. | .. |
|---|
| 2807 | 2778 | |
|---|
| 2808 | 2779 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
|---|
| 2809 | 2780 | |
|---|
| 2810 | | - snd_pcm_suspend_all(ice->pcm); |
|---|
| 2811 | | - snd_pcm_suspend_all(ice->pcm_pro); |
|---|
| 2812 | | - snd_pcm_suspend_all(ice->pcm_ds); |
|---|
| 2813 | 2781 | snd_ac97_suspend(ice->ac97); |
|---|
| 2814 | 2782 | |
|---|
| 2815 | 2783 | spin_lock_irq(&ice->reg_lock); |
|---|