2019-04-19 18:21:42 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
//
|
|
|
|
// Copyright 2007,2008 Simtec Electronics
|
|
|
|
//
|
|
|
|
// Based on sound/soc/pxa/spitz.c
|
|
|
|
// Copyright 2005 Wolfson Microelectronics PLC.
|
|
|
|
// Copyright 2005 Openedhand Ltd.
|
2009-03-04 08:49:27 +08:00
|
|
|
|
2011-07-16 00:38:28 +08:00
|
|
|
#include <linux/module.h>
|
2009-03-04 08:49:27 +08:00
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
|
|
|
|
#include "s3c2412-i2s.h"
|
|
|
|
#include "../codecs/wm8750.h"
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_route audio_map[] = {
|
|
|
|
{ "Headphone Jack", NULL, "LOUT1" },
|
|
|
|
{ "Headphone Jack", NULL, "ROUT1" },
|
|
|
|
{ "Internal Speaker", NULL, "LOUT2" },
|
|
|
|
{ "Internal Speaker", NULL, "ROUT2" },
|
|
|
|
{ "LINPUT1", NULL, "Line Input" },
|
|
|
|
{ "RINPUT1", NULL, "Line Input" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
|
|
|
|
SND_SOC_DAPM_HP("Headphone Jack", NULL),
|
|
|
|
SND_SOC_DAPM_SPK("Internal Speaker", NULL),
|
|
|
|
SND_SOC_DAPM_LINE("Line In", NULL),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int jive_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *params)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
2010-03-18 04:15:21 +08:00
|
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
2009-03-04 08:49:30 +08:00
|
|
|
struct s3c_i2sv2_rate_calc div;
|
2009-03-04 08:49:27 +08:00
|
|
|
unsigned int clk = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
switch (params_rate(params)) {
|
|
|
|
case 8000:
|
|
|
|
case 16000:
|
|
|
|
case 48000:
|
|
|
|
case 96000:
|
|
|
|
clk = 12288000;
|
|
|
|
break;
|
|
|
|
case 11025:
|
|
|
|
case 22050:
|
|
|
|
case 44100:
|
|
|
|
clk = 11289600;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-16 17:32:20 +08:00
|
|
|
s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
|
2010-04-27 14:56:45 +08:00
|
|
|
s3c_i2sv2_get_clock(cpu_dai));
|
2009-03-04 08:49:27 +08:00
|
|
|
|
|
|
|
/* set the codec system clock for DAC and ADC */
|
|
|
|
ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
|
|
|
|
SND_SOC_CLOCK_IN);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER,
|
|
|
|
div.clk_div - 1);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-17 00:59:29 +08:00
|
|
|
static const struct snd_soc_ops jive_ops = {
|
2009-03-04 08:49:27 +08:00
|
|
|
.hw_params = jive_hw_params,
|
|
|
|
};
|
|
|
|
|
2019-06-06 12:10:46 +08:00
|
|
|
SND_SOC_DAILINK_DEFS(wm8750,
|
|
|
|
DAILINK_COMP_ARRAY(COMP_CPU("s3c2412-i2s")),
|
|
|
|
DAILINK_COMP_ARRAY(COMP_CODEC("wm8750.0-001a", "wm8750-hifi")),
|
|
|
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("s3c2412-i2s")));
|
|
|
|
|
2009-03-04 08:49:27 +08:00
|
|
|
static struct snd_soc_dai_link jive_dai = {
|
|
|
|
.name = "wm8750",
|
|
|
|
.stream_name = "WM8750",
|
2015-01-02 00:16:21 +08:00
|
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
|
|
|
|
SND_SOC_DAIFMT_CBS_CFS,
|
2009-03-04 08:49:27 +08:00
|
|
|
.ops = &jive_ops,
|
2019-06-06 12:10:46 +08:00
|
|
|
SND_SOC_DAILINK_REG(wm8750),
|
2009-03-04 08:49:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* jive audio machine driver */
|
2009-04-16 17:32:20 +08:00
|
|
|
static struct snd_soc_card snd_soc_machine_jive = {
|
2009-03-04 08:49:27 +08:00
|
|
|
.name = "Jive",
|
2011-12-22 10:53:15 +08:00
|
|
|
.owner = THIS_MODULE,
|
2009-03-04 08:49:27 +08:00
|
|
|
.dai_link = &jive_dai,
|
|
|
|
.num_links = 1,
|
2011-10-08 20:30:17 +08:00
|
|
|
|
2011-12-07 17:44:47 +08:00
|
|
|
.dapm_widgets = wm8750_dapm_widgets,
|
2011-10-08 20:30:17 +08:00
|
|
|
.num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets),
|
|
|
|
.dapm_routes = audio_map,
|
|
|
|
.num_dapm_routes = ARRAY_SIZE(audio_map),
|
2015-01-16 21:34:52 +08:00
|
|
|
.fully_routed = true,
|
2009-03-04 08:49:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device *jive_snd_device;
|
|
|
|
|
|
|
|
static int __init jive_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!machine_is_jive())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
printk("JIVE WM8750 Audio support\n");
|
|
|
|
|
|
|
|
jive_snd_device = platform_device_alloc("soc-audio", -1);
|
|
|
|
if (!jive_snd_device)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-03-18 04:15:21 +08:00
|
|
|
platform_set_drvdata(jive_snd_device, &snd_soc_machine_jive);
|
2009-03-04 08:49:27 +08:00
|
|
|
ret = platform_device_add(jive_snd_device);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
platform_device_put(jive_snd_device);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit jive_exit(void)
|
|
|
|
{
|
|
|
|
platform_device_unregister(jive_snd_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(jive_init);
|
|
|
|
module_exit(jive_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
|
|
|
|
MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
|
|
|
|
MODULE_LICENSE("GPL");
|