2010-06-08 10:01:12 +00:00
|
|
|
/*
|
|
|
|
* snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Bluewater Systems Ltd
|
2011-06-15 04:45:36 +00:00
|
|
|
* Author: Ryan Mallon
|
2010-06-08 10:01:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
2011-07-15 16:38:28 +00:00
|
|
|
#include <linux/module.h>
|
2010-06-08 10:01:12 +00:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
#include <mach/hardware.h>
|
|
|
|
|
|
|
|
#include "../codecs/tlv320aic23.h"
|
|
|
|
|
|
|
|
#define CODEC_CLOCK 5644800
|
|
|
|
|
|
|
|
static int snappercl15_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *params)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
2010-03-17 20:15:21 +00:00
|
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
2010-06-08 10:01:12 +00:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK,
|
|
|
|
SND_SOC_CLOCK_IN);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = snd_soc_dai_set_sysclk(cpu_dai, 0, CODEC_CLOCK,
|
|
|
|
SND_SOC_CLOCK_OUT);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct snd_soc_ops snappercl15_ops = {
|
|
|
|
.hw_params = snappercl15_hw_params,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
|
|
|
|
SND_SOC_DAPM_HP("Headphone Jack", NULL),
|
|
|
|
SND_SOC_DAPM_LINE("Line In", NULL),
|
|
|
|
SND_SOC_DAPM_MIC("Mic Jack", NULL),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_route audio_map[] = {
|
|
|
|
{"Headphone Jack", NULL, "LHPOUT"},
|
|
|
|
{"Headphone Jack", NULL, "RHPOUT"},
|
|
|
|
|
|
|
|
{"LLINEIN", NULL, "Line In"},
|
|
|
|
{"RLINEIN", NULL, "Line In"},
|
|
|
|
|
|
|
|
{"MICIN", NULL, "Mic Jack"},
|
|
|
|
};
|
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
static int snappercl15_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd)
|
2010-06-08 10:01:12 +00:00
|
|
|
{
|
2010-03-17 20:15:21 +00:00
|
|
|
struct snd_soc_codec *codec = rtd->codec;
|
2010-11-05 13:53:46 +00:00
|
|
|
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
2010-03-17 20:15:21 +00:00
|
|
|
|
2010-11-05 13:53:46 +00:00
|
|
|
snd_soc_dapm_new_controls(dapm, tlv320aic23_dapm_widgets,
|
2010-06-08 10:01:12 +00:00
|
|
|
ARRAY_SIZE(tlv320aic23_dapm_widgets));
|
|
|
|
|
2010-11-05 13:53:46 +00:00
|
|
|
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
|
2010-06-08 10:01:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct snd_soc_dai_link snappercl15_dai = {
|
|
|
|
.name = "tlv320aic23",
|
|
|
|
.stream_name = "AIC23",
|
2010-03-17 20:15:21 +00:00
|
|
|
.cpu_dai_name = "ep93xx-i2s",
|
|
|
|
.codec_dai_name = "tlv320aic23-hifi",
|
|
|
|
.codec_name = "tlv320aic23-codec.0-001a",
|
|
|
|
.platform_name = "ep93xx-pcm-audio",
|
2010-06-08 10:01:12 +00:00
|
|
|
.init = snappercl15_tlv320aic23_init,
|
2011-12-17 07:41:11 +00:00
|
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
|
|
|
|
SND_SOC_DAIFMT_CBS_CFS,
|
2010-06-08 10:01:12 +00:00
|
|
|
.ops = &snappercl15_ops,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_soc_card snd_soc_snappercl15 = {
|
|
|
|
.name = "Snapper CL15",
|
2011-12-22 13:21:37 +00:00
|
|
|
.owner = THIS_MODULE,
|
2010-06-08 10:01:12 +00:00
|
|
|
.dai_link = &snappercl15_dai,
|
|
|
|
.num_links = 1,
|
|
|
|
};
|
|
|
|
|
2012-12-07 14:26:23 +00:00
|
|
|
static int snappercl15_probe(struct platform_device *pdev)
|
2010-06-08 10:01:12 +00:00
|
|
|
{
|
2011-09-11 09:28:52 +00:00
|
|
|
struct snd_soc_card *card = &snd_soc_snappercl15;
|
2010-06-08 10:01:12 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-01-11 03:14:31 +00:00
|
|
|
ret = ep93xx_i2s_acquire();
|
2010-06-08 10:01:12 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-09-11 09:28:52 +00:00
|
|
|
card->dev = &pdev->dev;
|
|
|
|
|
|
|
|
ret = snd_soc_register_card(card);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
|
|
|
|
ret);
|
|
|
|
ep93xx_i2s_release();
|
|
|
|
}
|
2010-06-08 10:01:12 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-12-07 14:26:23 +00:00
|
|
|
static int snappercl15_remove(struct platform_device *pdev)
|
2010-06-08 10:01:12 +00:00
|
|
|
{
|
2011-09-11 09:28:52 +00:00
|
|
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
snd_soc_unregister_card(card);
|
2010-06-08 10:01:12 +00:00
|
|
|
ep93xx_i2s_release();
|
2011-09-11 09:28:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver snappercl15_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "snappercl15-audio",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.probe = snappercl15_probe,
|
2012-12-07 14:26:23 +00:00
|
|
|
.remove = snappercl15_remove,
|
2011-09-11 09:28:52 +00:00
|
|
|
};
|
|
|
|
|
2011-11-24 04:07:55 +00:00
|
|
|
module_platform_driver(snappercl15_driver);
|
2010-06-08 10:01:12 +00:00
|
|
|
|
2011-06-15 04:45:36 +00:00
|
|
|
MODULE_AUTHOR("Ryan Mallon");
|
2010-06-08 10:01:12 +00:00
|
|
|
MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
|
|
|
|
MODULE_LICENSE("GPL");
|
2011-09-11 09:28:52 +00:00
|
|
|
MODULE_ALIAS("platform:snappercl15-audio");
|