hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/sound/soc/pxa/magician.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * SoC audio for HTC Magician
34 *
....@@ -6,12 +7,6 @@
67 * based on spitz.c,
78 * Authors: Liam Girdwood <lrg@slimlogic.co.uk>
89 * Richard Purdie <richard@openedhand.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of the GNU General Public License as published by the
12
- * Free Software Foundation; either version 2 of the License, or (at your
13
- * option) any later version.
14
- *
1510 */
1611
1712 #include <linux/module.h>
....@@ -73,7 +68,7 @@
7368
7469 static int magician_startup(struct snd_pcm_substream *substream)
7570 {
76
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
71
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
7772
7873 /* check the jack status at stream startup */
7974 magician_ext_control(&rtd->card->dapm);
....@@ -87,9 +82,9 @@
8782 static int magician_playback_hw_params(struct snd_pcm_substream *substream,
8883 struct snd_pcm_hw_params *params)
8984 {
90
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
91
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
92
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
85
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
86
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
87
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
9388 unsigned int width;
9489 int ret = 0;
9590
....@@ -125,9 +120,9 @@
125120 static int magician_capture_hw_params(struct snd_pcm_substream *substream,
126121 struct snd_pcm_hw_params *params)
127122 {
128
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
129
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
130
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
123
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
124
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
125
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
131126 int ret = 0;
132127
133128 /* set codec DAI configuration */
....@@ -290,24 +285,30 @@
290285 };
291286
292287 /* magician digital audio interface glue - connects codec <--> CPU */
288
+SND_SOC_DAILINK_DEFS(playback,
289
+ DAILINK_COMP_ARRAY(COMP_CPU("pxa-ssp-dai.0")),
290
+ DAILINK_COMP_ARRAY(COMP_CODEC("uda1380-codec.0-0018",
291
+ "uda1380-hifi-playback")),
292
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
293
+
294
+SND_SOC_DAILINK_DEFS(capture,
295
+ DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-i2s")),
296
+ DAILINK_COMP_ARRAY(COMP_CODEC("uda1380-codec.0-0018",
297
+ "uda1380-hifi-capture")),
298
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
299
+
293300 static struct snd_soc_dai_link magician_dai[] = {
294301 {
295302 .name = "uda1380",
296303 .stream_name = "UDA1380 Playback",
297
- .cpu_dai_name = "pxa-ssp-dai.0",
298
- .codec_dai_name = "uda1380-hifi-playback",
299
- .platform_name = "pxa-pcm-audio",
300
- .codec_name = "uda1380-codec.0-0018",
301304 .ops = &magician_playback_ops,
305
+ SND_SOC_DAILINK_REG(playback),
302306 },
303307 {
304308 .name = "uda1380",
305309 .stream_name = "UDA1380 Capture",
306
- .cpu_dai_name = "pxa2xx-i2s",
307
- .codec_dai_name = "uda1380-hifi-capture",
308
- .platform_name = "pxa-pcm-audio",
309
- .codec_name = "uda1380-codec.0-0018",
310310 .ops = &magician_capture_ops,
311
+ SND_SOC_DAILINK_REG(capture),
311312 }
312313 };
313314
....@@ -357,10 +358,10 @@
357358 adapter = i2c_get_adapter(0);
358359 if (!adapter)
359360 return -ENODEV;
360
- client = i2c_new_device(adapter, i2c_board_info);
361
+ client = i2c_new_client_device(adapter, i2c_board_info);
361362 i2c_put_adapter(adapter);
362
- if (!client)
363
- return -ENODEV;
363
+ if (IS_ERR(client))
364
+ return PTR_ERR(client);
364365
365366 ret = gpio_request(EGPIO_MAGICIAN_SPK_POWER, "SPK_POWER");
366367 if (ret)