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

Side by Side Diff: sound/soc/codecs/uda1380.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/codecs/uda134x.c ('k') | sound/soc/codecs/wl1273.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 * uda1380.c - Philips UDA1380 ALSA SoC audio driver 2 * uda1380.c - Philips UDA1380 ALSA SoC audio driver
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 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 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 * 7 *
8 * Copyright (c) 2007-2009 Philipp Zabel <philipp.zabel@gmail.com> 8 * Copyright (c) 2007-2009 Philipp Zabel <philipp.zabel@gmail.com>
9 * 9 *
10 * Modified by Richard Purdie <richard@openedhand.com> to fit into SoC 10 * Modified by Richard Purdie <richard@openedhand.com> to fit into SoC
11 * codec model. 11 * codec model.
12 * 12 *
13 * Copyright (c) 2005 Giorgio Padrin <giorgio@mandarinlogiq.org> 13 * Copyright (c) 2005 Giorgio Padrin <giorgio@mandarinlogiq.org>
14 * Copyright 2005 Openedhand Ltd. 14 * Copyright 2005 Openedhand Ltd.
15 */ 15 */
16 16
17 #include <linux/module.h> 17 #include <linux/module.h>
18 #include <linux/init.h> 18 #include <linux/init.h>
19 #include <linux/types.h> 19 #include <linux/types.h>
20 #include <linux/slab.h> 20 #include <linux/slab.h>
21 #include <linux/errno.h> 21 #include <linux/errno.h>
22 #include <linux/gpio.h> 22 #include <linux/gpio.h>
23 #include <linux/delay.h> 23 #include <linux/delay.h>
24 #include <linux/i2c.h> 24 #include <linux/i2c.h>
25 #include <linux/workqueue.h> 25 #include <linux/workqueue.h>
26 #include <sound/core.h> 26 #include <sound/core.h>
27 #include <sound/control.h> 27 #include <sound/control.h>
28 #include <sound/initval.h> 28 #include <sound/initval.h>
29 #include <sound/soc.h> 29 #include <sound/soc.h>
30 #include <sound/soc-dapm.h>
31 #include <sound/tlv.h> 30 #include <sound/tlv.h>
32 #include <sound/uda1380.h> 31 #include <sound/uda1380.h>
33 32
34 #include "uda1380.h" 33 #include "uda1380.h"
35 34
36 /* codec private data */ 35 /* codec private data */
37 struct uda1380_priv { 36 struct uda1380_priv {
38 struct snd_soc_codec *codec; 37 struct snd_soc_codec *codec;
39 u16 reg_cache[UDA1380_CACHEREGNUM];
40 unsigned int dac_clk; 38 unsigned int dac_clk;
41 struct work_struct work; 39 struct work_struct work;
42 void *control_data; 40 void *control_data;
43 }; 41 };
44 42
45 /* 43 /*
46 * uda1380 register cache 44 * uda1380 register cache
47 */ 45 */
48 static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = { 46 static const u16 uda1380_reg[UDA1380_CACHEREGNUM] = {
49 0x0502, 0x0000, 0x0000, 0x3f3f, 47 0x0502, 0x0000, 0x0000, 0x3f3f,
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 {"Right ADC", "Line", "Right PGA"}, 405 {"Right ADC", "Line", "Right PGA"},
408 406
409 /* inputs */ 407 /* inputs */
410 {"Mic LNA", NULL, "VINM"}, 408 {"Mic LNA", NULL, "VINM"},
411 {"Left PGA", NULL, "VINL"}, 409 {"Left PGA", NULL, "VINL"},
412 {"Right PGA", NULL, "VINR"}, 410 {"Right PGA", NULL, "VINR"},
413 }; 411 };
414 412
415 static int uda1380_add_widgets(struct snd_soc_codec *codec) 413 static int uda1380_add_widgets(struct snd_soc_codec *codec)
416 { 414 {
417 » snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets, 415 » struct snd_soc_dapm_context *dapm = &codec->dapm;
416
417 » snd_soc_dapm_new_controls(dapm, uda1380_dapm_widgets,
418 ARRAY_SIZE(uda1380_dapm_widgets)); 418 ARRAY_SIZE(uda1380_dapm_widgets));
419 419 » snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
420 » snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
421 420
422 return 0; 421 return 0;
423 } 422 }
424 423
425 static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, 424 static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai,
426 unsigned int fmt) 425 unsigned int fmt)
427 { 426 {
428 struct snd_soc_codec *codec = codec_dai->codec; 427 struct snd_soc_codec *codec = codec_dai->codec;
429 int iface; 428 int iface;
430 429
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 uda1380_write(codec, UDA1380_CLK, clk); 595 uda1380_write(codec, UDA1380_CLK, clk);
597 } 596 }
598 597
599 static int uda1380_set_bias_level(struct snd_soc_codec *codec, 598 static int uda1380_set_bias_level(struct snd_soc_codec *codec,
600 enum snd_soc_bias_level level) 599 enum snd_soc_bias_level level)
601 { 600 {
602 int pm = uda1380_read_reg_cache(codec, UDA1380_PM); 601 int pm = uda1380_read_reg_cache(codec, UDA1380_PM);
603 int reg; 602 int reg;
604 struct uda1380_platform_data *pdata = codec->dev->platform_data; 603 struct uda1380_platform_data *pdata = codec->dev->platform_data;
605 604
606 » if (codec->bias_level == level) 605 » if (codec->dapm.bias_level == level)
607 return 0; 606 return 0;
608 607
609 switch (level) { 608 switch (level) {
610 case SND_SOC_BIAS_ON: 609 case SND_SOC_BIAS_ON:
611 case SND_SOC_BIAS_PREPARE: 610 case SND_SOC_BIAS_PREPARE:
612 /* ADC, DAC on */ 611 /* ADC, DAC on */
613 uda1380_write(codec, UDA1380_PM, R02_PON_BIAS | pm); 612 uda1380_write(codec, UDA1380_PM, R02_PON_BIAS | pm);
614 break; 613 break;
615 case SND_SOC_BIAS_STANDBY: 614 case SND_SOC_BIAS_STANDBY:
616 » » if (codec->bias_level == SND_SOC_BIAS_OFF) { 615 » » if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
617 if (gpio_is_valid(pdata->gpio_power)) { 616 if (gpio_is_valid(pdata->gpio_power)) {
618 gpio_set_value(pdata->gpio_power, 1); 617 gpio_set_value(pdata->gpio_power, 1);
619 mdelay(1); 618 mdelay(1);
620 uda1380_reset(codec); 619 uda1380_reset(codec);
621 } 620 }
622 621
623 uda1380_sync_cache(codec); 622 uda1380_sync_cache(codec);
624 } 623 }
625 uda1380_write(codec, UDA1380_PM, 0x0); 624 uda1380_write(codec, UDA1380_PM, 0x0);
626 break; 625 break;
627 case SND_SOC_BIAS_OFF: 626 case SND_SOC_BIAS_OFF:
628 if (!gpio_is_valid(pdata->gpio_power)) 627 if (!gpio_is_valid(pdata->gpio_power))
629 break; 628 break;
630 629
631 gpio_set_value(pdata->gpio_power, 0); 630 gpio_set_value(pdata->gpio_power, 0);
632 631
633 /* Mark mixer regs cache dirty to sync them with 632 /* Mark mixer regs cache dirty to sync them with
634 * codec regs on power on. 633 * codec regs on power on.
635 */ 634 */
636 for (reg = UDA1380_MVOL; reg < UDA1380_CACHEREGNUM; reg++) 635 for (reg = UDA1380_MVOL; reg < UDA1380_CACHEREGNUM; reg++)
637 set_bit(reg - 0x10, &uda1380_cache_dirty); 636 set_bit(reg - 0x10, &uda1380_cache_dirty);
638 } 637 }
639 » codec->bias_level = level; 638 » codec->dapm.bias_level = level;
640 return 0; 639 return 0;
641 } 640 }
642 641
643 #define UDA1380_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 642 #define UDA1380_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
644 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ 643 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
645 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 644 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
646 645
647 static struct snd_soc_dai_ops uda1380_dai_ops = { 646 static struct snd_soc_dai_ops uda1380_dai_ops = {
648 .hw_params = uda1380_pcm_hw_params, 647 .hw_params = uda1380_pcm_hw_params,
649 .shutdown = uda1380_pcm_shutdown, 648 .shutdown = uda1380_pcm_shutdown,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 { 877 {
879 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 878 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
880 i2c_del_driver(&uda1380_i2c_driver); 879 i2c_del_driver(&uda1380_i2c_driver);
881 #endif 880 #endif
882 } 881 }
883 module_exit(uda1380_exit); 882 module_exit(uda1380_exit);
884 883
885 MODULE_AUTHOR("Giorgio Padrin"); 884 MODULE_AUTHOR("Giorgio Padrin");
886 MODULE_DESCRIPTION("Audio support for codec Philips UDA1380"); 885 MODULE_DESCRIPTION("Audio support for codec Philips UDA1380");
887 MODULE_LICENSE("GPL"); 886 MODULE_LICENSE("GPL");
OLDNEW
« no previous file with comments | « sound/soc/codecs/uda134x.c ('k') | sound/soc/codecs/wl1273.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698