alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] sound/soc/lapis: add machine driver v3 updated
@ 2011-12-09 11:03 Tomoya MORINAGA
  2011-12-09 12:24 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Tomoya MORINAGA @ 2011-12-09 11:03 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Lars-Peter Clausen, Dimitris Papastamos, Mike Frysinger,
	Daniel Mack, alsa-devel, linux-kernel
  Cc: qi.wang, yong.y.wang, joel.clark, kok.howg.ewe, Tomoya MORINAGA

Signed-off-by: Tomoya MORINAGA <tomoya.rohm@gmail.com>
---
V3 Update Mark's comments
 - Delete i2c_board_info data structure.
 - Delete i2c_new_device/i2c_put_adapter.
 - Delete .startup method.
 - Add error processing for failure of snd_soc_unregister_card.
 - Add MODULE_ALIAS
 - Change platform_driver name
 - Set to .dai_fmt of snd_soc_dai_link not use snd_soc_dai_set_fmt
---
 sound/soc/Kconfig                   |    1 +
 sound/soc/Makefile                  |    1 +
 sound/soc/lapis/Kconfig             |    5 +
 sound/soc/lapis/Makefile            |    5 +
 sound/soc/lapis/ml7213ioh-machine.c |  158 +++++++++++++++++++++++++++++++++++
 5 files changed, 170 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/lapis/Kconfig
 create mode 100644 sound/soc/lapis/Makefile
 create mode 100644 sound/soc/lapis/ml7213ioh-machine.c

diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 35e662d..63f8582 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -34,6 +34,7 @@ source "sound/soc/ep93xx/Kconfig"
 source "sound/soc/fsl/Kconfig"
 source "sound/soc/imx/Kconfig"
 source "sound/soc/jz4740/Kconfig"
+source "sound/soc/lapis/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
 source "sound/soc/kirkwood/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 9ea8ac8..002951f 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_SND_SOC)	+= ep93xx/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)   += imx/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
+obj-$(CONFIG_SND_SOC)   += lapis/
 obj-$(CONFIG_SND_SOC)	+= mid-x86/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
diff --git a/sound/soc/lapis/Kconfig b/sound/soc/lapis/Kconfig
new file mode 100644
index 0000000..f6c2fe5
--- /dev/null
+++ b/sound/soc/lapis/Kconfig
@@ -0,0 +1,5 @@
+config SND_SOC_ML7213_MACHINE
+	tristate "ML7213 IOH ASoC machine driver"
+	select SND_SOC_ML7213_PLATFORM
+	help
+	  This is ASoC machine driver for ML7213 IOH
diff --git a/sound/soc/lapis/Makefile b/sound/soc/lapis/Makefile
new file mode 100644
index 0000000..3560bd7
--- /dev/null
+++ b/sound/soc/lapis/Makefile
@@ -0,0 +1,5 @@
+# Platform
+snd-soc-ml7213-machine-objs := ml7213ioh-machine.o
+
+obj-$(CONFIG_SND_SOC_ML7213_PLATFORM) += snd-soc-ml7213-machine.o
+
diff --git a/sound/soc/lapis/ml7213ioh-machine.c b/sound/soc/lapis/ml7213ioh-machine.c
new file mode 100644
index 0000000..28e7919
--- /dev/null
+++ b/sound/soc/lapis/ml7213ioh-machine.c
@@ -0,0 +1,158 @@
+/*
+ * ml7213ioh-machine.c -- SoC Audio for LAPIS Semiconductor ML7213 IOH CRB
+ *
+ * Copyright (C) 2011 LAPIS Semiconductor 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; version 2 of the License.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
+ */
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <linux/i2c.h>
+#include "../codecs/ml26124.h"
+
+static const struct snd_soc_dapm_widget ml7213_dapm_widgets[] = {
+	SND_SOC_DAPM_SPK("Speaker", NULL),
+	SND_SOC_DAPM_LINE("LINEOUT", NULL),
+	SND_SOC_DAPM_LINE("LINEIN", NULL),
+	SND_SOC_DAPM_MIC("AnalogMIC", NULL),
+	SND_SOC_DAPM_MIC("DigitalMIC", NULL),
+};
+
+static const struct snd_soc_dapm_route ml7213_routes[] = {
+	{"Speaker", NULL, "SPOUT"},
+	{"LINEOUT", NULL, "LOUT"},
+	{"MIN", NULL, "AnalogMIC"},
+	{"MDIN", NULL, "DigitalMIC"},
+	{"MIN", NULL, "LINEIN"},
+};
+
+static int ml7213_ioh_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_codec *codec = rtd->codec;
+	struct snd_soc_dapm_context *dapm = &codec->dapm;
+
+	snd_soc_dapm_new_controls(dapm, ml7213_dapm_widgets,
+				  ARRAY_SIZE(ml7213_dapm_widgets));
+
+	snd_soc_dapm_add_routes(dapm, ml7213_routes, ARRAY_SIZE(ml7213_routes));
+	snd_soc_dapm_sync(dapm);
+
+	return 0;
+}
+
+static int ml7213_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;
+	unsigned int clk = 0;
+	int ret = 0;
+
+	switch (params_rate(params)) {
+	case 16000:
+	case 32000:
+	case 48000:
+		clk = 12288800;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	/* set the codec system clock for DAC and ADC */
+	ret = snd_soc_dai_set_sysclk(codec_dai, ML26124_USE_PLL, clk,
+				     SND_SOC_CLOCK_IN);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+
+static struct snd_soc_ops ml7213_ops = {
+	.hw_params = ml7213_hw_params,
+};
+
+static struct snd_soc_dai_link ioh_i2s_dai = {
+	.name = "ML7213",
+	.stream_name = "I2S HiFi",
+	.cpu_dai_name = "ml7213-i2s",
+	.codec_dai_name = "ml26124-hifi",
+	.platform_name	= "ml7213-i2s-pcm-audio",
+	.codec_name	= "ml26124-00GD",
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+					SND_SOC_DAIFMT_CBS_CFS,
+	.init = ml7213_ioh_init,
+	.ops = &ml7213_ops,
+};
+
+static struct snd_soc_card ioh_i2s_card = {
+	.name		= "ml7213",
+	.dai_link	= &ioh_i2s_dai,
+	.num_links	= 1,
+	.dapm_widgets	= ml7213_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(ml7213_dapm_widgets),
+	.dapm_routes	= ml7213_routes,
+	.num_dapm_routes	= ARRAY_SIZE(ml7213_routes),
+};
+
+static int __init ioh_i2s_probe(struct platform_device *pdev)
+{
+	ioh_i2s_card.dev = &pdev->dev;
+	snd_soc_register_card(&ioh_i2s_card);
+
+	return 0;
+}
+
+static int __exit ioh_i2s_remove(struct platform_device *pdev)
+{
+	int ret = snd_soc_unregister_card(&ioh_i2s_card);
+
+	if (ret) {
+		dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
+		ioh_i2s_card.dev = NULL;
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct platform_driver ioh_i2s_driver = {
+	.remove = ioh_i2s_remove,
+	.driver = {
+		.name = "ml7213ioh-i2s",
+		.owner = THIS_MODULE,
+	},
+	.probe	= ioh_i2s_probe,
+	.remove	= __devexit_p(ioh_i2s_remove),
+};
+
+static int __init ioh_i2s_init(void)
+{
+	return platform_driver_register(&ioh_i2s_driver);
+}
+
+static void __exit ioh_i2s_exit(void)
+{
+	return platform_driver_unregister(&ioh_i2s_driver);
+}
+
+module_init(ioh_i2s_init);
+module_exit(ioh_i2s_exit);
+
+MODULE_AUTHOR("Tomoya MORINAGA <tomoya.rohm@gmail.com>");
+MODULE_DESCRIPTION("LAPIS Semiconductor ML7213 IOH ALSA SoC machine driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:ml7213ioh-i2s");
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] sound/soc/lapis: add machine driver v3 updated
  2011-12-09 11:03 [PATCH v3] sound/soc/lapis: add machine driver v3 updated Tomoya MORINAGA
@ 2011-12-09 12:24 ` Mark Brown
  2011-12-12  6:56   ` Tomoya MORINAGA
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-12-09 12:24 UTC (permalink / raw)
  To: Tomoya MORINAGA
  Cc: Dimitris Papastamos, alsa-devel, Lars-Peter Clausen,
	Mike Frysinger, qi.wang, Takashi Iwai, linux-kernel, yong.y.wang,
	kok.howg.ewe, Daniel Mack, Liam Girdwood, joel.clark

On Fri, Dec 09, 2011 at 08:03:52PM +0900, Tomoya MORINAGA wrote:

> +	snd_soc_dapm_new_controls(dapm, ml7213_dapm_widgets,
> +				  ARRAY_SIZE(ml7213_dapm_widgets));
> +
> +	snd_soc_dapm_add_routes(dapm, ml7213_routes, ARRAY_SIZE(ml7213_routes));

You should also use table based init for these (see the card struct).
Otherwise this looks good, though obviously there's a dependency on the
CPU drivers.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] sound/soc/lapis: add machine driver v3 updated
  2011-12-09 12:24 ` Mark Brown
@ 2011-12-12  6:56   ` Tomoya MORINAGA
  2011-12-12  6:57     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Tomoya MORINAGA @ 2011-12-12  6:56 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Lars-Peter Clausen,
	Dimitris Papastamos, Mike Frysinger, Daniel Mack, alsa-devel,
	linux-kernel, qi.wang, yong.y.wang, joel.clark, kok.howg.ewe

2011/12/9 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> On Fri, Dec 09, 2011 at 08:03:52PM +0900, Tomoya MORINAGA wrote:
> Otherwise this looks good, though obviously there's a dependency on the
> CPU drivers.

I just started developing plat form driver.
According to platform.txt, soc/pxa/pxa2xx-pcm.c is shown as example.
Can I believes this description ?
If the driver is not modern, let me know the modern platform driver.

Thanks in advance.

tomoya

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] sound/soc/lapis: add machine driver v3 updated
  2011-12-12  6:56   ` Tomoya MORINAGA
@ 2011-12-12  6:57     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-12-12  6:57 UTC (permalink / raw)
  To: Tomoya MORINAGA
  Cc: Dimitris Papastamos, alsa-devel, Lars-Peter Clausen,
	Mike Frysinger, qi.wang, Takashi Iwai, linux-kernel, yong.y.wang,
	kok.howg.ewe, Daniel Mack, Liam Girdwood, joel.clark

On Mon, Dec 12, 2011 at 03:56:47PM +0900, Tomoya MORINAGA wrote:

> I just started developing plat form driver.
> According to platform.txt, soc/pxa/pxa2xx-pcm.c is shown as example.
> Can I believes this description ?
> If the driver is not modern, let me know the modern platform driver.

It's pretty old but there's not been many updates in the world of
platform drivers.  In general if you're looking for modern drivers git
log is your friend - look for things that are being actively worked on.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-12  6:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-09 11:03 [PATCH v3] sound/soc/lapis: add machine driver v3 updated Tomoya MORINAGA
2011-12-09 12:24 ` Mark Brown
2011-12-12  6:56   ` Tomoya MORINAGA
2011-12-12  6:57     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).