aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-core.c100
1 files changed, 54 insertions, 46 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a05b3450aee8..a3f091e0843a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -108,9 +108,9 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
108} 108}
109#endif 109#endif
110 110
111static inline const char* get_dai_name(int type) 111static inline const char *get_dai_name(int type)
112{ 112{
113 switch(type) { 113 switch (type) {
114 case SND_SOC_DAI_AC97_BUS: 114 case SND_SOC_DAI_AC97_BUS:
115 case SND_SOC_DAI_AC97: 115 case SND_SOC_DAI_AC97:
116 return "AC97"; 116 return "AC97";
@@ -178,9 +178,11 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
178 /* Check that the codec and cpu DAI's are compatible */ 178 /* Check that the codec and cpu DAI's are compatible */
179 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 179 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
180 runtime->hw.rate_min = 180 runtime->hw.rate_min =
181 max(codec_dai->playback.rate_min, cpu_dai->playback.rate_min); 181 max(codec_dai->playback.rate_min,
182 cpu_dai->playback.rate_min);
182 runtime->hw.rate_max = 183 runtime->hw.rate_max =
183 min(codec_dai->playback.rate_max, cpu_dai->playback.rate_max); 184 min(codec_dai->playback.rate_max,
185 cpu_dai->playback.rate_max);
184 runtime->hw.channels_min = 186 runtime->hw.channels_min =
185 max(codec_dai->playback.channels_min, 187 max(codec_dai->playback.channels_min,
186 cpu_dai->playback.channels_min); 188 cpu_dai->playback.channels_min);
@@ -193,9 +195,11 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
193 codec_dai->playback.rates & cpu_dai->playback.rates; 195 codec_dai->playback.rates & cpu_dai->playback.rates;
194 } else { 196 } else {
195 runtime->hw.rate_min = 197 runtime->hw.rate_min =
196 max(codec_dai->capture.rate_min, cpu_dai->capture.rate_min); 198 max(codec_dai->capture.rate_min,
199 cpu_dai->capture.rate_min);
197 runtime->hw.rate_max = 200 runtime->hw.rate_max =
198 min(codec_dai->capture.rate_max, cpu_dai->capture.rate_max); 201 min(codec_dai->capture.rate_max,
202 cpu_dai->capture.rate_max);
199 runtime->hw.channels_min = 203 runtime->hw.channels_min =
200 max(codec_dai->capture.channels_min, 204 max(codec_dai->capture.channels_min,
201 cpu_dai->capture.channels_min); 205 cpu_dai->capture.channels_min);
@@ -225,7 +229,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
225 goto machine_err; 229 goto machine_err;
226 } 230 }
227 231
228 dbg("asoc: %s <-> %s info:\n",codec_dai->name, cpu_dai->name); 232 dbg("asoc: %s <-> %s info:\n", codec_dai->name, cpu_dai->name);
229 dbg("asoc: rate mask 0x%x\n", runtime->hw.rates); 233 dbg("asoc: rate mask 0x%x\n", runtime->hw.rates);
230 dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min, 234 dbg("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
231 runtime->hw.channels_max); 235 runtime->hw.channels_max);
@@ -272,7 +276,7 @@ static void close_delayed_work(struct work_struct *work)
272 int i; 276 int i;
273 277
274 mutex_lock(&pcm_mutex); 278 mutex_lock(&pcm_mutex);
275 for(i = 0; i < codec->num_dai; i++) { 279 for (i = 0; i < codec->num_dai; i++) {
276 codec_dai = &codec->dai[i]; 280 codec_dai = &codec->dai[i];
277 281
278 dbg("pop wq checking: %s status: %s waiting: %s\n", 282 dbg("pop wq checking: %s status: %s waiting: %s\n",
@@ -511,7 +515,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
511 if (cpu_dai->ops.hw_params) { 515 if (cpu_dai->ops.hw_params) {
512 ret = cpu_dai->ops.hw_params(substream, params); 516 ret = cpu_dai->ops.hw_params(substream, params);
513 if (ret < 0) { 517 if (ret < 0) {
514 printk(KERN_ERR "asoc: can't set interface %s hw params\n", 518 printk(KERN_ERR "asoc: interface %s hw params failed\n",
515 cpu_dai->name); 519 cpu_dai->name);
516 goto interface_err; 520 goto interface_err;
517 } 521 }
@@ -520,7 +524,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
520 if (platform->pcm_ops->hw_params) { 524 if (platform->pcm_ops->hw_params) {
521 ret = platform->pcm_ops->hw_params(substream, params); 525 ret = platform->pcm_ops->hw_params(substream, params);
522 if (ret < 0) { 526 if (ret < 0) {
523 printk(KERN_ERR "asoc: can't set platform %s hw params\n", 527 printk(KERN_ERR "asoc: platform %s hw params failed\n",
524 platform->name); 528 platform->name);
525 goto platform_err; 529 goto platform_err;
526 } 530 }
@@ -539,7 +543,7 @@ interface_err:
539 codec_dai->ops.hw_free(substream); 543 codec_dai->ops.hw_free(substream);
540 544
541codec_err: 545codec_err:
542 if(machine->ops && machine->ops->hw_free) 546 if (machine->ops && machine->ops->hw_free)
543 machine->ops->hw_free(substream); 547 machine->ops->hw_free(substream);
544 548
545 mutex_unlock(&pcm_mutex); 549 mutex_unlock(&pcm_mutex);
@@ -628,15 +632,15 @@ static struct snd_pcm_ops soc_pcm_ops = {
628/* powers down audio subsystem for suspend */ 632/* powers down audio subsystem for suspend */
629static int soc_suspend(struct platform_device *pdev, pm_message_t state) 633static int soc_suspend(struct platform_device *pdev, pm_message_t state)
630{ 634{
631 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 635 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
632 struct snd_soc_machine *machine = socdev->machine; 636 struct snd_soc_machine *machine = socdev->machine;
633 struct snd_soc_platform *platform = socdev->platform; 637 struct snd_soc_platform *platform = socdev->platform;
634 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 638 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
635 struct snd_soc_codec *codec = socdev->codec; 639 struct snd_soc_codec *codec = socdev->codec;
636 int i; 640 int i;
637 641
638 /* mute any active DAC's */ 642 /* mute any active DAC's */
639 for(i = 0; i < machine->num_links; i++) { 643 for (i = 0; i < machine->num_links; i++) {
640 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai; 644 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai;
641 if (dai->dai_ops.digital_mute && dai->playback.active) 645 if (dai->dai_ops.digital_mute && dai->playback.active)
642 dai->dai_ops.digital_mute(dai, 1); 646 dai->dai_ops.digital_mute(dai, 1);
@@ -649,7 +653,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
649 if (machine->suspend_pre) 653 if (machine->suspend_pre)
650 machine->suspend_pre(pdev, state); 654 machine->suspend_pre(pdev, state);
651 655
652 for(i = 0; i < machine->num_links; i++) { 656 for (i = 0; i < machine->num_links; i++) {
653 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 657 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
654 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97) 658 if (cpu_dai->suspend && cpu_dai->type != SND_SOC_DAI_AC97)
655 cpu_dai->suspend(pdev, cpu_dai); 659 cpu_dai->suspend(pdev, cpu_dai);
@@ -661,7 +665,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
661 run_delayed_work(&socdev->delayed_work); 665 run_delayed_work(&socdev->delayed_work);
662 codec->suspend_bias_level = codec->bias_level; 666 codec->suspend_bias_level = codec->bias_level;
663 667
664 for(i = 0; i < codec->num_dai; i++) { 668 for (i = 0; i < codec->num_dai; i++) {
665 char *stream = codec->dai[i].playback.stream_name; 669 char *stream = codec->dai[i].playback.stream_name;
666 if (stream != NULL) 670 if (stream != NULL)
667 snd_soc_dapm_stream_event(codec, stream, 671 snd_soc_dapm_stream_event(codec, stream,
@@ -675,7 +679,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
675 if (codec_dev->suspend) 679 if (codec_dev->suspend)
676 codec_dev->suspend(pdev, state); 680 codec_dev->suspend(pdev, state);
677 681
678 for(i = 0; i < machine->num_links; i++) { 682 for (i = 0; i < machine->num_links; i++) {
679 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 683 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
680 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97) 684 if (cpu_dai->suspend && cpu_dai->type == SND_SOC_DAI_AC97)
681 cpu_dai->suspend(pdev, cpu_dai); 685 cpu_dai->suspend(pdev, cpu_dai);
@@ -690,17 +694,17 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
690/* powers up audio subsystem after a suspend */ 694/* powers up audio subsystem after a suspend */
691static int soc_resume(struct platform_device *pdev) 695static int soc_resume(struct platform_device *pdev)
692{ 696{
693 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 697 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
694 struct snd_soc_machine *machine = socdev->machine; 698 struct snd_soc_machine *machine = socdev->machine;
695 struct snd_soc_platform *platform = socdev->platform; 699 struct snd_soc_platform *platform = socdev->platform;
696 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 700 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
697 struct snd_soc_codec *codec = socdev->codec; 701 struct snd_soc_codec *codec = socdev->codec;
698 int i; 702 int i;
699 703
700 if (machine->resume_pre) 704 if (machine->resume_pre)
701 machine->resume_pre(pdev); 705 machine->resume_pre(pdev);
702 706
703 for(i = 0; i < machine->num_links; i++) { 707 for (i = 0; i < machine->num_links; i++) {
704 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 708 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
705 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97) 709 if (cpu_dai->resume && cpu_dai->type == SND_SOC_DAI_AC97)
706 cpu_dai->resume(pdev, cpu_dai); 710 cpu_dai->resume(pdev, cpu_dai);
@@ -709,8 +713,8 @@ static int soc_resume(struct platform_device *pdev)
709 if (codec_dev->resume) 713 if (codec_dev->resume)
710 codec_dev->resume(pdev); 714 codec_dev->resume(pdev);
711 715
712 for(i = 0; i < codec->num_dai; i++) { 716 for (i = 0; i < codec->num_dai; i++) {
713 char* stream = codec->dai[i].playback.stream_name; 717 char *stream = codec->dai[i].playback.stream_name;
714 if (stream != NULL) 718 if (stream != NULL)
715 snd_soc_dapm_stream_event(codec, stream, 719 snd_soc_dapm_stream_event(codec, stream,
716 SND_SOC_DAPM_STREAM_RESUME); 720 SND_SOC_DAPM_STREAM_RESUME);
@@ -720,14 +724,14 @@ static int soc_resume(struct platform_device *pdev)
720 SND_SOC_DAPM_STREAM_RESUME); 724 SND_SOC_DAPM_STREAM_RESUME);
721 } 725 }
722 726
723 /* unmute any active DAC's */ 727 /* unmute any active DACs */
724 for(i = 0; i < machine->num_links; i++) { 728 for (i = 0; i < machine->num_links; i++) {
725 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai; 729 struct snd_soc_codec_dai *dai = machine->dai_link[i].codec_dai;
726 if (dai->dai_ops.digital_mute && dai->playback.active) 730 if (dai->dai_ops.digital_mute && dai->playback.active)
727 dai->dai_ops.digital_mute(dai, 0); 731 dai->dai_ops.digital_mute(dai, 0);
728 } 732 }
729 733
730 for(i = 0; i < machine->num_links; i++) { 734 for (i = 0; i < machine->num_links; i++) {
731 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 735 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
732 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97) 736 if (cpu_dai->resume && cpu_dai->type != SND_SOC_DAI_AC97)
733 cpu_dai->resume(pdev, cpu_dai); 737 cpu_dai->resume(pdev, cpu_dai);
@@ -757,7 +761,7 @@ static int soc_probe(struct platform_device *pdev)
757 761
758 if (machine->probe) { 762 if (machine->probe) {
759 ret = machine->probe(pdev); 763 ret = machine->probe(pdev);
760 if(ret < 0) 764 if (ret < 0)
761 return ret; 765 return ret;
762 } 766 }
763 767
@@ -765,20 +769,20 @@ static int soc_probe(struct platform_device *pdev)
765 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai; 769 struct snd_soc_cpu_dai *cpu_dai = machine->dai_link[i].cpu_dai;
766 if (cpu_dai->probe) { 770 if (cpu_dai->probe) {
767 ret = cpu_dai->probe(pdev); 771 ret = cpu_dai->probe(pdev);
768 if(ret < 0) 772 if (ret < 0)
769 goto cpu_dai_err; 773 goto cpu_dai_err;
770 } 774 }
771 } 775 }
772 776
773 if (codec_dev->probe) { 777 if (codec_dev->probe) {
774 ret = codec_dev->probe(pdev); 778 ret = codec_dev->probe(pdev);
775 if(ret < 0) 779 if (ret < 0)
776 goto cpu_dai_err; 780 goto cpu_dai_err;
777 } 781 }
778 782
779 if (platform->probe) { 783 if (platform->probe) {
780 ret = platform->probe(pdev); 784 ret = platform->probe(pdev);
781 if(ret < 0) 785 if (ret < 0)
782 goto platform_err; 786 goto platform_err;
783 } 787 }
784 788
@@ -865,7 +869,7 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
865 codec_dai->codec = socdev->codec; 869 codec_dai->codec = socdev->codec;
866 870
867 /* check client and interface hw capabilities */ 871 /* check client and interface hw capabilities */
868 sprintf(new_name, "%s %s-%s-%d",dai_link->stream_name, codec_dai->name, 872 sprintf(new_name, "%s %s-%s-%d", dai_link->stream_name, codec_dai->name,
869 get_dai_name(cpu_dai->type), num); 873 get_dai_name(cpu_dai->type), num);
870 874
871 if (codec_dai->playback.channels_min) 875 if (codec_dai->playback.channels_min)
@@ -876,7 +880,8 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
876 ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback, 880 ret = snd_pcm_new(codec->card, new_name, codec->pcm_devs++, playback,
877 capture, &pcm); 881 capture, &pcm);
878 if (ret < 0) { 882 if (ret < 0) {
879 printk(KERN_ERR "asoc: can't create pcm for codec %s\n", codec->name); 883 printk(KERN_ERR "asoc: can't create pcm for codec %s\n",
884 codec->name);
880 kfree(rtd); 885 kfree(rtd);
881 return ret; 886 return ret;
882 } 887 }
@@ -925,8 +930,9 @@ static ssize_t codec_reg_show(struct device *dev,
925 step = codec->reg_cache_step; 930 step = codec->reg_cache_step;
926 931
927 count += sprintf(buf, "%s registers\n", codec->name); 932 count += sprintf(buf, "%s registers\n", codec->name);
928 for(i = 0; i < codec->reg_cache_size; i += step) 933 for (i = 0; i < codec->reg_cache_size; i += step)
929 count += sprintf(buf + count, "%2x: %4x\n", i, codec->read(codec, i)); 934 count += sprintf(buf + count, "%2x: %4x\n", i,
935 codec->read(codec, i));
930 936
931 return count; 937 return count;
932} 938}
@@ -1069,7 +1075,7 @@ int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
1069 strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver)); 1075 strncpy(codec->card->driver, codec->name, sizeof(codec->card->driver));
1070 1076
1071 /* create the pcms */ 1077 /* create the pcms */
1072 for(i = 0; i < machine->num_links; i++) { 1078 for (i = 0; i < machine->num_links; i++) {
1073 ret = soc_new_pcm(socdev, &machine->dai_link[i], i); 1079 ret = soc_new_pcm(socdev, &machine->dai_link[i], i);
1074 if (ret < 0) { 1080 if (ret < 0) {
1075 printk(KERN_ERR "asoc: can't create pcm %s\n", 1081 printk(KERN_ERR "asoc: can't create pcm %s\n",
@@ -1099,7 +1105,7 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
1099 struct snd_soc_machine *machine = socdev->machine; 1105 struct snd_soc_machine *machine = socdev->machine;
1100 int ret = 0, i, ac97 = 0, err = 0; 1106 int ret = 0, i, ac97 = 0, err = 0;
1101 1107
1102 for(i = 0; i < machine->num_links; i++) { 1108 for (i = 0; i < machine->num_links; i++) {
1103 if (socdev->machine->dai_link[i].init) { 1109 if (socdev->machine->dai_link[i].init) {
1104 err = socdev->machine->dai_link[i].init(codec); 1110 err = socdev->machine->dai_link[i].init(codec);
1105 if (err < 0) { 1111 if (err < 0) {
@@ -1108,7 +1114,7 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
1108 continue; 1114 continue;
1109 } 1115 }
1110 } 1116 }
1111 if (socdev->machine->dai_link[i].codec_dai->type == 1117 if (socdev->machine->dai_link[i].codec_dai->type ==
1112 SND_SOC_DAI_AC97_BUS) 1118 SND_SOC_DAI_AC97_BUS)
1113 ac97 = 1; 1119 ac97 = 1;
1114 } 1120 }
@@ -1119,7 +1125,7 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
1119 1125
1120 ret = snd_card_register(codec->card); 1126 ret = snd_card_register(codec->card);
1121 if (ret < 0) { 1127 if (ret < 0) {
1122 printk(KERN_ERR "asoc: failed to register soundcard for codec %s\n", 1128 printk(KERN_ERR "asoc: failed to register soundcard for %s\n",
1123 codec->name); 1129 codec->name);
1124 goto out; 1130 goto out;
1125 } 1131 }
@@ -1143,7 +1149,7 @@ int snd_soc_register_card(struct snd_soc_device *socdev)
1143 1149
1144 err = device_create_file(socdev->dev, &dev_attr_codec_reg); 1150 err = device_create_file(socdev->dev, &dev_attr_codec_reg);
1145 if (err < 0) 1151 if (err < 0)
1146 printk(KERN_WARNING "asoc: failed to add codec sysfs entries\n"); 1152 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
1147 1153
1148 mutex_unlock(&codec->mutex); 1154 mutex_unlock(&codec->mutex);
1149 1155
@@ -1169,7 +1175,7 @@ void snd_soc_free_pcms(struct snd_soc_device *socdev)
1169 1175
1170 mutex_lock(&codec->mutex); 1176 mutex_lock(&codec->mutex);
1171#ifdef CONFIG_SND_SOC_AC97_BUS 1177#ifdef CONFIG_SND_SOC_AC97_BUS
1172 for(i = 0; i < codec->num_dai; i++) { 1178 for (i = 0; i < codec->num_dai; i++) {
1173 codec_dai = &codec->dai[i]; 1179 codec_dai = &codec->dai[i];
1174 if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) { 1180 if (codec_dai->type == SND_SOC_DAI_AC97_BUS && codec->ac97) {
1175 soc_ac97_dev_unregister(codec); 1181 soc_ac97_dev_unregister(codec);
@@ -1279,7 +1285,8 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
1279 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) 1285 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
1280 ; 1286 ;
1281 val = snd_soc_read(codec, e->reg); 1287 val = snd_soc_read(codec, e->reg);
1282 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); 1288 ucontrol->value.enumerated.item[0]
1289 = (val >> e->shift_l) & (bitmask - 1);
1283 if (e->shift_l != e->shift_r) 1290 if (e->shift_l != e->shift_r)
1284 ucontrol->value.enumerated.item[1] = 1291 ucontrol->value.enumerated.item[1] =
1285 (val >> e->shift_r) & (bitmask - 1); 1292 (val >> e->shift_r) & (bitmask - 1);
@@ -1573,7 +1580,8 @@ int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
1573 val = val << shift; 1580 val = val << shift;
1574 val2 = val2 << shift; 1581 val2 = val2 << shift;
1575 1582
1576 if ((err = snd_soc_update_bits(codec, reg, val_mask, val)) < 0) 1583 err = snd_soc_update_bits(codec, reg, val_mask, val);
1584 if (err < 0)
1577 return err; 1585 return err;
1578 1586
1579 err = snd_soc_update_bits(codec, reg2, val_mask, val2); 1587 err = snd_soc_update_bits(codec, reg2, val_mask, val2);
@@ -1589,7 +1597,7 @@ static int __devinit snd_soc_init(void)
1589 1597
1590static void snd_soc_exit(void) 1598static void snd_soc_exit(void)
1591{ 1599{
1592 platform_driver_unregister(&soc_driver); 1600 platform_driver_unregister(&soc_driver);
1593} 1601}
1594 1602
1595module_init(snd_soc_init); 1603module_init(snd_soc_init);