forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4
kernel/sound/soc/pxa/pxa2xx-ac97.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/sound/pxa2xx-ac97.c -- AC97 support for the Intel PXA2xx chip.
34 *
45 * Author: Nicolas Pitre
56 * Created: Dec 02, 2004
67 * Copyright: MontaVista Software Inc.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129
1310 #include <linux/init.h>
....@@ -17,6 +14,7 @@
1714 #include <linux/dmaengine.h>
1815 #include <linux/dma/pxa-dma.h>
1916
17
+#include <sound/ac97/controller.h>
2018 #include <sound/core.h>
2119 #include <sound/ac97_codec.h>
2220 #include <sound/soc.h>
....@@ -27,43 +25,35 @@
2725 #include <mach/regs-ac97.h>
2826 #include <mach/audio.h>
2927
30
-static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
28
+static void pxa2xx_ac97_warm_reset(struct ac97_controller *adrv)
3129 {
3230 pxa2xx_ac97_try_warm_reset();
3331
3432 pxa2xx_ac97_finish_reset();
3533 }
3634
37
-static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
35
+static void pxa2xx_ac97_cold_reset(struct ac97_controller *adrv)
3836 {
3937 pxa2xx_ac97_try_cold_reset();
4038
4139 pxa2xx_ac97_finish_reset();
4240 }
4341
44
-static unsigned short pxa2xx_ac97_legacy_read(struct snd_ac97 *ac97,
45
- unsigned short reg)
42
+static int pxa2xx_ac97_read_actrl(struct ac97_controller *adrv, int slot,
43
+ unsigned short reg)
4644 {
47
- int ret;
48
-
49
- ret = pxa2xx_ac97_read(ac97->num, reg);
50
- if (ret < 0)
51
- return 0;
52
- else
53
- return (unsigned short)(ret & 0xffff);
45
+ return pxa2xx_ac97_read(slot, reg);
5446 }
5547
56
-static void pxa2xx_ac97_legacy_write(struct snd_ac97 *ac97,
57
- unsigned short reg, unsigned short val)
48
+static int pxa2xx_ac97_write_actrl(struct ac97_controller *adrv, int slot,
49
+ unsigned short reg, unsigned short val)
5850 {
59
- int ret;
60
-
61
- ret = pxa2xx_ac97_write(ac97->num, reg, val);
51
+ return pxa2xx_ac97_write(slot, reg, val);
6252 }
6353
64
-static struct snd_ac97_bus_ops pxa2xx_ac97_ops = {
65
- .read = pxa2xx_ac97_legacy_read,
66
- .write = pxa2xx_ac97_legacy_write,
54
+static struct ac97_controller_ops pxa2xx_ac97_ops = {
55
+ .read = pxa2xx_ac97_read_actrl,
56
+ .write = pxa2xx_ac97_write_actrl,
6757 .warm_reset = pxa2xx_ac97_warm_reset,
6858 .reset = pxa2xx_ac97_cold_reset,
6959 };
....@@ -167,7 +157,6 @@
167157 static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = {
168158 {
169159 .name = "pxa2xx-ac97",
170
- .bus_control = true,
171160 .playback = {
172161 .stream_name = "AC97 Playback",
173162 .channels_min = 2,
....@@ -184,7 +173,6 @@
184173 },
185174 {
186175 .name = "pxa2xx-ac97-aux",
187
- .bus_control = true,
188176 .playback = {
189177 .stream_name = "AC97 Aux Playback",
190178 .channels_min = 1,
....@@ -201,7 +189,6 @@
201189 },
202190 {
203191 .name = "pxa2xx-ac97-mic",
204
- .bus_control = true,
205192 .capture = {
206193 .stream_name = "AC97 Mic Capture",
207194 .channels_min = 1,
....@@ -214,9 +201,16 @@
214201
215202 static const struct snd_soc_component_driver pxa_ac97_component = {
216203 .name = "pxa-ac97",
217
- .ops = &pxa2xx_pcm_ops,
218
- .pcm_new = pxa2xx_soc_pcm_new,
219
- .pcm_free = pxa2xx_pcm_free_dma_buffers,
204
+ .pcm_construct = pxa2xx_soc_pcm_new,
205
+ .pcm_destruct = pxa2xx_soc_pcm_free,
206
+ .open = pxa2xx_soc_pcm_open,
207
+ .close = pxa2xx_soc_pcm_close,
208
+ .hw_params = pxa2xx_soc_pcm_hw_params,
209
+ .hw_free = pxa2xx_soc_pcm_hw_free,
210
+ .prepare = pxa2xx_soc_pcm_prepare,
211
+ .trigger = pxa2xx_soc_pcm_trigger,
212
+ .pointer = pxa2xx_soc_pcm_pointer,
213
+ .mmap = pxa2xx_soc_pcm_mmap,
220214 };
221215
222216 #ifdef CONFIG_OF
....@@ -233,6 +227,9 @@
233227 static int pxa2xx_ac97_dev_probe(struct platform_device *pdev)
234228 {
235229 int ret;
230
+ struct ac97_controller *ctrl;
231
+ pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
232
+ void **codecs_pdata;
236233
237234 if (pdev->id != -1) {
238235 dev_err(&pdev->dev, "PXA2xx has only one AC97 port.\n");
....@@ -245,22 +242,27 @@
245242 return ret;
246243 }
247244
248
- ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops);
249
- if (ret != 0)
250
- return ret;
245
+ codecs_pdata = pdata ? pdata->codec_pdata : NULL;
246
+ ctrl = snd_ac97_controller_register(&pxa2xx_ac97_ops, &pdev->dev,
247
+ AC97_SLOTS_AVAILABLE_ALL,
248
+ codecs_pdata);
249
+ if (IS_ERR(ctrl))
250
+ return PTR_ERR(ctrl);
251251
252
+ platform_set_drvdata(pdev, ctrl);
252253 /* Punt most of the init to the SoC probe; we may need the machine
253254 * driver to do interesting things with the clocking to get us up
254255 * and running.
255256 */
256
- return snd_soc_register_component(&pdev->dev, &pxa_ac97_component,
257
+ return devm_snd_soc_register_component(&pdev->dev, &pxa_ac97_component,
257258 pxa_ac97_dai_driver, ARRAY_SIZE(pxa_ac97_dai_driver));
258259 }
259260
260261 static int pxa2xx_ac97_dev_remove(struct platform_device *pdev)
261262 {
262
- snd_soc_unregister_component(&pdev->dev);
263
- snd_soc_set_ac97_ops(NULL);
263
+ struct ac97_controller *ctrl = platform_get_drvdata(pdev);
264
+
265
+ snd_ac97_controller_unregister(ctrl);
264266 pxa2xx_ac97_hw_remove(pdev);
265267 return 0;
266268 }