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

Side by Side Diff: sound/soc/samsung/neo1973_wm8753.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/samsung/neo1973_gta02_wm8753.c ('k') | sound/soc/samsung/pcm.h » ('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 * neo1973_wm8753.c -- SoC audio for Neo1973 2 * neo1973_wm8753.c -- SoC audio for Neo1973
3 * 3 *
4 * Copyright 2007 Wolfson Microelectronics PLC. 4 * Copyright 2007 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory 5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com 6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your 10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 */ 13 */
14 14
15 #include <linux/module.h> 15 #include <linux/module.h>
16 #include <linux/moduleparam.h> 16 #include <linux/moduleparam.h>
17 #include <linux/timer.h> 17 #include <linux/timer.h>
18 #include <linux/interrupt.h> 18 #include <linux/interrupt.h>
19 #include <linux/platform_device.h> 19 #include <linux/platform_device.h>
20 #include <linux/i2c.h> 20 #include <linux/i2c.h>
21 #include <sound/core.h> 21 #include <sound/core.h>
22 #include <sound/pcm.h> 22 #include <sound/pcm.h>
23 #include <sound/soc.h> 23 #include <sound/soc.h>
24 #include <sound/soc-dapm.h>
25 #include <sound/tlv.h> 24 #include <sound/tlv.h>
26 25
27 #include <asm/mach-types.h> 26 #include <asm/mach-types.h>
28 #include <asm/hardware/scoop.h>
29 #include <mach/regs-clock.h> 27 #include <mach/regs-clock.h>
30 #include <mach/regs-gpio.h> 28 #include <mach/regs-gpio.h>
31 #include <mach/hardware.h> 29 #include <mach/hardware.h>
32 #include <linux/io.h> 30 #include <linux/io.h>
33 #include <mach/spi-gpio.h> 31 #include <mach/spi-gpio.h>
34 32
35 #include <plat/regs-iis.h> 33 #include <plat/regs-iis.h>
36 34
37 #include "../codecs/wm8753.h" 35 #include "../codecs/wm8753.h"
38 #include "lm4857.h" 36 #include "lm4857.h"
39 #include "s3c-dma.h" 37 #include "dma.h"
40 #include "s3c24xx-i2s.h" 38 #include "s3c24xx-i2s.h"
41 39
42 /* define the scenarios */ 40 /* define the scenarios */
43 #define NEO_AUDIO_OFF 0 41 #define NEO_AUDIO_OFF 0
44 #define NEO_GSM_CALL_AUDIO_HANDSET 1 42 #define NEO_GSM_CALL_AUDIO_HANDSET 1
45 #define NEO_GSM_CALL_AUDIO_HEADSET 2 43 #define NEO_GSM_CALL_AUDIO_HEADSET 2
46 #define NEO_GSM_CALL_AUDIO_BLUETOOTH 3 44 #define NEO_GSM_CALL_AUDIO_BLUETOOTH 3
47 #define NEO_STEREO_TO_SPEAKERS 4 45 #define NEO_STEREO_TO_SPEAKERS 4
48 #define NEO_STEREO_TO_HEADPHONES 5 46 #define NEO_STEREO_TO_HEADPHONES 5
49 #define NEO_CAPTURE_HANDSET 6 47 #define NEO_CAPTURE_HANDSET 6
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 228
231 static int neo1973_get_scenario(struct snd_kcontrol *kcontrol, 229 static int neo1973_get_scenario(struct snd_kcontrol *kcontrol,
232 struct snd_ctl_elem_value *ucontrol) 230 struct snd_ctl_elem_value *ucontrol)
233 { 231 {
234 ucontrol->value.integer.value[0] = neo1973_scenario; 232 ucontrol->value.integer.value[0] = neo1973_scenario;
235 return 0; 233 return 0;
236 } 234 }
237 235
238 static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario) 236 static int set_scenario_endpoints(struct snd_soc_codec *codec, int scenario)
239 { 237 {
238 struct snd_soc_dapm_context *dapm = &codec->dapm;
239
240 pr_debug("Entered %s\n", __func__); 240 pr_debug("Entered %s\n", __func__);
241 241
242 switch (neo1973_scenario) { 242 switch (neo1973_scenario) {
243 case NEO_AUDIO_OFF: 243 case NEO_AUDIO_OFF:
244 » » snd_soc_dapm_disable_pin(codec, "Audio Out"); 244 » » snd_soc_dapm_disable_pin(dapm, "Audio Out");
245 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 245 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
246 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 246 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
247 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 247 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
248 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 248 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
249 break; 249 break;
250 case NEO_GSM_CALL_AUDIO_HANDSET: 250 case NEO_GSM_CALL_AUDIO_HANDSET:
251 » » snd_soc_dapm_enable_pin(codec, "Audio Out"); 251 » » snd_soc_dapm_enable_pin(dapm, "Audio Out");
252 » » snd_soc_dapm_enable_pin(codec, "GSM Line Out"); 252 » » snd_soc_dapm_enable_pin(dapm, "GSM Line Out");
253 » » snd_soc_dapm_enable_pin(codec, "GSM Line In"); 253 » » snd_soc_dapm_enable_pin(dapm, "GSM Line In");
254 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 254 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
255 » » snd_soc_dapm_enable_pin(codec, "Call Mic"); 255 » » snd_soc_dapm_enable_pin(dapm, "Call Mic");
256 break; 256 break;
257 case NEO_GSM_CALL_AUDIO_HEADSET: 257 case NEO_GSM_CALL_AUDIO_HEADSET:
258 » » snd_soc_dapm_enable_pin(codec, "Audio Out"); 258 » » snd_soc_dapm_enable_pin(dapm, "Audio Out");
259 » » snd_soc_dapm_enable_pin(codec, "GSM Line Out"); 259 » » snd_soc_dapm_enable_pin(dapm, "GSM Line Out");
260 » » snd_soc_dapm_enable_pin(codec, "GSM Line In"); 260 » » snd_soc_dapm_enable_pin(dapm, "GSM Line In");
261 » » snd_soc_dapm_enable_pin(codec, "Headset Mic"); 261 » » snd_soc_dapm_enable_pin(dapm, "Headset Mic");
262 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 262 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
263 break; 263 break;
264 case NEO_GSM_CALL_AUDIO_BLUETOOTH: 264 case NEO_GSM_CALL_AUDIO_BLUETOOTH:
265 » » snd_soc_dapm_disable_pin(codec, "Audio Out"); 265 » » snd_soc_dapm_disable_pin(dapm, "Audio Out");
266 » » snd_soc_dapm_enable_pin(codec, "GSM Line Out"); 266 » » snd_soc_dapm_enable_pin(dapm, "GSM Line Out");
267 » » snd_soc_dapm_enable_pin(codec, "GSM Line In"); 267 » » snd_soc_dapm_enable_pin(dapm, "GSM Line In");
268 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 268 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
269 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 269 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
270 break; 270 break;
271 case NEO_STEREO_TO_SPEAKERS: 271 case NEO_STEREO_TO_SPEAKERS:
272 » » snd_soc_dapm_enable_pin(codec, "Audio Out"); 272 » » snd_soc_dapm_enable_pin(dapm, "Audio Out");
273 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 273 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
274 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 274 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
275 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 275 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
276 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 276 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
277 break; 277 break;
278 case NEO_STEREO_TO_HEADPHONES: 278 case NEO_STEREO_TO_HEADPHONES:
279 » » snd_soc_dapm_enable_pin(codec, "Audio Out"); 279 » » snd_soc_dapm_enable_pin(dapm, "Audio Out");
280 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 280 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
281 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 281 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
282 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 282 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
283 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 283 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
284 break; 284 break;
285 case NEO_CAPTURE_HANDSET: 285 case NEO_CAPTURE_HANDSET:
286 » » snd_soc_dapm_disable_pin(codec, "Audio Out"); 286 » » snd_soc_dapm_disable_pin(dapm, "Audio Out");
287 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 287 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
288 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 288 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
289 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 289 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
290 » » snd_soc_dapm_enable_pin(codec, "Call Mic"); 290 » » snd_soc_dapm_enable_pin(dapm, "Call Mic");
291 break; 291 break;
292 case NEO_CAPTURE_HEADSET: 292 case NEO_CAPTURE_HEADSET:
293 » » snd_soc_dapm_disable_pin(codec, "Audio Out"); 293 » » snd_soc_dapm_disable_pin(dapm, "Audio Out");
294 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 294 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
295 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 295 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
296 » » snd_soc_dapm_enable_pin(codec, "Headset Mic"); 296 » » snd_soc_dapm_enable_pin(dapm, "Headset Mic");
297 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 297 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
298 break; 298 break;
299 case NEO_CAPTURE_BLUETOOTH: 299 case NEO_CAPTURE_BLUETOOTH:
300 » » snd_soc_dapm_disable_pin(codec, "Audio Out"); 300 » » snd_soc_dapm_disable_pin(dapm, "Audio Out");
301 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 301 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
302 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 302 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
303 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 303 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
304 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 304 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
305 break; 305 break;
306 default: 306 default:
307 » » snd_soc_dapm_disable_pin(codec, "Audio Out"); 307 » » snd_soc_dapm_disable_pin(dapm, "Audio Out");
308 » » snd_soc_dapm_disable_pin(codec, "GSM Line Out"); 308 » » snd_soc_dapm_disable_pin(dapm, "GSM Line Out");
309 » » snd_soc_dapm_disable_pin(codec, "GSM Line In"); 309 » » snd_soc_dapm_disable_pin(dapm, "GSM Line In");
310 » » snd_soc_dapm_disable_pin(codec, "Headset Mic"); 310 » » snd_soc_dapm_disable_pin(dapm, "Headset Mic");
311 » » snd_soc_dapm_disable_pin(codec, "Call Mic"); 311 » » snd_soc_dapm_disable_pin(dapm, "Call Mic");
312 } 312 }
313 313
314 » snd_soc_dapm_sync(codec); 314 » snd_soc_dapm_sync(dapm);
315 315
316 return 0; 316 return 0;
317 } 317 }
318 318
319 static int neo1973_set_scenario(struct snd_kcontrol *kcontrol, 319 static int neo1973_set_scenario(struct snd_kcontrol *kcontrol,
320 struct snd_ctl_elem_value *ucontrol) 320 struct snd_ctl_elem_value *ucontrol)
321 { 321 {
322 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 322 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
323 323
324 pr_debug("Entered %s\n", __func__); 324 pr_debug("Entered %s\n", __func__);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 }; 495 };
496 496
497 /* 497 /*
498 * This is an example machine initialisation for a wm8753 connected to a 498 * This is an example machine initialisation for a wm8753 connected to a
499 * neo1973 II. It is missing logic to detect hp/mic insertions and logic 499 * neo1973 II. It is missing logic to detect hp/mic insertions and logic
500 * to re-route the audio in such an event. 500 * to re-route the audio in such an event.
501 */ 501 */
502 static int neo1973_wm8753_init(struct snd_soc_pcm_runtime *rtd) 502 static int neo1973_wm8753_init(struct snd_soc_pcm_runtime *rtd)
503 { 503 {
504 struct snd_soc_codec *codec = rtd->codec; 504 struct snd_soc_codec *codec = rtd->codec;
505 struct snd_soc_dapm_context *dapm = &codec->dapm;
505 int err; 506 int err;
506 507
507 pr_debug("Entered %s\n", __func__); 508 pr_debug("Entered %s\n", __func__);
508 509
509 /* set up NC codec pins */ 510 /* set up NC codec pins */
510 » snd_soc_dapm_nc_pin(codec, "LOUT2"); 511 » snd_soc_dapm_nc_pin(dapm, "LOUT2");
511 » snd_soc_dapm_nc_pin(codec, "ROUT2"); 512 » snd_soc_dapm_nc_pin(dapm, "ROUT2");
512 » snd_soc_dapm_nc_pin(codec, "OUT3"); 513 » snd_soc_dapm_nc_pin(dapm, "OUT3");
513 » snd_soc_dapm_nc_pin(codec, "OUT4"); 514 » snd_soc_dapm_nc_pin(dapm, "OUT4");
514 » snd_soc_dapm_nc_pin(codec, "LINE1"); 515 » snd_soc_dapm_nc_pin(dapm, "LINE1");
515 » snd_soc_dapm_nc_pin(codec, "LINE2"); 516 » snd_soc_dapm_nc_pin(dapm, "LINE2");
516 517
517 /* Add neo1973 specific widgets */ 518 /* Add neo1973 specific widgets */
518 » snd_soc_dapm_new_controls(codec, wm8753_dapm_widgets, 519 » snd_soc_dapm_new_controls(dapm, wm8753_dapm_widgets,
519 ARRAY_SIZE(wm8753_dapm_widgets)); 520 ARRAY_SIZE(wm8753_dapm_widgets));
520 521
521 /* set endpoints to default mode */ 522 /* set endpoints to default mode */
522 set_scenario_endpoints(codec, NEO_AUDIO_OFF); 523 set_scenario_endpoints(codec, NEO_AUDIO_OFF);
523 524
524 /* add neo1973 specific controls */ 525 /* add neo1973 specific controls */
525 err = snd_soc_add_controls(codec, wm8753_neo1973_controls, 526 err = snd_soc_add_controls(codec, wm8753_neo1973_controls,
526 ARRAY_SIZE(8753_neo1973_controls)); 527 ARRAY_SIZE(8753_neo1973_controls));
527 if (err < 0) 528 if (err < 0)
528 return err; 529 return err;
529 530
530 /* set up neo1973 specific audio routes */ 531 /* set up neo1973 specific audio routes */
531 » err = snd_soc_dapm_add_routes(codec, dapm_routes, 532 » err = snd_soc_dapm_add_routes(dapm, dapm_routes,
532 ARRAY_SIZE(dapm_routes)); 533 ARRAY_SIZE(dapm_routes));
533 534
534 » snd_soc_dapm_sync(codec); 535 » snd_soc_dapm_sync(dapm);
535 return 0; 536 return 0;
536 } 537 }
537 538
538 /* 539 /*
539 * BT Codec DAI 540 * BT Codec DAI
540 */ 541 */
541 static struct snd_soc_dai bt_dai = { 542 static struct snd_soc_dai bt_dai = {
542 .name = "bluetooth-dai", 543 .name = "bluetooth-dai",
543 .playback = { 544 .playback = {
544 .channels_min = 1, 545 .channels_min = 1,
545 .channels_max = 1, 546 .channels_max = 1,
546 .rates = SNDRV_PCM_RATE_8000, 547 .rates = SNDRV_PCM_RATE_8000,
547 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 548 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
548 .capture = { 549 .capture = {
549 .channels_min = 1, 550 .channels_min = 1,
550 .channels_max = 1, 551 .channels_max = 1,
551 .rates = SNDRV_PCM_RATE_8000, 552 .rates = SNDRV_PCM_RATE_8000,
552 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 553 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
553 }; 554 };
554 555
555 static struct snd_soc_dai_link neo1973_dai[] = { 556 static struct snd_soc_dai_link neo1973_dai[] = {
556 { /* Hifi Playback - for similatious use with voice below */ 557 { /* Hifi Playback - for similatious use with voice below */
557 .name = "WM8753", 558 .name = "WM8753",
558 .stream_name = "WM8753 HiFi", 559 .stream_name = "WM8753 HiFi",
559 » .platform_name = "s3c24xx-pcm-audio", 560 » .platform_name = "samsung-audio",
560 » .cpu_dai_name = "s3c24xx-i2s", 561 » .cpu_dai_name = "s3c24xx-iis",
561 .codec_dai_name = "wm8753-hifi", 562 .codec_dai_name = "wm8753-hifi",
562 » .codec_name = "wm8753-codec.0-0x1a", 563 » .codec_name = "wm8753-codec.0-001a",
563 .init = neo1973_wm8753_init, 564 .init = neo1973_wm8753_init,
564 .ops = &neo1973_hifi_ops, 565 .ops = &neo1973_hifi_ops,
565 }, 566 },
566 { /* Voice via BT */ 567 { /* Voice via BT */
567 .name = "Bluetooth", 568 .name = "Bluetooth",
568 .stream_name = "Voice", 569 .stream_name = "Voice",
569 » .platform_name = "s3c24xx-pcm-audio", 570 » .platform_name = "samsung-audio",
570 .cpu_dai_name = "bluetooth-dai", 571 .cpu_dai_name = "bluetooth-dai",
571 .codec_dai_name = "wm8753-voice", 572 .codec_dai_name = "wm8753-voice",
572 » .codec_name = "wm8753-codec.0-0x1a", 573 » .codec_name = "wm8753-codec.0-001a",
573 .ops = &neo1973_voice_ops, 574 .ops = &neo1973_voice_ops,
574 }, 575 },
575 }; 576 };
576 577
577 static struct snd_soc_card neo1973 = { 578 static struct snd_soc_card neo1973 = {
578 .name = "neo1973", 579 .name = "neo1973",
579 .dai_link = neo1973_dai, 580 .dai_link = neo1973_dai,
580 .num_links = ARRAY_SIZE(neo1973_dai), 581 .num_links = ARRAY_SIZE(neo1973_dai),
581 }; 582 };
582 583
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 platform_device_unregister(neo1973_snd_device); 696 platform_device_unregister(neo1973_snd_device);
696 } 697 }
697 698
698 module_init(neo1973_init); 699 module_init(neo1973_init);
699 module_exit(neo1973_exit); 700 module_exit(neo1973_exit);
700 701
701 /* Module information */ 702 /* Module information */
702 MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org, www.openmoko.org"); 703 MODULE_AUTHOR("Graeme Gregory, graeme@openmoko.org, www.openmoko.org");
703 MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973"); 704 MODULE_DESCRIPTION("ALSA SoC WM8753 Neo1973");
704 MODULE_LICENSE("GPL"); 705 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/samsung/neo1973_gta02_wm8753.c ('k') | sound/soc/samsung/pcm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698