Skip to content

Commit

Permalink
ASoC: bf5xx-ad1836: convert to use snd_soc_register_card
Browse files Browse the repository at this point in the history
Cpu dai and codec name are passed in through platform data.

Signed-off-by: Scott Jiang <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
Scott Jiang authored and broonie committed Aug 17, 2012
1 parent d987569 commit d14a13d
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions sound/soc/blackfin/bf5xx-ad1836.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,62 +59,63 @@ static struct snd_soc_ops bf5xx_ad1836_ops = {
#define BF5XX_AD1836_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \
SND_SOC_DAIFMT_CBM_CFM)

static struct snd_soc_dai_link bf5xx_ad1836_dai[] = {
{
.name = "ad1836",
.stream_name = "AD1836",
.cpu_dai_name = "bfin-tdm.0",
.codec_dai_name = "ad1836-hifi",
.platform_name = "bfin-tdm-pcm-audio",
.codec_name = "spi0.4",
.ops = &bf5xx_ad1836_ops,
.dai_fmt = BF5XX_AD1836_DAIFMT,
},
{
.name = "ad1836",
.stream_name = "AD1836",
.cpu_dai_name = "bfin-tdm.1",
.codec_dai_name = "ad1836-hifi",
.platform_name = "bfin-tdm-pcm-audio",
.codec_name = "spi0.4",
.ops = &bf5xx_ad1836_ops,
.dai_fmt = BF5XX_AD1836_DAIFMT,
},
static struct snd_soc_dai_link bf5xx_ad1836_dai = {
.name = "ad1836",
.stream_name = "AD1836",
.codec_dai_name = "ad1836-hifi",
.platform_name = "bfin-tdm-pcm-audio",
.ops = &bf5xx_ad1836_ops,
.dai_fmt = BF5XX_AD1836_DAIFMT,
};

static struct snd_soc_card bf5xx_ad1836 = {
.name = "bfin-ad1836",
.owner = THIS_MODULE,
.dai_link = &bf5xx_ad1836_dai[CONFIG_SND_BF5XX_SPORT_NUM],
.dai_link = &bf5xx_ad1836_dai,
.num_links = 1,
};

static struct platform_device *bfxx_ad1836_snd_device;

static int __init bf5xx_ad1836_init(void)
static __devinit int bf5xx_ad1836_driver_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = &bf5xx_ad1836;
const char **link_name;
int ret;

bfxx_ad1836_snd_device = platform_device_alloc("soc-audio", -1);
if (!bfxx_ad1836_snd_device)
return -ENOMEM;
link_name = pdev->dev.platform_data;
if (!link_name) {
dev_err(&pdev->dev, "No platform data supplied\n");
return -EINVAL;
}
bf5xx_ad1836_dai.cpu_dai_name = link_name[0];
bf5xx_ad1836_dai.codec_name = link_name[1];

platform_set_drvdata(bfxx_ad1836_snd_device, &bf5xx_ad1836);
ret = platform_device_add(bfxx_ad1836_snd_device);
card->dev = &pdev->dev;
platform_set_drvdata(pdev, card);

ret = snd_soc_register_card(card);
if (ret)
platform_device_put(bfxx_ad1836_snd_device);

dev_err(&pdev->dev, "Failed to register card\n");
return ret;
}

static void __exit bf5xx_ad1836_exit(void)
static int __devexit bf5xx_ad1836_driver_remove(struct platform_device *pdev)
{
platform_device_unregister(bfxx_ad1836_snd_device);
struct snd_soc_card *card = platform_get_drvdata(pdev);

snd_soc_unregister_card(card);
return 0;
}

module_init(bf5xx_ad1836_init);
module_exit(bf5xx_ad1836_exit);
static struct platform_driver bf5xx_ad1836_driver = {
.driver = {
.name = "bfin-snd-ad1836",
.owner = THIS_MODULE,
.pm = &snd_soc_pm_ops,
},
.probe = bf5xx_ad1836_driver_probe,
.remove = __devexit_p(bf5xx_ad1836_driver_remove),
};
module_platform_driver(bf5xx_ad1836_driver);

/* Module information */
MODULE_AUTHOR("Barry Song");
Expand Down

0 comments on commit d14a13d

Please sign in to comment.