Skip to content

Commit

Permalink
ASoC: omap-abe-twl6040: Introduce driver data for runtime parameters
Browse files Browse the repository at this point in the history
In preparation to Device Tree support.
With DT booted kernel we can not rely on pdata which used to
hold information needed for the driver at runtime.
Use the card's driver data to hold these informations from now on.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@ti.com>
  • Loading branch information
Peter Ujfalusi authored and Liam Girdwood committed May 22, 2012
1 parent 7d09f9e commit 356bccb
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions sound/soc/omap/omap-abe-twl6040.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,25 @@
#include "omap-pcm.h"
#include "../codecs/twl6040.h"

struct abe_twl6040 {
int jack_detection; /* board can detect jack events */
int mclk_freq; /* MCLK frequency speed for twl6040 */
};

static int omap_abe_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_card *card = codec->card;
struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
int clk_id, freq;
int ret;

clk_id = twl6040_get_clk_id(rtd->codec);
if (clk_id == TWL6040_SYSCLK_SEL_HPPLL)
freq = pdata->mclk_freq;
freq = priv->mclk_freq;
else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL)
freq = 32768;
else
Expand Down Expand Up @@ -176,6 +181,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_card *card = codec->card;
struct snd_soc_dapm_context *dapm = &codec->dapm;
struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card);
int hs_trim;
int ret = 0;

Expand All @@ -199,7 +205,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
TWL6040_HSF_TRIM_RIGHT(hs_trim));

/* Headset jack detection only if it is supported */
if (pdata->jack_detection) {
if (priv->jack_detection) {
ret = snd_soc_jack_new(codec, "Headset Jack",
SND_JACK_HEADSET, &hs_jack);
if (ret)
Expand Down Expand Up @@ -265,6 +271,7 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
{
struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev);
struct snd_soc_card *card = &omap_abe_card;
struct abe_twl6040 *priv;
int num_links = 0;
int ret;

Expand All @@ -275,14 +282,22 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
return -ENODEV;
}

priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;

if (pdata->card_name) {
card->name = pdata->card_name;
} else {
dev_err(&pdev->dev, "Card name is not provided\n");
return -ENODEV;
}

if (!pdata->mclk_freq) {
priv->jack_detection = pdata->jack_detection;
priv->mclk_freq = pdata->mclk_freq;


if (!priv->mclk_freq) {
dev_err(&pdev->dev, "MCLK frequency missing\n");
return -ENODEV;
}
Expand All @@ -295,6 +310,8 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
card->dai_link = abe_twl6040_dai_links;
card->num_links = num_links;

snd_soc_card_set_drvdata(card, priv);

ret = snd_soc_register_card(card);
if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
Expand Down

0 comments on commit 356bccb

Please sign in to comment.