hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/sound/ppc/pmac.c
....@@ -1,22 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * PMac DBDMA lowlevel functions
34 *
45 * Copyright (c) by Takashi Iwai <tiwai@suse.de>
56 * code based on dmasound.c.
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 as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
207 */
218
229
....@@ -37,11 +24,11 @@
3724
3825
3926 /* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */
40
-static int awacs_freqs[8] = {
27
+static const int awacs_freqs[8] = {
4128 44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350
4229 };
4330 /* fixed frequency table for tumbler */
44
-static int tumbler_freqs[1] = {
31
+static const int tumbler_freqs[1] = {
4532 44100
4633 };
4734
....@@ -118,24 +105,6 @@
118105 {
119106 return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
120107 SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK;
121
-}
122
-
123
-/*
124
- * allocate buffers
125
- */
126
-static int snd_pmac_pcm_hw_params(struct snd_pcm_substream *subs,
127
- struct snd_pcm_hw_params *hw_params)
128
-{
129
- return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params));
130
-}
131
-
132
-/*
133
- * release buffers
134
- */
135
-static int snd_pmac_pcm_hw_free(struct snd_pcm_substream *subs)
136
-{
137
- snd_pcm_lib_free_pages(subs);
138
- return 0;
139108 }
140109
141110 /*
....@@ -257,7 +226,7 @@
257226 offset += rec->period_size;
258227 }
259228 /* make loop */
260
- cp->command = cpu_to_le16(DBDMA_NOP + BR_ALWAYS);
229
+ cp->command = cpu_to_le16(DBDMA_NOP | BR_ALWAYS);
261230 cp->cmd_dep = cpu_to_le32(rec->cmd.addr);
262231
263232 snd_pmac_dma_stop(rec);
....@@ -684,9 +653,6 @@
684653 static const struct snd_pcm_ops snd_pmac_playback_ops = {
685654 .open = snd_pmac_playback_open,
686655 .close = snd_pmac_playback_close,
687
- .ioctl = snd_pcm_lib_ioctl,
688
- .hw_params = snd_pmac_pcm_hw_params,
689
- .hw_free = snd_pmac_pcm_hw_free,
690656 .prepare = snd_pmac_playback_prepare,
691657 .trigger = snd_pmac_playback_trigger,
692658 .pointer = snd_pmac_playback_pointer,
....@@ -695,9 +661,6 @@
695661 static const struct snd_pcm_ops snd_pmac_capture_ops = {
696662 .open = snd_pmac_capture_open,
697663 .close = snd_pmac_capture_close,
698
- .ioctl = snd_pcm_lib_ioctl,
699
- .hw_params = snd_pmac_pcm_hw_params,
700
- .hw_free = snd_pmac_pcm_hw_free,
701664 .prepare = snd_pmac_capture_prepare,
702665 .trigger = snd_pmac_capture_trigger,
703666 .pointer = snd_pmac_capture_pointer,
....@@ -734,9 +697,9 @@
734697 chip->capture.cur_freqs = chip->freqs_ok;
735698
736699 /* preallocate 64k buffer */
737
- snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
738
- &chip->pdev->dev,
739
- 64 * 1024, 64 * 1024);
700
+ snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
701
+ &chip->pdev->dev,
702
+ 64 * 1024, 64 * 1024);
740703
741704 return 0;
742705 }
....@@ -763,7 +726,7 @@
763726 chip->extra_dma.cmds->xfer_status = cpu_to_le16(0);
764727 chip->extra_dma.cmds->cmd_dep = cpu_to_le32(chip->extra_dma.addr);
765728 chip->extra_dma.cmds->phy_addr = cpu_to_le32(addr);
766
- chip->extra_dma.cmds->command = cpu_to_le16(OUTPUT_MORE + BR_ALWAYS);
729
+ chip->extra_dma.cmds->command = cpu_to_le16(OUTPUT_MORE | BR_ALWAYS);
767730 out_le32(&chip->awacs->control,
768731 (in_le32(&chip->awacs->control) & ~0x1f00)
769732 | (speed << 8));
....@@ -908,7 +871,7 @@
908871
909872 /* if seems that Keylargo can't byte-swap */
910873 for (mio = chip->node->parent; mio; mio = mio->parent) {
911
- if (strcmp(mio->name, "mac-io") == 0) {
874
+ if (of_node_name_eq(mio, "mac-io")) {
912875 if (of_device_is_compatible(mio, "Keylargo"))
913876 chip->can_byte_swap = 0;
914877 break;
....@@ -1141,7 +1104,7 @@
11411104 return 0;
11421105 }
11431106
1144
-static struct snd_kcontrol_new auto_mute_controls[] = {
1107
+static const struct snd_kcontrol_new auto_mute_controls[] = {
11451108 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11461109 .name = "Auto Mute Switch",
11471110 .info = snd_pmac_boolean_mono_info,
....@@ -1180,7 +1143,7 @@
11801143 int i, err;
11811144 unsigned int irq;
11821145 unsigned long ctrl_addr, txdma_addr, rxdma_addr;
1183
- static struct snd_device_ops ops = {
1146
+ static const struct snd_device_ops ops = {
11841147 .dev_free = snd_pmac_dev_free,
11851148 };
11861149
....@@ -1211,7 +1174,7 @@
12111174 np = chip->node;
12121175 chip->requested = 0;
12131176 if (chip->is_k2) {
1214
- static char *rnames[] = {
1177
+ static const char * const rnames[] = {
12151178 "Sound Control", "Sound DMA" };
12161179 for (i = 0; i < 2; i ++) {
12171180 if (of_address_to_resource(np->parent, i,
....@@ -1236,7 +1199,7 @@
12361199 txdma_addr = chip->rsrc[1].start;
12371200 rxdma_addr = txdma_addr + 0x100;
12381201 } else {
1239
- static char *rnames[] = {
1202
+ static const char * const rnames[] = {
12401203 "Sound Control", "Sound Tx DMA", "Sound Rx DMA" };
12411204 for (i = 0; i < 3; i ++) {
12421205 if (of_address_to_resource(np, i,
....@@ -1313,7 +1276,7 @@
13131276 } else if (chip->is_pbook_G3) {
13141277 struct device_node* mio;
13151278 for (mio = chip->node->parent; mio; mio = mio->parent) {
1316
- if (strcmp(mio->name, "mac-io") == 0) {
1279
+ if (of_node_name_eq(mio, "mac-io")) {
13171280 struct resource r;
13181281 if (of_address_to_resource(mio, 0, &r) == 0)
13191282 chip->macio_base =
....@@ -1365,7 +1328,6 @@
13651328 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
13661329 if (chip->suspend)
13671330 chip->suspend(chip);
1368
- snd_pcm_suspend_all(chip->pcm);
13691331 spin_lock_irqsave(&chip->reg_lock, flags);
13701332 snd_pmac_beep_stop(chip);
13711333 spin_unlock_irqrestore(&chip->reg_lock, flags);