[kernel] rename 014-samsung_flash patch to a better name, thanks maddes
[openwrt.git] / target / linux / xburst / patches-2.6.34 / 065-qi_lb60-sound.patch
1 From 53b1d94ccca6a06e86460344f7c38949d53374b6 Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Sat, 24 Apr 2010 12:36:15 +0200
4 Subject: [PATCH] Add qi_lb60 SoC sound board driver
5
6 ---
7 sound/soc/jz4740/Kconfig | 8 ++
8 sound/soc/jz4740/Makefile | 4 +
9 sound/soc/jz4740/qi_lb60.c | 182 ++++++++++++++++++++++++++++++++++++++++++++
10 3 files changed, 194 insertions(+), 0 deletions(-)
11 create mode 100644 sound/soc/jz4740/qi_lb60.c
12
13 diff --git a/sound/soc/jz4740/Kconfig b/sound/soc/jz4740/Kconfig
14 index 39df949..e546c30 100644
15 --- a/sound/soc/jz4740/Kconfig
16 +++ b/sound/soc/jz4740/Kconfig
17 @@ -11,3 +11,11 @@ config SND_JZ4740_SOC_I2S
18 tristate "SoC Audio (I2S protocol) for Ingenic jz4740 chip"
19 help
20 Say Y if you want to use I2S protocol and I2S codec on Ingenic Jz4740 QI_LB60 board.
21 +
22 +config SND_JZ4740_SOC_QI_LB60
23 + tristate "SoC Audio support for Qi Hardware Ben Nanonote"
24 + depends on SND_JZ4740_SOC && JZ4740_QI_LB60
25 + select SND_JZ4740_SOC_I2S
26 + select SND_SOC_JZCODEC
27 + help
28 + Say Y if you want to add support for SoC audio of internal codec on Ingenic Jz4740 QI_LB60 board.
29 diff --git a/sound/soc/jz4740/Makefile b/sound/soc/jz4740/Makefile
30 index 1be8d19..be873c1 100644
31 --- a/sound/soc/jz4740/Makefile
32 +++ b/sound/soc/jz4740/Makefile
33 @@ -7,3 +7,7 @@ snd-soc-jz4740-i2s-objs := jz4740-i2s.o
34 obj-$(CONFIG_SND_JZ4740_SOC) += snd-soc-jz4740.o
35 obj-$(CONFIG_SND_JZ4740_SOC_I2S) += snd-soc-jz4740-i2s.o
36
37 +# Jz4740 Machine Support
38 +snd-soc-qi-lb60-objs := qi_lb60.o
39 +
40 +obj-$(CONFIG_SND_JZ4740_SOC_QI_LB60) += snd-soc-qi-lb60.o
41 diff --git a/sound/soc/jz4740/qi_lb60.c b/sound/soc/jz4740/qi_lb60.c
42 new file mode 100644
43 index 0000000..a2ce3cf
44 --- /dev/null
45 +++ b/sound/soc/jz4740/qi_lb60.c
46 @@ -0,0 +1,182 @@
47 +/*
48 + * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de>
49 + *
50 + * This program is free software; you can redistribute it and/or modify
51 + * it under the terms of the GNU General Public License version 2 as
52 + * published by the Free Software Foundation.
53 + *
54 + * You should have received a copy of the GNU General Public License along
55 + * with this program; if not, write to the Free Software Foundation, Inc.,
56 + * 675 Mass Ave, Cambridge, MA 02139, USA.
57 + *
58 + */
59 +
60 +#include <linux/module.h>
61 +#include <linux/moduleparam.h>
62 +#include <linux/timer.h>
63 +#include <linux/interrupt.h>
64 +#include <linux/platform_device.h>
65 +#include <sound/core.h>
66 +#include <sound/pcm.h>
67 +#include <sound/soc.h>
68 +#include <sound/soc-dapm.h>
69 +#include <linux/gpio.h>
70 +
71 +#include "../codecs/jzcodec.h"
72 +#include "jz4740-pcm.h"
73 +#include "jz4740-i2s.h"
74 +
75 +
76 +#define QI_LB60_SND_GPIO JZ_GPIO_PORTB(29)
77 +#define QI_LB60_AMP_GPIO JZ_GPIO_PORTD(4)
78 +
79 +static int qi_lb60_spk_event(struct snd_soc_dapm_widget *widget,
80 + struct snd_kcontrol *ctrl, int event)
81 +{
82 + int on = 0;
83 + if (event & SND_SOC_DAPM_POST_PMU)
84 + on = 1;
85 + else if (event & SND_SOC_DAPM_PRE_PMD)
86 + on = 0;
87 +
88 + gpio_set_value(QI_LB60_SND_GPIO, on);
89 + gpio_set_value(QI_LB60_AMP_GPIO, on);
90 +
91 + return 0;
92 +}
93 +
94 +static const struct snd_soc_dapm_widget qi_lb60_widgets[] = {
95 + SND_SOC_DAPM_SPK("Speaker", qi_lb60_spk_event),
96 + SND_SOC_DAPM_MIC("Mic", NULL),
97 +};
98 +
99 +static const struct snd_soc_dapm_route qi_lb60_routes[] = {
100 + {"Mic", NULL, "MIC"},
101 + {"Speaker", NULL, "LOUT"},
102 + {"Speaker", NULL, "ROUT"},
103 +};
104 +
105 +#define QI_LB60_DAIFMT (SND_SOC_DAIFMT_I2S | \
106 + SND_SOC_DAIFMT_NB_NF | \
107 + SND_SOC_DAIFMT_CBM_CFM)
108 +
109 +static int qi_lb60_codec_init(struct snd_soc_codec *codec)
110 +{
111 + int ret;
112 + struct snd_soc_dai *cpu_dai = codec->socdev->card->dai_link->cpu_dai;
113 + struct snd_soc_dai *codec_dai = codec->socdev->card->dai_link->codec_dai;
114 +
115 + snd_soc_dapm_nc_pin(codec, "LIN");
116 + snd_soc_dapm_nc_pin(codec, "RIN");
117 +
118 + ret = snd_soc_dai_set_fmt(codec_dai, QI_LB60_DAIFMT);
119 + if (ret < 0) {
120 + dev_err(codec->dev, "Failed to set codec dai format: %d\n", ret);
121 + return ret;
122 + }
123 +
124 + ret = snd_soc_dai_set_fmt(cpu_dai, QI_LB60_DAIFMT);
125 + if (ret < 0) {
126 + dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret);
127 + return ret;
128 + }
129 +
130 + ret = snd_soc_dai_set_sysclk(codec_dai, JZCODEC_SYSCLK, 111,
131 + SND_SOC_CLOCK_IN);
132 + if (ret < 0) {
133 + dev_err(codec->dev, "Failed to set codec dai sysclk: %d\n", ret);
134 + return ret;
135 + }
136 +
137 + snd_soc_dapm_new_controls(codec, qi_lb60_widgets, ARRAY_SIZE(qi_lb60_widgets));
138 +
139 + snd_soc_dapm_add_routes(codec, qi_lb60_routes, ARRAY_SIZE(qi_lb60_routes));
140 +
141 + snd_soc_dapm_sync(codec);
142 +
143 + return 0;
144 +}
145 +
146 +static struct snd_soc_dai_link qi_lb60_dai = {
147 + .name = "jz-codec",
148 + .stream_name = "JZCODEC",
149 + .cpu_dai = &jz4740_i2s_dai,
150 + .codec_dai = &jz_codec_dai,
151 + .init = qi_lb60_codec_init,
152 +};
153 +
154 +static struct snd_soc_card qi_lb60 = {
155 + .name = "QI LB60",
156 + .dai_link = &qi_lb60_dai,
157 + .num_links = 1,
158 + .platform = &jz4740_soc_platform,
159 +};
160 +
161 +static struct snd_soc_device qi_lb60_snd_devdata = {
162 + .card = &qi_lb60,
163 + .codec_dev = &soc_codec_dev_jzcodec,
164 +};
165 +
166 +static struct platform_device *qi_lb60_snd_device;
167 +
168 +static int __init qi_lb60_init(void)
169 +{
170 + int ret;
171 +
172 + qi_lb60_snd_device = platform_device_alloc("soc-audio", -1);
173 +
174 + if (!qi_lb60_snd_device)
175 + return -ENOMEM;
176 +
177 +
178 + ret = gpio_request(QI_LB60_SND_GPIO, "SND");
179 + if (ret) {
180 + pr_err("qi_lb60 snd: Failed to request SND GPIO(%d): %d\n",
181 + QI_LB60_SND_GPIO, ret);
182 + goto err_device_put;
183 + }
184 +
185 + ret = gpio_request(QI_LB60_AMP_GPIO, "AMP");
186 + if (ret) {
187 + pr_err("qi_lb60 snd: Failed to request AMP GPIO(%d): %d\n",
188 + QI_LB60_AMP_GPIO, ret);
189 + goto err_gpio_free_snd;
190 + }
191 +
192 + gpio_direction_output(JZ_GPIO_PORTB(29), 0);
193 + gpio_direction_output(JZ_GPIO_PORTD(4), 0);
194 +
195 + platform_set_drvdata(qi_lb60_snd_device, &qi_lb60_snd_devdata);
196 + qi_lb60_snd_devdata.dev = &qi_lb60_snd_device->dev;
197 + ret = platform_device_add(qi_lb60_snd_device);
198 + if (ret) {
199 + pr_err("qi_lb60 snd: Failed to add snd soc device: %d\n", ret);
200 + goto err_unset_pdata;
201 + }
202 +
203 + return 0;
204 +
205 +err_unset_pdata:
206 + platform_set_drvdata(qi_lb60_snd_device, NULL);
207 +/*err_gpio_free_amp:*/
208 + gpio_free(QI_LB60_AMP_GPIO);
209 +err_gpio_free_snd:
210 + gpio_free(QI_LB60_SND_GPIO);
211 +err_device_put:
212 + platform_device_put(qi_lb60_snd_device);
213 +
214 + return ret;
215 +}
216 +module_init(qi_lb60_init);
217 +
218 +static void __exit qi_lb60_exit(void)
219 +{
220 + gpio_free(QI_LB60_AMP_GPIO);
221 + gpio_free(QI_LB60_SND_GPIO);
222 + platform_device_unregister(qi_lb60_snd_device);
223 +}
224 +module_exit(qi_lb60_exit);
225 +
226 +MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
227 +MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
228 +MODULE_LICENSE("GPL v2");
229 --
230 1.5.6.5
231
This page took 0.053252 seconds and 5 git commands to generate.