| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for ESS Solo-1 (ES1938, ES1946, ES1969) soundcard |
|---|
| 3 | 4 | * Copyright (c) by Jaromir Koutek <miri@punknet.cz>, |
|---|
| .. | .. |
|---|
| 10 | 11 | * |
|---|
| 11 | 12 | * TODO: |
|---|
| 12 | 13 | * Rewrite better spinlocks |
|---|
| 13 | | - * |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 16 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 17 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 18 | | - * (at your option) any later version. |
|---|
| 19 | | - * |
|---|
| 20 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 23 | | - * GNU General Public License for more details. |
|---|
| 24 | | - * |
|---|
| 25 | | - * You should have received a copy of the GNU General Public License |
|---|
| 26 | | - * along with this program; if not, write to the Free Software |
|---|
| 27 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 28 | | - * |
|---|
| 29 | 14 | */ |
|---|
| 30 | 15 | |
|---|
| 31 | 16 | /* |
|---|
| .. | .. |
|---|
| 878 | 863 | return 0; |
|---|
| 879 | 864 | } |
|---|
| 880 | 865 | |
|---|
| 881 | | -/* |
|---|
| 882 | | - * buffer management |
|---|
| 883 | | - */ |
|---|
| 884 | | -static int snd_es1938_pcm_hw_params(struct snd_pcm_substream *substream, |
|---|
| 885 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 886 | | - |
|---|
| 887 | | -{ |
|---|
| 888 | | - int err; |
|---|
| 889 | | - |
|---|
| 890 | | - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) |
|---|
| 891 | | - return err; |
|---|
| 892 | | - return 0; |
|---|
| 893 | | -} |
|---|
| 894 | | - |
|---|
| 895 | | -static int snd_es1938_pcm_hw_free(struct snd_pcm_substream *substream) |
|---|
| 896 | | -{ |
|---|
| 897 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 898 | | -} |
|---|
| 899 | | - |
|---|
| 900 | 866 | /* ---------------------------------------------------------------------- |
|---|
| 901 | 867 | * Audio1 Capture (ADC) |
|---|
| 902 | 868 | * ----------------------------------------------------------------------*/ |
|---|
| .. | .. |
|---|
| 1011 | 977 | static const struct snd_pcm_ops snd_es1938_playback_ops = { |
|---|
| 1012 | 978 | .open = snd_es1938_playback_open, |
|---|
| 1013 | 979 | .close = snd_es1938_playback_close, |
|---|
| 1014 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1015 | | - .hw_params = snd_es1938_pcm_hw_params, |
|---|
| 1016 | | - .hw_free = snd_es1938_pcm_hw_free, |
|---|
| 1017 | 980 | .prepare = snd_es1938_playback_prepare, |
|---|
| 1018 | 981 | .trigger = snd_es1938_playback_trigger, |
|---|
| 1019 | 982 | .pointer = snd_es1938_playback_pointer, |
|---|
| .. | .. |
|---|
| 1022 | 985 | static const struct snd_pcm_ops snd_es1938_capture_ops = { |
|---|
| 1023 | 986 | .open = snd_es1938_capture_open, |
|---|
| 1024 | 987 | .close = snd_es1938_capture_close, |
|---|
| 1025 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1026 | | - .hw_params = snd_es1938_pcm_hw_params, |
|---|
| 1027 | | - .hw_free = snd_es1938_pcm_hw_free, |
|---|
| 1028 | 988 | .prepare = snd_es1938_capture_prepare, |
|---|
| 1029 | 989 | .trigger = snd_es1938_capture_trigger, |
|---|
| 1030 | 990 | .pointer = snd_es1938_capture_pointer, |
|---|
| .. | .. |
|---|
| 1046 | 1006 | pcm->info_flags = 0; |
|---|
| 1047 | 1007 | strcpy(pcm->name, "ESS Solo-1"); |
|---|
| 1048 | 1008 | |
|---|
| 1049 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1050 | | - snd_dma_pci_data(chip->pci), 64*1024, 64*1024); |
|---|
| 1009 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, |
|---|
| 1010 | + &chip->pci->dev, 64*1024, 64*1024); |
|---|
| 1051 | 1011 | |
|---|
| 1052 | 1012 | chip->pcm = pcm; |
|---|
| 1053 | 1013 | return 0; |
|---|
| .. | .. |
|---|
| 1347 | 1307 | |
|---|
| 1348 | 1308 | static const DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0); |
|---|
| 1349 | 1309 | |
|---|
| 1350 | | -static struct snd_kcontrol_new snd_es1938_controls[] = { |
|---|
| 1310 | +static const struct snd_kcontrol_new snd_es1938_controls[] = { |
|---|
| 1351 | 1311 | ES1938_DOUBLE_TLV("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0, |
|---|
| 1352 | 1312 | db_scale_master), |
|---|
| 1353 | 1313 | ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), |
|---|
| .. | .. |
|---|
| 1460 | 1420 | * PM support |
|---|
| 1461 | 1421 | */ |
|---|
| 1462 | 1422 | |
|---|
| 1463 | | -static unsigned char saved_regs[SAVED_REG_SIZE+1] = { |
|---|
| 1423 | +static const unsigned char saved_regs[SAVED_REG_SIZE+1] = { |
|---|
| 1464 | 1424 | 0x14, 0x1a, 0x1c, 0x3a, 0x3c, 0x3e, 0x36, 0x38, |
|---|
| 1465 | 1425 | 0x50, 0x52, 0x60, 0x61, 0x62, 0x63, 0x64, 0x68, |
|---|
| 1466 | 1426 | 0x69, 0x6a, 0x6b, 0x6d, 0x6e, 0x6f, 0x7c, 0x7d, |
|---|
| .. | .. |
|---|
| 1472 | 1432 | { |
|---|
| 1473 | 1433 | struct snd_card *card = dev_get_drvdata(dev); |
|---|
| 1474 | 1434 | struct es1938 *chip = card->private_data; |
|---|
| 1475 | | - unsigned char *s, *d; |
|---|
| 1435 | + const unsigned char *s; |
|---|
| 1436 | + unsigned char *d; |
|---|
| 1476 | 1437 | |
|---|
| 1477 | 1438 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
|---|
| 1478 | | - snd_pcm_suspend_all(chip->pcm); |
|---|
| 1479 | 1439 | |
|---|
| 1480 | 1440 | /* save mixer-related registers */ |
|---|
| 1481 | 1441 | for (s = saved_regs, d = chip->saved_regs; *s; s++, d++) |
|---|
| .. | .. |
|---|
| 1485 | 1445 | if (chip->irq >= 0) { |
|---|
| 1486 | 1446 | free_irq(chip->irq, chip); |
|---|
| 1487 | 1447 | chip->irq = -1; |
|---|
| 1448 | + card->sync_irq = -1; |
|---|
| 1488 | 1449 | } |
|---|
| 1489 | 1450 | return 0; |
|---|
| 1490 | 1451 | } |
|---|
| .. | .. |
|---|
| 1494 | 1455 | struct pci_dev *pci = to_pci_dev(dev); |
|---|
| 1495 | 1456 | struct snd_card *card = dev_get_drvdata(dev); |
|---|
| 1496 | 1457 | struct es1938 *chip = card->private_data; |
|---|
| 1497 | | - unsigned char *s, *d; |
|---|
| 1458 | + const unsigned char *s; |
|---|
| 1459 | + unsigned char *d; |
|---|
| 1498 | 1460 | |
|---|
| 1499 | 1461 | if (request_irq(pci->irq, snd_es1938_interrupt, |
|---|
| 1500 | 1462 | IRQF_SHARED, KBUILD_MODNAME, chip)) { |
|---|
| .. | .. |
|---|
| 1504 | 1466 | return -EIO; |
|---|
| 1505 | 1467 | } |
|---|
| 1506 | 1468 | chip->irq = pci->irq; |
|---|
| 1469 | + card->sync_irq = chip->irq; |
|---|
| 1507 | 1470 | snd_es1938_chip_init(chip); |
|---|
| 1508 | 1471 | |
|---|
| 1509 | 1472 | /* restore mixer-related registers */ |
|---|
| .. | .. |
|---|
| 1587 | 1550 | { |
|---|
| 1588 | 1551 | struct es1938 *chip; |
|---|
| 1589 | 1552 | int err; |
|---|
| 1590 | | - static struct snd_device_ops ops = { |
|---|
| 1553 | + static const struct snd_device_ops ops = { |
|---|
| 1591 | 1554 | .dev_free = snd_es1938_dev_free, |
|---|
| 1592 | 1555 | }; |
|---|
| 1593 | 1556 | |
|---|
| .. | .. |
|---|
| 1632 | 1595 | return -EBUSY; |
|---|
| 1633 | 1596 | } |
|---|
| 1634 | 1597 | chip->irq = pci->irq; |
|---|
| 1598 | + card->sync_irq = chip->irq; |
|---|
| 1635 | 1599 | dev_dbg(card->dev, |
|---|
| 1636 | 1600 | "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n", |
|---|
| 1637 | 1601 | chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port); |
|---|
| .. | .. |
|---|
| 1655 | 1619 | static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id) |
|---|
| 1656 | 1620 | { |
|---|
| 1657 | 1621 | struct es1938 *chip = dev_id; |
|---|
| 1658 | | - unsigned char status, audiostatus; |
|---|
| 1622 | + unsigned char status; |
|---|
| 1623 | + __always_unused unsigned char audiostatus; |
|---|
| 1659 | 1624 | int handled = 0; |
|---|
| 1660 | 1625 | |
|---|
| 1661 | 1626 | status = inb(SLIO_REG(chip, IRQCONTROL)); |
|---|