.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Matt Wu <Matt_Wu@acersoftech.com.cn> |
---|
3 | 4 | * Apr 26, 2001 |
---|
.. | .. |
---|
8 | 9 | * |
---|
9 | 10 | * TODO: |
---|
10 | 11 | * -- |
---|
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 | | - * |
---|
26 | 12 | */ |
---|
27 | 13 | |
---|
28 | 14 | #include <linux/io.h> |
---|
.. | .. |
---|
1084 | 1070 | { |
---|
1085 | 1071 | struct snd_ali *codec = snd_pcm_substream_chip(substream); |
---|
1086 | 1072 | struct snd_pcm_substream *s; |
---|
1087 | | - unsigned int what, whati, capture_flag; |
---|
| 1073 | + unsigned int what, whati; |
---|
1088 | 1074 | struct snd_ali_voice *pvoice, *evoice; |
---|
1089 | 1075 | unsigned int val; |
---|
1090 | 1076 | int do_start; |
---|
.. | .. |
---|
1102 | 1088 | return -EINVAL; |
---|
1103 | 1089 | } |
---|
1104 | 1090 | |
---|
1105 | | - what = whati = capture_flag = 0; |
---|
| 1091 | + what = whati = 0; |
---|
1106 | 1092 | snd_pcm_group_for_each_entry(s, substream) { |
---|
1107 | 1093 | if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { |
---|
1108 | 1094 | pvoice = s->runtime->private_data; |
---|
.. | .. |
---|
1124 | 1110 | evoice->running = 0; |
---|
1125 | 1111 | } |
---|
1126 | 1112 | snd_pcm_trigger_done(s, substream); |
---|
1127 | | - if (pvoice->mode) |
---|
1128 | | - capture_flag = 1; |
---|
1129 | 1113 | } |
---|
1130 | 1114 | } |
---|
1131 | 1115 | spin_lock(&codec->reg_lock); |
---|
.. | .. |
---|
1152 | 1136 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
1153 | 1137 | struct snd_ali_voice *pvoice = runtime->private_data; |
---|
1154 | 1138 | struct snd_ali_voice *evoice = pvoice->extra; |
---|
1155 | | - int err; |
---|
1156 | 1139 | |
---|
1157 | | - err = snd_pcm_lib_malloc_pages(substream, |
---|
1158 | | - params_buffer_bytes(hw_params)); |
---|
1159 | | - if (err < 0) |
---|
1160 | | - return err; |
---|
1161 | | - |
---|
1162 | 1140 | /* voice management */ |
---|
1163 | 1141 | |
---|
1164 | 1142 | if (params_buffer_size(hw_params) / 2 != |
---|
.. | .. |
---|
1189 | 1167 | struct snd_ali_voice *pvoice = runtime->private_data; |
---|
1190 | 1168 | struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; |
---|
1191 | 1169 | |
---|
1192 | | - snd_pcm_lib_free_pages(substream); |
---|
1193 | 1170 | if (evoice) { |
---|
1194 | 1171 | snd_ali_free_voice(codec, evoice); |
---|
1195 | 1172 | pvoice->extra = NULL; |
---|
1196 | 1173 | } |
---|
1197 | 1174 | 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); |
---|
1210 | 1175 | } |
---|
1211 | 1176 | |
---|
1212 | 1177 | static int snd_ali_playback_prepare(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
1433 | 1398 | return cso; |
---|
1434 | 1399 | } |
---|
1435 | 1400 | |
---|
1436 | | -static struct snd_pcm_hardware snd_ali_playback = |
---|
| 1401 | +static const struct snd_pcm_hardware snd_ali_playback = |
---|
1437 | 1402 | { |
---|
1438 | 1403 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
---|
1439 | 1404 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
---|
.. | .. |
---|
1459 | 1424 | * Capture support device description |
---|
1460 | 1425 | */ |
---|
1461 | 1426 | |
---|
1462 | | -static struct snd_pcm_hardware snd_ali_capture = |
---|
| 1427 | +static const struct snd_pcm_hardware snd_ali_capture = |
---|
1463 | 1428 | { |
---|
1464 | 1429 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
---|
1465 | 1430 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
---|
.. | .. |
---|
1490 | 1455 | } |
---|
1491 | 1456 | |
---|
1492 | 1457 | 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) |
---|
1494 | 1459 | { |
---|
1495 | 1460 | struct snd_ali *codec = snd_pcm_substream_chip(substream); |
---|
1496 | 1461 | struct snd_pcm_runtime *runtime = substream->runtime; |
---|
.. | .. |
---|
1540 | 1505 | static const struct snd_pcm_ops snd_ali_playback_ops = { |
---|
1541 | 1506 | .open = snd_ali_playback_open, |
---|
1542 | 1507 | .close = snd_ali_playback_close, |
---|
1543 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1544 | 1508 | .hw_params = snd_ali_playback_hw_params, |
---|
1545 | 1509 | .hw_free = snd_ali_playback_hw_free, |
---|
1546 | 1510 | .prepare = snd_ali_playback_prepare, |
---|
.. | .. |
---|
1551 | 1515 | static const struct snd_pcm_ops snd_ali_capture_ops = { |
---|
1552 | 1516 | .open = snd_ali_capture_open, |
---|
1553 | 1517 | .close = snd_ali_close, |
---|
1554 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1555 | | - .hw_params = snd_ali_hw_params, |
---|
1556 | | - .hw_free = snd_ali_hw_free, |
---|
1557 | 1518 | .prepare = snd_ali_prepare, |
---|
1558 | 1519 | .trigger = snd_ali_trigger, |
---|
1559 | 1520 | .pointer = snd_ali_pointer, |
---|
.. | .. |
---|
1571 | 1532 | snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, |
---|
1572 | 1533 | params_rate(hw_params)); |
---|
1573 | 1534 | snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); |
---|
1574 | | - return snd_ali_hw_params(substream, hw_params); |
---|
| 1535 | + return 0; |
---|
1575 | 1536 | } |
---|
1576 | 1537 | |
---|
1577 | | -static struct snd_pcm_hardware snd_ali_modem = |
---|
| 1538 | +static const struct snd_pcm_hardware snd_ali_modem = |
---|
1578 | 1539 | { |
---|
1579 | 1540 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
---|
1580 | 1541 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
---|
.. | .. |
---|
1626 | 1587 | static const struct snd_pcm_ops snd_ali_modem_playback_ops = { |
---|
1627 | 1588 | .open = snd_ali_modem_playback_open, |
---|
1628 | 1589 | .close = snd_ali_close, |
---|
1629 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1630 | 1590 | .hw_params = snd_ali_modem_hw_params, |
---|
1631 | | - .hw_free = snd_ali_hw_free, |
---|
1632 | 1591 | .prepare = snd_ali_prepare, |
---|
1633 | 1592 | .trigger = snd_ali_trigger, |
---|
1634 | 1593 | .pointer = snd_ali_pointer, |
---|
.. | .. |
---|
1637 | 1596 | static const struct snd_pcm_ops snd_ali_modem_capture_ops = { |
---|
1638 | 1597 | .open = snd_ali_modem_capture_open, |
---|
1639 | 1598 | .close = snd_ali_close, |
---|
1640 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1641 | 1599 | .hw_params = snd_ali_modem_hw_params, |
---|
1642 | | - .hw_free = snd_ali_hw_free, |
---|
1643 | 1600 | .prepare = snd_ali_prepare, |
---|
1644 | 1601 | .trigger = snd_ali_trigger, |
---|
1645 | 1602 | .pointer = snd_ali_pointer, |
---|
.. | .. |
---|
1685 | 1642 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, |
---|
1686 | 1643 | desc->capture_ops); |
---|
1687 | 1644 | |
---|
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); |
---|
1691 | 1647 | |
---|
1692 | 1648 | pcm->info_flags = 0; |
---|
1693 | 1649 | pcm->dev_class = desc->class; |
---|
.. | .. |
---|
1818 | 1774 | return change; |
---|
1819 | 1775 | } |
---|
1820 | 1776 | |
---|
1821 | | -static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] = { |
---|
| 1777 | +static const struct snd_kcontrol_new snd_ali5451_mixer_spdif[] = { |
---|
1822 | 1778 | /* spdif aplayback switch */ |
---|
1823 | 1779 | /* FIXME: "IEC958 Playback Switch" may conflict with one on ac97_codec */ |
---|
1824 | 1780 | ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), 0, 0), |
---|
.. | .. |
---|
1833 | 1789 | struct snd_ac97_template ac97; |
---|
1834 | 1790 | unsigned int idx; |
---|
1835 | 1791 | int i, err; |
---|
1836 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 1792 | + static const struct snd_ac97_bus_ops ops = { |
---|
1837 | 1793 | .write = snd_ali_codec_write, |
---|
1838 | 1794 | .read = snd_ali_codec_read, |
---|
1839 | 1795 | }; |
---|
.. | .. |
---|
1882 | 1838 | return 0; |
---|
1883 | 1839 | |
---|
1884 | 1840 | 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++) |
---|
1887 | 1842 | snd_ac97_suspend(chip->ac97[i]); |
---|
1888 | | - } |
---|
1889 | 1843 | |
---|
1890 | 1844 | spin_lock_irq(&chip->reg_lock); |
---|
1891 | 1845 | |
---|
.. | .. |
---|
2051 | 2005 | |
---|
2052 | 2006 | static void snd_ali_proc_init(struct snd_ali *codec) |
---|
2053 | 2007 | { |
---|
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); |
---|
2057 | 2009 | } |
---|
2058 | 2010 | |
---|
2059 | 2011 | static int snd_ali_resources(struct snd_ali *codec) |
---|
.. | .. |
---|
2072 | 2024 | return -EBUSY; |
---|
2073 | 2025 | } |
---|
2074 | 2026 | codec->irq = codec->pci->irq; |
---|
| 2027 | + codec->card->sync_irq = codec->irq; |
---|
2075 | 2028 | dev_dbg(codec->card->dev, "resources allocated.\n"); |
---|
2076 | 2029 | return 0; |
---|
2077 | 2030 | } |
---|
.. | .. |
---|
2091 | 2044 | struct snd_ali *codec; |
---|
2092 | 2045 | int i, err; |
---|
2093 | 2046 | unsigned short cmdw; |
---|
2094 | | - static struct snd_device_ops ops = { |
---|
| 2047 | + static const struct snd_device_ops ops = { |
---|
2095 | 2048 | .dev_free = snd_ali_dev_free, |
---|
2096 | 2049 | }; |
---|
2097 | 2050 | |
---|
.. | .. |
---|
2144 | 2097 | snd_ali_free(codec); |
---|
2145 | 2098 | return -EBUSY; |
---|
2146 | 2099 | } |
---|
2147 | | - |
---|
2148 | | - synchronize_irq(pci->irq); |
---|
2149 | 2100 | |
---|
2150 | 2101 | codec->synth.chmap = 0; |
---|
2151 | 2102 | codec->synth.chcnt = 0; |
---|