Version:  2.0.40 2.2.26 2.4.37 2.6.39 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15

Linux/sound/soc/pxa/brownstone.c

  1 /*
  2  * linux/sound/soc/pxa/brownstone.c
  3  *
  4  * Copyright (C) 2011 Marvell International Ltd.
  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 as published by
  8  * the Free Software Foundation; either version 2 of the License, or
  9  * (at your option) any later version.
 10  *
 11  */
 12 
 13 #include <linux/module.h>
 14 #include <sound/core.h>
 15 #include <sound/pcm.h>
 16 #include <sound/soc.h>
 17 #include <sound/jack.h>
 18 
 19 #include "../codecs/wm8994.h"
 20 #include "mmp-sspa.h"
 21 
 22 static const struct snd_kcontrol_new brownstone_dapm_control[] = {
 23         SOC_DAPM_PIN_SWITCH("Ext Spk"),
 24 };
 25 
 26 static const struct snd_soc_dapm_widget brownstone_dapm_widgets[] = {
 27         SND_SOC_DAPM_SPK("Ext Spk", NULL),
 28         SND_SOC_DAPM_HP("Headset Stereophone", NULL),
 29         SND_SOC_DAPM_MIC("Headset Mic", NULL),
 30         SND_SOC_DAPM_MIC("Main Mic", NULL),
 31 };
 32 
 33 static const struct snd_soc_dapm_route brownstone_audio_map[] = {
 34         {"Ext Spk", NULL, "SPKOUTLP"},
 35         {"Ext Spk", NULL, "SPKOUTLN"},
 36         {"Ext Spk", NULL, "SPKOUTRP"},
 37         {"Ext Spk", NULL, "SPKOUTRN"},
 38 
 39         {"Headset Stereophone", NULL, "HPOUT1L"},
 40         {"Headset Stereophone", NULL, "HPOUT1R"},
 41 
 42         {"IN1RN", NULL, "Headset Mic"},
 43 
 44         {"DMIC1DAT", NULL, "MICBIAS1"},
 45         {"MICBIAS1", NULL, "Main Mic"},
 46 };
 47 
 48 static int brownstone_wm8994_init(struct snd_soc_pcm_runtime *rtd)
 49 {
 50         struct snd_soc_codec *codec = rtd->codec;
 51         struct snd_soc_dapm_context *dapm = &codec->dapm;
 52 
 53         snd_soc_dapm_enable_pin(dapm, "Ext Spk");
 54         snd_soc_dapm_enable_pin(dapm, "Headset Stereophone");
 55         snd_soc_dapm_enable_pin(dapm, "Headset Mic");
 56         snd_soc_dapm_enable_pin(dapm, "Main Mic");
 57 
 58         /* set endpoints to not connected */
 59         snd_soc_dapm_nc_pin(dapm, "HPOUT2P");
 60         snd_soc_dapm_nc_pin(dapm, "HPOUT2N");
 61         snd_soc_dapm_nc_pin(dapm, "LINEOUT1N");
 62         snd_soc_dapm_nc_pin(dapm, "LINEOUT1P");
 63         snd_soc_dapm_nc_pin(dapm, "LINEOUT2N");
 64         snd_soc_dapm_nc_pin(dapm, "LINEOUT2P");
 65         snd_soc_dapm_nc_pin(dapm, "IN1LN");
 66         snd_soc_dapm_nc_pin(dapm, "IN1LP");
 67         snd_soc_dapm_nc_pin(dapm, "IN1RP");
 68         snd_soc_dapm_nc_pin(dapm, "IN2LP:VXRN");
 69         snd_soc_dapm_nc_pin(dapm, "IN2RN");
 70         snd_soc_dapm_nc_pin(dapm, "IN2RP:VXRP");
 71         snd_soc_dapm_nc_pin(dapm, "IN2LN");
 72 
 73         snd_soc_dapm_sync(dapm);
 74 
 75         return 0;
 76 }
 77 
 78 static int brownstone_wm8994_hw_params(struct snd_pcm_substream *substream,
 79                                        struct snd_pcm_hw_params *params)
 80 {
 81         struct snd_soc_pcm_runtime *rtd = substream->private_data;
 82         struct snd_soc_dai *codec_dai = rtd->codec_dai;
 83         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 84         int freq_out, sspa_mclk, sysclk;
 85         int sspa_div;
 86 
 87         if (params_rate(params) > 11025) {
 88                 freq_out  = params_rate(params) * 512;
 89                 sysclk    = params_rate(params) * 256;
 90                 sspa_mclk = params_rate(params) * 64;
 91         } else {
 92                 freq_out  = params_rate(params) * 1024;
 93                 sysclk    = params_rate(params) * 512;
 94                 sspa_mclk = params_rate(params) * 64;
 95         }
 96         sspa_div = freq_out;
 97         do_div(sspa_div, sspa_mclk);
 98 
 99         snd_soc_dai_set_sysclk(cpu_dai, MMP_SSPA_CLK_AUDIO, freq_out, 0);
100         snd_soc_dai_set_pll(cpu_dai, MMP_SYSCLK, 0, freq_out, sysclk);
101         snd_soc_dai_set_pll(cpu_dai, MMP_SSPA_CLK, 0, freq_out, sspa_mclk);
102 
103         /* set wm8994 sysclk */
104         snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, sysclk, 0);
105 
106         return 0;
107 }
108 
109 /* machine stream operations */
110 static struct snd_soc_ops brownstone_ops = {
111         .hw_params = brownstone_wm8994_hw_params,
112 };
113 
114 static struct snd_soc_dai_link brownstone_wm8994_dai[] = {
115 {
116         .name           = "WM8994",
117         .stream_name    = "WM8994 HiFi",
118         .cpu_dai_name   = "mmp-sspa-dai.0",
119         .codec_dai_name = "wm8994-aif1",
120         .platform_name  = "mmp-pcm-audio",
121         .codec_name     = "wm8994-codec",
122         .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
123                                 SND_SOC_DAIFMT_CBS_CFS,
124         .ops            = &brownstone_ops,
125         .init           = brownstone_wm8994_init,
126 },
127 };
128 
129 /* audio machine driver */
130 static struct snd_soc_card brownstone = {
131         .name         = "brownstone",
132         .owner        = THIS_MODULE,
133         .dai_link     = brownstone_wm8994_dai,
134         .num_links    = ARRAY_SIZE(brownstone_wm8994_dai),
135 
136         .controls = brownstone_dapm_control,
137         .num_controls = ARRAY_SIZE(brownstone_dapm_control),
138         .dapm_widgets = brownstone_dapm_widgets,
139         .num_dapm_widgets = ARRAY_SIZE(brownstone_dapm_widgets),
140         .dapm_routes = brownstone_audio_map,
141         .num_dapm_routes = ARRAY_SIZE(brownstone_audio_map),
142 };
143 
144 static int brownstone_probe(struct platform_device *pdev)
145 {
146         int ret;
147 
148         brownstone.dev = &pdev->dev;
149         ret = snd_soc_register_card(&brownstone);
150         if (ret)
151                 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
152                                 ret);
153         return ret;
154 }
155 
156 static int brownstone_remove(struct platform_device *pdev)
157 {
158         snd_soc_unregister_card(&brownstone);
159         return 0;
160 }
161 
162 static struct platform_driver mmp_driver = {
163         .driver         = {
164                 .name   = "brownstone-audio",
165                 .owner  = THIS_MODULE,
166                 .pm     = &snd_soc_pm_ops,
167         },
168         .probe          = brownstone_probe,
169         .remove         = brownstone_remove,
170 };
171 
172 module_platform_driver(mmp_driver);
173 
174 MODULE_AUTHOR("Leo Yan <leoy@marvell.com>");
175 MODULE_DESCRIPTION("ALSA SoC Brownstone");
176 MODULE_LICENSE("GPL");
177 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us