diff options
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/omap/omap-abe-twl6040.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 4388de9b81f2..9d93793d3077 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c | |||
@@ -40,6 +40,11 @@ | |||
40 | #include "omap-pcm.h" | 40 | #include "omap-pcm.h" |
41 | #include "../codecs/twl6040.h" | 41 | #include "../codecs/twl6040.h" |
42 | 42 | ||
43 | struct abe_twl6040 { | ||
44 | int jack_detection; /* board can detect jack events */ | ||
45 | int mclk_freq; /* MCLK frequency speed for twl6040 */ | ||
46 | }; | ||
47 | |||
43 | static int omap_abe_hw_params(struct snd_pcm_substream *substream, | 48 | static int omap_abe_hw_params(struct snd_pcm_substream *substream, |
44 | struct snd_pcm_hw_params *params) | 49 | struct snd_pcm_hw_params *params) |
45 | { | 50 | { |
@@ -47,13 +52,13 @@ static int omap_abe_hw_params(struct snd_pcm_substream *substream, | |||
47 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 52 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
48 | struct snd_soc_codec *codec = rtd->codec; | 53 | struct snd_soc_codec *codec = rtd->codec; |
49 | struct snd_soc_card *card = codec->card; | 54 | struct snd_soc_card *card = codec->card; |
50 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); | 55 | struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); |
51 | int clk_id, freq; | 56 | int clk_id, freq; |
52 | int ret; | 57 | int ret; |
53 | 58 | ||
54 | clk_id = twl6040_get_clk_id(rtd->codec); | 59 | clk_id = twl6040_get_clk_id(rtd->codec); |
55 | if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) | 60 | if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) |
56 | freq = pdata->mclk_freq; | 61 | freq = priv->mclk_freq; |
57 | else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) | 62 | else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) |
58 | freq = 32768; | 63 | freq = 32768; |
59 | else | 64 | else |
@@ -176,6 +181,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) | |||
176 | struct snd_soc_card *card = codec->card; | 181 | struct snd_soc_card *card = codec->card; |
177 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 182 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
178 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); | 183 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); |
184 | struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); | ||
179 | int hs_trim; | 185 | int hs_trim; |
180 | int ret = 0; | 186 | int ret = 0; |
181 | 187 | ||
@@ -199,7 +205,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) | |||
199 | TWL6040_HSF_TRIM_RIGHT(hs_trim)); | 205 | TWL6040_HSF_TRIM_RIGHT(hs_trim)); |
200 | 206 | ||
201 | /* Headset jack detection only if it is supported */ | 207 | /* Headset jack detection only if it is supported */ |
202 | if (pdata->jack_detection) { | 208 | if (priv->jack_detection) { |
203 | ret = snd_soc_jack_new(codec, "Headset Jack", | 209 | ret = snd_soc_jack_new(codec, "Headset Jack", |
204 | SND_JACK_HEADSET, &hs_jack); | 210 | SND_JACK_HEADSET, &hs_jack); |
205 | if (ret) | 211 | if (ret) |
@@ -265,6 +271,7 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
265 | { | 271 | { |
266 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev); | 272 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev); |
267 | struct snd_soc_card *card = &omap_abe_card; | 273 | struct snd_soc_card *card = &omap_abe_card; |
274 | struct abe_twl6040 *priv; | ||
268 | int num_links = 0; | 275 | int num_links = 0; |
269 | int ret; | 276 | int ret; |
270 | 277 | ||
@@ -275,6 +282,10 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
275 | return -ENODEV; | 282 | return -ENODEV; |
276 | } | 283 | } |
277 | 284 | ||
285 | priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL); | ||
286 | if (priv == NULL) | ||
287 | return -ENOMEM; | ||
288 | |||
278 | if (pdata->card_name) { | 289 | if (pdata->card_name) { |
279 | card->name = pdata->card_name; | 290 | card->name = pdata->card_name; |
280 | } else { | 291 | } else { |
@@ -282,7 +293,11 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
282 | return -ENODEV; | 293 | return -ENODEV; |
283 | } | 294 | } |
284 | 295 | ||
285 | if (!pdata->mclk_freq) { | 296 | priv->jack_detection = pdata->jack_detection; |
297 | priv->mclk_freq = pdata->mclk_freq; | ||
298 | |||
299 | |||
300 | if (!priv->mclk_freq) { | ||
286 | dev_err(&pdev->dev, "MCLK frequency missing\n"); | 301 | dev_err(&pdev->dev, "MCLK frequency missing\n"); |
287 | return -ENODEV; | 302 | return -ENODEV; |
288 | } | 303 | } |
@@ -295,6 +310,8 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
295 | card->dai_link = abe_twl6040_dai_links; | 310 | card->dai_link = abe_twl6040_dai_links; |
296 | card->num_links = num_links; | 311 | card->num_links = num_links; |
297 | 312 | ||
313 | snd_soc_card_set_drvdata(card, priv); | ||
314 | |||
298 | ret = snd_soc_register_card(card); | 315 | ret = snd_soc_register_card(card); |
299 | if (ret) | 316 | if (ret) |
300 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | 317 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |