hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/sound/pci/intel8x0m.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ALSA modem driver for Intel ICH (i8x0) chipsets
34 *
....@@ -5,22 +6,6 @@
56 *
67 * This is modified (by Sasha Khapyorsky <sashak@alsa-project.org>) version
78 * of ALSA ICH sound driver intel8x0.c .
8
- *
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
- *
249 */
2510
2611 #include <linux/io.h>
....@@ -303,7 +288,7 @@
303288 /* return the GLOB_STA bit for the corresponding codec */
304289 static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec)
305290 {
306
- static unsigned int codec_bit[3] = {
291
+ static const unsigned int codec_bit[3] = {
307292 ICH_PCR, ICH_SCR, ICH_TCR
308293 };
309294 if (snd_BUG_ON(codec >= 3))
....@@ -568,17 +553,6 @@
568553 return 0;
569554 }
570555
571
-static int snd_intel8x0m_hw_params(struct snd_pcm_substream *substream,
572
- struct snd_pcm_hw_params *hw_params)
573
-{
574
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
575
-}
576
-
577
-static int snd_intel8x0m_hw_free(struct snd_pcm_substream *substream)
578
-{
579
- return snd_pcm_lib_free_pages(substream);
580
-}
581
-
582556 static snd_pcm_uframes_t snd_intel8x0m_pcm_pointer(struct snd_pcm_substream *substream)
583557 {
584558 struct intel8x0m *chip = snd_pcm_substream_chip(substream);
....@@ -688,9 +662,6 @@
688662 static const struct snd_pcm_ops snd_intel8x0m_playback_ops = {
689663 .open = snd_intel8x0m_playback_open,
690664 .close = snd_intel8x0m_playback_close,
691
- .ioctl = snd_pcm_lib_ioctl,
692
- .hw_params = snd_intel8x0m_hw_params,
693
- .hw_free = snd_intel8x0m_hw_free,
694665 .prepare = snd_intel8x0m_pcm_prepare,
695666 .trigger = snd_intel8x0m_pcm_trigger,
696667 .pointer = snd_intel8x0m_pcm_pointer,
....@@ -699,9 +670,6 @@
699670 static const struct snd_pcm_ops snd_intel8x0m_capture_ops = {
700671 .open = snd_intel8x0m_capture_open,
701672 .close = snd_intel8x0m_capture_close,
702
- .ioctl = snd_pcm_lib_ioctl,
703
- .hw_params = snd_intel8x0m_hw_params,
704
- .hw_free = snd_intel8x0m_hw_free,
705673 .prepare = snd_intel8x0m_pcm_prepare,
706674 .trigger = snd_intel8x0m_pcm_trigger,
707675 .pointer = snd_intel8x0m_pcm_pointer,
....@@ -718,7 +686,7 @@
718686 };
719687
720688 static int snd_intel8x0m_pcm1(struct intel8x0m *chip, int device,
721
- struct ich_pcm_table *rec)
689
+ const struct ich_pcm_table *rec)
722690 {
723691 struct snd_pcm *pcm;
724692 int err;
....@@ -748,15 +716,15 @@
748716 strcpy(pcm->name, chip->card->shortname);
749717 chip->pcm[device] = pcm;
750718
751
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
752
- snd_dma_pci_data(chip->pci),
753
- rec->prealloc_size,
754
- rec->prealloc_max_size);
719
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
720
+ &chip->pci->dev,
721
+ rec->prealloc_size,
722
+ rec->prealloc_max_size);
755723
756724 return 0;
757725 }
758726
759
-static struct ich_pcm_table intel_pcms[] = {
727
+static const struct ich_pcm_table intel_pcms[] = {
760728 {
761729 .suffix = "Modem",
762730 .playback_ops = &snd_intel8x0m_playback_ops,
....@@ -769,7 +737,7 @@
769737 static int snd_intel8x0m_pcm(struct intel8x0m *chip)
770738 {
771739 int i, tblsize, device, err;
772
- struct ich_pcm_table *tbl, *rec;
740
+ const struct ich_pcm_table *tbl, *rec;
773741
774742 #if 1
775743 tbl = intel_pcms;
....@@ -833,7 +801,7 @@
833801 struct snd_ac97 *x97;
834802 int err;
835803 unsigned int glob_sta = 0;
836
- static struct snd_ac97_bus_ops ops = {
804
+ static const struct snd_ac97_bus_ops ops = {
837805 .write = snd_intel8x0m_codec_write,
838806 .read = snd_intel8x0m_codec_read,
839807 };
....@@ -1025,15 +993,13 @@
1025993 {
1026994 struct snd_card *card = dev_get_drvdata(dev);
1027995 struct intel8x0m *chip = card->private_data;
1028
- int i;
1029996
1030997 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1031
- for (i = 0; i < chip->pcm_devs; i++)
1032
- snd_pcm_suspend_all(chip->pcm[i]);
1033998 snd_ac97_suspend(chip->ac97);
1034999 if (chip->irq >= 0) {
10351000 free_irq(chip->irq, chip);
10361001 chip->irq = -1;
1002
+ card->sync_irq = -1;
10371003 }
10381004 return 0;
10391005 }
....@@ -1052,6 +1018,7 @@
10521018 return -EIO;
10531019 }
10541020 chip->irq = pci->irq;
1021
+ card->sync_irq = chip->irq;
10551022 snd_intel8x0m_chip_init(chip, 0);
10561023 snd_ac97_resume(chip->ac97);
10571024
....@@ -1087,10 +1054,8 @@
10871054
10881055 static void snd_intel8x0m_proc_init(struct intel8x0m *chip)
10891056 {
1090
- struct snd_info_entry *entry;
1091
-
1092
- if (! snd_card_proc_new(chip->card, "intel8x0m", &entry))
1093
- snd_info_set_text_ops(entry, chip, snd_intel8x0m_proc_read);
1057
+ snd_card_ro_proc_new(chip->card, "intel8x0m", chip,
1058
+ snd_intel8x0m_proc_read);
10941059 }
10951060
10961061 static int snd_intel8x0m_dev_free(struct snd_device *device)
....@@ -1114,14 +1079,14 @@
11141079 unsigned int i;
11151080 unsigned int int_sta_masks;
11161081 struct ichdev *ichdev;
1117
- static struct snd_device_ops ops = {
1082
+ static const struct snd_device_ops ops = {
11181083 .dev_free = snd_intel8x0m_dev_free,
11191084 };
1120
- static struct ich_reg_info intel_regs[2] = {
1085
+ static const struct ich_reg_info intel_regs[2] = {
11211086 { ICH_MIINT, 0 },
11221087 { ICH_MOINT, 0x10 },
11231088 };
1124
- struct ich_reg_info *tbl;
1089
+ const struct ich_reg_info *tbl;
11251090
11261091 *r_intel8x0m = NULL;
11271092
....@@ -1196,7 +1161,7 @@
11961161
11971162 /* allocate buffer descriptor lists */
11981163 /* the start of each lists must be aligned to 8 bytes */
1199
- if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
1164
+ if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
12001165 chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2,
12011166 &chip->bdbars) < 0) {
12021167 snd_intel8x0m_free(chip);
....@@ -1228,6 +1193,7 @@
12281193 return -EBUSY;
12291194 }
12301195 chip->irq = pci->irq;
1196
+ card->sync_irq = chip->irq;
12311197
12321198 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
12331199 snd_intel8x0m_free(chip);