[alsa-devel] [PATCH v2 9/9] ASoC: mediatek: Add mt2701-cs42448 driver and config option.

2016-06-02 Thread Garlic Tseng
Add machine driver and config option for MT2701.

Signed-off-by: Garlic Tseng 
---
 sound/soc/mediatek/Kconfig |  21 ++
 sound/soc/mediatek/Makefile|   1 +
 sound/soc/mediatek/mt2701/Makefile |  19 ++
 sound/soc/mediatek/mt2701/mt2701-cs42448.c | 422 +
 4 files changed, 463 insertions(+)
 create mode 100644 sound/soc/mediatek/mt2701/Makefile
 create mode 100644 sound/soc/mediatek/mt2701/mt2701-cs42448.c

diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index ff1a419..0ecb785 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -7,6 +7,27 @@ config SND_SOC_MEDIATEK
  Select Y if you have such device.
  If unsure select "N".
 
+config SND_SOC_MT2701
+   tristate "ASoC support for Mediatek MT2701 chip"
+   depends on ARCH_MEDIATEK
+   select SND_SOC_MEDIATEK
+   help
+ This adds ASoC driver for Mediatek MT2701 boards
+ that can be used with other codecs.
+ Select Y if you have such device.
+ If unsure select "N".
+
+config SND_SOC_MT2701_CS42448
+   tristate "SND_SOC_MT2701_CS42448"
+   depends on SND_SOC_MT2701
+   select SND_SOC_CS42XX8_I2C
+   select SND_SOC_BT_SCO
+   help
+ This adds ASoC driver for Mediatek MT2701 boards
+ with the CS42448 codecs.
+ Select Y if you have such device.
+ If unsure select "N".
+
 config SND_SOC_MT8173
tristate "ASoC support for Mediatek MT8173 chip"
depends on ARCH_MEDIATEK
diff --git a/sound/soc/mediatek/Makefile b/sound/soc/mediatek/Makefile
index 3d893be..5133215 100644
--- a/sound/soc/mediatek/Makefile
+++ b/sound/soc/mediatek/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_SND_SOC_MEDIATEK) += common/
+obj-$(CONFIG_SND_SOC_MT2701) += mt2701/
 obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
 
diff --git a/sound/soc/mediatek/mt2701/Makefile 
b/sound/soc/mediatek/mt2701/Makefile
new file mode 100644
index 000..31c3d04
--- /dev/null
+++ b/sound/soc/mediatek/mt2701/Makefile
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2015 MediaTek Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+# platform driver
+snd-soc-mt2701-afe-objs := mt2701-afe-pcm.o mt2701-afe-clock-ctrl.o
+obj-$(CONFIG_SND_SOC_MT2701) += snd-soc-mt2701-afe.o
+
+# machine driver
+obj-$(CONFIG_SND_SOC_MT2701_CS42448) += mt2701-cs42448.o
diff --git a/sound/soc/mediatek/mt2701/mt2701-cs42448.c 
b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
new file mode 100644
index 000..fce159f
--- /dev/null
+++ b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
@@ -0,0 +1,422 @@
+/*
+ * mt2701-cs42448.c  --  MT2701 CS42448 ALSA SoC machine driver
+ *
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ir Lian 
+ *  Garlic Tseng 
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mt2701-afe-common.h"
+
+struct mt2701_cs42448_private {
+   int i2s1_in_mux;
+   int i2s1_in_mux_gpio_sel_1;
+   int i2s1_in_mux_gpio_sel_2;
+};
+
+static const char * const i2sin_mux_switch_text[] = {
+   "ADC_SDOUT2",
+   "ADC_SDOUT3",
+   "I2S_IN_1",
+   "I2S_IN_2",
+};
+
+static const struct soc_enum i2sin_mux_enum =
+   SOC_ENUM_SINGLE_EXT(4, i2sin_mux_switch_text);
+
+static int mt2701_cs42448_i2sin1_mux_get(struct snd_kcontrol *kcontrol,
+struct snd_ctl_elem_value *ucontrol)
+{
+   struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
+   struct mt2701_cs42448_private *priv = snd_soc_card_get_drvdata(card);
+
+   ucontrol->value.integer.value[0] = priv->i2s1_in_mux;
+   return 0;
+}
+
+static int mt2701_cs42448_i2sin1_mux_set(struct snd_kcontrol *kcontrol,
+struct snd_ctl_elem_value *ucontrol)
+{
+   struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
+   struct mt2701_cs42448_private *priv = snd_soc_card_get_drvdata(card);
+
+   if (ucontrol->value.integer.value[0] == priv->i2s1_in_mux)
+   return 0;
+
+   

[alsa-devel] [PATCH v2 9/9] ASoC: mediatek: Add mt2701-cs42448 driver and config option.

2016-06-02 Thread Garlic Tseng
Add machine driver and config option for MT2701.

Signed-off-by: Garlic Tseng 
---
 sound/soc/mediatek/Kconfig |  21 ++
 sound/soc/mediatek/Makefile|   1 +
 sound/soc/mediatek/mt2701/Makefile |  19 ++
 sound/soc/mediatek/mt2701/mt2701-cs42448.c | 422 +
 4 files changed, 463 insertions(+)
 create mode 100644 sound/soc/mediatek/mt2701/Makefile
 create mode 100644 sound/soc/mediatek/mt2701/mt2701-cs42448.c

diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
index ff1a419..0ecb785 100644
--- a/sound/soc/mediatek/Kconfig
+++ b/sound/soc/mediatek/Kconfig
@@ -7,6 +7,27 @@ config SND_SOC_MEDIATEK
  Select Y if you have such device.
  If unsure select "N".
 
+config SND_SOC_MT2701
+   tristate "ASoC support for Mediatek MT2701 chip"
+   depends on ARCH_MEDIATEK
+   select SND_SOC_MEDIATEK
+   help
+ This adds ASoC driver for Mediatek MT2701 boards
+ that can be used with other codecs.
+ Select Y if you have such device.
+ If unsure select "N".
+
+config SND_SOC_MT2701_CS42448
+   tristate "SND_SOC_MT2701_CS42448"
+   depends on SND_SOC_MT2701
+   select SND_SOC_CS42XX8_I2C
+   select SND_SOC_BT_SCO
+   help
+ This adds ASoC driver for Mediatek MT2701 boards
+ with the CS42448 codecs.
+ Select Y if you have such device.
+ If unsure select "N".
+
 config SND_SOC_MT8173
tristate "ASoC support for Mediatek MT8173 chip"
depends on ARCH_MEDIATEK
diff --git a/sound/soc/mediatek/Makefile b/sound/soc/mediatek/Makefile
index 3d893be..5133215 100644
--- a/sound/soc/mediatek/Makefile
+++ b/sound/soc/mediatek/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_SND_SOC_MEDIATEK) += common/
+obj-$(CONFIG_SND_SOC_MT2701) += mt2701/
 obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
 
diff --git a/sound/soc/mediatek/mt2701/Makefile 
b/sound/soc/mediatek/mt2701/Makefile
new file mode 100644
index 000..31c3d04
--- /dev/null
+++ b/sound/soc/mediatek/mt2701/Makefile
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2015 MediaTek Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+# platform driver
+snd-soc-mt2701-afe-objs := mt2701-afe-pcm.o mt2701-afe-clock-ctrl.o
+obj-$(CONFIG_SND_SOC_MT2701) += snd-soc-mt2701-afe.o
+
+# machine driver
+obj-$(CONFIG_SND_SOC_MT2701_CS42448) += mt2701-cs42448.o
diff --git a/sound/soc/mediatek/mt2701/mt2701-cs42448.c 
b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
new file mode 100644
index 000..fce159f
--- /dev/null
+++ b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
@@ -0,0 +1,422 @@
+/*
+ * mt2701-cs42448.c  --  MT2701 CS42448 ALSA SoC machine driver
+ *
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Ir Lian 
+ *  Garlic Tseng 
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mt2701-afe-common.h"
+
+struct mt2701_cs42448_private {
+   int i2s1_in_mux;
+   int i2s1_in_mux_gpio_sel_1;
+   int i2s1_in_mux_gpio_sel_2;
+};
+
+static const char * const i2sin_mux_switch_text[] = {
+   "ADC_SDOUT2",
+   "ADC_SDOUT3",
+   "I2S_IN_1",
+   "I2S_IN_2",
+};
+
+static const struct soc_enum i2sin_mux_enum =
+   SOC_ENUM_SINGLE_EXT(4, i2sin_mux_switch_text);
+
+static int mt2701_cs42448_i2sin1_mux_get(struct snd_kcontrol *kcontrol,
+struct snd_ctl_elem_value *ucontrol)
+{
+   struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
+   struct mt2701_cs42448_private *priv = snd_soc_card_get_drvdata(card);
+
+   ucontrol->value.integer.value[0] = priv->i2s1_in_mux;
+   return 0;
+}
+
+static int mt2701_cs42448_i2sin1_mux_set(struct snd_kcontrol *kcontrol,
+struct snd_ctl_elem_value *ucontrol)
+{
+   struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
+   struct mt2701_cs42448_private *priv = snd_soc_card_get_drvdata(card);
+
+   if (ucontrol->value.integer.value[0] == priv->i2s1_in_mux)
+   return 0;
+
+   switch (ucontrol->value.integer.value[0]) {
+   case 0:
+