Date: | 2011-08-02 10:55:56 (11 years 9 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 4b901a3373154bd3502a23d66742d2a5240d637c |
Message: | MIPS: A320: Add SoC sound support for Dingoo A320 |
Files: |
sound/soc/jz4740/Kconfig (1 diff) sound/soc/jz4740/Makefile (1 diff) sound/soc/jz4740/a320.c (1 diff) |
Change Details
sound/soc/jz4740/Kconfig | ||
---|---|---|
21 | 21 | help |
22 | 22 | Say Y if you want to add support for ASoC audio on the Qi LB60 board |
23 | 23 | a.k.a Qi Ben NanoNote. |
24 | ||
25 | config SND_JZ4740_SOC_A320 | |
26 | bool "SoC Audio support for Dingoo A320" | |
27 | depends on SND_JZ4740_SOC && JZ4740_A320 | |
28 | select SND_JZ4740_SOC_I2S | |
29 | select SND_SOC_JZ4740_CODEC | |
30 | help | |
31 | Say Y if you want to add support for SoC audio on the Dingoo A320 | |
32 | game and media player. |
sound/soc/jz4740/Makefile | ||
---|---|---|
9 | 9 | |
10 | 10 | # Jz4740 Machine Support |
11 | 11 | snd-soc-qi-lb60-objs := qi_lb60.o |
12 | snd-soc-a320-objs := a320.o | |
12 | 13 | |
13 | 14 | obj-$(CONFIG_SND_JZ4740_SOC_QI_LB60) += snd-soc-qi-lb60.o |
15 | obj-$(CONFIG_SND_JZ4740_SOC_A320) += snd-soc-a320.o |
sound/soc/jz4740/a320.c | ||
---|---|---|
1 | /* | |
2 | * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de> | |
3 | * Copyright (C) 2010-2011, Maarten ter Huurne <maarten@treewalker.org> | |
4 | * Copyright (C) 2011, Paul Cercueil <paul@crapouillou.net> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * You should have received a copy of the GNU General Public License along | |
11 | * with this program; if not, write to the Free Software Foundation, Inc., | |
12 | * 675 Mass Ave, Cambridge, MA 02139, USA. | |
13 | * | |
14 | */ | |
15 | ||
16 | #include <linux/module.h> | |
17 | #include <linux/moduleparam.h> | |
18 | #include <linux/timer.h> | |
19 | #include <linux/interrupt.h> | |
20 | #include <linux/platform_device.h> | |
21 | #include <sound/core.h> | |
22 | #include <sound/pcm.h> | |
23 | #include <sound/soc.h> | |
24 | #include <linux/gpio.h> | |
25 | ||
26 | #define A320_SPK_GPIO JZ_GPIO_PORTC(27) | |
27 | #define A320_HPTV_GPIO JZ_GPIO_PORTD(7) | |
28 | ||
29 | static int a320_spk_event(struct snd_soc_dapm_widget *widget, | |
30 | struct snd_kcontrol *ctrl, int event) | |
31 | { | |
32 | gpio_set_value(A320_SPK_GPIO, SND_SOC_DAPM_EVENT_ON(event)); | |
33 | return 0; | |
34 | } | |
35 | ||
36 | static int a320_hptv_event( | |
37 | struct snd_soc_dapm_widget *widget, | |
38 | struct snd_kcontrol *ctrl, int event) | |
39 | { | |
40 | gpio_set_value(A320_HPTV_GPIO, SND_SOC_DAPM_EVENT_ON(event)); | |
41 | return 0; | |
42 | } | |
43 | ||
44 | static const struct snd_kcontrol_new a320_controls[] = { | |
45 | SOC_DAPM_PIN_SWITCH("Speaker"), | |
46 | SOC_DAPM_PIN_SWITCH("Headphones + TV-out"), | |
47 | }; | |
48 | ||
49 | static const struct snd_soc_dapm_widget a320_widgets[] = { | |
50 | SND_SOC_DAPM_MIC("Mic", NULL), | |
51 | SND_SOC_DAPM_SPK("Speaker", a320_spk_event), | |
52 | SND_SOC_DAPM_LINE("Headphones + TV-out", a320_hptv_event), | |
53 | }; | |
54 | ||
55 | static const struct snd_soc_dapm_route a320_routes[] = { | |
56 | {"Mic", NULL, "MIC"}, | |
57 | {"Speaker", NULL, "LOUT"}, | |
58 | {"Speaker", NULL, "ROUT"}, | |
59 | {"Headphones + TV-out", NULL, "LOUT"}, | |
60 | {"Headphones + TV-out", NULL, "ROUT"}, | |
61 | }; | |
62 | ||
63 | #define A320_DAIFMT (SND_SOC_DAIFMT_I2S | \ | |
64 | SND_SOC_DAIFMT_NB_NF | \ | |
65 | SND_SOC_DAIFMT_CBM_CFM) | |
66 | ||
67 | static int a320_codec_init(struct snd_soc_pcm_runtime *rtd) | |
68 | { | |
69 | struct snd_soc_codec *codec = rtd->codec; | |
70 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | |
71 | struct snd_soc_dapm_context *dapm = &codec->dapm; | |
72 | int ret; | |
73 | ||
74 | ret = snd_soc_dai_set_fmt(cpu_dai, A320_DAIFMT); | |
75 | if (ret < 0) { | |
76 | dev_err(codec->dev, "Failed to set cpu dai format: %d\n", ret); | |
77 | return ret; | |
78 | } | |
79 | ||
80 | snd_soc_add_card_controls(rtd->card, a320_controls, | |
81 | ARRAY_SIZE(a320_controls)); | |
82 | ||
83 | snd_soc_dapm_new_controls(dapm, a320_widgets, ARRAY_SIZE(a320_widgets)); | |
84 | snd_soc_dapm_add_routes(dapm, a320_routes, ARRAY_SIZE(a320_routes)); | |
85 | snd_soc_dapm_sync(dapm); | |
86 | ||
87 | return 0; | |
88 | } | |
89 | ||
90 | static struct snd_soc_dai_link a320_dai = { | |
91 | .name = "jz4740", | |
92 | .stream_name = "jz4740", | |
93 | .cpu_dai_name = "jz4740-i2s", | |
94 | .platform_name = "jz4740-pcm-audio", | |
95 | .codec_dai_name = "jz4740-hifi", | |
96 | .codec_name = "jz4740-codec", | |
97 | .init = a320_codec_init, | |
98 | }; | |
99 | ||
100 | static struct snd_soc_card a320 = { | |
101 | .name = "Dingoo A320", | |
102 | .owner = THIS_MODULE, | |
103 | .dai_link = &a320_dai, | |
104 | .num_links = 1, | |
105 | }; | |
106 | ||
107 | static int __devinit a320_probe(struct platform_device *pdev) | |
108 | { | |
109 | struct snd_soc_card *card = &a320; | |
110 | int ret; | |
111 | ||
112 | ret = gpio_request(A320_SPK_GPIO, "SPK"); | |
113 | if (ret) { | |
114 | dev_err(&pdev->dev, "Failed to request SPK GPIO(%d): %d\n", | |
115 | A320_SPK_GPIO, ret); | |
116 | return ret; | |
117 | } | |
118 | ||
119 | ret = gpio_request(A320_HPTV_GPIO, "HPTV"); | |
120 | if (ret) { | |
121 | dev_err(&pdev->dev, "Failed to request HPTV GPIO(%d): %d\n", | |
122 | A320_HPTV_GPIO, ret); | |
123 | goto err_gpio_free_spk; | |
124 | } | |
125 | ||
126 | gpio_direction_output(A320_SPK_GPIO, 0); | |
127 | gpio_direction_output(A320_HPTV_GPIO, 0); | |
128 | ||
129 | card->dev = &pdev->dev; | |
130 | ||
131 | ret = snd_soc_register_card(card); | |
132 | if (ret) { | |
133 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | |
134 | ret); | |
135 | goto err_gpio_free_hptv; | |
136 | } | |
137 | ||
138 | return 0; | |
139 | ||
140 | err_gpio_free_hptv: | |
141 | gpio_free(A320_HPTV_GPIO); | |
142 | err_gpio_free_spk: | |
143 | gpio_free(A320_SPK_GPIO); | |
144 | ||
145 | return ret; | |
146 | } | |
147 | ||
148 | static int __devexit a320_remove(struct platform_device *pdev) | |
149 | { | |
150 | struct snd_soc_card *card = platform_get_drvdata(pdev); | |
151 | ||
152 | snd_soc_unregister_card(card); | |
153 | gpio_free(A320_HPTV_GPIO); | |
154 | gpio_free(A320_SPK_GPIO); | |
155 | return 0; | |
156 | } | |
157 | ||
158 | static struct platform_driver a320_driver = { | |
159 | .driver = { | |
160 | .name = "a320-audio", | |
161 | .owner = THIS_MODULE, | |
162 | }, | |
163 | .probe = a320_probe, | |
164 | .remove = __devexit_p(a320_remove), | |
165 | }; | |
166 | ||
167 | module_platform_driver(a320_driver); | |
168 | ||
169 | MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>, Maarten ter Huurne <maarten@treewalker.org>, Paul Cercueil <paul@crapouillou.net>"); | |
170 | MODULE_DESCRIPTION("ALSA SoC Dingoo A320 Audio support"); | |
171 | MODULE_LICENSE("GPL v2"); | |
172 | MODULE_ALIAS("platform:a320-audio"); |
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