Date: | 2010-04-24 12:38:41 (13 years 7 months ago) |
---|---|
Author: | Lars C. |
Commit: | 6d0bc149a5950ceb0a29c5e4311416b4c19c608d |
Message: | Add N526 sound SoC board driver |
Files: |
sound/soc/jz4740/Kconfig (1 diff) sound/soc/jz4740/Makefile (1 diff) sound/soc/jz4740/n526.c (1 diff) |
Change Details
sound/soc/jz4740/Kconfig | ||
---|---|---|
27 | 27 | select SND_SOC_JZCODEC |
28 | 28 | help |
29 | 29 | Say Y if you want to enable support for SoC audio on the Hanvon N516. |
30 | ||
31 | config SND_JZ4740_SOC_N526 | |
32 | tristate "SoC Audio support for Hanvon N526 eBook reader" | |
33 | depends on SND_JZ4740_SOC && JZ4740_N526 | |
34 | select SND_JZ4740_SOC_I2S | |
35 | select SND_SOC_JZCODEC | |
36 | help | |
37 | Say Y if you want to enable support for SoC audio on the Hanvon N526. |
sound/soc/jz4740/Makefile | ||
---|---|---|
10 | 10 | # Jz4740 Machine Support |
11 | 11 | snd-soc-qi-lb60-objs := qi_lb60.o |
12 | 12 | snd-soc-n516-objs := n516.o |
13 | snd-soc-n526-objs := n526.o | |
13 | 14 | |
14 | 15 | obj-$(CONFIG_SND_JZ4740_SOC_QI_LB60) += snd-soc-qi-lb60.o |
15 | 16 | obj-$(CONFIG_SND_JZ4740_SOC_N516) += snd-soc-n516.o |
17 | obj-$(CONFIG_SND_JZ4740_SOC_N526) += snd-soc-n526.o |
sound/soc/jz4740/n526.c | ||
---|---|---|
1 | /* | |
2 | * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * You should have received a copy of the GNU General Public License along | |
9 | * with this program; if not, write to the Free Software Foundation, Inc., | |
10 | * 675 Mass Ave, Cambridge, MA 02139, USA. | |
11 | * | |
12 | */ | |
13 | ||
14 | #include <linux/module.h> | |
15 | #include <linux/moduleparam.h> | |
16 | #include <linux/timer.h> | |
17 | #include <linux/interrupt.h> | |
18 | #include <linux/platform_device.h> | |
19 | #include <sound/core.h> | |
20 | #include <sound/pcm.h> | |
21 | #include <sound/soc.h> | |
22 | #include <sound/soc-dapm.h> | |
23 | #include <linux/gpio.h> | |
24 | ||
25 | #include "../codecs/jzcodec.h" | |
26 | #include "jz4740-pcm.h" | |
27 | #include "jz4740-i2s.h" | |
28 | ||
29 | #define N526_AMP_EN_GPIO JZ_GPIO_PORTD(4) | |
30 | ||
31 | static int n526_spk_event(struct snd_soc_dapm_widget *widget, | |
32 | struct snd_kcontrol *ctrl, int event) | |
33 | { | |
34 | gpio_set_value(N526_AMP_EN_GPIO, !SND_SOC_DAPM_EVENT_OFF(event)); | |
35 | return 0; | |
36 | } | |
37 | ||
38 | static const struct snd_soc_dapm_widget n526_widgets[] = { | |
39 | SND_SOC_DAPM_SPK("Speaker", n526_spk_event), | |
40 | SND_SOC_DAPM_HP("Headphone", NULL), | |
41 | SND_SOC_DAPM_MIC("Mic", NULL), | |
42 | }; | |
43 | ||
44 | static const struct snd_soc_dapm_route n526_routes[] = { | |
45 | {"Mic", NULL, "MIC"}, | |
46 | {"Speaker", NULL, "LOUT"}, | |
47 | {"Speaker", NULL, "ROUT"}, | |
48 | {"Headphone", NULL, "LOUT"}, | |
49 | {"Headphone", NULL, "ROUT"}, | |
50 | }; | |
51 | ||
52 | static const struct snd_kcontrol_new n526_controls[] = { | |
53 | SOC_DAPM_PIN_SWITCH("Speaker"), | |
54 | }; | |
55 | ||
56 | #define N526_DAIFMT (SND_SOC_DAIFMT_I2S | \ | |
57 | SND_SOC_DAIFMT_NB_NF | \ | |
58 | SND_SOC_DAIFMT_CBM_CFM) | |
59 | ||
60 | static int n526_codec_init(struct snd_soc_codec *codec) | |
61 | { | |
62 | int ret; | |
63 | struct snd_soc_dai *cpu_dai = codec->socdev->card->dai_link->cpu_dai; | |
64 | struct snd_soc_dai *codec_dai = codec->socdev->card->dai_link->codec_dai; | |
65 | ||
66 | snd_soc_dapm_nc_pin(codec, "LIN"); | |
67 | snd_soc_dapm_nc_pin(codec, "RIN"); | |
68 | ||
69 | ret = snd_soc_dai_set_fmt(codec_dai, N526_DAIFMT); | |
70 | if (ret < 0) { | |
71 | dev_err(codec->dev, "Failed to set codec dai format: %d\n", ret); | |
72 | return ret; | |
73 | } | |
74 | ||
75 | ret = snd_soc_dai_set_fmt(cpu_dai, N526_DAIFMT); | |
76 | if (ret < 0) { | |
77 | dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret); | |
78 | return ret; | |
79 | } | |
80 | ||
81 | ret = snd_soc_dai_set_sysclk(codec_dai, JZCODEC_SYSCLK, 111, | |
82 | SND_SOC_CLOCK_IN); | |
83 | if (ret < 0) { | |
84 | dev_err(codec->dev, "Failed to set codec dai sysclk: %d\n", ret); | |
85 | return ret; | |
86 | } | |
87 | ||
88 | snd_soc_dapm_new_controls(codec, n526_widgets, ARRAY_SIZE(n526_widgets)); | |
89 | ||
90 | snd_soc_add_controls(codec, n526_controls, | |
91 | ARRAY_SIZE(n526_controls)); | |
92 | ||
93 | snd_soc_dapm_add_routes(codec, n526_routes, ARRAY_SIZE(n526_routes)); | |
94 | ||
95 | snd_soc_dapm_sync(codec); | |
96 | ||
97 | return 0; | |
98 | } | |
99 | ||
100 | static struct snd_soc_dai_link n526_dai = { | |
101 | .name = "jz-codec", | |
102 | .stream_name = "JZCODEC", | |
103 | .cpu_dai = &jz4740_i2s_dai, | |
104 | .codec_dai = &jz_codec_dai, | |
105 | .init = n526_codec_init, | |
106 | }; | |
107 | ||
108 | static struct snd_soc_card n526 = { | |
109 | .name = "N526", | |
110 | .dai_link = &n526_dai, | |
111 | .num_links = 1, | |
112 | .platform = &jz4740_soc_platform, | |
113 | }; | |
114 | ||
115 | static struct snd_soc_device n526_snd_devdata = { | |
116 | .card = &n526, | |
117 | .codec_dev = &soc_codec_dev_jzcodec, | |
118 | }; | |
119 | ||
120 | static struct platform_device *n526_snd_device; | |
121 | ||
122 | static int __init n526_init(void) | |
123 | { | |
124 | int ret; | |
125 | ||
126 | n526_snd_device = platform_device_alloc("soc-audio", -1); | |
127 | ||
128 | if (!n526_snd_device) | |
129 | return -ENOMEM; | |
130 | ||
131 | ret = gpio_request(N526_AMP_EN_GPIO, "AMP"); | |
132 | if (ret) { | |
133 | pr_err("n526 snd: Failed to request AMP GPIO(%d): %d\n", | |
134 | N526_AMP_EN_GPIO, ret); | |
135 | goto err_device_put; | |
136 | } | |
137 | ||
138 | gpio_direction_output(JZ_GPIO_PORTD(4), 0); | |
139 | ||
140 | platform_set_drvdata(n526_snd_device, &n526_snd_devdata); | |
141 | n526_snd_devdata.dev = &n526_snd_device->dev; | |
142 | ret = platform_device_add(n526_snd_device); | |
143 | if (ret) { | |
144 | pr_err("n526 snd: Failed to add snd soc device: %d\n", ret); | |
145 | goto err_unset_pdata; | |
146 | } | |
147 | ||
148 | return 0; | |
149 | ||
150 | err_unset_pdata: | |
151 | platform_set_drvdata(n526_snd_device, NULL); | |
152 | gpio_free(N526_AMP_EN_GPIO); | |
153 | err_device_put: | |
154 | platform_device_put(n526_snd_device); | |
155 | ||
156 | return ret; | |
157 | } | |
158 | module_init(n526_init); | |
159 | ||
160 | static void __exit n526_exit(void) | |
161 | { | |
162 | gpio_free(N526_AMP_EN_GPIO); | |
163 | platform_device_unregister(n526_snd_device); | |
164 | } | |
165 | module_exit(n526_exit); | |
166 | ||
167 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); | |
168 | MODULE_DESCRIPTION("ALSA SoC N526 audio support"); | |
169 | MODULE_LICENSE("GPL v2"); |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9