bfin-eval-adau1701.c 3.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
/*
 * Machine driver for EVAL-ADAU1701MINIZ on Analog Devices bfin
 * evaluation boards.
 *
 * Copyright 2011 Analog Devices Inc.
 * Author: Lars-Peter Clausen <lars@metafoo.de>
 *
 * Licensed under the GPL-2 or later.
 */

#include <linux/module.h>
#include <linux/device.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>

#include "../codecs/adau1701.h"

static const struct snd_soc_dapm_widget bfin_eval_adau1701_dapm_widgets[] = {
	SND_SOC_DAPM_SPK("Speaker", NULL),
	SND_SOC_DAPM_LINE("Line Out", NULL),
	SND_SOC_DAPM_LINE("Line In", NULL),
};

static const struct snd_soc_dapm_route bfin_eval_adau1701_dapm_routes[] = {
	{ "Speaker", NULL, "OUT0" },
	{ "Speaker", NULL, "OUT1" },
	{ "Line Out", NULL, "OUT2" },
	{ "Line Out", NULL, "OUT3" },

	{ "IN0", NULL, "Line In" },
	{ "IN1", NULL, "Line In" },
};

static int bfin_eval_adau1701_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;
	int ret;

	ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1701_CLK_SRC_OSC, 12288000,
			SND_SOC_CLOCK_IN);

	return ret;
}

static struct snd_soc_ops bfin_eval_adau1701_ops = {
	.hw_params = bfin_eval_adau1701_hw_params,
};

L
Lars-Peter Clausen 已提交
53 54 55
#define BFIN_EVAL_ADAU1701_DAI_FMT (SND_SOC_DAIFMT_I2S | \
				SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM)

56 57 58 59 60 61 62 63 64
static struct snd_soc_dai_link bfin_eval_adau1701_dai[] = {
	{
		.name = "adau1701",
		.stream_name = "adau1701",
		.cpu_dai_name = "bfin-i2s.0",
		.codec_dai_name = "adau1701",
		.platform_name = "bfin-i2s-pcm-audio",
		.codec_name = "adau1701.0-0034",
		.ops = &bfin_eval_adau1701_ops,
L
Lars-Peter Clausen 已提交
65
		.dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT,
66 67 68 69 70 71 72 73 74
	},
	{
		.name = "adau1701",
		.stream_name = "adau1701",
		.cpu_dai_name = "bfin-i2s.1",
		.codec_dai_name = "adau1701",
		.platform_name = "bfin-i2s-pcm-audio",
		.codec_name = "adau1701.0-0034",
		.ops = &bfin_eval_adau1701_ops,
L
Lars-Peter Clausen 已提交
75
		.dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT,
76 77 78 79 80
	},
};

static struct snd_soc_card bfin_eval_adau1701 = {
	.name = "bfin-eval-adau1701",
81
	.owner = THIS_MODULE,
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
	.dai_link = &bfin_eval_adau1701_dai[CONFIG_SND_BF5XX_SPORT_NUM],
	.num_links = 1,

	.dapm_widgets		= bfin_eval_adau1701_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(bfin_eval_adau1701_dapm_widgets),
	.dapm_routes		= bfin_eval_adau1701_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(bfin_eval_adau1701_dapm_routes),
};

static int bfin_eval_adau1701_probe(struct platform_device *pdev)
{
	struct snd_soc_card *card = &bfin_eval_adau1701;

	card->dev = &pdev->dev;

	return snd_soc_register_card(&bfin_eval_adau1701);
}

static int __devexit bfin_eval_adau1701_remove(struct platform_device *pdev)
{
	struct snd_soc_card *card = platform_get_drvdata(pdev);

	snd_soc_unregister_card(card);

	return 0;
}

static struct platform_driver bfin_eval_adau1701_driver = {
	.driver = {
		.name = "bfin-eval-adau1701",
		.owner = THIS_MODULE,
		.pm = &snd_soc_pm_ops,
	},
	.probe = bfin_eval_adau1701_probe,
	.remove = __devexit_p(bfin_eval_adau1701_remove),
};

119
module_platform_driver(bfin_eval_adau1701_driver);
120 121 122 123 124

MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:bfin-eval-adau1701");