2010-06-08 04:01:12 -06:00
|
|
|
/*
|
|
|
|
* snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Bluewater Systems Ltd
|
2011-06-14 22:45:36 -06:00
|
|
|
* Author: Ryan Mallon
|
2010-06-08 04:01:12 -06: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 10:38:28 -06:00
|
|
|
#include <linux/module.h>
|
2010-06-08 04:01:12 -06: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 14:15:21 -06:00
|
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
2010-06-08 04:01:12 -06: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 14:15:21 -06:00
|
|
|
static int snappercl15_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd)
|
2010-06-08 04:01:12 -06:00
|
|
|
{
|
2010-03-17 14:15:21 -06:00
|
|
|
struct snd_soc_codec *codec = rtd->codec;
|
2010-11-05 07:53:46 -06:00
|
|
|
struct snd_soc_dapm_context *dapm = &codec->dapm;
|
2010-03-17 14:15:21 -06:00
|
|
|
|
2010-11-05 07:53:46 -06:00
|
|
|
snd_soc_dapm_new_controls(dapm, tlv320aic23_dapm_widgets,
|
2010-06-08 04:01:12 -06:00
|
|
|
ARRAY_SIZE(tlv320aic23_dapm_widgets));
|
|
|
|
|
2010-11-05 07:53:46 -06:00
|
|
|
snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
|
2010-06-08 04:01:12 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct snd_soc_dai_link snappercl15_dai = {
|
|
|
|
.name = "tlv320aic23",
|
|
|
|
.stream_name = "AIC23",
|
2010-03-17 14:15:21 -06: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 04:01:12 -06:00
|
|
|
.init = snappercl15_tlv320aic23_init,
|
2011-12-17 00:41:11 -07:00
|
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
|
|
|
|
SND_SOC_DAIFMT_CBS_CFS,
|
2010-06-08 04:01:12 -06:00
|
|
|
.ops = &snappercl15_ops,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_soc_card snd_soc_snappercl15 = {
|
|
|
|
.name = "Snapper CL15",
|
2011-12-22 06:21:37 -07:00
|
|
|
.owner = THIS_MODULE,
|
2010-06-08 04:01:12 -06:00
|
|
|
.dai_link = &snappercl15_dai,
|
|
|
|
.num_links = 1,
|
|
|
|
};
|
|
|
|
|
2012-12-07 07:26:23 -07:00
|
|
|
static int snappercl15_probe(struct platform_device *pdev)
|
2010-06-08 04:01:12 -06:00
|
|
|
{
|
2011-09-11 03:28:52 -06:00
|
|
|
struct snd_soc_card *card = &snd_soc_snappercl15;
|
2010-06-08 04:01:12 -06:00
|
|
|
int ret;
|
|
|
|
|
2012-01-10 20:14:31 -07:00
|
|
|
ret = ep93xx_i2s_acquire();
|
2010-06-08 04:01:12 -06:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-09-11 03:28:52 -06: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 04:01:12 -06:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-12-07 07:26:23 -07:00
|
|
|
static int snappercl15_remove(struct platform_device *pdev)
|
2010-06-08 04:01:12 -06:00
|
|
|
{
|
2011-09-11 03:28:52 -06:00
|
|
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
snd_soc_unregister_card(card);
|
2010-06-08 04:01:12 -06:00
|
|
|
ep93xx_i2s_release();
|
2011-09-11 03:28:52 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver snappercl15_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "snappercl15-audio",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.probe = snappercl15_probe,
|
2012-12-07 07:26:23 -07:00
|
|
|
.remove = snappercl15_remove,
|
2011-09-11 03:28:52 -06:00
|
|
|
};
|
|
|
|
|
2011-11-23 21:07:55 -07:00
|
|
|
module_platform_driver(snappercl15_driver);
|
2010-06-08 04:01:12 -06:00
|
|
|
|
2011-06-14 22:45:36 -06:00
|
|
|
MODULE_AUTHOR("Ryan Mallon");
|
2010-06-08 04:01:12 -06:00
|
|
|
MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
|
|
|
|
MODULE_LICENSE("GPL");
|
2011-09-11 03:28:52 -06:00
|
|
|
MODULE_ALIAS("platform:snappercl15-audio");
|