.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
---|
3 | 4 | * Routines for control of YMF724/740/744/754 chips |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
8 | | - * (at your option) any later version. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, write to the Free Software |
---|
17 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | | - * |
---|
19 | 5 | */ |
---|
20 | 6 | |
---|
21 | 7 | #include <linux/delay.h> |
---|
.. | .. |
---|
136 | 122 | } |
---|
137 | 123 | } |
---|
138 | 124 | |
---|
139 | | -static u32 def_rate[8] = { |
---|
| 125 | +static const u32 def_rate[8] = { |
---|
140 | 126 | 100, 2000, 8000, 11025, 16000, 22050, 32000, 48000 |
---|
141 | 127 | }; |
---|
142 | 128 | |
---|
143 | 129 | static u32 snd_ymfpci_calc_lpfK(u32 rate) |
---|
144 | 130 | { |
---|
145 | 131 | u32 i; |
---|
146 | | - static u32 val[8] = { |
---|
| 132 | + static const u32 val[8] = { |
---|
147 | 133 | 0x00570000, 0x06AA0000, 0x18B20000, 0x20930000, |
---|
148 | 134 | 0x2B9A0000, 0x35A10000, 0x3EAA0000, 0x40000000 |
---|
149 | 135 | }; |
---|
.. | .. |
---|
159 | 145 | static u32 snd_ymfpci_calc_lpfQ(u32 rate) |
---|
160 | 146 | { |
---|
161 | 147 | u32 i; |
---|
162 | | - static u32 val[8] = { |
---|
| 148 | + static const u32 val[8] = { |
---|
163 | 149 | 0x35280000, 0x34A70000, 0x32020000, 0x31770000, |
---|
164 | 150 | 0x31390000, 0x31C90000, 0x33D00000, 0x40000000 |
---|
165 | 151 | }; |
---|
.. | .. |
---|
306 | 292 | struct snd_ymfpci_pcm *ypcm; |
---|
307 | 293 | u32 pos, delta; |
---|
308 | 294 | |
---|
309 | | - if ((ypcm = voice->ypcm) == NULL) |
---|
| 295 | + ypcm = voice->ypcm; |
---|
| 296 | + if (!ypcm) |
---|
310 | 297 | return; |
---|
311 | 298 | if (ypcm->substream == NULL) |
---|
312 | 299 | return; |
---|
.. | .. |
---|
414 | 401 | kctl = chip->pcm_mixer[substream->number].ctl; |
---|
415 | 402 | kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; |
---|
416 | 403 | } |
---|
417 | | - /* fall through */ |
---|
| 404 | + fallthrough; |
---|
418 | 405 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
---|
419 | 406 | case SNDRV_PCM_TRIGGER_SUSPEND: |
---|
420 | 407 | chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0; |
---|
.. | .. |
---|
601 | 588 | |
---|
602 | 589 | static int snd_ymfpci_ac3_init(struct snd_ymfpci *chip) |
---|
603 | 590 | { |
---|
604 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), |
---|
| 591 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, |
---|
605 | 592 | 4096, &chip->ac3_tmp_base) < 0) |
---|
606 | 593 | return -ENOMEM; |
---|
607 | 594 | |
---|
.. | .. |
---|
642 | 629 | struct snd_ymfpci_pcm *ypcm = runtime->private_data; |
---|
643 | 630 | int err; |
---|
644 | 631 | |
---|
645 | | - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) |
---|
646 | | - return err; |
---|
647 | | - if ((err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params))) < 0) |
---|
| 632 | + err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params)); |
---|
| 633 | + if (err < 0) |
---|
648 | 634 | return err; |
---|
649 | 635 | return 0; |
---|
650 | 636 | } |
---|
.. | .. |
---|
661 | 647 | |
---|
662 | 648 | /* wait, until the PCI operations are not finished */ |
---|
663 | 649 | snd_ymfpci_irq_wait(chip); |
---|
664 | | - snd_pcm_lib_free_pages(substream); |
---|
665 | 650 | if (ypcm->voices[1]) { |
---|
666 | 651 | snd_ymfpci_voice_free(chip, ypcm->voices[1]); |
---|
667 | 652 | ypcm->voices[1] = NULL; |
---|
.. | .. |
---|
697 | 682 | return 0; |
---|
698 | 683 | } |
---|
699 | 684 | |
---|
700 | | -static int snd_ymfpci_capture_hw_params(struct snd_pcm_substream *substream, |
---|
701 | | - struct snd_pcm_hw_params *hw_params) |
---|
702 | | -{ |
---|
703 | | - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); |
---|
704 | | -} |
---|
705 | | - |
---|
706 | 685 | static int snd_ymfpci_capture_hw_free(struct snd_pcm_substream *substream) |
---|
707 | 686 | { |
---|
708 | 687 | struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); |
---|
709 | 688 | |
---|
710 | 689 | /* wait, until the PCI operations are not finished */ |
---|
711 | 690 | snd_ymfpci_irq_wait(chip); |
---|
712 | | - return snd_pcm_lib_free_pages(substream); |
---|
| 691 | + return 0; |
---|
713 | 692 | } |
---|
714 | 693 | |
---|
715 | 694 | static int snd_ymfpci_capture_prepare(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
955 | 934 | struct snd_ymfpci_pcm *ypcm; |
---|
956 | 935 | int err; |
---|
957 | 936 | |
---|
958 | | - if ((err = snd_ymfpci_playback_open_1(substream)) < 0) |
---|
| 937 | + err = snd_ymfpci_playback_open_1(substream); |
---|
| 938 | + if (err < 0) |
---|
959 | 939 | return err; |
---|
960 | 940 | ypcm = runtime->private_data; |
---|
961 | 941 | ypcm->output_front = 1; |
---|
.. | .. |
---|
977 | 957 | struct snd_ymfpci_pcm *ypcm; |
---|
978 | 958 | int err; |
---|
979 | 959 | |
---|
980 | | - if ((err = snd_ymfpci_playback_open_1(substream)) < 0) |
---|
| 960 | + err = snd_ymfpci_playback_open_1(substream); |
---|
| 961 | + if (err < 0) |
---|
981 | 962 | return err; |
---|
982 | 963 | ypcm = runtime->private_data; |
---|
983 | 964 | ypcm->output_front = 0; |
---|
.. | .. |
---|
1005 | 986 | struct snd_ymfpci_pcm *ypcm; |
---|
1006 | 987 | int err; |
---|
1007 | 988 | |
---|
1008 | | - if ((err = snd_ymfpci_playback_open_1(substream)) < 0) |
---|
| 989 | + err = snd_ymfpci_playback_open_1(substream); |
---|
| 990 | + if (err < 0) |
---|
1009 | 991 | return err; |
---|
1010 | 992 | ypcm = runtime->private_data; |
---|
1011 | 993 | ypcm->output_front = 0; |
---|
.. | .. |
---|
1126 | 1108 | static const struct snd_pcm_ops snd_ymfpci_playback_ops = { |
---|
1127 | 1109 | .open = snd_ymfpci_playback_open, |
---|
1128 | 1110 | .close = snd_ymfpci_playback_close, |
---|
1129 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1130 | 1111 | .hw_params = snd_ymfpci_playback_hw_params, |
---|
1131 | 1112 | .hw_free = snd_ymfpci_playback_hw_free, |
---|
1132 | 1113 | .prepare = snd_ymfpci_playback_prepare, |
---|
.. | .. |
---|
1137 | 1118 | static const struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { |
---|
1138 | 1119 | .open = snd_ymfpci_capture_rec_open, |
---|
1139 | 1120 | .close = snd_ymfpci_capture_close, |
---|
1140 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1141 | | - .hw_params = snd_ymfpci_capture_hw_params, |
---|
1142 | 1121 | .hw_free = snd_ymfpci_capture_hw_free, |
---|
1143 | 1122 | .prepare = snd_ymfpci_capture_prepare, |
---|
1144 | 1123 | .trigger = snd_ymfpci_capture_trigger, |
---|
.. | .. |
---|
1150 | 1129 | struct snd_pcm *pcm; |
---|
1151 | 1130 | int err; |
---|
1152 | 1131 | |
---|
1153 | | - if ((err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm)) < 0) |
---|
| 1132 | + err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm); |
---|
| 1133 | + if (err < 0) |
---|
1154 | 1134 | return err; |
---|
1155 | 1135 | pcm->private_data = chip; |
---|
1156 | 1136 | |
---|
.. | .. |
---|
1162 | 1142 | strcpy(pcm->name, "YMFPCI"); |
---|
1163 | 1143 | chip->pcm = pcm; |
---|
1164 | 1144 | |
---|
1165 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1166 | | - snd_dma_pci_data(chip->pci), 64*1024, 256*1024); |
---|
| 1145 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 1146 | + &chip->pci->dev, 64*1024, 256*1024); |
---|
1167 | 1147 | |
---|
1168 | 1148 | return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
1169 | 1149 | snd_pcm_std_chmaps, 2, 0, NULL); |
---|
.. | .. |
---|
1172 | 1152 | static const struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { |
---|
1173 | 1153 | .open = snd_ymfpci_capture_ac97_open, |
---|
1174 | 1154 | .close = snd_ymfpci_capture_close, |
---|
1175 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1176 | | - .hw_params = snd_ymfpci_capture_hw_params, |
---|
1177 | 1155 | .hw_free = snd_ymfpci_capture_hw_free, |
---|
1178 | 1156 | .prepare = snd_ymfpci_capture_prepare, |
---|
1179 | 1157 | .trigger = snd_ymfpci_capture_trigger, |
---|
.. | .. |
---|
1185 | 1163 | struct snd_pcm *pcm; |
---|
1186 | 1164 | int err; |
---|
1187 | 1165 | |
---|
1188 | | - if ((err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm)) < 0) |
---|
| 1166 | + err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm); |
---|
| 1167 | + if (err < 0) |
---|
1189 | 1168 | return err; |
---|
1190 | 1169 | pcm->private_data = chip; |
---|
1191 | 1170 | |
---|
.. | .. |
---|
1197 | 1176 | chip->device_id == PCI_DEVICE_ID_YAMAHA_754 ? "Direct Recording" : "AC'97"); |
---|
1198 | 1177 | chip->pcm2 = pcm; |
---|
1199 | 1178 | |
---|
1200 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1201 | | - snd_dma_pci_data(chip->pci), 64*1024, 256*1024); |
---|
| 1179 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 1180 | + &chip->pci->dev, 64*1024, 256*1024); |
---|
1202 | 1181 | |
---|
1203 | 1182 | return 0; |
---|
1204 | 1183 | } |
---|
.. | .. |
---|
1206 | 1185 | static const struct snd_pcm_ops snd_ymfpci_playback_spdif_ops = { |
---|
1207 | 1186 | .open = snd_ymfpci_playback_spdif_open, |
---|
1208 | 1187 | .close = snd_ymfpci_playback_spdif_close, |
---|
1209 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1210 | 1188 | .hw_params = snd_ymfpci_playback_hw_params, |
---|
1211 | 1189 | .hw_free = snd_ymfpci_playback_hw_free, |
---|
1212 | 1190 | .prepare = snd_ymfpci_playback_prepare, |
---|
.. | .. |
---|
1219 | 1197 | struct snd_pcm *pcm; |
---|
1220 | 1198 | int err; |
---|
1221 | 1199 | |
---|
1222 | | - if ((err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm)) < 0) |
---|
| 1200 | + err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm); |
---|
| 1201 | + if (err < 0) |
---|
1223 | 1202 | return err; |
---|
1224 | 1203 | pcm->private_data = chip; |
---|
1225 | 1204 | |
---|
.. | .. |
---|
1230 | 1209 | strcpy(pcm->name, "YMFPCI - IEC958"); |
---|
1231 | 1210 | chip->pcm_spdif = pcm; |
---|
1232 | 1211 | |
---|
1233 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1234 | | - snd_dma_pci_data(chip->pci), 64*1024, 256*1024); |
---|
| 1212 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 1213 | + &chip->pci->dev, 64*1024, 256*1024); |
---|
1235 | 1214 | |
---|
1236 | 1215 | return 0; |
---|
1237 | 1216 | } |
---|
.. | .. |
---|
1239 | 1218 | static const struct snd_pcm_ops snd_ymfpci_playback_4ch_ops = { |
---|
1240 | 1219 | .open = snd_ymfpci_playback_4ch_open, |
---|
1241 | 1220 | .close = snd_ymfpci_playback_4ch_close, |
---|
1242 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1243 | 1221 | .hw_params = snd_ymfpci_playback_hw_params, |
---|
1244 | 1222 | .hw_free = snd_ymfpci_playback_hw_free, |
---|
1245 | 1223 | .prepare = snd_ymfpci_playback_prepare, |
---|
.. | .. |
---|
1260 | 1238 | struct snd_pcm *pcm; |
---|
1261 | 1239 | int err; |
---|
1262 | 1240 | |
---|
1263 | | - if ((err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm)) < 0) |
---|
| 1241 | + err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm); |
---|
| 1242 | + if (err < 0) |
---|
1264 | 1243 | return err; |
---|
1265 | 1244 | pcm->private_data = chip; |
---|
1266 | 1245 | |
---|
.. | .. |
---|
1271 | 1250 | strcpy(pcm->name, "YMFPCI - Rear PCM"); |
---|
1272 | 1251 | chip->pcm_4ch = pcm; |
---|
1273 | 1252 | |
---|
1274 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1275 | | - snd_dma_pci_data(chip->pci), 64*1024, 256*1024); |
---|
| 1253 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
| 1254 | + &chip->pci->dev, 64*1024, 256*1024); |
---|
1276 | 1255 | |
---|
1277 | 1256 | return snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
---|
1278 | 1257 | surround_map, 2, 0, NULL); |
---|
.. | .. |
---|
1618 | 1597 | .put = snd_ymfpci_put_dup4ch, |
---|
1619 | 1598 | }; |
---|
1620 | 1599 | |
---|
1621 | | -static struct snd_kcontrol_new snd_ymfpci_controls[] = { |
---|
| 1600 | +static const struct snd_kcontrol_new snd_ymfpci_controls[] = { |
---|
1622 | 1601 | { |
---|
1623 | 1602 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
---|
1624 | 1603 | .name = "Wave Playback Volume", |
---|
.. | .. |
---|
1810 | 1789 | struct snd_pcm_substream *substream; |
---|
1811 | 1790 | unsigned int idx; |
---|
1812 | 1791 | int err; |
---|
1813 | | - static struct snd_ac97_bus_ops ops = { |
---|
| 1792 | + static const struct snd_ac97_bus_ops ops = { |
---|
1814 | 1793 | .write = snd_ymfpci_codec_write, |
---|
1815 | 1794 | .read = snd_ymfpci_codec_read, |
---|
1816 | 1795 | }; |
---|
1817 | 1796 | |
---|
1818 | | - if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) |
---|
| 1797 | + err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus); |
---|
| 1798 | + if (err < 0) |
---|
1819 | 1799 | return err; |
---|
1820 | 1800 | chip->ac97_bus->private_free = snd_ymfpci_mixer_free_ac97_bus; |
---|
1821 | 1801 | chip->ac97_bus->no_vra = 1; /* YMFPCI doesn't need VRA */ |
---|
.. | .. |
---|
1823 | 1803 | memset(&ac97, 0, sizeof(ac97)); |
---|
1824 | 1804 | ac97.private_data = chip; |
---|
1825 | 1805 | ac97.private_free = snd_ymfpci_mixer_free_ac97; |
---|
1826 | | - if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) |
---|
| 1806 | + err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97); |
---|
| 1807 | + if (err < 0) |
---|
1827 | 1808 | return err; |
---|
1828 | 1809 | |
---|
1829 | 1810 | /* to be sure */ |
---|
.. | .. |
---|
1831 | 1812 | AC97_EA_VRA|AC97_EA_VRM, 0); |
---|
1832 | 1813 | |
---|
1833 | 1814 | for (idx = 0; idx < ARRAY_SIZE(snd_ymfpci_controls); idx++) { |
---|
1834 | | - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip))) < 0) |
---|
| 1815 | + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip)); |
---|
| 1816 | + if (err < 0) |
---|
1835 | 1817 | return err; |
---|
1836 | 1818 | } |
---|
1837 | 1819 | if (chip->ac97->ext_id & AC97_EI_SDAC) { |
---|
.. | .. |
---|
1844 | 1826 | /* add S/PDIF control */ |
---|
1845 | 1827 | if (snd_BUG_ON(!chip->pcm_spdif)) |
---|
1846 | 1828 | return -ENXIO; |
---|
1847 | | - if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0) |
---|
| 1829 | + kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip); |
---|
| 1830 | + err = snd_ctl_add(chip->card, kctl); |
---|
| 1831 | + if (err < 0) |
---|
1848 | 1832 | return err; |
---|
1849 | 1833 | kctl->id.device = chip->pcm_spdif->device; |
---|
1850 | | - if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip))) < 0) |
---|
| 1834 | + kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip); |
---|
| 1835 | + err = snd_ctl_add(chip->card, kctl); |
---|
| 1836 | + if (err < 0) |
---|
1851 | 1837 | return err; |
---|
1852 | 1838 | kctl->id.device = chip->pcm_spdif->device; |
---|
1853 | | - if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip))) < 0) |
---|
| 1839 | + kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip); |
---|
| 1840 | + err = snd_ctl_add(chip->card, kctl); |
---|
| 1841 | + if (err < 0) |
---|
1854 | 1842 | return err; |
---|
1855 | 1843 | kctl->id.device = chip->pcm_spdif->device; |
---|
1856 | 1844 | chip->spdif_pcm_ctl = kctl; |
---|
1857 | 1845 | |
---|
1858 | 1846 | /* direct recording source */ |
---|
1859 | | - if (chip->device_id == PCI_DEVICE_ID_YAMAHA_754 && |
---|
1860 | | - (err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_drec_source, chip))) < 0) |
---|
1861 | | - return err; |
---|
| 1847 | + if (chip->device_id == PCI_DEVICE_ID_YAMAHA_754) { |
---|
| 1848 | + kctl = snd_ctl_new1(&snd_ymfpci_drec_source, chip); |
---|
| 1849 | + err = snd_ctl_add(chip->card, kctl); |
---|
| 1850 | + if (err < 0) |
---|
| 1851 | + return err; |
---|
| 1852 | + } |
---|
1862 | 1853 | |
---|
1863 | 1854 | /* |
---|
1864 | 1855 | * shared rear/line-in |
---|
1865 | 1856 | */ |
---|
1866 | 1857 | if (rear_switch) { |
---|
1867 | | - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_rear_shared, chip))) < 0) |
---|
| 1858 | + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_rear_shared, chip)); |
---|
| 1859 | + if (err < 0) |
---|
1868 | 1860 | return err; |
---|
1869 | 1861 | } |
---|
1870 | 1862 | |
---|
.. | .. |
---|
1877 | 1869 | kctl->id.device = chip->pcm->device; |
---|
1878 | 1870 | kctl->id.subdevice = idx; |
---|
1879 | 1871 | kctl->private_value = (unsigned long)substream; |
---|
1880 | | - if ((err = snd_ctl_add(chip->card, kctl)) < 0) |
---|
| 1872 | + err = snd_ctl_add(chip->card, kctl); |
---|
| 1873 | + if (err < 0) |
---|
1881 | 1874 | return err; |
---|
1882 | 1875 | chip->pcm_mixer[idx].left = 0x8000; |
---|
1883 | 1876 | chip->pcm_mixer[idx].right = 0x8000; |
---|
.. | .. |
---|
1938 | 1931 | return 0; |
---|
1939 | 1932 | } |
---|
1940 | 1933 | |
---|
1941 | | -static struct snd_timer_hardware snd_ymfpci_timer_hw = { |
---|
| 1934 | +static const struct snd_timer_hardware snd_ymfpci_timer_hw = { |
---|
1942 | 1935 | .flags = SNDRV_TIMER_HW_AUTO, |
---|
1943 | 1936 | .resolution = 10417, /* 1 / 96 kHz = 10.41666...us */ |
---|
1944 | 1937 | .ticks = 0x10000, |
---|
.. | .. |
---|
1958 | 1951 | tid.card = chip->card->number; |
---|
1959 | 1952 | tid.device = device; |
---|
1960 | 1953 | tid.subdevice = 0; |
---|
1961 | | - if ((err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer)) >= 0) { |
---|
| 1954 | + err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer); |
---|
| 1955 | + if (err >= 0) { |
---|
1962 | 1956 | strcpy(timer->name, "YMFPCI timer"); |
---|
1963 | 1957 | timer->private_data = chip; |
---|
1964 | 1958 | timer->hw = snd_ymfpci_timer_hw; |
---|
.. | .. |
---|
1985 | 1979 | |
---|
1986 | 1980 | static int snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) |
---|
1987 | 1981 | { |
---|
1988 | | - struct snd_info_entry *entry; |
---|
1989 | | - |
---|
1990 | | - if (! snd_card_proc_new(card, "ymfpci", &entry)) |
---|
1991 | | - snd_info_set_text_ops(entry, chip, snd_ymfpci_proc_read); |
---|
1992 | | - return 0; |
---|
| 1982 | + return snd_card_ro_proc_new(card, "ymfpci", chip, snd_ymfpci_proc_read); |
---|
1993 | 1983 | } |
---|
1994 | 1984 | |
---|
1995 | 1985 | /* |
---|
.. | .. |
---|
2126 | 2116 | chip->work_size; |
---|
2127 | 2117 | /* work_ptr must be aligned to 256 bytes, but it's already |
---|
2128 | 2118 | covered with the kernel page allocation mechanism */ |
---|
2129 | | - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), |
---|
| 2119 | + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, |
---|
2130 | 2120 | size, &chip->work_ptr) < 0) |
---|
2131 | 2121 | return -ENOMEM; |
---|
2132 | 2122 | ptr = chip->work_ptr.area; |
---|
.. | .. |
---|
2174 | 2164 | chip->work_base = ptr; |
---|
2175 | 2165 | chip->work_base_addr = ptr_addr; |
---|
2176 | 2166 | |
---|
2177 | | - snd_BUG_ON(ptr + chip->work_size != |
---|
| 2167 | + snd_BUG_ON(ptr + PAGE_ALIGN(chip->work_size) != |
---|
2178 | 2168 | chip->work_ptr.area + chip->work_ptr.bytes); |
---|
2179 | 2169 | |
---|
2180 | 2170 | snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr); |
---|
.. | .. |
---|
2268 | 2258 | } |
---|
2269 | 2259 | |
---|
2270 | 2260 | #ifdef CONFIG_PM_SLEEP |
---|
2271 | | -static int saved_regs_index[] = { |
---|
| 2261 | +static const int saved_regs_index[] = { |
---|
2272 | 2262 | /* spdif */ |
---|
2273 | 2263 | YDSXGR_SPDIFOUTCTRL, |
---|
2274 | 2264 | YDSXGR_SPDIFOUTSTATUS, |
---|
.. | .. |
---|
2304 | 2294 | unsigned int i; |
---|
2305 | 2295 | |
---|
2306 | 2296 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
2307 | | - snd_pcm_suspend_all(chip->pcm); |
---|
2308 | | - snd_pcm_suspend_all(chip->pcm2); |
---|
2309 | | - snd_pcm_suspend_all(chip->pcm_spdif); |
---|
2310 | | - snd_pcm_suspend_all(chip->pcm_4ch); |
---|
2311 | 2297 | snd_ac97_suspend(chip->ac97); |
---|
2312 | 2298 | for (i = 0; i < YDSXGR_NUM_SAVED_REGS; i++) |
---|
2313 | 2299 | chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]); |
---|
.. | .. |
---|
2365 | 2351 | { |
---|
2366 | 2352 | struct snd_ymfpci *chip; |
---|
2367 | 2353 | int err; |
---|
2368 | | - static struct snd_device_ops ops = { |
---|
| 2354 | + static const struct snd_device_ops ops = { |
---|
2369 | 2355 | .dev_free = snd_ymfpci_dev_free, |
---|
2370 | 2356 | }; |
---|
2371 | 2357 | |
---|
2372 | 2358 | *rchip = NULL; |
---|
2373 | 2359 | |
---|
2374 | 2360 | /* enable PCI device */ |
---|
2375 | | - if ((err = pci_enable_device(pci)) < 0) |
---|
| 2361 | + err = pci_enable_device(pci); |
---|
| 2362 | + if (err < 0) |
---|
2376 | 2363 | return err; |
---|
2377 | 2364 | |
---|
2378 | 2365 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
---|
.. | .. |
---|
2391 | 2378 | chip->device_id = pci->device; |
---|
2392 | 2379 | chip->rev = pci->revision; |
---|
2393 | 2380 | chip->reg_area_phys = pci_resource_start(pci, 0); |
---|
2394 | | - chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000); |
---|
| 2381 | + chip->reg_area_virt = ioremap(chip->reg_area_phys, 0x8000); |
---|
2395 | 2382 | pci_set_master(pci); |
---|
2396 | 2383 | chip->src441_used = -1; |
---|
2397 | 2384 | |
---|
2398 | | - if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { |
---|
| 2385 | + chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI"); |
---|
| 2386 | + if (!chip->res_reg_area) { |
---|
2399 | 2387 | dev_err(chip->card->dev, |
---|
2400 | 2388 | "unable to grab memory region 0x%lx-0x%lx\n", |
---|
2401 | 2389 | chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); |
---|
.. | .. |
---|
2409 | 2397 | goto free_chip; |
---|
2410 | 2398 | } |
---|
2411 | 2399 | chip->irq = pci->irq; |
---|
| 2400 | + card->sync_irq = chip->irq; |
---|
2412 | 2401 | |
---|
2413 | 2402 | snd_ymfpci_aclink_reset(pci); |
---|
2414 | 2403 | if (snd_ymfpci_codec_ready(chip, 0) < 0) { |
---|