forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/isa/ad1816a/ad1816a_lib.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 ad1816a.c - lowlevel code for Analog Devices AD1816A chip.
34 Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it>
45
5
- This program is free software; you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation; either version 2 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program; if not, write to the Free Software
17
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
186 */
197
208 #include <linux/delay.h>
....@@ -216,17 +204,6 @@
216204 struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
217205 return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,
218206 SNDRV_PCM_STREAM_CAPTURE, cmd, 1);
219
-}
220
-
221
-static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream,
222
- struct snd_pcm_hw_params *hw_params)
223
-{
224
- return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
225
-}
226
-
227
-static int snd_ad1816a_hw_free(struct snd_pcm_substream *substream)
228
-{
229
- return snd_pcm_lib_free_pages(substream);
230207 }
231208
232209 static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream)
....@@ -432,7 +409,7 @@
432409 return 0;
433410 }
434411
435
-static struct snd_timer_hardware snd_ad1816a_timer_table = {
412
+static const struct snd_timer_hardware snd_ad1816a_timer_table = {
436413 .flags = SNDRV_TIMER_HW_AUTO,
437414 .resolution = 10000,
438415 .ticks = 65535,
....@@ -518,7 +495,6 @@
518495 int reg;
519496 unsigned long flags;
520497
521
- snd_pcm_suspend_all(chip->pcm);
522498 spin_lock_irqsave(&chip->lock, flags);
523499 for (reg = 0; reg < 48; reg++)
524500 chip->image[reg] = snd_ad1816a_read(chip, reg);
....@@ -601,7 +577,7 @@
601577 unsigned long port, int irq, int dma1, int dma2,
602578 struct snd_ad1816a *chip)
603579 {
604
- static struct snd_device_ops ops = {
580
+ static const struct snd_device_ops ops = {
605581 .dev_free = snd_ad1816a_dev_free,
606582 };
607583 int error;
....@@ -621,6 +597,7 @@
621597 return -EBUSY;
622598 }
623599 chip->irq = irq;
600
+ card->sync_irq = chip->irq;
624601 if (request_dma(dma1, "AD1816A - 1")) {
625602 snd_printk(KERN_ERR "ad1816a: can't grab DMA1 %d\n", dma1);
626603 snd_ad1816a_free(chip);
....@@ -657,9 +634,6 @@
657634 static const struct snd_pcm_ops snd_ad1816a_playback_ops = {
658635 .open = snd_ad1816a_playback_open,
659636 .close = snd_ad1816a_playback_close,
660
- .ioctl = snd_pcm_lib_ioctl,
661
- .hw_params = snd_ad1816a_hw_params,
662
- .hw_free = snd_ad1816a_hw_free,
663637 .prepare = snd_ad1816a_playback_prepare,
664638 .trigger = snd_ad1816a_playback_trigger,
665639 .pointer = snd_ad1816a_playback_pointer,
....@@ -668,9 +642,6 @@
668642 static const struct snd_pcm_ops snd_ad1816a_capture_ops = {
669643 .open = snd_ad1816a_capture_open,
670644 .close = snd_ad1816a_capture_close,
671
- .ioctl = snd_pcm_lib_ioctl,
672
- .hw_params = snd_ad1816a_hw_params,
673
- .hw_free = snd_ad1816a_hw_free,
674645 .prepare = snd_ad1816a_capture_prepare,
675646 .trigger = snd_ad1816a_capture_trigger,
676647 .pointer = snd_ad1816a_capture_pointer,
....@@ -693,9 +664,8 @@
693664 strcpy(pcm->name, snd_ad1816a_chip_id(chip));
694665 snd_ad1816a_init(chip);
695666
696
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
697
- snd_dma_isa_data(),
698
- 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
667
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev,
668
+ 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
699669
700670 chip->pcm = pcm;
701671 return 0;
....@@ -914,7 +884,7 @@
914884 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
915885 static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
916886
917
-static struct snd_kcontrol_new snd_ad1816a_controls[] = {
887
+static const struct snd_kcontrol_new snd_ad1816a_controls[] = {
918888 AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1),
919889 AD1816A_DOUBLE_TLV("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1,
920890 db_scale_5bit),