hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/sound/arm/aaci.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver
34 *
45 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
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 version 2 as
8
- * published by the Free Software Foundation.
96 *
107 * Documentation: ARM DDI 0173B
118 */
....@@ -383,7 +380,7 @@
383380 static int aaci_rule_channels(struct snd_pcm_hw_params *p,
384381 struct snd_pcm_hw_rule *rule)
385382 {
386
- static unsigned int channel_list[] = { 2, 4, 6 };
383
+ static const unsigned int channel_list[] = { 2, 4, 6 };
387384 struct aaci *aaci = rule->private;
388385 unsigned int mask = 1 << 0, slots;
389386
....@@ -486,11 +483,6 @@
486483 snd_ac97_pcm_close(aacirun->pcm);
487484 aacirun->pcm_open = 0;
488485
489
- /*
490
- * Clear out the DMA and any allocated buffers.
491
- */
492
- snd_pcm_lib_free_pages(substream);
493
-
494486 return 0;
495487 }
496488
....@@ -505,6 +497,7 @@
505497 struct snd_pcm_hw_params *params)
506498 {
507499 struct aaci_runtime *aacirun = substream->runtime->private_data;
500
+ struct aaci *aaci = substream->private_data;
508501 unsigned int channels = params_channels(params);
509502 unsigned int rate = params_rate(params);
510503 int dbl = rate > 48000;
....@@ -520,25 +513,19 @@
520513 if (dbl && channels != 2)
521514 return -EINVAL;
522515
523
- err = snd_pcm_lib_malloc_pages(substream,
524
- params_buffer_bytes(params));
525
- if (err >= 0) {
526
- struct aaci *aaci = substream->private_data;
516
+ err = snd_ac97_pcm_open(aacirun->pcm, rate, channels,
517
+ aacirun->pcm->r[dbl].slots);
527518
528
- err = snd_ac97_pcm_open(aacirun->pcm, rate, channels,
529
- aacirun->pcm->r[dbl].slots);
519
+ aacirun->pcm_open = err == 0;
520
+ aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
521
+ aacirun->cr |= channels_to_slotmask[channels + dbl * 2];
530522
531
- aacirun->pcm_open = err == 0;
532
- aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
533
- aacirun->cr |= channels_to_slotmask[channels + dbl * 2];
534
-
535
- /*
536
- * fifo_bytes is the number of bytes we transfer to/from
537
- * the FIFO, including padding. So that's x4. As we're
538
- * in compact mode, the FIFO is half the size.
539
- */
540
- aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2;
541
- }
523
+ /*
524
+ * fifo_bytes is the number of bytes we transfer to/from
525
+ * the FIFO, including padding. So that's x4. As we're
526
+ * in compact mode, the FIFO is half the size.
527
+ */
528
+ aacirun->fifo_bytes = aaci->fifo_depth * 4 / 2;
542529
543530 return err;
544531 }
....@@ -638,7 +625,6 @@
638625 static const struct snd_pcm_ops aaci_playback_ops = {
639626 .open = aaci_pcm_open,
640627 .close = aaci_pcm_close,
641
- .ioctl = snd_pcm_lib_ioctl,
642628 .hw_params = aaci_pcm_hw_params,
643629 .hw_free = aaci_pcm_hw_free,
644630 .prepare = aaci_pcm_prepare,
....@@ -741,7 +727,6 @@
741727 static const struct snd_pcm_ops aaci_capture_ops = {
742728 .open = aaci_pcm_open,
743729 .close = aaci_pcm_close,
744
- .ioctl = snd_pcm_lib_ioctl,
745730 .hw_params = aaci_pcm_hw_params,
746731 .hw_free = aaci_pcm_hw_free,
747732 .prepare = aaci_pcm_capture_prepare,
....@@ -757,7 +742,6 @@
757742 {
758743 struct aaci *aaci = card->private_data;
759744 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold);
760
- snd_pcm_suspend_all(aaci->pcm);
761745 return 0;
762746 }
763747
....@@ -827,7 +811,7 @@
827811 }
828812 };
829813
830
-static struct snd_ac97_bus_ops aaci_bus_ops = {
814
+static const struct snd_ac97_bus_ops aaci_bus_ops = {
831815 .write = aaci_ac97_write,
832816 .read = aaci_ac97_read,
833817 };
....@@ -941,8 +925,9 @@
941925
942926 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
943927 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops);
944
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
945
- NULL, 0, 64 * 1024);
928
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
929
+ aaci->card->dev,
930
+ 0, 64 * 1024);
946931 }
947932
948933 return ret;
....@@ -1070,7 +1055,7 @@
10701055 return ret;
10711056 }
10721057
1073
-static int aaci_remove(struct amba_device *dev)
1058
+static void aaci_remove(struct amba_device *dev)
10741059 {
10751060 struct snd_card *card = amba_get_drvdata(dev);
10761061
....@@ -1081,8 +1066,6 @@
10811066 snd_card_free(card);
10821067 amba_release_regions(dev);
10831068 }
1084
-
1085
- return 0;
10861069 }
10871070
10881071 static struct amba_id aaci_ids[] = {