summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Zhen <zhen1.chen@samsung.com>2014-03-28 03:35:25 (GMT)
committerSylwester Nawrocki <s.nawrocki@samsung.com>2014-04-08 10:12:06 (GMT)
commit613cd5a6c89ba153ade411385ec44176578d4d6a (patch)
tree0aa5cd3fb78bfde4159cac90a34013912b190b0b
parent9e381efc19fc941ec11b1fdf73ba6b7cc5beea99 (diff)
downloadlinux-3.10-613cd5a6c89ba153ade411385ec44176578d4d6a.zip
linux-3.10-613cd5a6c89ba153ade411385ec44176578d4d6a.tar.gz
linux-3.10-613cd5a6c89ba153ade411385ec44176578d4d6a.tar.bz2
ASoC: samsung: add machine driver for odroidx2refs/changes/78/18678/16
This machine driver primary define the audio path,the supported data format and sample frequency. Change-Id: I2cdb5f6f65b67d0039f234930210f75c1be9fe38 Signed-off-by: Chen Zhen <zhen1.chen@samsung.com>
-rw-r--r--sound/soc/samsung/Kconfig8
-rw-r--r--sound/soc/samsung/Makefile2
-rw-r--r--sound/soc/samsung/odroidx2_max98090.c179
3 files changed, 189 insertions, 0 deletions
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index fe8819b..8bbd794 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -240,3 +240,11 @@ config SND_SOC_SAMSUNG_EXYNOS4_WM1811
select SND_SAMSUNG_I2S
help
Say Y if you want to add support for SoC audio on the Tizen Exynos4 board.
+
+config SND_SOC_ODROIDX2
+ tristate "Audio support for Odroidx2"
+ depends on SND_SOC_SAMSUNG
+ select SND_SOC_MAX98090
+ select SND_SAMSUNG_I2S
+ help
+ Say Y here to enable audio support for the Odroidx2.
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index 1e212e4..8a675f1 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -45,6 +45,7 @@ snd-soc-lowland-objs := lowland.o
snd-soc-littlemill-objs := littlemill.o
snd-soc-bells-objs := bells.o
snd-soc-exynos4-wm1811-objs := exynos4_wm1811.o
+snd-soc-odroidx2-max98090-objs := odroidx2_max98090.o
obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o
obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
@@ -71,3 +72,4 @@ obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o
obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o
obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o
obj-$(CONFIG_SND_SOC_SAMSUNG_EXYNOS4_WM1811) += snd-soc-exynos4-wm1811.o
+obj-$(CONFIG_SND_SOC_ODROIDX2) += snd-soc-odroidx2-max98090.o
diff --git a/sound/soc/samsung/odroidx2_max98090.c b/sound/soc/samsung/odroidx2_max98090.c
new file mode 100644
index 0000000..50bf81f
--- /dev/null
+++ b/sound/soc/samsung/odroidx2_max98090.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2014 Samsung Electronics Co., Ltd.
+ *
+ * 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/of.h>
+#include <linux/module.h>
+#include <sound/soc.h>
+#include <sound/pcm_params.h>
+#include "i2s.h"
+
+static int odroidx2_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;
+ struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+ int bfs, rfs, ret;
+ unsigned long rclk;
+
+ switch (params_format(params)) {
+ case SNDRV_PCM_FORMAT_U24:
+ case SNDRV_PCM_FORMAT_S24:
+ bfs = 48;
+ break;
+ case SNDRV_PCM_FORMAT_U16_LE:
+ case SNDRV_PCM_FORMAT_S16_LE:
+ bfs = 32;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ switch (params_rate(params)) {
+ case 16000:
+ case 22050:
+ case 24000:
+ case 32000:
+ case 44100:
+ case 48000:
+ case 88200:
+ case 96000:
+ if (bfs == 48)
+ rfs = 384;
+ else
+ rfs = 256;
+ break;
+ case 64000:
+ rfs = 384;
+ break;
+ case 8000:
+ case 11025:
+ case 12000:
+ if (bfs == 48)
+ rfs = 768;
+ else
+ rfs = 512;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ rclk = params_rate(params) * rfs;
+
+ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
+ | SND_SOC_DAIFMT_NB_NF
+ | SND_SOC_DAIFMT_CBS_CFS);
+ if (ret < 0)
+ return ret;
+
+ ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
+ | SND_SOC_DAIFMT_NB_NF
+ | SND_SOC_DAIFMT_CBS_CFS);
+ if (ret < 0)
+ return ret;
+
+ ret = snd_soc_dai_set_sysclk(codec_dai, 0, rclk, SND_SOC_CLOCK_IN);
+ if (ret < 0)
+ return ret;
+
+ ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK,
+ 0, SND_SOC_CLOCK_OUT);
+ if (ret < 0)
+ return ret;
+
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, SAMSUNG_I2S_DIV_BCLK, bfs);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static struct snd_soc_ops odroidx2_ops = {
+ .hw_params = odroidx2_hw_params,
+};
+
+static struct snd_soc_dai_link odroidx2_dai[] = {
+ {
+ .name = "MAX98090",
+ .stream_name = "MAX98090 PCM",
+ .codec_dai_name = "HiFi",
+ .ops = &odroidx2_ops,
+ },
+};
+
+static struct snd_soc_card odroidx2 = {
+ .name = "odroidx2",
+ .owner = THIS_MODULE,
+ .dai_link = odroidx2_dai,
+ .num_links = ARRAY_SIZE(odroidx2_dai),
+};
+
+static int odroidx2_audio_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct snd_soc_card *card = &odroidx2;
+
+ if (!np)
+ return -ENODEV;
+
+ card->dev = &pdev->dev;
+
+ odroidx2_dai[0].codec_name = NULL;
+ odroidx2_dai[0].codec_of_node = of_parse_phandle(np,
+ "samsung,audio-codec", 0);
+ if (!odroidx2_dai[0].codec_of_node) {
+ dev_err(&pdev->dev,
+ "Property 'samsung,audio-codec' missing or invalid\n");
+ return -EINVAL;
+ }
+
+ odroidx2_dai[0].cpu_name = NULL;
+ odroidx2_dai[0].cpu_of_node = of_parse_phandle(np,
+ "samsung,i2s-controller", 0);
+ if (!odroidx2_dai[0].cpu_of_node) {
+ dev_err(&pdev->dev,
+ "Property 'samsung,i2s-controller' missing or invalid\n");
+ return -EINVAL;
+ }
+
+ odroidx2_dai[0].platform_of_node = odroidx2_dai[0].cpu_of_node;
+
+ return snd_soc_register_card(card);
+}
+
+static int odroidx2_audio_remove(struct platform_device *pdev)
+{
+ struct snd_soc_card *card = platform_get_drvdata(pdev);
+
+ snd_soc_unregister_card(card);
+
+ return 0;
+}
+
+static const struct of_device_id odroidx2_audio_of_match[] = {
+ { .compatible = "samsung,odroidx2-audio", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, odroid_audio_of_match);
+
+static struct platform_driver odroidx2_audio_driver = {
+ .driver = {
+ .name = "odroidx2-audio",
+ .owner = THIS_MODULE,
+ .of_match_table = odroidx2_audio_of_match,
+ },
+ .probe = odroidx2_audio_probe,
+ .remove = odroidx2_audio_remove,
+};
+
+module_platform_driver(odroidx2_audio_driver);
+
+MODULE_AUTHOR("zhen1.chen@samsung.com");
+MODULE_DESCRIPTION("ALSA SoC Odroidx2 Audio Support");
+MODULE_LICENSE("GPL v2");