forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/samsung/rx1950_uda1380.c
....@@ -1,33 +1,24 @@
1
-/*
2
- * rx1950.c -- ALSA Soc Audio Layer
3
- *
4
- * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
5
- *
6
- * Based on smdk2440.c and magician.c
7
- *
8
- * Authors: Graeme Gregory graeme.gregory@wolfsonmicro.com
9
- * Philipp Zabel <philipp.zabel@gmail.com>
10
- * Denis Grigoriev <dgreenday@gmail.com>
11
- * Vasily Khoruzhick <anarsoul@gmail.com>
12
- *
13
- * This program is free software; you can redistribute it and/or modify it
14
- * under the terms of the GNU General Public License as published by the
15
- * Free Software Foundation; either version 2 of the License, or (at your
16
- * option) any later version.
17
- *
18
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// rx1950.c - ALSA SoC Audio Layer
4
+//
5
+// Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
6
+//
7
+// Based on smdk2440.c and magician.c
8
+//
9
+// Authors: Graeme Gregory graeme.gregory@wolfsonmicro.com
10
+// Philipp Zabel <philipp.zabel@gmail.com>
11
+// Denis Grigoriev <dgreenday@gmail.com>
12
+// Vasily Khoruzhick <anarsoul@gmail.com>
1913
2014 #include <linux/types.h>
21
-#include <linux/gpio.h>
15
+#include <linux/gpio/consumer.h>
2216 #include <linux/module.h>
2317
2418 #include <sound/soc.h>
2519 #include <sound/jack.h>
2620
27
-#include <mach/gpio-samsung.h>
2821 #include "regs-iis.h"
29
-#include <asm/mach-types.h>
30
-
3122 #include "s3c24xx-i2s.h"
3223
3324 static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd);
....@@ -64,7 +55,6 @@
6455
6556 static struct snd_soc_jack_gpio hp_jack_gpios[] = {
6657 [0] = {
67
- .gpio = S3C2410_GPG(12),
6858 .name = "hp-gpio",
6959 .report = SND_JACK_HEADPHONE,
7060 .invert = 1,
....@@ -78,18 +68,21 @@
7868 };
7969
8070 /* s3c24xx digital audio interface glue - connects codec <--> CPU */
71
+SND_SOC_DAILINK_DEFS(uda1380,
72
+ DAILINK_COMP_ARRAY(COMP_CPU("s3c24xx-iis")),
73
+ DAILINK_COMP_ARRAY(COMP_CODEC("uda1380-codec.0-001a",
74
+ "uda1380-hifi")),
75
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("s3c24xx-iis")));
76
+
8177 static struct snd_soc_dai_link rx1950_uda1380_dai[] = {
8278 {
8379 .name = "uda1380",
8480 .stream_name = "UDA1380 Duplex",
85
- .cpu_dai_name = "s3c24xx-iis",
86
- .codec_dai_name = "uda1380-hifi",
8781 .init = rx1950_uda1380_init,
88
- .platform_name = "s3c24xx-iis",
89
- .codec_name = "uda1380-codec.0-001a",
9082 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
9183 SND_SOC_DAIFMT_CBS_CFS,
9284 .ops = &rx1950_ops,
85
+ SND_SOC_DAILINK_REG(uda1380),
9386 },
9487 };
9588
....@@ -126,8 +119,6 @@
126119 .num_dapm_routes = ARRAY_SIZE(audio_map),
127120 };
128121
129
-static struct platform_device *s3c24xx_snd_device;
130
-
131122 static int rx1950_startup(struct snd_pcm_substream *substream)
132123 {
133124 struct snd_pcm_runtime *runtime = substream->runtime;
....@@ -137,13 +128,15 @@
137128 &hw_rates);
138129 }
139130
131
+static struct gpio_desc *gpiod_speaker_power;
132
+
140133 static int rx1950_spk_power(struct snd_soc_dapm_widget *w,
141134 struct snd_kcontrol *kcontrol, int event)
142135 {
143136 if (SND_SOC_DAPM_EVENT_ON(event))
144
- gpio_set_value(S3C2410_GPA(1), 1);
137
+ gpiod_set_value(gpiod_speaker_power, 1);
145138 else
146
- gpio_set_value(S3C2410_GPA(1), 0);
139
+ gpiod_set_value(gpiod_speaker_power, 0);
147140
148141 return 0;
149142 }
....@@ -151,8 +144,8 @@
151144 static int rx1950_hw_params(struct snd_pcm_substream *substream,
152145 struct snd_pcm_hw_params *params)
153146 {
154
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
155
- struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
147
+ struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
148
+ struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
156149 int div;
157150 int ret;
158151 unsigned int rate = params_rate(params);
....@@ -217,57 +210,35 @@
217210 return 0;
218211 }
219212
220
-static int __init rx1950_init(void)
213
+static int rx1950_probe(struct platform_device *pdev)
221214 {
222
- int ret;
223
-
224
- if (!machine_is_rx1950())
225
- return -ENODEV;
215
+ struct device *dev = &pdev->dev;
226216
227217 /* configure some gpios */
228
- ret = gpio_request(S3C2410_GPA(1), "speaker-power");
229
- if (ret)
230
- goto err_gpio;
231
-
232
- ret = gpio_direction_output(S3C2410_GPA(1), 0);
233
- if (ret)
234
- goto err_gpio_conf;
235
-
236
- s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
237
- if (!s3c24xx_snd_device) {
238
- ret = -ENOMEM;
239
- goto err_plat_alloc;
218
+ gpiod_speaker_power = devm_gpiod_get(dev, "speaker-power", GPIOD_OUT_LOW);
219
+ if (IS_ERR(gpiod_speaker_power)) {
220
+ dev_err(dev, "cannot get gpio\n");
221
+ return PTR_ERR(gpiod_speaker_power);
240222 }
241223
242
- platform_set_drvdata(s3c24xx_snd_device, &rx1950_asoc);
243
- ret = platform_device_add(s3c24xx_snd_device);
224
+ hp_jack_gpios[0].gpiod_dev = dev;
225
+ rx1950_asoc.dev = dev;
244226
245
- if (ret) {
246
- platform_device_put(s3c24xx_snd_device);
247
- goto err_plat_add;
248
- }
249
-
250
- return 0;
251
-
252
-err_plat_add:
253
-err_plat_alloc:
254
-err_gpio_conf:
255
- gpio_free(S3C2410_GPA(1));
256
-
257
-err_gpio:
258
- return ret;
227
+ return devm_snd_soc_register_card(dev, &rx1950_asoc);
259228 }
260229
261
-static void __exit rx1950_exit(void)
262
-{
263
- platform_device_unregister(s3c24xx_snd_device);
264
- gpio_free(S3C2410_GPA(1));
265
-}
230
+static struct platform_driver rx1950_audio = {
231
+ .driver = {
232
+ .name = "rx1950-audio",
233
+ .pm = &snd_soc_pm_ops,
234
+ },
235
+ .probe = rx1950_probe,
236
+};
266237
267
-module_init(rx1950_init);
268
-module_exit(rx1950_exit);
238
+module_platform_driver(rx1950_audio);
269239
270240 /* Module information */
271241 MODULE_AUTHOR("Vasily Khoruzhick");
272242 MODULE_DESCRIPTION("ALSA SoC RX1950");
273243 MODULE_LICENSE("GPL");
244
+MODULE_ALIAS("platform:rx1950-audio");