hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/ppc/snd_ps3.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Audio support for PS3
34 * Copyright (C) 2007 Sony Computer Entertainment Inc.
45 * All rights reserved.
56 * Copyright 2006, 2007 Sony Corporation
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License
9
- * as published by the Free Software Foundation; version 2 of the Licence.
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
197 */
208
219 #include <linux/dma-mapping.h>
....@@ -233,21 +221,20 @@
233221 int fill_stages, dma_ch, stage;
234222 enum snd_ps3_ch ch;
235223 uint32_t ch0_kick_event = 0; /* initialize to mute gcc */
236
- void *start_vaddr;
237224 unsigned long irqsave;
238225 int silent = 0;
239226
240227 switch (filltype) {
241228 case SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL:
242229 silent = 1;
243
- /* intentionally fall thru */
230
+ fallthrough;
244231 case SND_PS3_DMA_FILLTYPE_FIRSTFILL:
245232 ch0_kick_event = PS3_AUDIO_KICK_EVENT_ALWAYS;
246233 break;
247234
248235 case SND_PS3_DMA_FILLTYPE_SILENT_RUNNING:
249236 silent = 1;
250
- /* intentionally fall thru */
237
+ fallthrough;
251238 case SND_PS3_DMA_FILLTYPE_RUNNING:
252239 ch0_kick_event = PS3_AUDIO_KICK_EVENT_SERIALOUT0_EMPTY;
253240 break;
....@@ -257,7 +244,6 @@
257244 fill_stages = 4;
258245 spin_lock_irqsave(&card->dma_lock, irqsave);
259246 for (ch = 0; ch < 2; ch++) {
260
- start_vaddr = card->dma_next_transfer_vaddr[0];
261247 for (stage = 0; stage < fill_stages; stage++) {
262248 dma_ch = stage * 2 + ch;
263249 if (silent)
....@@ -526,9 +512,7 @@
526512 {
527513 struct snd_pcm_runtime *runtime = substream->runtime;
528514 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
529
- int pcm_index;
530515
531
- pcm_index = substream->pcm->device;
532516 /* to retrieve substream/runtime in interrupt handler */
533517 card->substream = substream;
534518
....@@ -549,22 +533,6 @@
549533 /* mute on */
550534 snd_ps3_mute(1);
551535 return 0;
552
-};
553
-
554
-static int snd_ps3_pcm_hw_params(struct snd_pcm_substream *substream,
555
- struct snd_pcm_hw_params *hw_params)
556
-{
557
- size_t size;
558
-
559
- /* alloc transport buffer */
560
- size = params_buffer_bytes(hw_params);
561
- snd_pcm_lib_malloc_pages(substream, size);
562
- return 0;
563
-};
564
-
565
-static int snd_ps3_pcm_hw_free(struct snd_pcm_substream *substream)
566
-{
567
- return snd_pcm_lib_free_pages(substream);
568536 };
569537
570538 static int snd_ps3_delay_to_bytes(struct snd_pcm_substream *substream,
....@@ -644,7 +612,6 @@
644612 int cmd)
645613 {
646614 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream);
647
- int ret = 0;
648615
649616 switch (cmd) {
650617 case SNDRV_PCM_TRIGGER_START:
....@@ -681,7 +648,7 @@
681648
682649 }
683650
684
- return ret;
651
+ return 0;
685652 };
686653
687654 /*
....@@ -748,7 +715,7 @@
748715 return 0;
749716 }
750717
751
-static struct snd_kcontrol_new spdif_ctls[] = {
718
+static const struct snd_kcontrol_new spdif_ctls[] = {
752719 {
753720 .access = SNDRV_CTL_ELEM_ACCESS_READ,
754721 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
....@@ -775,9 +742,6 @@
775742 static const struct snd_pcm_ops snd_ps3_pcm_spdif_ops = {
776743 .open = snd_ps3_pcm_open,
777744 .close = snd_ps3_pcm_close,
778
- .ioctl = snd_pcm_lib_ioctl,
779
- .hw_params = snd_ps3_pcm_hw_params,
780
- .hw_free = snd_ps3_pcm_hw_free,
781745 .prepare = snd_ps3_pcm_prepare,
782746 .trigger = snd_ps3_pcm_trigger,
783747 .pointer = snd_ps3_pcm_pointer,
....@@ -962,7 +926,7 @@
962926 PAGE_SHIFT, /* use system page size */
963927 0, /* dma type; not used */
964928 NULL,
965
- _ALIGN_UP(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
929
+ ALIGN(SND_PS3_DMA_REGION_SIZE, PAGE_SIZE));
966930 dev->d_region->ioid = PS3_AUDIO_IOID;
967931
968932 ret = ps3_dma_region_create(dev->d_region);
....@@ -1024,15 +988,11 @@
1024988
1025989 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED;
1026990 /* pre-alloc PCM DMA buffer*/
1027
- ret = snd_pcm_lib_preallocate_pages_for_all(the_card.pcm,
1028
- SNDRV_DMA_TYPE_DEV,
1029
- &dev->core,
1030
- SND_PS3_PCM_PREALLOC_SIZE,
1031
- SND_PS3_PCM_PREALLOC_SIZE);
1032
- if (ret < 0) {
1033
- pr_info("%s: prealloc failed\n", __func__);
1034
- goto clean_card;
1035
- }
991
+ snd_pcm_set_managed_buffer_all(the_card.pcm,
992
+ SNDRV_DMA_TYPE_DEV,
993
+ &dev->core,
994
+ SND_PS3_PCM_PREALLOC_SIZE,
995
+ SND_PS3_PCM_PREALLOC_SIZE);
1036996
1037997 /*
1038998 * allocate null buffer