hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/pci/pcxhr/pcxhr.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Digigram pcxhr compatible soundcards
34 *
45 * main file with alsa callbacks
56 *
67 * Copyright (c) 2004 by Digigram <alsa@digigram.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
218 */
229
2310
....@@ -149,7 +136,7 @@
149136 short fw_file_set;
150137 short firmware_num;
151138 };
152
-static struct board_parameters pcxhr_board_params[] = {
139
+static const struct board_parameters pcxhr_board_params[] = {
153140 [PCI_ID_VX882HR] = { "VX882HR", 4, 4, 0, 41 },
154141 [PCI_ID_PCX882HR] = { "PCX882HR", 4, 4, 0, 41 },
155142 [PCI_ID_VX881HR] = { "VX881HR", 4, 4, 0, 41 },
....@@ -953,32 +940,16 @@
953940 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
954941 struct pcxhr_mgr *mgr = chip->mgr;
955942 struct pcxhr_stream *stream = subs->runtime->private_data;
956
- snd_pcm_format_t format;
957
- int err;
958
- int channels;
959
-
960
- /* set up channels */
961
- channels = params_channels(hw);
962
-
963
- /* set up format for the stream */
964
- format = params_format(hw);
965943
966944 mutex_lock(&mgr->setup_mutex);
967945
968
- stream->channels = channels;
969
- stream->format = format;
970
-
971
- /* allocate buffer */
972
- err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw));
946
+ /* set up channels */
947
+ stream->channels = params_channels(hw);
948
+ /* set up format for the stream */
949
+ stream->format = params_format(hw);
973950
974951 mutex_unlock(&mgr->setup_mutex);
975952
976
- return err;
977
-}
978
-
979
-static int pcxhr_hw_free(struct snd_pcm_substream *subs)
980
-{
981
- snd_pcm_lib_free_pages(subs);
982953 return 0;
983954 }
984955
....@@ -1149,10 +1120,8 @@
11491120 static const struct snd_pcm_ops pcxhr_ops = {
11501121 .open = pcxhr_open,
11511122 .close = pcxhr_close,
1152
- .ioctl = snd_pcm_lib_ioctl,
11531123 .prepare = pcxhr_prepare,
11541124 .hw_params = pcxhr_hw_params,
1155
- .hw_free = pcxhr_hw_free,
11561125 .trigger = pcxhr_trigger,
11571126 .pointer = pcxhr_stream_pointer,
11581127 };
....@@ -1183,9 +1152,9 @@
11831152 pcm->nonatomic = true;
11841153 strcpy(pcm->name, name);
11851154
1186
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1187
- snd_dma_pci_data(chip->mgr->pci),
1188
- 32*1024, 32*1024);
1155
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
1156
+ &chip->mgr->pci->dev,
1157
+ 32*1024, 32*1024);
11891158 chip->pcm = pcm;
11901159 return 0;
11911160 }
....@@ -1210,7 +1179,7 @@
12101179 {
12111180 int err;
12121181 struct snd_pcxhr *chip;
1213
- static struct snd_device_ops ops = {
1182
+ static const struct snd_device_ops ops = {
12141183 .dev_free = pcxhr_chip_dev_free,
12151184 };
12161185
....@@ -1221,6 +1190,7 @@
12211190 chip->card = card;
12221191 chip->chip_idx = idx;
12231192 chip->mgr = mgr;
1193
+ card->sync_irq = mgr->irq;
12241194
12251195 if (idx < mgr->playback_chips)
12261196 /* stereo or mono streams */
....@@ -1454,21 +1424,14 @@
14541424
14551425 static void pcxhr_proc_init(struct snd_pcxhr *chip)
14561426 {
1457
- struct snd_info_entry *entry;
1458
-
1459
- if (! snd_card_proc_new(chip->card, "info", &entry))
1460
- snd_info_set_text_ops(entry, chip, pcxhr_proc_info);
1461
- if (! snd_card_proc_new(chip->card, "sync", &entry))
1462
- snd_info_set_text_ops(entry, chip, pcxhr_proc_sync);
1427
+ snd_card_ro_proc_new(chip->card, "info", chip, pcxhr_proc_info);
1428
+ snd_card_ro_proc_new(chip->card, "sync", chip, pcxhr_proc_sync);
14631429 /* gpio available on stereo sound cards only */
1464
- if (chip->mgr->is_hr_stereo &&
1465
- !snd_card_proc_new(chip->card, "gpio", &entry)) {
1466
- snd_info_set_text_ops(entry, chip, pcxhr_proc_gpio_read);
1467
- entry->c.text.write = pcxhr_proc_gpo_write;
1468
- entry->mode |= 0200;
1469
- }
1470
- if (!snd_card_proc_new(chip->card, "ltc", &entry))
1471
- snd_info_set_text_ops(entry, chip, pcxhr_proc_ltc);
1430
+ if (chip->mgr->is_hr_stereo)
1431
+ snd_card_rw_proc_new(chip->card, "gpio", chip,
1432
+ pcxhr_proc_gpio_read,
1433
+ pcxhr_proc_gpo_write);
1434
+ snd_card_ro_proc_new(chip->card, "ltc", chip, pcxhr_proc_ltc);
14721435 }
14731436 /* end of proc interface */
14741437
....@@ -1664,7 +1627,7 @@
16641627
16651628 /* create hostport purgebuffer */
16661629 size = PAGE_ALIGN(sizeof(struct pcxhr_hostport));
1667
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
1630
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
16681631 size, &mgr->hostport) < 0) {
16691632 pcxhr_free(mgr);
16701633 return -ENOMEM;