.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for generic ESS AudioDrive ES18xx soundcards |
---|
3 | 4 | * Copyright (c) by Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de> |
---|
4 | 5 | * Copyright (c) by Abramo Bagnara <abramo@alsa-project.org> |
---|
5 | | - * |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License as published by |
---|
9 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
10 | | - * (at your option) any later version. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | | - * |
---|
17 | | - * You should have received a copy of the GNU General Public License |
---|
18 | | - * along with this program; if not, write to the Free Software |
---|
19 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
20 | | - * |
---|
21 | 6 | */ |
---|
22 | 7 | /* GENERAL NOTES: |
---|
23 | 8 | * |
---|
.. | .. |
---|
449 | 434 | struct snd_pcm_hw_params *hw_params) |
---|
450 | 435 | { |
---|
451 | 436 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
---|
452 | | - int shift, err; |
---|
| 437 | + int shift; |
---|
453 | 438 | |
---|
454 | 439 | shift = 0; |
---|
455 | 440 | if (params_channels(hw_params) == 2) |
---|
.. | .. |
---|
468 | 453 | } else { |
---|
469 | 454 | chip->dma1_shift = shift; |
---|
470 | 455 | } |
---|
471 | | - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) |
---|
472 | | - return err; |
---|
473 | 456 | return 0; |
---|
474 | | -} |
---|
475 | | - |
---|
476 | | -static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream) |
---|
477 | | -{ |
---|
478 | | - return snd_pcm_lib_free_pages(substream); |
---|
479 | 457 | } |
---|
480 | 458 | |
---|
481 | 459 | static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, |
---|
.. | .. |
---|
558 | 536 | struct snd_pcm_hw_params *hw_params) |
---|
559 | 537 | { |
---|
560 | 538 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
---|
561 | | - int shift, err; |
---|
| 539 | + int shift; |
---|
562 | 540 | |
---|
563 | 541 | shift = 0; |
---|
564 | 542 | if ((chip->caps & ES18XX_DUPLEX_MONO) && |
---|
.. | .. |
---|
572 | 550 | if (snd_pcm_format_width(params_format(hw_params)) == 16) |
---|
573 | 551 | shift++; |
---|
574 | 552 | chip->dma1_shift = shift; |
---|
575 | | - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) |
---|
576 | | - return err; |
---|
577 | 553 | return 0; |
---|
578 | 554 | } |
---|
579 | 555 | |
---|
.. | .. |
---|
930 | 906 | else |
---|
931 | 907 | chip->playback_b_substream = NULL; |
---|
932 | 908 | |
---|
933 | | - snd_pcm_lib_free_pages(substream); |
---|
934 | 909 | return 0; |
---|
935 | 910 | } |
---|
936 | 911 | |
---|
.. | .. |
---|
939 | 914 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
---|
940 | 915 | |
---|
941 | 916 | chip->capture_a_substream = NULL; |
---|
942 | | - snd_pcm_lib_free_pages(substream); |
---|
943 | 917 | return 0; |
---|
944 | 918 | } |
---|
945 | 919 | |
---|
.. | .. |
---|
981 | 955 | case 0x1887: |
---|
982 | 956 | case 0x1888: |
---|
983 | 957 | return snd_ctl_enum_info(uinfo, 1, 5, texts5Source); |
---|
984 | | - case 0x1869: /* DS somewhat contradictory for 1869: could be be 5 or 8 */ |
---|
| 958 | + case 0x1869: /* DS somewhat contradictory for 1869: could be 5 or 8 */ |
---|
985 | 959 | case 0x1879: |
---|
986 | 960 | return snd_ctl_enum_info(uinfo, 1, 8, texts8Source); |
---|
987 | 961 | default: |
---|
.. | .. |
---|
991 | 965 | |
---|
992 | 966 | static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
---|
993 | 967 | { |
---|
994 | | - static unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3}; |
---|
| 968 | + static const unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3}; |
---|
995 | 969 | struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); |
---|
996 | 970 | int muxSource = snd_es18xx_mixer_read(chip, 0x1c) & 0x07; |
---|
997 | 971 | if (!(chip->version == 0x1869 || chip->version == 0x1879)) { |
---|
.. | .. |
---|
1008 | 982 | |
---|
1009 | 983 | static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
---|
1010 | 984 | { |
---|
1011 | | - static unsigned char map4Source[4] = {0, 2, 6, 7}; |
---|
| 985 | + static const unsigned char map4Source[4] = {0, 2, 6, 7}; |
---|
1012 | 986 | struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); |
---|
1013 | 987 | unsigned char val = ucontrol->value.enumerated.item[0]; |
---|
1014 | 988 | unsigned char retVal = 0; |
---|
.. | .. |
---|
1024 | 998 | val = 3; |
---|
1025 | 999 | } else |
---|
1026 | 1000 | retVal = snd_es18xx_mixer_bits(chip, 0x7a, 0x08, 0x00) != 0x00; |
---|
1027 | | - /* fall through */ |
---|
| 1001 | + fallthrough; |
---|
1028 | 1002 | /* 4 source chips */ |
---|
1029 | 1003 | case 0x1868: |
---|
1030 | 1004 | case 0x1878: |
---|
.. | .. |
---|
1272 | 1246 | * The controls that are universal to all chipsets are fully initialized |
---|
1273 | 1247 | * here. |
---|
1274 | 1248 | */ |
---|
1275 | | -static struct snd_kcontrol_new snd_es18xx_base_controls[] = { |
---|
| 1249 | +static const struct snd_kcontrol_new snd_es18xx_base_controls[] = { |
---|
1276 | 1250 | ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), |
---|
1277 | 1251 | ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), |
---|
1278 | 1252 | ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), |
---|
.. | .. |
---|
1291 | 1265 | } |
---|
1292 | 1266 | }; |
---|
1293 | 1267 | |
---|
1294 | | -static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = { |
---|
| 1268 | +static const struct snd_kcontrol_new snd_es18xx_recmix_controls[] = { |
---|
1295 | 1269 | ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), |
---|
1296 | 1270 | ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), |
---|
1297 | 1271 | ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), |
---|
.. | .. |
---|
1303 | 1277 | /* |
---|
1304 | 1278 | * The chipset specific mixer controls |
---|
1305 | 1279 | */ |
---|
1306 | | -static struct snd_kcontrol_new snd_es18xx_opt_speaker = |
---|
| 1280 | +static const struct snd_kcontrol_new snd_es18xx_opt_speaker = |
---|
1307 | 1281 | ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0); |
---|
1308 | 1282 | |
---|
1309 | | -static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { |
---|
| 1283 | +static const struct snd_kcontrol_new snd_es18xx_opt_1869[] = { |
---|
1310 | 1284 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, ES18XX_FL_INVERT), |
---|
1311 | 1285 | ES18XX_SINGLE("Video Playback Switch", 0, 0x7f, 0, 1, 0), |
---|
1312 | 1286 | ES18XX_DOUBLE("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), |
---|
1313 | 1287 | ES18XX_DOUBLE("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0) |
---|
1314 | 1288 | }; |
---|
1315 | 1289 | |
---|
1316 | | -static struct snd_kcontrol_new snd_es18xx_opt_1878 = |
---|
| 1290 | +static const struct snd_kcontrol_new snd_es18xx_opt_1878 = |
---|
1317 | 1291 | ES18XX_DOUBLE("Video Playback Volume", 0, 0x68, 0x68, 4, 0, 15, 0); |
---|
1318 | 1292 | |
---|
1319 | | -static struct snd_kcontrol_new snd_es18xx_opt_1879[] = { |
---|
| 1293 | +static const struct snd_kcontrol_new snd_es18xx_opt_1879[] = { |
---|
1320 | 1294 | ES18XX_SINGLE("Video Playback Switch", 0, 0x71, 6, 1, 0), |
---|
1321 | 1295 | ES18XX_DOUBLE("Video Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), |
---|
1322 | 1296 | ES18XX_DOUBLE("Video Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0) |
---|
1323 | 1297 | }; |
---|
1324 | 1298 | |
---|
1325 | | -static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = { |
---|
| 1299 | +static const struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = { |
---|
1326 | 1300 | ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0), |
---|
1327 | 1301 | }; |
---|
1328 | 1302 | |
---|
1329 | | -static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = { |
---|
| 1303 | +static const struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = { |
---|
1330 | 1304 | ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), |
---|
1331 | 1305 | ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0) |
---|
1332 | 1306 | }; |
---|
1333 | 1307 | |
---|
1334 | | -static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = { |
---|
| 1308 | +static const struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = { |
---|
1335 | 1309 | ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), |
---|
1336 | 1310 | { |
---|
1337 | 1311 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
---|
.. | .. |
---|
1342 | 1316 | } |
---|
1343 | 1317 | }; |
---|
1344 | 1318 | |
---|
1345 | | -static struct snd_kcontrol_new snd_es18xx_micpre1_control = |
---|
| 1319 | +static const struct snd_kcontrol_new snd_es18xx_micpre1_control = |
---|
1346 | 1320 | ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0); |
---|
1347 | 1321 | |
---|
1348 | | -static struct snd_kcontrol_new snd_es18xx_micpre2_control = |
---|
| 1322 | +static const struct snd_kcontrol_new snd_es18xx_micpre2_control = |
---|
1349 | 1323 | ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0); |
---|
1350 | 1324 | |
---|
1351 | | -static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { |
---|
| 1325 | +static const struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { |
---|
1352 | 1326 | { |
---|
1353 | 1327 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
---|
1354 | 1328 | .name = "Hardware Master Playback Volume", |
---|
.. | .. |
---|
1366 | 1340 | ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0), |
---|
1367 | 1341 | }; |
---|
1368 | 1342 | |
---|
1369 | | -static struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = { |
---|
| 1343 | +static const struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = { |
---|
1370 | 1344 | ES18XX_SINGLE("GPO0 Switch", 0, ES18XX_PM, 0, 1, ES18XX_FL_PMPORT), |
---|
1371 | 1345 | ES18XX_SINGLE("GPO1 Switch", 0, ES18XX_PM, 1, 1, ES18XX_FL_PMPORT), |
---|
1372 | 1346 | }; |
---|
.. | .. |
---|
1669 | 1643 | static const struct snd_pcm_ops snd_es18xx_playback_ops = { |
---|
1670 | 1644 | .open = snd_es18xx_playback_open, |
---|
1671 | 1645 | .close = snd_es18xx_playback_close, |
---|
1672 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1673 | 1646 | .hw_params = snd_es18xx_playback_hw_params, |
---|
1674 | | - .hw_free = snd_es18xx_pcm_hw_free, |
---|
1675 | 1647 | .prepare = snd_es18xx_playback_prepare, |
---|
1676 | 1648 | .trigger = snd_es18xx_playback_trigger, |
---|
1677 | 1649 | .pointer = snd_es18xx_playback_pointer, |
---|
.. | .. |
---|
1680 | 1652 | static const struct snd_pcm_ops snd_es18xx_capture_ops = { |
---|
1681 | 1653 | .open = snd_es18xx_capture_open, |
---|
1682 | 1654 | .close = snd_es18xx_capture_close, |
---|
1683 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1684 | 1655 | .hw_params = snd_es18xx_capture_hw_params, |
---|
1685 | | - .hw_free = snd_es18xx_pcm_hw_free, |
---|
1686 | 1656 | .prepare = snd_es18xx_capture_prepare, |
---|
1687 | 1657 | .trigger = snd_es18xx_capture_trigger, |
---|
1688 | 1658 | .pointer = snd_es18xx_capture_pointer, |
---|
.. | .. |
---|
1716 | 1686 | sprintf(pcm->name, "ESS AudioDrive ES%x", chip->version); |
---|
1717 | 1687 | chip->pcm = pcm; |
---|
1718 | 1688 | |
---|
1719 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1720 | | - snd_dma_isa_data(), |
---|
1721 | | - 64*1024, |
---|
1722 | | - chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); |
---|
| 1689 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, |
---|
| 1690 | + 64*1024, |
---|
| 1691 | + chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); |
---|
1723 | 1692 | return 0; |
---|
1724 | 1693 | } |
---|
1725 | 1694 | |
---|
.. | .. |
---|
1730 | 1699 | struct snd_es18xx *chip = card->private_data; |
---|
1731 | 1700 | |
---|
1732 | 1701 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
---|
1733 | | - |
---|
1734 | | - snd_pcm_suspend_all(chip->pcm); |
---|
1735 | 1702 | |
---|
1736 | 1703 | /* power down */ |
---|
1737 | 1704 | chip->pm_reg = (unsigned char)snd_es18xx_read(chip, ES18XX_PM); |
---|
.. | .. |
---|
1786 | 1753 | int irq, int dma1, int dma2) |
---|
1787 | 1754 | { |
---|
1788 | 1755 | struct snd_es18xx *chip = card->private_data; |
---|
1789 | | - static struct snd_device_ops ops = { |
---|
| 1756 | + static const struct snd_device_ops ops = { |
---|
1790 | 1757 | .dev_free = snd_es18xx_dev_free, |
---|
1791 | 1758 | }; |
---|
1792 | 1759 | int err; |
---|
.. | .. |
---|
1814 | 1781 | return -EBUSY; |
---|
1815 | 1782 | } |
---|
1816 | 1783 | chip->irq = irq; |
---|
| 1784 | + card->sync_irq = chip->irq; |
---|
1817 | 1785 | |
---|
1818 | 1786 | if (request_dma(dma1, "ES18xx DMA 1")) { |
---|
1819 | 1787 | snd_es18xx_free(card); |
---|
.. | .. |
---|
2205 | 2173 | static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev) |
---|
2206 | 2174 | { |
---|
2207 | 2175 | int err; |
---|
2208 | | - static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; |
---|
2209 | | - static int possible_dmas[] = {1, 0, 3, 5, -1}; |
---|
| 2176 | + static const int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; |
---|
| 2177 | + static const int possible_dmas[] = {1, 0, 3, 5, -1}; |
---|
2210 | 2178 | |
---|
2211 | 2179 | if (irq[dev] == SNDRV_AUTO_IRQ) { |
---|
2212 | 2180 | if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { |
---|
.. | .. |
---|
2230 | 2198 | if (port[dev] != SNDRV_AUTO_PORT) { |
---|
2231 | 2199 | return snd_es18xx_isa_probe1(dev, pdev); |
---|
2232 | 2200 | } else { |
---|
2233 | | - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; |
---|
| 2201 | + static const unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; |
---|
2234 | 2202 | int i; |
---|
2235 | 2203 | for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { |
---|
2236 | 2204 | port[dev] = possible_ports[i]; |
---|