Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: sound/soc/pxa/spitz.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/pxa/saarb.c ('k') | sound/soc/pxa/tavorevb3.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * spitz.c -- SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita 2 * spitz.c -- SoC audio for Sharp SL-Cxx00 models Spitz, Borzoi and Akita
3 * 3 *
4 * Copyright 2005 Wolfson Microelectronics PLC. 4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Copyright 2005 Openedhand Ltd. 5 * Copyright 2005 Openedhand Ltd.
6 * 6 *
7 * Authors: Liam Girdwood <lrg@slimlogic.co.uk> 7 * Authors: Liam Girdwood <lrg@slimlogic.co.uk>
8 * Richard Purdie <richard@openedhand.com> 8 * Richard Purdie <richard@openedhand.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 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 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 12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16 16
17 #include <linux/module.h> 17 #include <linux/module.h>
18 #include <linux/moduleparam.h> 18 #include <linux/moduleparam.h>
19 #include <linux/timer.h> 19 #include <linux/timer.h>
20 #include <linux/interrupt.h> 20 #include <linux/interrupt.h>
21 #include <linux/platform_device.h> 21 #include <linux/platform_device.h>
22 #include <linux/gpio.h> 22 #include <linux/gpio.h>
23 #include <sound/core.h> 23 #include <sound/core.h>
24 #include <sound/pcm.h> 24 #include <sound/pcm.h>
25 #include <sound/soc.h> 25 #include <sound/soc.h>
26 #include <sound/soc-dapm.h>
27 26
28 #include <asm/mach-types.h> 27 #include <asm/mach-types.h>
29 #include <mach/spitz.h> 28 #include <mach/spitz.h>
30 #include "../codecs/wm8750.h" 29 #include "../codecs/wm8750.h"
31 #include "pxa2xx-i2s.h" 30 #include "pxa2xx-i2s.h"
32 31
33 #define SPITZ_HP 0 32 #define SPITZ_HP 0
34 #define SPITZ_MIC 1 33 #define SPITZ_MIC 1
35 #define SPITZ_LINE 2 34 #define SPITZ_LINE 2
36 #define SPITZ_HEADSET 3 35 #define SPITZ_HEADSET 3
37 #define SPITZ_HP_OFF 4 36 #define SPITZ_HP_OFF 4
38 #define SPITZ_SPK_ON 0 37 #define SPITZ_SPK_ON 0
39 #define SPITZ_SPK_OFF 1 38 #define SPITZ_SPK_OFF 1
40 39
41 /* audio clock in Hz - rounded from 12.235MHz */ 40 /* audio clock in Hz - rounded from 12.235MHz */
42 #define SPITZ_AUDIO_CLOCK 12288000 41 #define SPITZ_AUDIO_CLOCK 12288000
43 42
44 static int spitz_jack_func; 43 static int spitz_jack_func;
45 static int spitz_spk_func; 44 static int spitz_spk_func;
46 45
47 static void spitz_ext_control(struct snd_soc_codec *codec) 46 static void spitz_ext_control(struct snd_soc_codec *codec)
48 { 47 {
48 struct snd_soc_dapm_context *dapm = &codec->dapm;
49
49 if (spitz_spk_func == SPITZ_SPK_ON) 50 if (spitz_spk_func == SPITZ_SPK_ON)
50 » » snd_soc_dapm_enable_pin(codec, "Ext Spk"); 51 » » snd_soc_dapm_enable_pin(dapm, "Ext Spk");
51 else 52 else
52 » » snd_soc_dapm_disable_pin(codec, "Ext Spk"); 53 » » snd_soc_dapm_disable_pin(dapm, "Ext Spk");
53 54
54 /* set up jack connection */ 55 /* set up jack connection */
55 switch (spitz_jack_func) { 56 switch (spitz_jack_func) {
56 case SPITZ_HP: 57 case SPITZ_HP:
57 /* enable and unmute hp jack, disable mic bias */ 58 /* enable and unmute hp jack, disable mic bias */
58 » » snd_soc_dapm_disable_pin(codec, "Headset Jack"); 59 » » snd_soc_dapm_disable_pin(dapm, "Headset Jack");
59 » » snd_soc_dapm_disable_pin(codec, "Mic Jack"); 60 » » snd_soc_dapm_disable_pin(dapm, "Mic Jack");
60 » » snd_soc_dapm_disable_pin(codec, "Line Jack"); 61 » » snd_soc_dapm_disable_pin(dapm, "Line Jack");
61 » » snd_soc_dapm_enable_pin(codec, "Headphone Jack"); 62 » » snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
62 gpio_set_value(SPITZ_GPIO_MUTE_L, 1); 63 gpio_set_value(SPITZ_GPIO_MUTE_L, 1);
63 gpio_set_value(SPITZ_GPIO_MUTE_R, 1); 64 gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
64 break; 65 break;
65 case SPITZ_MIC: 66 case SPITZ_MIC:
66 /* enable mic jack and bias, mute hp */ 67 /* enable mic jack and bias, mute hp */
67 » » snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 68 » » snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
68 » » snd_soc_dapm_disable_pin(codec, "Headset Jack"); 69 » » snd_soc_dapm_disable_pin(dapm, "Headset Jack");
69 » » snd_soc_dapm_disable_pin(codec, "Line Jack"); 70 » » snd_soc_dapm_disable_pin(dapm, "Line Jack");
70 » » snd_soc_dapm_enable_pin(codec, "Mic Jack"); 71 » » snd_soc_dapm_enable_pin(dapm, "Mic Jack");
71 gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 72 gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
72 gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 73 gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
73 break; 74 break;
74 case SPITZ_LINE: 75 case SPITZ_LINE:
75 /* enable line jack, disable mic bias and mute hp */ 76 /* enable line jack, disable mic bias and mute hp */
76 » » snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 77 » » snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
77 » » snd_soc_dapm_disable_pin(codec, "Headset Jack"); 78 » » snd_soc_dapm_disable_pin(dapm, "Headset Jack");
78 » » snd_soc_dapm_disable_pin(codec, "Mic Jack"); 79 » » snd_soc_dapm_disable_pin(dapm, "Mic Jack");
79 » » snd_soc_dapm_enable_pin(codec, "Line Jack"); 80 » » snd_soc_dapm_enable_pin(dapm, "Line Jack");
80 gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 81 gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
81 gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 82 gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
82 break; 83 break;
83 case SPITZ_HEADSET: 84 case SPITZ_HEADSET:
84 /* enable and unmute headset jack enable mic bias, mute L hp */ 85 /* enable and unmute headset jack enable mic bias, mute L hp */
85 » » snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 86 » » snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
86 » » snd_soc_dapm_enable_pin(codec, "Mic Jack"); 87 » » snd_soc_dapm_enable_pin(dapm, "Mic Jack");
87 » » snd_soc_dapm_disable_pin(codec, "Line Jack"); 88 » » snd_soc_dapm_disable_pin(dapm, "Line Jack");
88 » » snd_soc_dapm_enable_pin(codec, "Headset Jack"); 89 » » snd_soc_dapm_enable_pin(dapm, "Headset Jack");
89 gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 90 gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
90 gpio_set_value(SPITZ_GPIO_MUTE_R, 1); 91 gpio_set_value(SPITZ_GPIO_MUTE_R, 1);
91 break; 92 break;
92 case SPITZ_HP_OFF: 93 case SPITZ_HP_OFF:
93 94
94 /* jack removed, everything off */ 95 /* jack removed, everything off */
95 » » snd_soc_dapm_disable_pin(codec, "Headphone Jack"); 96 » » snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
96 » » snd_soc_dapm_disable_pin(codec, "Headset Jack"); 97 » » snd_soc_dapm_disable_pin(dapm, "Headset Jack");
97 » » snd_soc_dapm_disable_pin(codec, "Mic Jack"); 98 » » snd_soc_dapm_disable_pin(dapm, "Mic Jack");
98 » » snd_soc_dapm_disable_pin(codec, "Line Jack"); 99 » » snd_soc_dapm_disable_pin(dapm, "Line Jack");
99 gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 100 gpio_set_value(SPITZ_GPIO_MUTE_L, 0);
100 gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 101 gpio_set_value(SPITZ_GPIO_MUTE_R, 0);
101 break; 102 break;
102 } 103 }
103 » snd_soc_dapm_sync(codec); 104 » snd_soc_dapm_sync(dapm);
104 } 105 }
105 106
106 static int spitz_startup(struct snd_pcm_substream *substream) 107 static int spitz_startup(struct snd_pcm_substream *substream)
107 { 108 {
108 struct snd_soc_pcm_runtime *rtd = substream->private_data; 109 struct snd_soc_pcm_runtime *rtd = substream->private_data;
109 struct snd_soc_codec *codec = rtd->codec; 110 struct snd_soc_codec *codec = rtd->codec;
110 111
111 mutex_lock(&codec->mutex); 112 mutex_lock(&codec->mutex);
112 113
113 /* check the jack status at stream startup */ 114 /* check the jack status at stream startup */
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk, 275 SOC_ENUM_EXT("Speaker Function", spitz_enum[1], spitz_get_spk,
275 spitz_set_spk), 276 spitz_set_spk),
276 }; 277 };
277 278
278 /* 279 /*
279 * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device 280 * Logic for a wm8750 as connected on a Sharp SL-Cxx00 Device
280 */ 281 */
281 static int spitz_wm8750_init(struct snd_soc_pcm_runtime *rtd) 282 static int spitz_wm8750_init(struct snd_soc_pcm_runtime *rtd)
282 { 283 {
283 struct snd_soc_codec *codec = rtd->codec; 284 struct snd_soc_codec *codec = rtd->codec;
285 struct snd_soc_dapm_context *dapm = &codec->dapm;
284 int err; 286 int err;
285 287
286 /* NC codec pins */ 288 /* NC codec pins */
287 » snd_soc_dapm_nc_pin(codec, "RINPUT1"); 289 » snd_soc_dapm_nc_pin(dapm, "RINPUT1");
288 » snd_soc_dapm_nc_pin(codec, "LINPUT2"); 290 » snd_soc_dapm_nc_pin(dapm, "LINPUT2");
289 » snd_soc_dapm_nc_pin(codec, "RINPUT2"); 291 » snd_soc_dapm_nc_pin(dapm, "RINPUT2");
290 » snd_soc_dapm_nc_pin(codec, "LINPUT3"); 292 » snd_soc_dapm_nc_pin(dapm, "LINPUT3");
291 » snd_soc_dapm_nc_pin(codec, "RINPUT3"); 293 » snd_soc_dapm_nc_pin(dapm, "RINPUT3");
292 » snd_soc_dapm_nc_pin(codec, "OUT3"); 294 » snd_soc_dapm_nc_pin(dapm, "OUT3");
293 » snd_soc_dapm_nc_pin(codec, "MONO1"); 295 » snd_soc_dapm_nc_pin(dapm, "MONO1");
294 296
295 /* Add spitz specific controls */ 297 /* Add spitz specific controls */
296 err = snd_soc_add_controls(codec, wm8750_spitz_controls, 298 err = snd_soc_add_controls(codec, wm8750_spitz_controls,
297 ARRAY_SIZE(wm8750_spitz_controls)); 299 ARRAY_SIZE(wm8750_spitz_controls));
298 if (err < 0) 300 if (err < 0)
299 return err; 301 return err;
300 302
301 /* Add spitz specific widgets */ 303 /* Add spitz specific widgets */
302 » snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, 304 » snd_soc_dapm_new_controls(dapm, wm8750_dapm_widgets,
303 ARRAY_SIZE(wm8750_dapm_widgets)); 305 ARRAY_SIZE(wm8750_dapm_widgets));
304 306
305 /* Set up spitz specific audio paths */ 307 /* Set up spitz specific audio paths */
306 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); 308 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
307 309
308 » snd_soc_dapm_sync(codec); 310 » snd_soc_dapm_sync(dapm);
309 return 0; 311 return 0;
310 } 312 }
311 313
312 /* spitz digital audio interface glue - connects codec <--> CPU */ 314 /* spitz digital audio interface glue - connects codec <--> CPU */
313 static struct snd_soc_dai_link spitz_dai = { 315 static struct snd_soc_dai_link spitz_dai = {
314 .name = "wm8750", 316 .name = "wm8750",
315 .stream_name = "WM8750", 317 .stream_name = "WM8750",
316 » .cpu_dai_name = "pxa-is2", 318 » .cpu_dai_name = "pxa2xx-i2s",
317 .codec_dai_name = "wm8750-hifi", 319 .codec_dai_name = "wm8750-hifi",
318 .platform_name = "pxa-pcm-audio", 320 .platform_name = "pxa-pcm-audio",
319 » .codec_name = "wm8750-codec.0-001a", 321 » .codec_name = "wm8750-codec.0-001b",
320 .init = spitz_wm8750_init, 322 .init = spitz_wm8750_init,
321 .ops = &spitz_ops, 323 .ops = &spitz_ops,
322 }; 324 };
323 325
324 /* spitz audio machine driver */ 326 /* spitz audio machine driver */
325 static struct snd_soc_card snd_soc_spitz = { 327 static struct snd_soc_card snd_soc_spitz = {
326 .name = "Spitz", 328 .name = "Spitz",
327 .dai_link = &spitz_dai, 329 .dai_link = &spitz_dai,
328 .num_links = 1, 330 .num_links = 1,
329 }; 331 };
(...skipping 24 matching lines...) Expand all
354 { 356 {
355 platform_device_unregister(spitz_snd_device); 357 platform_device_unregister(spitz_snd_device);
356 } 358 }
357 359
358 module_init(spitz_init); 360 module_init(spitz_init);
359 module_exit(spitz_exit); 361 module_exit(spitz_exit);
360 362
361 MODULE_AUTHOR("Richard Purdie"); 363 MODULE_AUTHOR("Richard Purdie");
362 MODULE_DESCRIPTION("ALSA SoC Spitz"); 364 MODULE_DESCRIPTION("ALSA SoC Spitz");
363 MODULE_LICENSE("GPL"); 365 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/pxa/saarb.c ('k') | sound/soc/pxa/tavorevb3.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698