hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/sound/pci/riptide/riptide.c
....@@ -1,22 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for the Conexant Riptide Soundchip
34 *
45 * Copyright (c) 2004 Peter Gruber <nokos@gmx.net>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- *
206 */
217 /*
228 History:
....@@ -375,9 +361,9 @@
375361 enum { SB_CMD = 0, MODEM_CMD, I2S_CMD0, I2S_CMD1, FM_CMD, MAX_CMD };
376362
377363 struct lbuspath {
378
- unsigned char *noconv;
379
- unsigned char *stereo;
380
- unsigned char *mono;
364
+ const unsigned char *noconv;
365
+ const unsigned char *stereo;
366
+ const unsigned char *mono;
381367 };
382368
383369 struct cmdport {
....@@ -459,7 +445,6 @@
459445 union firmware_version firmware;
460446
461447 spinlock_t lock;
462
- struct tasklet_struct riptide_tq;
463448 struct snd_info_entry *proc_entry;
464449
465450 unsigned long received_irqs;
....@@ -478,7 +463,7 @@
478463
479464 struct pcmhw { /* pcm descriptor */
480465 struct lbuspath paths;
481
- unsigned char *lbuspath;
466
+ const unsigned char *lbuspath;
482467 unsigned char source;
483468 unsigned char intdec[2];
484469 unsigned char mixer;
....@@ -531,7 +516,7 @@
531516 /*
532517 */
533518
534
-static unsigned char lbusin2out[E2SINK_MAX + 1][2] = {
519
+static const unsigned char lbusin2out[E2SINK_MAX + 1][2] = {
535520 {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT,
536521 LS_NONE2},
537522 {NO_OUT, LS_NONE1}, {NO_OUT, LS_NONE2}, {NO_OUT, LS_NONE1}, {NO_OUT,
....@@ -571,63 +556,63 @@
571556 LS_NONE2},
572557 };
573558
574
-static unsigned char lbus_play_opl3[] = {
559
+static const unsigned char lbus_play_opl3[] = {
575560 DIGITAL_MIXER_IN0 + FM_MIXER, 0xff
576561 };
577
-static unsigned char lbus_play_modem[] = {
562
+static const unsigned char lbus_play_modem[] = {
578563 DIGITAL_MIXER_IN0 + MODEM_MIXER, 0xff
579564 };
580
-static unsigned char lbus_play_i2s[] = {
565
+static const unsigned char lbus_play_i2s[] = {
581566 INTER0_IN + I2S_INTDEC, DIGITAL_MIXER_IN0 + I2S_MIXER, 0xff
582567 };
583
-static unsigned char lbus_play_out[] = {
568
+static const unsigned char lbus_play_out[] = {
584569 PDAC2ACLNK, 0xff
585570 };
586
-static unsigned char lbus_play_outhp[] = {
571
+static const unsigned char lbus_play_outhp[] = {
587572 HNDSPK2ACLNK, 0xff
588573 };
589
-static unsigned char lbus_play_noconv1[] = {
574
+static const unsigned char lbus_play_noconv1[] = {
590575 DIGITAL_MIXER_IN0, 0xff
591576 };
592
-static unsigned char lbus_play_stereo1[] = {
577
+static const unsigned char lbus_play_stereo1[] = {
593578 INTER0_IN, DIGITAL_MIXER_IN0, 0xff
594579 };
595
-static unsigned char lbus_play_mono1[] = {
580
+static const unsigned char lbus_play_mono1[] = {
596581 INTERM0_IN, DIGITAL_MIXER_IN0, 0xff
597582 };
598
-static unsigned char lbus_play_noconv2[] = {
583
+static const unsigned char lbus_play_noconv2[] = {
599584 DIGITAL_MIXER_IN1, 0xff
600585 };
601
-static unsigned char lbus_play_stereo2[] = {
586
+static const unsigned char lbus_play_stereo2[] = {
602587 INTER1_IN, DIGITAL_MIXER_IN1, 0xff
603588 };
604
-static unsigned char lbus_play_mono2[] = {
589
+static const unsigned char lbus_play_mono2[] = {
605590 INTERM1_IN, DIGITAL_MIXER_IN1, 0xff
606591 };
607
-static unsigned char lbus_play_noconv3[] = {
592
+static const unsigned char lbus_play_noconv3[] = {
608593 DIGITAL_MIXER_IN2, 0xff
609594 };
610
-static unsigned char lbus_play_stereo3[] = {
595
+static const unsigned char lbus_play_stereo3[] = {
611596 INTER2_IN, DIGITAL_MIXER_IN2, 0xff
612597 };
613
-static unsigned char lbus_play_mono3[] = {
598
+static const unsigned char lbus_play_mono3[] = {
614599 INTERM2_IN, DIGITAL_MIXER_IN2, 0xff
615600 };
616
-static unsigned char lbus_rec_noconv1[] = {
601
+static const unsigned char lbus_rec_noconv1[] = {
617602 LBUS2ARM_FIFO5, 0xff
618603 };
619
-static unsigned char lbus_rec_stereo1[] = {
604
+static const unsigned char lbus_rec_stereo1[] = {
620605 DECIM0_IN, LBUS2ARM_FIFO5, 0xff
621606 };
622
-static unsigned char lbus_rec_mono1[] = {
607
+static const unsigned char lbus_rec_mono1[] = {
623608 DECIMM3_IN, LBUS2ARM_FIFO5, 0xff
624609 };
625610
626
-static unsigned char play_ids[] = { 4, 1, 2, };
627
-static unsigned char play_sources[] = {
611
+static const unsigned char play_ids[] = { 4, 1, 2, };
612
+static const unsigned char play_sources[] = {
628613 ARM2LBUS_FIFO4, ARM2LBUS_FIFO1, ARM2LBUS_FIFO2,
629614 };
630
-static struct lbuspath lbus_play_paths[] = {
615
+static const struct lbuspath lbus_play_paths[] = {
631616 {
632617 .noconv = lbus_play_noconv1,
633618 .stereo = lbus_play_stereo1,
....@@ -751,7 +736,7 @@
751736
752737 static void
753738 alloclbuspath(struct cmdif *cif, unsigned char source,
754
- unsigned char *path, unsigned char *mixer, unsigned char *s)
739
+ const unsigned char *path, unsigned char *mixer, unsigned char *s)
755740 {
756741 while (*path != 0xff) {
757742 unsigned char sink, type;
....@@ -779,7 +764,7 @@
779764 }
780765 }
781766 if (*path++ & SPLIT_PATH) {
782
- unsigned char *npath = path;
767
+ const unsigned char *npath = path;
783768
784769 while (*npath != 0xff)
785770 npath++;
....@@ -789,7 +774,7 @@
789774 }
790775
791776 static void
792
-freelbuspath(struct cmdif *cif, unsigned char source, unsigned char *path)
777
+freelbuspath(struct cmdif *cif, unsigned char source, const unsigned char *path)
793778 {
794779 while (*path != 0xff) {
795780 unsigned char sink;
....@@ -801,7 +786,7 @@
801786 source = lbusin2out[sink][0];
802787 }
803788 if (*path++ & SPLIT_PATH) {
804
- unsigned char *npath = path;
789
+ const unsigned char *npath = path;
805790
806791 while (*npath != 0xff)
807792 npath++;
....@@ -1084,9 +1069,9 @@
10841069 return 0;
10851070 }
10861071
1087
-static void riptide_handleirq(unsigned long dev_id)
1072
+static irqreturn_t riptide_handleirq(int irq, void *dev_id)
10881073 {
1089
- struct snd_riptide *chip = (void *)dev_id;
1074
+ struct snd_riptide *chip = dev_id;
10901075 struct cmdif *cif = chip->cif;
10911076 struct snd_pcm_substream *substream[PLAYBACK_SUBSTREAMS + 1];
10921077 struct snd_pcm_runtime *runtime;
....@@ -1097,7 +1082,7 @@
10971082 unsigned int flag;
10981083
10991084 if (!cif)
1100
- return;
1085
+ return IRQ_HANDLED;
11011086
11021087 for (i = 0; i < PLAYBACK_SUBSTREAMS; i++)
11031088 substream[i] = chip->playback_substream[i];
....@@ -1148,6 +1133,8 @@
11481133 }
11491134 }
11501135 }
1136
+
1137
+ return IRQ_HANDLED;
11511138 }
11521139
11531140 #ifdef CONFIG_PM_SLEEP
....@@ -1158,7 +1145,6 @@
11581145
11591146 chip->in_suspend = 1;
11601147 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1161
- snd_pcm_suspend_all(chip->pcm);
11621148 snd_ac97_suspend(chip->ac97);
11631149 return 0;
11641150 }
....@@ -1456,7 +1442,7 @@
14561442 struct snd_pcm_runtime *runtime = substream->runtime;
14571443 struct pcmhw *data = get_pcmhwdev(substream);
14581444 struct cmdif *cif = chip->cif;
1459
- unsigned char *lbuspath = NULL;
1445
+ const unsigned char *lbuspath = NULL;
14601446 unsigned int rate, channels;
14611447 int err = 0;
14621448 snd_pcm_format_t format;
....@@ -1565,7 +1551,7 @@
15651551 if (sgdlist->area)
15661552 snd_dma_free_pages(sgdlist);
15671553 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
1568
- snd_dma_pci_data(chip->pci),
1554
+ &chip->pci->dev,
15691555 sizeof(struct sgd) * (DESC_MAX_MASK + 1),
15701556 sgdlist)) < 0) {
15711557 snd_printk(KERN_ERR "Riptide: failed to alloc %d dma bytes\n",
....@@ -1573,8 +1559,7 @@
15731559 return err;
15741560 }
15751561 data->sgdbuf = (struct sgd *)sgdlist->area;
1576
- return snd_pcm_lib_malloc_pages(substream,
1577
- params_buffer_bytes(hw_params));
1562
+ return 0;
15781563 }
15791564
15801565 static int snd_riptide_hw_free(struct snd_pcm_substream *substream)
....@@ -1596,7 +1581,7 @@
15961581 data->sgdlist.area = NULL;
15971582 }
15981583 }
1599
- return snd_pcm_lib_free_pages(substream);
1584
+ return 0;
16001585 }
16011586
16021587 static int snd_riptide_playback_open(struct snd_pcm_substream *substream)
....@@ -1672,22 +1657,18 @@
16721657 static const struct snd_pcm_ops snd_riptide_playback_ops = {
16731658 .open = snd_riptide_playback_open,
16741659 .close = snd_riptide_playback_close,
1675
- .ioctl = snd_pcm_lib_ioctl,
16761660 .hw_params = snd_riptide_hw_params,
16771661 .hw_free = snd_riptide_hw_free,
16781662 .prepare = snd_riptide_prepare,
1679
- .page = snd_pcm_sgbuf_ops_page,
16801663 .trigger = snd_riptide_trigger,
16811664 .pointer = snd_riptide_pointer,
16821665 };
16831666 static const struct snd_pcm_ops snd_riptide_capture_ops = {
16841667 .open = snd_riptide_capture_open,
16851668 .close = snd_riptide_capture_close,
1686
- .ioctl = snd_pcm_lib_ioctl,
16871669 .hw_params = snd_riptide_hw_params,
16881670 .hw_free = snd_riptide_hw_free,
16891671 .prepare = snd_riptide_prepare,
1690
- .page = snd_pcm_sgbuf_ops_page,
16911672 .trigger = snd_riptide_trigger,
16921673 .pointer = snd_riptide_pointer,
16931674 };
....@@ -1709,9 +1690,8 @@
17091690 pcm->info_flags = 0;
17101691 strcpy(pcm->name, "RIPTIDE");
17111692 chip->pcm = pcm;
1712
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1713
- snd_dma_pci_data(chip->pci),
1714
- 64 * 1024, 128 * 1024);
1693
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1694
+ &chip->pci->dev, 64 * 1024, 128 * 1024);
17151695 return 0;
17161696 }
17171697
....@@ -1720,13 +1700,14 @@
17201700 {
17211701 struct snd_riptide *chip = dev_id;
17221702 struct cmdif *cif = chip->cif;
1703
+ irqreturn_t ret = IRQ_HANDLED;
17231704
17241705 if (cif) {
17251706 chip->received_irqs++;
17261707 if (IS_EOBIRQ(cif->hwport) || IS_EOSIRQ(cif->hwport) ||
17271708 IS_EOCIRQ(cif->hwport)) {
17281709 chip->handled_irqs++;
1729
- tasklet_schedule(&chip->riptide_tq);
1710
+ ret = IRQ_WAKE_THREAD;
17301711 }
17311712 if (chip->rmidi && IS_MPUIRQ(cif->hwport)) {
17321713 chip->handled_irqs++;
....@@ -1735,7 +1716,7 @@
17351716 }
17361717 SET_AIACK(cif->hwport);
17371718 }
1738
- return IRQ_HANDLED;
1719
+ return ret;
17391720 }
17401721
17411722 static void
....@@ -1845,7 +1826,7 @@
18451826 struct snd_riptide *chip;
18461827 struct riptideport *hwport;
18471828 int err;
1848
- static struct snd_device_ops ops = {
1829
+ static const struct snd_device_ops ops = {
18491830 .dev_free = snd_riptide_dev_free,
18501831 };
18511832
....@@ -1864,7 +1845,6 @@
18641845 chip->received_irqs = 0;
18651846 chip->handled_irqs = 0;
18661847 chip->cif = NULL;
1867
- tasklet_init(&chip->riptide_tq, riptide_handleirq, (unsigned long)chip);
18681848
18691849 if ((chip->res_port =
18701850 request_region(chip->port, 64, "RIPTIDE")) == NULL) {
....@@ -1877,14 +1857,16 @@
18771857 hwport = (struct riptideport *)chip->port;
18781858 UNSET_AIE(hwport);
18791859
1880
- if (request_irq(pci->irq, snd_riptide_interrupt, IRQF_SHARED,
1881
- KBUILD_MODNAME, chip)) {
1860
+ if (request_threaded_irq(pci->irq, snd_riptide_interrupt,
1861
+ riptide_handleirq, IRQF_SHARED,
1862
+ KBUILD_MODNAME, chip)) {
18821863 snd_printk(KERN_ERR "Riptide: unable to grab IRQ %d\n",
18831864 pci->irq);
18841865 snd_riptide_free(chip);
18851866 return -EBUSY;
18861867 }
18871868 chip->irq = pci->irq;
1869
+ card->sync_irq = chip->irq;
18881870 chip->device_id = pci->device;
18891871 pci_set_master(pci);
18901872 if ((err = snd_riptide_initialize(chip)) < 0) {
....@@ -1974,10 +1956,8 @@
19741956
19751957 static void snd_riptide_proc_init(struct snd_riptide *chip)
19761958 {
1977
- struct snd_info_entry *entry;
1978
-
1979
- if (!snd_card_proc_new(chip->card, "riptide", &entry))
1980
- snd_info_set_text_ops(entry, chip, snd_riptide_proc_read);
1959
+ snd_card_ro_proc_new(chip->card, "riptide", chip,
1960
+ snd_riptide_proc_read);
19811961 }
19821962
19831963 static int snd_riptide_mixer(struct snd_riptide *chip)
....@@ -1985,7 +1965,7 @@
19851965 struct snd_ac97_bus *pbus;
19861966 struct snd_ac97_template ac97;
19871967 int err = 0;
1988
- static struct snd_ac97_bus_ops ops = {
1968
+ static const struct snd_ac97_bus_ops ops = {
19891969 .write = snd_riptide_codec_write,
19901970 .read = snd_riptide_codec_read,
19911971 };