.. | .. |
---|
| 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 CS4231(A)/CS4232/InterWave & compatible chips |
---|
.. | .. |
---|
7 | 8 | * Yamaha OPL3-SA3 chip |
---|
8 | 9 | * - CS4231 (GUS MAX) - still trouble with occasional noises |
---|
9 | 10 | * - broken initialization? |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or modify |
---|
12 | | - * it under the terms of the GNU General Public License as published by |
---|
13 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
14 | | - * (at your option) any later version. |
---|
15 | | - * |
---|
16 | | - * This program is distributed in the hope that it will be useful, |
---|
17 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | | - * GNU General Public License for more details. |
---|
20 | | - * |
---|
21 | | - * You should have received a copy of the GNU General Public License |
---|
22 | | - * along with this program; if not, write to the Free Software |
---|
23 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
24 | | - * |
---|
25 | 11 | */ |
---|
26 | 12 | |
---|
27 | 13 | #include <linux/delay.h> |
---|
.. | .. |
---|
52 | 38 | * Some variables |
---|
53 | 39 | */ |
---|
54 | 40 | |
---|
55 | | -static unsigned char freq_bits[14] = { |
---|
| 41 | +static const unsigned char freq_bits[14] = { |
---|
56 | 42 | /* 5510 */ 0x00 | CS4231_XTAL2, |
---|
57 | 43 | /* 6620 */ 0x0E | CS4231_XTAL2, |
---|
58 | 44 | /* 8000 */ 0x00 | CS4231_XTAL1, |
---|
.. | .. |
---|
86 | 72 | &hw_constraints_rates); |
---|
87 | 73 | } |
---|
88 | 74 | |
---|
89 | | -static unsigned char snd_wss_original_image[32] = |
---|
| 75 | +static const unsigned char snd_wss_original_image[32] = |
---|
90 | 76 | { |
---|
91 | 77 | 0x00, /* 00/00 - lic */ |
---|
92 | 78 | 0x00, /* 01/01 - ric */ |
---|
.. | .. |
---|
122 | 108 | 0x00, /* 1f/31 - cbrl */ |
---|
123 | 109 | }; |
---|
124 | 110 | |
---|
125 | | -static unsigned char snd_opti93x_original_image[32] = |
---|
| 111 | +static const unsigned char snd_opti93x_original_image[32] = |
---|
126 | 112 | { |
---|
127 | 113 | 0x00, /* 00/00 - l_mixout_outctrl */ |
---|
128 | 114 | 0x00, /* 01/01 - r_mixout_outctrl */ |
---|
.. | .. |
---|
975 | 961 | return 0; |
---|
976 | 962 | } |
---|
977 | 963 | |
---|
978 | | -static struct snd_timer_hardware snd_wss_timer_table = |
---|
| 964 | +static const struct snd_timer_hardware snd_wss_timer_table = |
---|
979 | 965 | { |
---|
980 | 966 | .flags = SNDRV_TIMER_HW_AUTO, |
---|
981 | 967 | .resolution = 9945, |
---|
.. | .. |
---|
996 | 982 | { |
---|
997 | 983 | struct snd_wss *chip = snd_pcm_substream_chip(substream); |
---|
998 | 984 | unsigned char new_pdfr; |
---|
999 | | - int err; |
---|
1000 | 985 | |
---|
1001 | | - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) |
---|
1002 | | - return err; |
---|
1003 | 986 | new_pdfr = snd_wss_get_format(chip, params_format(hw_params), |
---|
1004 | 987 | params_channels(hw_params)) | |
---|
1005 | 988 | snd_wss_get_rate(params_rate(hw_params)); |
---|
1006 | 989 | chip->set_playback_format(chip, hw_params, new_pdfr); |
---|
1007 | 990 | return 0; |
---|
1008 | | -} |
---|
1009 | | - |
---|
1010 | | -static int snd_wss_playback_hw_free(struct snd_pcm_substream *substream) |
---|
1011 | | -{ |
---|
1012 | | - return snd_pcm_lib_free_pages(substream); |
---|
1013 | 991 | } |
---|
1014 | 992 | |
---|
1015 | 993 | static int snd_wss_playback_prepare(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
1039 | 1017 | { |
---|
1040 | 1018 | struct snd_wss *chip = snd_pcm_substream_chip(substream); |
---|
1041 | 1019 | unsigned char new_cdfr; |
---|
1042 | | - int err; |
---|
1043 | 1020 | |
---|
1044 | | - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) |
---|
1045 | | - return err; |
---|
1046 | 1021 | new_cdfr = snd_wss_get_format(chip, params_format(hw_params), |
---|
1047 | 1022 | params_channels(hw_params)) | |
---|
1048 | 1023 | snd_wss_get_rate(params_rate(hw_params)); |
---|
1049 | 1024 | chip->set_capture_format(chip, hw_params, new_cdfr); |
---|
1050 | 1025 | return 0; |
---|
1051 | | -} |
---|
1052 | | - |
---|
1053 | | -static int snd_wss_capture_hw_free(struct snd_pcm_substream *substream) |
---|
1054 | | -{ |
---|
1055 | | - return snd_pcm_lib_free_pages(substream); |
---|
1056 | 1026 | } |
---|
1057 | 1027 | |
---|
1058 | 1028 | static int snd_wss_capture_prepare(struct snd_pcm_substream *substream) |
---|
.. | .. |
---|
1625 | 1595 | int reg; |
---|
1626 | 1596 | unsigned long flags; |
---|
1627 | 1597 | |
---|
1628 | | - snd_pcm_suspend_all(chip->pcm); |
---|
1629 | 1598 | spin_lock_irqsave(&chip->reg_lock, flags); |
---|
1630 | 1599 | for (reg = 0; reg < 32; reg++) |
---|
1631 | 1600 | chip->image[reg] = snd_wss_in(chip, reg); |
---|
.. | .. |
---|
1803 | 1772 | unsigned short hwshare, |
---|
1804 | 1773 | struct snd_wss **rchip) |
---|
1805 | 1774 | { |
---|
1806 | | - static struct snd_device_ops ops = { |
---|
| 1775 | + static const struct snd_device_ops ops = { |
---|
1807 | 1776 | .dev_free = snd_wss_dev_free, |
---|
1808 | 1777 | }; |
---|
1809 | 1778 | struct snd_wss *chip; |
---|
.. | .. |
---|
1842 | 1811 | return -EBUSY; |
---|
1843 | 1812 | } |
---|
1844 | 1813 | chip->irq = irq; |
---|
| 1814 | + card->sync_irq = chip->irq; |
---|
1845 | 1815 | if (!(hwshare & WSS_HWSHARE_DMA1) && request_dma(dma1, "WSS - 1")) { |
---|
1846 | 1816 | snd_printk(KERN_ERR "wss: can't grab DMA1 %d\n", dma1); |
---|
1847 | 1817 | snd_wss_free(chip); |
---|
.. | .. |
---|
1902 | 1872 | static const struct snd_pcm_ops snd_wss_playback_ops = { |
---|
1903 | 1873 | .open = snd_wss_playback_open, |
---|
1904 | 1874 | .close = snd_wss_playback_close, |
---|
1905 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1906 | 1875 | .hw_params = snd_wss_playback_hw_params, |
---|
1907 | | - .hw_free = snd_wss_playback_hw_free, |
---|
1908 | 1876 | .prepare = snd_wss_playback_prepare, |
---|
1909 | 1877 | .trigger = snd_wss_trigger, |
---|
1910 | 1878 | .pointer = snd_wss_playback_pointer, |
---|
.. | .. |
---|
1913 | 1881 | static const struct snd_pcm_ops snd_wss_capture_ops = { |
---|
1914 | 1882 | .open = snd_wss_capture_open, |
---|
1915 | 1883 | .close = snd_wss_capture_close, |
---|
1916 | | - .ioctl = snd_pcm_lib_ioctl, |
---|
1917 | 1884 | .hw_params = snd_wss_capture_hw_params, |
---|
1918 | | - .hw_free = snd_wss_capture_hw_free, |
---|
1919 | 1885 | .prepare = snd_wss_capture_prepare, |
---|
1920 | 1886 | .trigger = snd_wss_trigger, |
---|
1921 | 1887 | .pointer = snd_wss_capture_pointer, |
---|
.. | .. |
---|
1942 | 1908 | pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; |
---|
1943 | 1909 | strcpy(pcm->name, snd_wss_chip_id(chip)); |
---|
1944 | 1910 | |
---|
1945 | | - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
---|
1946 | | - snd_dma_isa_data(), |
---|
1947 | | - 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); |
---|
| 1911 | + snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, |
---|
| 1912 | + 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); |
---|
1948 | 1913 | |
---|
1949 | 1914 | chip->pcm = pcm; |
---|
1950 | 1915 | return 0; |
---|
.. | .. |
---|
2192 | 2157 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); |
---|
2193 | 2158 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); |
---|
2194 | 2159 | |
---|
2195 | | -static struct snd_kcontrol_new snd_wss_controls[] = { |
---|
| 2160 | +static const struct snd_kcontrol_new snd_wss_controls[] = { |
---|
2196 | 2161 | WSS_DOUBLE("PCM Playback Switch", 0, |
---|
2197 | 2162 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
---|
2198 | 2163 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
---|