* [PATCH] ASoC: Add HP iPAQ H1940 support
@ 2010-09-12 10:55 Vasily Khoruzhick
2010-09-12 12:14 ` Jassi Brar
` (2 more replies)
0 siblings, 3 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-12 10:55 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, alsa-devel, Ben Dooks, Arnaud
Cc: Vasily Khoruzhick
This patch depends on gpiolib support for h1940 latch access,
here's link to patch in ml archive:
http://www.spinics.net/lists/arm-kernel/msg98042.html
I hope Ben will find some time to merge it into his tree
before 2.6.37 merge window :)
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
---
sound/soc/s3c24xx/Kconfig | 8 +
sound/soc/s3c24xx/Makefile | 2 +
sound/soc/s3c24xx/h1940_uda1380.c | 296 +++++++++++++++++++++++++++++++++++++
3 files changed, 306 insertions(+), 0 deletions(-)
create mode 100644 sound/soc/s3c24xx/h1940_uda1380.c
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 7d8235d..6b50509 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -118,6 +118,14 @@ config SND_S3C24XX_SOC_SIMTEC_HERMES
select SND_SOC_TLV320AIC3X
select SND_S3C24XX_SOC_SIMTEC
+config SND_S3C24XX_SOC_H1940_UDA1380
+ tristate "Audio support for the HP iPAQ H1940"
+ depends on SND_S3C24XX_SOC && ARCH_H1940
+ select SND_S3C24XX_SOC_I2S
+ select SND_SOC_UDA1380
+ help
+ This driver provides audio support for HP iPAQ h1940 PDA.
+
config SND_S3C24XX_SOC_RX1950_UDA1380
tristate "Audio support for the HP iPAQ RX1950"
depends on SND_S3C24XX_SOC && MACH_RX1950
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index dd412a9..33a7c68 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -28,6 +28,7 @@ snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o
+snd-soc-h1940-uda1380-objs := h1940_uda1380.o
snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
snd-soc-smdk-wm9713-objs := smdk_wm9713.o
snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
@@ -44,6 +45,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o
obj-$(CONFIG_SND_S3C24XX_SOC_RX1950_UDA1380) += snd-soc-rx1950-uda1380.o
+obj-$(CONFIG_SND_S3C24XX_SOC_H1940_UDA1380) += snd-soc-h1940-uda1380.o
obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
obj-$(CONFIG_SND_SOC_SMDK_WM9713) += snd-soc-smdk-wm9713.o
obj-$(CONFIG_SND_S3C64XX_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
diff --git a/sound/soc/s3c24xx/h1940_uda1380.c b/sound/soc/s3c24xx/h1940_uda1380.c
new file mode 100644
index 0000000..77550fa
--- /dev/null
+++ b/sound/soc/s3c24xx/h1940_uda1380.c
@@ -0,0 +1,296 @@
+/*
+ * h1940-uda1380.c -- ALSA Soc Audio Layer
+ *
+ * Copyright (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
+ * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ * 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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/uda1380.h>
+#include <sound/jack.h>
+
+#include <plat/regs-iis.h>
+
+#include <mach/h1940-latch.h>
+
+#include <asm/mach-types.h>
+
+#include "s3c-dma.h"
+#include "s3c24xx-i2s.h"
+#include "../codecs/uda1380.h"
+
+static unsigned int rates[] = {
+ 11025,
+ 22050,
+ 44100,
+};
+
+static struct snd_pcm_hw_constraint_list hw_rates = {
+ .count = ARRAY_SIZE(rates),
+ .list = rates,
+ .mask = 0,
+};
+
+static struct snd_soc_jack hp_jack;
+
+static struct snd_soc_jack_pin hp_jack_pins[] = {
+ {
+ .pin = "Headphone Jack",
+ .mask = SND_JACK_HEADPHONE,
+ },
+ {
+ .pin = "Speaker",
+ .mask = SND_JACK_HEADPHONE,
+ .invert = 1,
+ },
+};
+
+static struct snd_soc_jack_gpio hp_jack_gpios[] = {
+ {
+ .gpio = S3C2410_GPG(4),
+ .name = "hp-gpio",
+ .report = SND_JACK_HEADPHONE,
+ .invert = 1,
+ .debounce_time = 200,
+ },
+};
+
+static int h1940_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+
+ runtime->hw.rate_min = hw_rates.list[0];
+ runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
+ runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
+
+ return snd_pcm_hw_constraint_list(runtime, 0,
+ SNDRV_PCM_HW_PARAM_RATE,
+ &hw_rates);
+}
+
+static int h1940_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 *cpu_dai = rtd->cpu_dai;
+ struct snd_soc_dai *codec_dai = rtd->codec_dai;
+ int div;
+ int ret;
+ unsigned int rate = params_rate(params);
+
+ switch (rate) {
+ case 11025:
+ case 22050:
+ case 44100:
+ div = s3c24xx_i2s_get_clockrate() / (384 * rate);
+ if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate))
+ div++;
+ break;
+ default:
+ printk(KERN_ERR "%s: rate %d is not supported\n",
+ __func__, rate);
+ return -EINVAL;
+ }
+
+ /* set codec DAI configuration */
+ 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;
+
+ /* set cpu DAI configuration */
+ 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;
+
+ /* select clock source */
+ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
+ SND_SOC_CLOCK_OUT);
+ if (ret < 0)
+ return ret;
+
+ /* set MCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
+ S3C2410_IISMOD_384FS);
+ if (ret < 0)
+ return ret;
+
+ /* set BCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK,
+ S3C2410_IISMOD_32FS);
+ if (ret < 0)
+ return ret;
+
+ /* set prescaler division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
+ S3C24XX_PRESCALE(div, div));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static struct snd_soc_ops h1940_ops = {
+ .startup = h1940_startup,
+ .hw_params = h1940_hw_params,
+};
+
+static int h1940_spk_power(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ if (SND_SOC_DAPM_EVENT_ON(event))
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 1);
+ else
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 0);
+
+ return 0;
+}
+
+/* h1940 machine dapm widgets */
+static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_MIC("Mic Jack", NULL),
+ SND_SOC_DAPM_SPK("Speaker", h1940_spk_power),
+};
+
+/* h1940 machine audio_map */
+static const struct snd_soc_dapm_route audio_map[] = {
+ /* headphone connected to VOUTLHP, VOUTRHP */
+ {"Headphone Jack", NULL, "VOUTLHP"},
+ {"Headphone Jack", NULL, "VOUTRHP"},
+
+ /* ext speaker connected to VOUTL, VOUTR */
+ {"Speaker", NULL, "VOUTL"},
+ {"Speaker", NULL, "VOUTR"},
+
+ /* mic is connected to VINM */
+ {"VINM", NULL, "Mic Jack"},
+};
+
+static struct platform_device *s3c24xx_snd_device;
+
+static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_codec *codec = rtd->codec;
+ int err;
+
+ /* Add h1940 specific widgets */
+ err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
+ ARRAY_SIZE(uda1380_dapm_widgets));
+ if (err)
+ return err;
+
+ /* Set up h1940 specific audio path audio_mapnects */
+ err = snd_soc_dapm_add_routes(codec, audio_map,
+ ARRAY_SIZE(audio_map));
+ if (err)
+ return err;
+
+ snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+ snd_soc_dapm_enable_pin(codec, "Speaker");
+ snd_soc_dapm_enable_pin(codec, "Mic Jack");
+
+ snd_soc_dapm_sync(codec);
+
+ snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
+ &hp_jack);
+
+ snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
+ hp_jack_pins);
+
+ snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+
+ return 0;
+}
+
+/* s3c24xx digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link h1940_uda1380_dai[] = {
+ {
+ .name = "uda1380",
+ .stream_name = "UDA1380 Duplex",
+ .cpu_dai_name = "s3c24xx-iis",
+ .codec_dai_name = "uda1380-hifi",
+ .init = h1940_uda1380_init,
+ .platform_name = "s3c24xx-pcm-audio",
+ .codec_name = "uda1380-codec.0-001a",
+ .ops = &h1940_ops,
+ },
+};
+
+static struct snd_soc_card h1940_asoc = {
+ .name = "h1940",
+ .dai_link = h1940_uda1380_dai,
+ .num_links = ARRAY_SIZE(h1940_uda1380_dai),
+};
+
+static int __init h1940_init(void)
+{
+ int ret;
+
+ if (!machine_is_h1940())
+ return -ENODEV;
+
+ /* configure some gpios */
+ ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
+ if (ret)
+ goto err_out;
+
+ ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
+ if (ret)
+ goto err_gpio;
+
+ s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
+ if (!s3c24xx_snd_device) {
+ ret = -ENOMEM;
+ goto err_gpio;
+ }
+
+ platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
+ ret = platform_device_add(s3c24xx_snd_device);
+
+ if (ret)
+ goto err_plat;
+
+ return 0;
+
+err_plat:
+ platform_device_put(s3c24xx_snd_device);
+err_gpio:
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+
+err_out:
+ return ret;
+}
+
+static void __exit h1940_exit(void)
+{
+ platform_device_unregister(s3c24xx_snd_device);
+ snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+}
+
+module_init(h1940_init);
+module_exit(h1940_exit);
+
+/* Module information */
+MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
+MODULE_DESCRIPTION("ALSA SoC H1940");
+MODULE_LICENSE("GPL");
--
1.7.2.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] ASoC: Add HP iPAQ H1940 support
2010-09-12 10:55 [PATCH] ASoC: Add HP iPAQ H1940 support Vasily Khoruzhick
@ 2010-09-12 12:14 ` Jassi Brar
2010-09-12 12:15 ` Vasily Khoruzhick
2010-09-12 12:18 ` [PATCH v2 0/1] " Vasily Khoruzhick
2010-09-12 12:18 ` [PATCH v2 1/1] " Vasily Khoruzhick
2 siblings, 1 reply; 21+ messages in thread
From: Jassi Brar @ 2010-09-12 12:14 UTC (permalink / raw)
To: Vasily Khoruzhick
Cc: alsa-devel, Mark Brown, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
On Sun, Sep 12, 2010 at 7:55 PM, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> This patch depends on gpiolib support for h1940 latch access,
> here's link to patch in ml archive:
>
> http://www.spinics.net/lists/arm-kernel/msg98042.html
>
> I hope Ben will find some time to merge it into his tree
> before 2.6.37 merge window :)
Do you want this too to go into changelog ? ;)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] ASoC: Add HP iPAQ H1940 support
2010-09-12 12:14 ` Jassi Brar
@ 2010-09-12 12:15 ` Vasily Khoruzhick
0 siblings, 0 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-12 12:15 UTC (permalink / raw)
To: Jassi Brar
Cc: alsa-devel, Mark Brown, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
[-- Attachment #1.1: Type: Text/Plain, Size: 552 bytes --]
В сообщении от 12 сентября 2010 15:14:27 автор Jassi Brar написал:
> On Sun, Sep 12, 2010 at 7:55 PM, Vasily Khoruzhick <anarsoul@gmail.com>
wrote:
> > This patch depends on gpiolib support for h1940 latch access,
> > here's link to patch in ml archive:
> >
> > http://www.spinics.net/lists/arm-kernel/msg98042.html
> >
> > I hope Ben will find some time to merge it into his tree
> > before 2.6.37 merge window :)
>
> Do you want this too to go into changelog ? ;)
Nope, will send v2 with cover soon
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 0/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 10:55 [PATCH] ASoC: Add HP iPAQ H1940 support Vasily Khoruzhick
2010-09-12 12:14 ` Jassi Brar
@ 2010-09-12 12:18 ` Vasily Khoruzhick
2010-09-12 12:18 ` [PATCH v2 1/1] " Vasily Khoruzhick
2 siblings, 0 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-12 12:18 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, alsa-devel, Ben Dooks, Arnaud
This patch depends on gpiolib support for h1940 latch access,
here's link to patch in ml archive:
http://www.spinics.net/lists/arm-kernel/msg98042.html
I hope Ben will find some time to merge it into his tree
before 2.6.37 merge window :)
v2: - printk replaced via dev_err;
- added module alias
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 10:55 [PATCH] ASoC: Add HP iPAQ H1940 support Vasily Khoruzhick
2010-09-12 12:14 ` Jassi Brar
2010-09-12 12:18 ` [PATCH v2 0/1] " Vasily Khoruzhick
@ 2010-09-12 12:18 ` Vasily Khoruzhick
2010-09-12 13:25 ` Marek Vasut
` (2 more replies)
2 siblings, 3 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-12 12:18 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, alsa-devel, Ben Dooks, Arnaud
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
---
sound/soc/s3c24xx/Kconfig | 8 +
sound/soc/s3c24xx/Makefile | 2 +
sound/soc/s3c24xx/h1940_uda1380.c | 297 +++++++++++++++++++++++++++++++++++++
3 files changed, 307 insertions(+), 0 deletions(-)
create mode 100644 sound/soc/s3c24xx/h1940_uda1380.c
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 7d8235d..6b50509 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -118,6 +118,14 @@ config SND_S3C24XX_SOC_SIMTEC_HERMES
select SND_SOC_TLV320AIC3X
select SND_S3C24XX_SOC_SIMTEC
+config SND_S3C24XX_SOC_H1940_UDA1380
+ tristate "Audio support for the HP iPAQ H1940"
+ depends on SND_S3C24XX_SOC && ARCH_H1940
+ select SND_S3C24XX_SOC_I2S
+ select SND_SOC_UDA1380
+ help
+ This driver provides audio support for HP iPAQ h1940 PDA.
+
config SND_S3C24XX_SOC_RX1950_UDA1380
tristate "Audio support for the HP iPAQ RX1950"
depends on SND_S3C24XX_SOC && MACH_RX1950
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index dd412a9..33a7c68 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -28,6 +28,7 @@ snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o
+snd-soc-h1940-uda1380-objs := h1940_uda1380.o
snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
snd-soc-smdk-wm9713-objs := smdk_wm9713.o
snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
@@ -44,6 +45,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o
obj-$(CONFIG_SND_S3C24XX_SOC_RX1950_UDA1380) += snd-soc-rx1950-uda1380.o
+obj-$(CONFIG_SND_S3C24XX_SOC_H1940_UDA1380) += snd-soc-h1940-uda1380.o
obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
obj-$(CONFIG_SND_SOC_SMDK_WM9713) += snd-soc-smdk-wm9713.o
obj-$(CONFIG_SND_S3C64XX_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
diff --git a/sound/soc/s3c24xx/h1940_uda1380.c b/sound/soc/s3c24xx/h1940_uda1380.c
new file mode 100644
index 0000000..5dbc0ea
--- /dev/null
+++ b/sound/soc/s3c24xx/h1940_uda1380.c
@@ -0,0 +1,297 @@
+/*
+ * h1940-uda1380.c -- ALSA Soc Audio Layer
+ *
+ * Copyright (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
+ * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ * 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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/uda1380.h>
+#include <sound/jack.h>
+
+#include <plat/regs-iis.h>
+
+#include <mach/h1940-latch.h>
+
+#include <asm/mach-types.h>
+
+#include "s3c-dma.h"
+#include "s3c24xx-i2s.h"
+#include "../codecs/uda1380.h"
+
+static unsigned int rates[] = {
+ 11025,
+ 22050,
+ 44100,
+};
+
+static struct snd_pcm_hw_constraint_list hw_rates = {
+ .count = ARRAY_SIZE(rates),
+ .list = rates,
+ .mask = 0,
+};
+
+static struct snd_soc_jack hp_jack;
+
+static struct snd_soc_jack_pin hp_jack_pins[] = {
+ {
+ .pin = "Headphone Jack",
+ .mask = SND_JACK_HEADPHONE,
+ },
+ {
+ .pin = "Speaker",
+ .mask = SND_JACK_HEADPHONE,
+ .invert = 1,
+ },
+};
+
+static struct snd_soc_jack_gpio hp_jack_gpios[] = {
+ {
+ .gpio = S3C2410_GPG(4),
+ .name = "hp-gpio",
+ .report = SND_JACK_HEADPHONE,
+ .invert = 1,
+ .debounce_time = 200,
+ },
+};
+
+static int h1940_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+
+ runtime->hw.rate_min = hw_rates.list[0];
+ runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
+ runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
+
+ return snd_pcm_hw_constraint_list(runtime, 0,
+ SNDRV_PCM_HW_PARAM_RATE,
+ &hw_rates);
+}
+
+static int h1940_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 *cpu_dai = rtd->cpu_dai;
+ struct snd_soc_dai *codec_dai = rtd->codec_dai;
+ int div;
+ int ret;
+ unsigned int rate = params_rate(params);
+
+ switch (rate) {
+ case 11025:
+ case 22050:
+ case 44100:
+ div = s3c24xx_i2s_get_clockrate() / (384 * rate);
+ if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate))
+ div++;
+ break;
+ default:
+ dev_err(&rtd->dev, "%s: rate %d is not supported\n",
+ __func__, rate);
+ return -EINVAL;
+ }
+
+ /* set codec DAI configuration */
+ 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;
+
+ /* set cpu DAI configuration */
+ 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;
+
+ /* select clock source */
+ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
+ SND_SOC_CLOCK_OUT);
+ if (ret < 0)
+ return ret;
+
+ /* set MCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
+ S3C2410_IISMOD_384FS);
+ if (ret < 0)
+ return ret;
+
+ /* set BCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK,
+ S3C2410_IISMOD_32FS);
+ if (ret < 0)
+ return ret;
+
+ /* set prescaler division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
+ S3C24XX_PRESCALE(div, div));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static struct snd_soc_ops h1940_ops = {
+ .startup = h1940_startup,
+ .hw_params = h1940_hw_params,
+};
+
+static int h1940_spk_power(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ if (SND_SOC_DAPM_EVENT_ON(event))
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 1);
+ else
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 0);
+
+ return 0;
+}
+
+/* h1940 machine dapm widgets */
+static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_MIC("Mic Jack", NULL),
+ SND_SOC_DAPM_SPK("Speaker", h1940_spk_power),
+};
+
+/* h1940 machine audio_map */
+static const struct snd_soc_dapm_route audio_map[] = {
+ /* headphone connected to VOUTLHP, VOUTRHP */
+ {"Headphone Jack", NULL, "VOUTLHP"},
+ {"Headphone Jack", NULL, "VOUTRHP"},
+
+ /* ext speaker connected to VOUTL, VOUTR */
+ {"Speaker", NULL, "VOUTL"},
+ {"Speaker", NULL, "VOUTR"},
+
+ /* mic is connected to VINM */
+ {"VINM", NULL, "Mic Jack"},
+};
+
+static struct platform_device *s3c24xx_snd_device;
+
+static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_codec *codec = rtd->codec;
+ int err;
+
+ /* Add h1940 specific widgets */
+ err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
+ ARRAY_SIZE(uda1380_dapm_widgets));
+ if (err)
+ return err;
+
+ /* Set up h1940 specific audio path audio_mapnects */
+ err = snd_soc_dapm_add_routes(codec, audio_map,
+ ARRAY_SIZE(audio_map));
+ if (err)
+ return err;
+
+ snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+ snd_soc_dapm_enable_pin(codec, "Speaker");
+ snd_soc_dapm_enable_pin(codec, "Mic Jack");
+
+ snd_soc_dapm_sync(codec);
+
+ snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
+ &hp_jack);
+
+ snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
+ hp_jack_pins);
+
+ snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+
+ return 0;
+}
+
+/* s3c24xx digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link h1940_uda1380_dai[] = {
+ {
+ .name = "uda1380",
+ .stream_name = "UDA1380 Duplex",
+ .cpu_dai_name = "s3c24xx-iis",
+ .codec_dai_name = "uda1380-hifi",
+ .init = h1940_uda1380_init,
+ .platform_name = "s3c24xx-pcm-audio",
+ .codec_name = "uda1380-codec.0-001a",
+ .ops = &h1940_ops,
+ },
+};
+
+static struct snd_soc_card h1940_asoc = {
+ .name = "h1940",
+ .dai_link = h1940_uda1380_dai,
+ .num_links = ARRAY_SIZE(h1940_uda1380_dai),
+};
+
+static int __init h1940_init(void)
+{
+ int ret;
+
+ if (!machine_is_h1940())
+ return -ENODEV;
+
+ /* configure some gpios */
+ ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
+ if (ret)
+ goto err_out;
+
+ ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
+ if (ret)
+ goto err_gpio;
+
+ s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
+ if (!s3c24xx_snd_device) {
+ ret = -ENOMEM;
+ goto err_gpio;
+ }
+
+ platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
+ ret = platform_device_add(s3c24xx_snd_device);
+
+ if (ret)
+ goto err_plat;
+
+ return 0;
+
+err_plat:
+ platform_device_put(s3c24xx_snd_device);
+err_gpio:
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+
+err_out:
+ return ret;
+}
+
+static void __exit h1940_exit(void)
+{
+ platform_device_unregister(s3c24xx_snd_device);
+ snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+}
+
+module_init(h1940_init);
+module_exit(h1940_exit);
+
+/* Module information */
+MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
+MODULE_DESCRIPTION("ALSA SoC H1940");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:soc-audio");
--
1.7.2.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 12:18 ` [PATCH v2 1/1] " Vasily Khoruzhick
@ 2010-09-12 13:25 ` Marek Vasut
2010-09-12 17:07 ` Jassi Brar
2010-09-13 9:07 ` [PATCH v2 " Mark Brown
2 siblings, 0 replies; 21+ messages in thread
From: Marek Vasut @ 2010-09-12 13:25 UTC (permalink / raw)
To: alsa-devel
Cc: Vasily Khoruzhick, Mark Brown, Arnaud Patard (Rtp),
Ben Dooks, Liam Girdwood
Dne Ne 12. září 2010 14:18:47 Vasily Khoruzhick napsal(a):
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
have my:
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
> ---
> sound/soc/s3c24xx/Kconfig | 8 +
> sound/soc/s3c24xx/Makefile | 2 +
> sound/soc/s3c24xx/h1940_uda1380.c | 297
> +++++++++++++++++++++++++++++++++++++ 3 files changed, 307 insertions(+),
> 0 deletions(-)
> create mode 100644 sound/soc/s3c24xx/h1940_uda1380.c
>
> diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
> index 7d8235d..6b50509 100644
> --- a/sound/soc/s3c24xx/Kconfig
> +++ b/sound/soc/s3c24xx/Kconfig
> @@ -118,6 +118,14 @@ config SND_S3C24XX_SOC_SIMTEC_HERMES
> select SND_SOC_TLV320AIC3X
> select SND_S3C24XX_SOC_SIMTEC
>
> +config SND_S3C24XX_SOC_H1940_UDA1380
> + tristate "Audio support for the HP iPAQ H1940"
> + depends on SND_S3C24XX_SOC && ARCH_H1940
> + select SND_S3C24XX_SOC_I2S
> + select SND_SOC_UDA1380
> + help
> + This driver provides audio support for HP iPAQ h1940 PDA.
> +
> config SND_S3C24XX_SOC_RX1950_UDA1380
> tristate "Audio support for the HP iPAQ RX1950"
> depends on SND_S3C24XX_SOC && MACH_RX1950
> diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
> index dd412a9..33a7c68 100644
> --- a/sound/soc/s3c24xx/Makefile
> +++ b/sound/soc/s3c24xx/Makefile
> @@ -28,6 +28,7 @@ snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
> snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
> snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
> snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o
> +snd-soc-h1940-uda1380-objs := h1940_uda1380.o
> snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
> snd-soc-smdk-wm9713-objs := smdk_wm9713.o
> snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
> @@ -44,6 +45,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) +=
> snd-soc-s3c24xx-simtec.o obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) +=
> snd-soc-s3c24xx-simtec-hermes.o
> obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) +=
> snd-soc-s3c24xx-simtec-tlv320aic23.o
> obj-$(CONFIG_SND_S3C24XX_SOC_RX1950_UDA1380) += snd-soc-rx1950-uda1380.o
> +obj-$(CONFIG_SND_S3C24XX_SOC_H1940_UDA1380) += snd-soc-h1940-uda1380.o
> obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
> obj-$(CONFIG_SND_SOC_SMDK_WM9713) += snd-soc-smdk-wm9713.o
> obj-$(CONFIG_SND_S3C64XX_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
> diff --git a/sound/soc/s3c24xx/h1940_uda1380.c
> b/sound/soc/s3c24xx/h1940_uda1380.c new file mode 100644
> index 0000000..5dbc0ea
> --- /dev/null
> +++ b/sound/soc/s3c24xx/h1940_uda1380.c
> @@ -0,0 +1,297 @@
> +/*
> + * h1940-uda1380.c -- ALSA Soc Audio Layer
> + *
> + * Copyright (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
> + * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
> + *
> + * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
> + *
> + * 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/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c.h>
> +#include <linux/gpio.h>
> +
> +#include <sound/soc.h>
> +#include <sound/soc-dapm.h>
> +#include <sound/uda1380.h>
> +#include <sound/jack.h>
> +
> +#include <plat/regs-iis.h>
> +
> +#include <mach/h1940-latch.h>
> +
> +#include <asm/mach-types.h>
> +
> +#include "s3c-dma.h"
> +#include "s3c24xx-i2s.h"
> +#include "../codecs/uda1380.h"
> +
> +static unsigned int rates[] = {
> + 11025,
> + 22050,
> + 44100,
> +};
> +
> +static struct snd_pcm_hw_constraint_list hw_rates = {
> + .count = ARRAY_SIZE(rates),
> + .list = rates,
> + .mask = 0,
> +};
> +
> +static struct snd_soc_jack hp_jack;
> +
> +static struct snd_soc_jack_pin hp_jack_pins[] = {
> + {
> + .pin = "Headphone Jack",
> + .mask = SND_JACK_HEADPHONE,
> + },
> + {
> + .pin = "Speaker",
> + .mask = SND_JACK_HEADPHONE,
> + .invert = 1,
> + },
> +};
> +
> +static struct snd_soc_jack_gpio hp_jack_gpios[] = {
> + {
> + .gpio = S3C2410_GPG(4),
> + .name = "hp-gpio",
> + .report = SND_JACK_HEADPHONE,
> + .invert = 1,
> + .debounce_time = 200,
> + },
> +};
> +
> +static int h1940_startup(struct snd_pcm_substream *substream)
> +{
> + struct snd_pcm_runtime *runtime = substream->runtime;
> +
> + runtime->hw.rate_min = hw_rates.list[0];
> + runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
> + runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
> +
> + return snd_pcm_hw_constraint_list(runtime, 0,
> + SNDRV_PCM_HW_PARAM_RATE,
> + &hw_rates);
> +}
> +
> +static int h1940_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 *cpu_dai = rtd->cpu_dai;
> + struct snd_soc_dai *codec_dai = rtd->codec_dai;
> + int div;
> + int ret;
> + unsigned int rate = params_rate(params);
> +
> + switch (rate) {
> + case 11025:
> + case 22050:
> + case 44100:
> + div = s3c24xx_i2s_get_clockrate() / (384 * rate);
> + if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate))
> + div++;
> + break;
> + default:
> + dev_err(&rtd->dev, "%s: rate %d is not supported\n",
> + __func__, rate);
> + return -EINVAL;
> + }
> +
> + /* set codec DAI configuration */
> + 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;
> +
> + /* set cpu DAI configuration */
> + 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;
> +
> + /* select clock source */
> + ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
> + SND_SOC_CLOCK_OUT);
> + if (ret < 0)
> + return ret;
> +
> + /* set MCLK division for sample rate */
> + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
> + S3C2410_IISMOD_384FS);
> + if (ret < 0)
> + return ret;
> +
> + /* set BCLK division for sample rate */
> + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK,
> + S3C2410_IISMOD_32FS);
> + if (ret < 0)
> + return ret;
> +
> + /* set prescaler division for sample rate */
> + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
> + S3C24XX_PRESCALE(div, div));
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
> +static struct snd_soc_ops h1940_ops = {
> + .startup = h1940_startup,
> + .hw_params = h1940_hw_params,
> +};
> +
> +static int h1940_spk_power(struct snd_soc_dapm_widget *w,
> + struct snd_kcontrol *kcontrol, int event)
> +{
> + if (SND_SOC_DAPM_EVENT_ON(event))
> + gpio_set_value(H1940_LATCH_AUDIO_POWER, 1);
> + else
> + gpio_set_value(H1940_LATCH_AUDIO_POWER, 0);
> +
> + return 0;
> +}
> +
> +/* h1940 machine dapm widgets */
> +static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
> + SND_SOC_DAPM_HP("Headphone Jack", NULL),
> + SND_SOC_DAPM_MIC("Mic Jack", NULL),
> + SND_SOC_DAPM_SPK("Speaker", h1940_spk_power),
> +};
> +
> +/* h1940 machine audio_map */
> +static const struct snd_soc_dapm_route audio_map[] = {
> + /* headphone connected to VOUTLHP, VOUTRHP */
> + {"Headphone Jack", NULL, "VOUTLHP"},
> + {"Headphone Jack", NULL, "VOUTRHP"},
> +
> + /* ext speaker connected to VOUTL, VOUTR */
> + {"Speaker", NULL, "VOUTL"},
> + {"Speaker", NULL, "VOUTR"},
> +
> + /* mic is connected to VINM */
> + {"VINM", NULL, "Mic Jack"},
> +};
> +
> +static struct platform_device *s3c24xx_snd_device;
> +
> +static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
> +{
> + struct snd_soc_codec *codec = rtd->codec;
> + int err;
> +
> + /* Add h1940 specific widgets */
> + err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
> + ARRAY_SIZE(uda1380_dapm_widgets));
> + if (err)
> + return err;
> +
> + /* Set up h1940 specific audio path audio_mapnects */
> + err = snd_soc_dapm_add_routes(codec, audio_map,
> + ARRAY_SIZE(audio_map));
> + if (err)
> + return err;
> +
> + snd_soc_dapm_enable_pin(codec, "Headphone Jack");
> + snd_soc_dapm_enable_pin(codec, "Speaker");
> + snd_soc_dapm_enable_pin(codec, "Mic Jack");
> +
> + snd_soc_dapm_sync(codec);
> +
> + snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
> + &hp_jack);
> +
> + snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
> + hp_jack_pins);
> +
> + snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
> + hp_jack_gpios);
> +
> + return 0;
> +}
> +
> +/* s3c24xx digital audio interface glue - connects codec <--> CPU */
> +static struct snd_soc_dai_link h1940_uda1380_dai[] = {
> + {
> + .name = "uda1380",
> + .stream_name = "UDA1380 Duplex",
> + .cpu_dai_name = "s3c24xx-iis",
> + .codec_dai_name = "uda1380-hifi",
> + .init = h1940_uda1380_init,
> + .platform_name = "s3c24xx-pcm-audio",
> + .codec_name = "uda1380-codec.0-001a",
> + .ops = &h1940_ops,
> + },
> +};
> +
> +static struct snd_soc_card h1940_asoc = {
> + .name = "h1940",
> + .dai_link = h1940_uda1380_dai,
> + .num_links = ARRAY_SIZE(h1940_uda1380_dai),
> +};
> +
> +static int __init h1940_init(void)
> +{
> + int ret;
> +
> + if (!machine_is_h1940())
> + return -ENODEV;
> +
> + /* configure some gpios */
> + ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
> + if (ret)
> + goto err_out;
> +
> + ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
> + if (ret)
> + goto err_gpio;
> +
> + s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
> + if (!s3c24xx_snd_device) {
> + ret = -ENOMEM;
> + goto err_gpio;
> + }
> +
> + platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
> + ret = platform_device_add(s3c24xx_snd_device);
> +
> + if (ret)
> + goto err_plat;
> +
> + return 0;
> +
> +err_plat:
> + platform_device_put(s3c24xx_snd_device);
> +err_gpio:
> + gpio_free(H1940_LATCH_AUDIO_POWER);
> +
> +err_out:
> + return ret;
> +}
> +
> +static void __exit h1940_exit(void)
> +{
> + platform_device_unregister(s3c24xx_snd_device);
> + snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
> + hp_jack_gpios);
> + gpio_free(H1940_LATCH_AUDIO_POWER);
> +}
> +
> +module_init(h1940_init);
> +module_exit(h1940_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
> +MODULE_DESCRIPTION("ALSA SoC H1940");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:soc-audio");
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 12:18 ` [PATCH v2 1/1] " Vasily Khoruzhick
2010-09-12 13:25 ` Marek Vasut
@ 2010-09-12 17:07 ` Jassi Brar
2010-09-12 18:09 ` Vasily Khoruzhick
2010-09-13 9:07 ` [PATCH v2 " Mark Brown
2 siblings, 1 reply; 21+ messages in thread
From: Jassi Brar @ 2010-09-12 17:07 UTC (permalink / raw)
To: Vasily Khoruzhick
Cc: alsa-devel, Mark Brown, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
On Sun, Sep 12, 2010 at 9:18 PM, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
> ---
> sound/soc/s3c24xx/Kconfig | 8 +
> sound/soc/s3c24xx/Makefile | 2 +
> sound/soc/s3c24xx/h1940_uda1380.c | 297 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 307 insertions(+), 0 deletions(-)
> create mode 100644 sound/soc/s3c24xx/h1940_uda1380.c
>
> diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
> index 7d8235d..6b50509 100644
> --- a/sound/soc/s3c24xx/Kconfig
> +++ b/sound/soc/s3c24xx/Kconfig
> @@ -118,6 +118,14 @@ config SND_S3C24XX_SOC_SIMTEC_HERMES
> select SND_SOC_TLV320AIC3X
> select SND_S3C24XX_SOC_SIMTEC
>
> +config SND_S3C24XX_SOC_H1940_UDA1380
> + tristate "Audio support for the HP iPAQ H1940"
> + depends on SND_S3C24XX_SOC && ARCH_H1940
> + select SND_S3C24XX_SOC_I2S
> + select SND_SOC_UDA1380
> + help
> + This driver provides audio support for HP iPAQ h1940 PDA.
> +
> config SND_S3C24XX_SOC_RX1950_UDA1380
> tristate "Audio support for the HP iPAQ RX1950"
> depends on SND_S3C24XX_SOC && MACH_RX1950
> diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
> index dd412a9..33a7c68 100644
> --- a/sound/soc/s3c24xx/Makefile
> +++ b/sound/soc/s3c24xx/Makefile
> @@ -28,6 +28,7 @@ snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
> snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
> snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
> snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o
> +snd-soc-h1940-uda1380-objs := h1940_uda1380.o
> snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
> snd-soc-smdk-wm9713-objs := smdk_wm9713.o
> snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
> @@ -44,6 +45,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o
> obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o
> obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o
> obj-$(CONFIG_SND_S3C24XX_SOC_RX1950_UDA1380) += snd-soc-rx1950-uda1380.o
> +obj-$(CONFIG_SND_S3C24XX_SOC_H1940_UDA1380) += snd-soc-h1940-uda1380.o
> obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
> obj-$(CONFIG_SND_SOC_SMDK_WM9713) += snd-soc-smdk-wm9713.o
> obj-$(CONFIG_SND_S3C64XX_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
> diff --git a/sound/soc/s3c24xx/h1940_uda1380.c b/sound/soc/s3c24xx/h1940_uda1380.c
> new file mode 100644
> index 0000000..5dbc0ea
> --- /dev/null
> +++ b/sound/soc/s3c24xx/h1940_uda1380.c
> @@ -0,0 +1,297 @@
> +/*
> + * h1940-uda1380.c -- ALSA Soc Audio Layer
> + *
> + * Copyright (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
> + * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
> + *
> + * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
> + *
> + * 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/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c.h>
> +#include <linux/gpio.h>
> +
> +#include <sound/soc.h>
> +#include <sound/soc-dapm.h>
> +#include <sound/uda1380.h>
> +#include <sound/jack.h>
> +
> +#include <plat/regs-iis.h>
> +
> +#include <mach/h1940-latch.h>
> +
> +#include <asm/mach-types.h>
> +
> +#include "s3c-dma.h"
> +#include "s3c24xx-i2s.h"
> +#include "../codecs/uda1380.h"
> +
> +static unsigned int rates[] = {
> + 11025,
> + 22050,
> + 44100,
> +};
> +
> +static struct snd_pcm_hw_constraint_list hw_rates = {
> + .count = ARRAY_SIZE(rates),
> + .list = rates,
> + .mask = 0,
> +};
> +
> +static struct snd_soc_jack hp_jack;
> +
> +static struct snd_soc_jack_pin hp_jack_pins[] = {
> + {
> + .pin = "Headphone Jack",
> + .mask = SND_JACK_HEADPHONE,
> + },
> + {
> + .pin = "Speaker",
> + .mask = SND_JACK_HEADPHONE,
> + .invert = 1,
> + },
> +};
> +
> +static struct snd_soc_jack_gpio hp_jack_gpios[] = {
> + {
> + .gpio = S3C2410_GPG(4),
> + .name = "hp-gpio",
> + .report = SND_JACK_HEADPHONE,
> + .invert = 1,
> + .debounce_time = 200,
> + },
> +};
> +
> +static int h1940_startup(struct snd_pcm_substream *substream)
> +{
> + struct snd_pcm_runtime *runtime = substream->runtime;
> +
> + runtime->hw.rate_min = hw_rates.list[0];
> + runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
> + runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
> +
> + return snd_pcm_hw_constraint_list(runtime, 0,
> + SNDRV_PCM_HW_PARAM_RATE,
> + &hw_rates);
> +}
> +
> +static int h1940_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 *cpu_dai = rtd->cpu_dai;
> + struct snd_soc_dai *codec_dai = rtd->codec_dai;
> + int div;
> + int ret;
> + unsigned int rate = params_rate(params);
> +
> + switch (rate) {
> + case 11025:
> + case 22050:
> + case 44100:
> + div = s3c24xx_i2s_get_clockrate() / (384 * rate);
> + if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate))
> + div++;
> + break;
> + default:
> + dev_err(&rtd->dev, "%s: rate %d is not supported\n",
> + __func__, rate);
> + return -EINVAL;
> + }
> +
> + /* set codec DAI configuration */
> + 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;
> +
> + /* set cpu DAI configuration */
> + 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;
> +
> + /* select clock source */
> + ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
> + SND_SOC_CLOCK_OUT);
> + if (ret < 0)
> + return ret;
> +
> + /* set MCLK division for sample rate */
> + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
> + S3C2410_IISMOD_384FS);
> + if (ret < 0)
> + return ret;
> +
> + /* set BCLK division for sample rate */
> + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK,
> + S3C2410_IISMOD_32FS);
> + if (ret < 0)
> + return ret;
> +
> + /* set prescaler division for sample rate */
> + ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
> + S3C24XX_PRESCALE(div, div));
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
> +static struct snd_soc_ops h1940_ops = {
> + .startup = h1940_startup,
> + .hw_params = h1940_hw_params,
> +};
> +
> +static int h1940_spk_power(struct snd_soc_dapm_widget *w,
> + struct snd_kcontrol *kcontrol, int event)
> +{
> + if (SND_SOC_DAPM_EVENT_ON(event))
> + gpio_set_value(H1940_LATCH_AUDIO_POWER, 1);
> + else
> + gpio_set_value(H1940_LATCH_AUDIO_POWER, 0);
> +
> + return 0;
> +}
> +
> +/* h1940 machine dapm widgets */
> +static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
> + SND_SOC_DAPM_HP("Headphone Jack", NULL),
> + SND_SOC_DAPM_MIC("Mic Jack", NULL),
> + SND_SOC_DAPM_SPK("Speaker", h1940_spk_power),
> +};
> +
> +/* h1940 machine audio_map */
> +static const struct snd_soc_dapm_route audio_map[] = {
> + /* headphone connected to VOUTLHP, VOUTRHP */
> + {"Headphone Jack", NULL, "VOUTLHP"},
> + {"Headphone Jack", NULL, "VOUTRHP"},
> +
> + /* ext speaker connected to VOUTL, VOUTR */
> + {"Speaker", NULL, "VOUTL"},
> + {"Speaker", NULL, "VOUTR"},
> +
> + /* mic is connected to VINM */
> + {"VINM", NULL, "Mic Jack"},
> +};
> +
> +static struct platform_device *s3c24xx_snd_device;
> +
> +static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
> +{
> + struct snd_soc_codec *codec = rtd->codec;
> + int err;
> +
> + /* Add h1940 specific widgets */
> + err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
> + ARRAY_SIZE(uda1380_dapm_widgets));
> + if (err)
> + return err;
> +
> + /* Set up h1940 specific audio path audio_mapnects */
> + err = snd_soc_dapm_add_routes(codec, audio_map,
> + ARRAY_SIZE(audio_map));
> + if (err)
> + return err;
> +
> + snd_soc_dapm_enable_pin(codec, "Headphone Jack");
> + snd_soc_dapm_enable_pin(codec, "Speaker");
> + snd_soc_dapm_enable_pin(codec, "Mic Jack");
> +
> + snd_soc_dapm_sync(codec);
> +
> + snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
> + &hp_jack);
> +
> + snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
> + hp_jack_pins);
> +
> + snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
> + hp_jack_gpios);
> +
> + return 0;
> +}
> +
> +/* s3c24xx digital audio interface glue - connects codec <--> CPU */
> +static struct snd_soc_dai_link h1940_uda1380_dai[] = {
> + {
> + .name = "uda1380",
> + .stream_name = "UDA1380 Duplex",
> + .cpu_dai_name = "s3c24xx-iis",
> + .codec_dai_name = "uda1380-hifi",
> + .init = h1940_uda1380_init,
> + .platform_name = "s3c24xx-pcm-audio",
> + .codec_name = "uda1380-codec.0-001a",
> + .ops = &h1940_ops,
> + },
> +};
> +
> +static struct snd_soc_card h1940_asoc = {
> + .name = "h1940",
> + .dai_link = h1940_uda1380_dai,
> + .num_links = ARRAY_SIZE(h1940_uda1380_dai),
> +};
> +
> +static int __init h1940_init(void)
> +{
> + int ret;
> +
> + if (!machine_is_h1940())
> + return -ENODEV;
> +
> + /* configure some gpios */
> + ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
> + if (ret)
> + goto err_out;
> +
> + ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
> + if (ret)
> + goto err_gpio;
> +
> + s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
> + if (!s3c24xx_snd_device) {
> + ret = -ENOMEM;
> + goto err_gpio;
> + }
> +
> + platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
> + ret = platform_device_add(s3c24xx_snd_device);
> +
> + if (ret)
> + goto err_plat;
> +
> + return 0;
> +
> +err_plat:
> + platform_device_put(s3c24xx_snd_device);
> +err_gpio:
> + gpio_free(H1940_LATCH_AUDIO_POWER);
> +
> +err_out:
> + return ret;
> +}
> +
> +static void __exit h1940_exit(void)
> +{
> + platform_device_unregister(s3c24xx_snd_device);
> + snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
> + hp_jack_gpios);
> + gpio_free(H1940_LATCH_AUDIO_POWER);
> +}
> +
> +module_init(h1940_init);
> +module_exit(h1940_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
> +MODULE_DESCRIPTION("ALSA SoC H1940");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:soc-audio");
Is platform:soc-audio specific enough in multi-platform builds of the OS?
Though it is unlikely there would ever be such a conflict, but still...
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 17:07 ` Jassi Brar
@ 2010-09-12 18:09 ` Vasily Khoruzhick
2010-09-13 1:09 ` Jassi Brar
0 siblings, 1 reply; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-12 18:09 UTC (permalink / raw)
To: Jassi Brar
Cc: alsa-devel, Mark Brown, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
[-- Attachment #1.1: Type: Text/Plain, Size: 355 bytes --]
В сообщении от 12 сентября 2010 20:07:41 автор Jassi Brar написал:
> Is platform:soc-audio specific enough in multi-platform builds of the OS?
> Though it is unlikely there would ever be such a conflict, but still...
Other glue drivers just can't load, usually they include machine check in
module_init.
Regards
Vasily
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 18:09 ` Vasily Khoruzhick
@ 2010-09-13 1:09 ` Jassi Brar
2010-09-13 9:05 ` Mark Brown
0 siblings, 1 reply; 21+ messages in thread
From: Jassi Brar @ 2010-09-13 1:09 UTC (permalink / raw)
To: Vasily Khoruzhick
Cc: alsa-devel, Mark Brown, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
On Mon, Sep 13, 2010 at 3:09 AM, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> В сообщении от 12 сентября 2010 20:07:41 автор Jassi Brar написал:
>
>> Is platform:soc-audio specific enough in multi-platform builds of the OS?
>> Though it is unlikely there would ever be such a conflict, but still...
>
> Other glue drivers just can't load, usually they include machine check in
> module_init.
Btw, sound/soc/soc-core.c is the real 'soc-audio' driver module not
the MACHINE driver.
Turns out, sound/soc/soc-core.c already has the
MODULE_ALIAS("platform:soc-audio");
So it seems like an immediate conflict.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-13 1:09 ` Jassi Brar
@ 2010-09-13 9:05 ` Mark Brown
2010-09-13 9:12 ` Vasily Khoruzhick
` (2 more replies)
0 siblings, 3 replies; 21+ messages in thread
From: Mark Brown @ 2010-09-13 9:05 UTC (permalink / raw)
To: Jassi Brar
Cc: Vasily Khoruzhick, alsa-devel, Arnaud Patard (Rtp),
Ben Dooks, Liam Girdwood
On Mon, Sep 13, 2010 at 10:09:16AM +0900, Jassi Brar wrote:
> Btw, sound/soc/soc-core.c is the real 'soc-audio' driver module not
> the MACHINE driver.
> Turns out, sound/soc/soc-core.c already has the
> MODULE_ALIAS("platform:soc-audio");
> So it seems like an immediate conflict.
Indeed - the MODULE_ALIAS() goes along with the device driver, not with
the registration of the device.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-12 12:18 ` [PATCH v2 1/1] " Vasily Khoruzhick
2010-09-12 13:25 ` Marek Vasut
2010-09-12 17:07 ` Jassi Brar
@ 2010-09-13 9:07 ` Mark Brown
2 siblings, 0 replies; 21+ messages in thread
From: Mark Brown @ 2010-09-13 9:07 UTC (permalink / raw)
To: Vasily Khoruzhick
Cc: alsa-devel, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
On Sun, Sep 12, 2010 at 03:18:47PM +0300, Vasily Khoruzhick wrote:
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Aside from the MODULE_ALIAS thing Jassi picked up on this looks good.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-13 9:05 ` Mark Brown
@ 2010-09-13 9:12 ` Vasily Khoruzhick
2010-09-13 9:47 ` [PATCH v3 0/1] " Vasily Khoruzhick
2010-09-13 9:47 ` [PATCH v3 1/1] " Vasily Khoruzhick
2 siblings, 0 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-13 9:12 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel, Jassi Brar, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
[-- Attachment #1.1: Type: Text/Plain, Size: 393 bytes --]
В сообщении от 13 сентября 2010 12:05:43 автор Mark Brown написал:
> Indeed - the MODULE_ALIAS() goes along with the device driver, not with
> the registration of the device.
Ok, will resend fixed version soon, however as I said on IRC, please, don't
merge this patch until Ben review/merge this patch:
http://www.spinics.net/lists/arm-kernel/msg98042.html
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 0/1] ASoC: Add HP iPAQ H1940 support
2010-09-13 9:05 ` Mark Brown
2010-09-13 9:12 ` Vasily Khoruzhick
@ 2010-09-13 9:47 ` Vasily Khoruzhick
2010-09-13 9:47 ` [PATCH v3 1/1] " Vasily Khoruzhick
2 siblings, 0 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-13 9:47 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, alsa-devel, Ben Dooks, Arnaud
This patch depends on gpiolib support for h1940 latch access,
here's link to patch in ml archive:
http://www.spinics.net/lists/arm-kernel/msg98042.html
I hope Ben will find some time to merge it into his tree
before 2.6.37 merge window :)
v2: - printk replaced via dev_err;
- added module alias
v3: - removed module alias
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-13 9:05 ` Mark Brown
2010-09-13 9:12 ` Vasily Khoruzhick
2010-09-13 9:47 ` [PATCH v3 0/1] " Vasily Khoruzhick
@ 2010-09-13 9:47 ` Vasily Khoruzhick
2010-09-20 10:38 ` Mark Brown
2 siblings, 1 reply; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-13 9:47 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, alsa-devel, Ben Dooks, Arnaud
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
---
sound/soc/s3c24xx/Kconfig | 8 +
sound/soc/s3c24xx/Makefile | 2 +
sound/soc/s3c24xx/h1940_uda1380.c | 296 +++++++++++++++++++++++++++++++++++++
3 files changed, 306 insertions(+), 0 deletions(-)
create mode 100644 sound/soc/s3c24xx/h1940_uda1380.c
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 7d8235d..6b50509 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -118,6 +118,14 @@ config SND_S3C24XX_SOC_SIMTEC_HERMES
select SND_SOC_TLV320AIC3X
select SND_S3C24XX_SOC_SIMTEC
+config SND_S3C24XX_SOC_H1940_UDA1380
+ tristate "Audio support for the HP iPAQ H1940"
+ depends on SND_S3C24XX_SOC && ARCH_H1940
+ select SND_S3C24XX_SOC_I2S
+ select SND_SOC_UDA1380
+ help
+ This driver provides audio support for HP iPAQ h1940 PDA.
+
config SND_S3C24XX_SOC_RX1950_UDA1380
tristate "Audio support for the HP iPAQ RX1950"
depends on SND_S3C24XX_SOC && MACH_RX1950
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index dd412a9..33a7c68 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -28,6 +28,7 @@ snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o
+snd-soc-h1940-uda1380-objs := h1940_uda1380.o
snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
snd-soc-smdk-wm9713-objs := smdk_wm9713.o
snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
@@ -44,6 +45,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o
obj-$(CONFIG_SND_S3C24XX_SOC_RX1950_UDA1380) += snd-soc-rx1950-uda1380.o
+obj-$(CONFIG_SND_S3C24XX_SOC_H1940_UDA1380) += snd-soc-h1940-uda1380.o
obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
obj-$(CONFIG_SND_SOC_SMDK_WM9713) += snd-soc-smdk-wm9713.o
obj-$(CONFIG_SND_S3C64XX_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
diff --git a/sound/soc/s3c24xx/h1940_uda1380.c b/sound/soc/s3c24xx/h1940_uda1380.c
new file mode 100644
index 0000000..8e21c5e
--- /dev/null
+++ b/sound/soc/s3c24xx/h1940_uda1380.c
@@ -0,0 +1,296 @@
+/*
+ * h1940-uda1380.c -- ALSA Soc Audio Layer
+ *
+ * Copyright (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
+ * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ * 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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/uda1380.h>
+#include <sound/jack.h>
+
+#include <plat/regs-iis.h>
+
+#include <mach/h1940-latch.h>
+
+#include <asm/mach-types.h>
+
+#include "s3c-dma.h"
+#include "s3c24xx-i2s.h"
+#include "../codecs/uda1380.h"
+
+static unsigned int rates[] = {
+ 11025,
+ 22050,
+ 44100,
+};
+
+static struct snd_pcm_hw_constraint_list hw_rates = {
+ .count = ARRAY_SIZE(rates),
+ .list = rates,
+ .mask = 0,
+};
+
+static struct snd_soc_jack hp_jack;
+
+static struct snd_soc_jack_pin hp_jack_pins[] = {
+ {
+ .pin = "Headphone Jack",
+ .mask = SND_JACK_HEADPHONE,
+ },
+ {
+ .pin = "Speaker",
+ .mask = SND_JACK_HEADPHONE,
+ .invert = 1,
+ },
+};
+
+static struct snd_soc_jack_gpio hp_jack_gpios[] = {
+ {
+ .gpio = S3C2410_GPG(4),
+ .name = "hp-gpio",
+ .report = SND_JACK_HEADPHONE,
+ .invert = 1,
+ .debounce_time = 200,
+ },
+};
+
+static int h1940_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+
+ runtime->hw.rate_min = hw_rates.list[0];
+ runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
+ runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
+
+ return snd_pcm_hw_constraint_list(runtime, 0,
+ SNDRV_PCM_HW_PARAM_RATE,
+ &hw_rates);
+}
+
+static int h1940_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 *cpu_dai = rtd->cpu_dai;
+ struct snd_soc_dai *codec_dai = rtd->codec_dai;
+ int div;
+ int ret;
+ unsigned int rate = params_rate(params);
+
+ switch (rate) {
+ case 11025:
+ case 22050:
+ case 44100:
+ div = s3c24xx_i2s_get_clockrate() / (384 * rate);
+ if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate))
+ div++;
+ break;
+ default:
+ dev_err(&rtd->dev, "%s: rate %d is not supported\n",
+ __func__, rate);
+ return -EINVAL;
+ }
+
+ /* set codec DAI configuration */
+ 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;
+
+ /* set cpu DAI configuration */
+ 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;
+
+ /* select clock source */
+ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
+ SND_SOC_CLOCK_OUT);
+ if (ret < 0)
+ return ret;
+
+ /* set MCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
+ S3C2410_IISMOD_384FS);
+ if (ret < 0)
+ return ret;
+
+ /* set BCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK,
+ S3C2410_IISMOD_32FS);
+ if (ret < 0)
+ return ret;
+
+ /* set prescaler division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
+ S3C24XX_PRESCALE(div, div));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static struct snd_soc_ops h1940_ops = {
+ .startup = h1940_startup,
+ .hw_params = h1940_hw_params,
+};
+
+static int h1940_spk_power(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ if (SND_SOC_DAPM_EVENT_ON(event))
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 1);
+ else
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 0);
+
+ return 0;
+}
+
+/* h1940 machine dapm widgets */
+static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_MIC("Mic Jack", NULL),
+ SND_SOC_DAPM_SPK("Speaker", h1940_spk_power),
+};
+
+/* h1940 machine audio_map */
+static const struct snd_soc_dapm_route audio_map[] = {
+ /* headphone connected to VOUTLHP, VOUTRHP */
+ {"Headphone Jack", NULL, "VOUTLHP"},
+ {"Headphone Jack", NULL, "VOUTRHP"},
+
+ /* ext speaker connected to VOUTL, VOUTR */
+ {"Speaker", NULL, "VOUTL"},
+ {"Speaker", NULL, "VOUTR"},
+
+ /* mic is connected to VINM */
+ {"VINM", NULL, "Mic Jack"},
+};
+
+static struct platform_device *s3c24xx_snd_device;
+
+static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_codec *codec = rtd->codec;
+ int err;
+
+ /* Add h1940 specific widgets */
+ err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
+ ARRAY_SIZE(uda1380_dapm_widgets));
+ if (err)
+ return err;
+
+ /* Set up h1940 specific audio path audio_mapnects */
+ err = snd_soc_dapm_add_routes(codec, audio_map,
+ ARRAY_SIZE(audio_map));
+ if (err)
+ return err;
+
+ snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+ snd_soc_dapm_enable_pin(codec, "Speaker");
+ snd_soc_dapm_enable_pin(codec, "Mic Jack");
+
+ snd_soc_dapm_sync(codec);
+
+ snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
+ &hp_jack);
+
+ snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
+ hp_jack_pins);
+
+ snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+
+ return 0;
+}
+
+/* s3c24xx digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link h1940_uda1380_dai[] = {
+ {
+ .name = "uda1380",
+ .stream_name = "UDA1380 Duplex",
+ .cpu_dai_name = "s3c24xx-iis",
+ .codec_dai_name = "uda1380-hifi",
+ .init = h1940_uda1380_init,
+ .platform_name = "s3c24xx-pcm-audio",
+ .codec_name = "uda1380-codec.0-001a",
+ .ops = &h1940_ops,
+ },
+};
+
+static struct snd_soc_card h1940_asoc = {
+ .name = "h1940",
+ .dai_link = h1940_uda1380_dai,
+ .num_links = ARRAY_SIZE(h1940_uda1380_dai),
+};
+
+static int __init h1940_init(void)
+{
+ int ret;
+
+ if (!machine_is_h1940())
+ return -ENODEV;
+
+ /* configure some gpios */
+ ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
+ if (ret)
+ goto err_out;
+
+ ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
+ if (ret)
+ goto err_gpio;
+
+ s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
+ if (!s3c24xx_snd_device) {
+ ret = -ENOMEM;
+ goto err_gpio;
+ }
+
+ platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
+ ret = platform_device_add(s3c24xx_snd_device);
+
+ if (ret)
+ goto err_plat;
+
+ return 0;
+
+err_plat:
+ platform_device_put(s3c24xx_snd_device);
+err_gpio:
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+
+err_out:
+ return ret;
+}
+
+static void __exit h1940_exit(void)
+{
+ platform_device_unregister(s3c24xx_snd_device);
+ snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+}
+
+module_init(h1940_init);
+module_exit(h1940_exit);
+
+/* Module information */
+MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
+MODULE_DESCRIPTION("ALSA SoC H1940");
+MODULE_LICENSE("GPL");
--
1.7.2.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-13 9:47 ` [PATCH v3 1/1] " Vasily Khoruzhick
@ 2010-09-20 10:38 ` Mark Brown
2010-09-27 7:47 ` [PATCH RESEND " Vasily Khoruzhick
0 siblings, 1 reply; 21+ messages in thread
From: Mark Brown @ 2010-09-20 10:38 UTC (permalink / raw)
To: Vasily Khoruzhick
Cc: alsa-devel, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
On Mon, Sep 13, 2010 at 12:47:18PM +0300, Vasily Khoruzhick wrote:
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
This looks fine - please resubmit when the dependencies have been
merged.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH RESEND v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-20 10:38 ` Mark Brown
@ 2010-09-27 7:47 ` Vasily Khoruzhick
2010-09-27 15:06 ` Mark Brown
0 siblings, 1 reply; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-27 7:47 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, alsa-devel, Ben Dooks, Arnaud
Cc: Vasily Khoruzhick
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
---
This patch can be merged upstream now, since dependencies
were merged into Ben's tree
v2: printk replaced via dev_err, added module alias
v3: removed module alias
sound/soc/s3c24xx/Kconfig | 8 +
sound/soc/s3c24xx/Makefile | 2 +
sound/soc/s3c24xx/h1940_uda1380.c | 296 +++++++++++++++++++++++++++++++++++++
3 files changed, 306 insertions(+), 0 deletions(-)
create mode 100644 sound/soc/s3c24xx/h1940_uda1380.c
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
index 7d8235d..6b50509 100644
--- a/sound/soc/s3c24xx/Kconfig
+++ b/sound/soc/s3c24xx/Kconfig
@@ -118,6 +118,14 @@ config SND_S3C24XX_SOC_SIMTEC_HERMES
select SND_SOC_TLV320AIC3X
select SND_S3C24XX_SOC_SIMTEC
+config SND_S3C24XX_SOC_H1940_UDA1380
+ tristate "Audio support for the HP iPAQ H1940"
+ depends on SND_S3C24XX_SOC && ARCH_H1940
+ select SND_S3C24XX_SOC_I2S
+ select SND_SOC_UDA1380
+ help
+ This driver provides audio support for HP iPAQ h1940 PDA.
+
config SND_S3C24XX_SOC_RX1950_UDA1380
tristate "Audio support for the HP iPAQ RX1950"
depends on SND_S3C24XX_SOC && MACH_RX1950
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
index dd412a9..33a7c68 100644
--- a/sound/soc/s3c24xx/Makefile
+++ b/sound/soc/s3c24xx/Makefile
@@ -28,6 +28,7 @@ snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o
snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o
snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o
snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o
+snd-soc-h1940-uda1380-objs := h1940_uda1380.o
snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
snd-soc-smdk-wm9713-objs := smdk_wm9713.o
snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
@@ -44,6 +45,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o
obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o
obj-$(CONFIG_SND_S3C24XX_SOC_RX1950_UDA1380) += snd-soc-rx1950-uda1380.o
+obj-$(CONFIG_SND_S3C24XX_SOC_H1940_UDA1380) += snd-soc-h1940-uda1380.o
obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
obj-$(CONFIG_SND_SOC_SMDK_WM9713) += snd-soc-smdk-wm9713.o
obj-$(CONFIG_SND_S3C64XX_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
diff --git a/sound/soc/s3c24xx/h1940_uda1380.c b/sound/soc/s3c24xx/h1940_uda1380.c
new file mode 100644
index 0000000..8e21c5e
--- /dev/null
+++ b/sound/soc/s3c24xx/h1940_uda1380.c
@@ -0,0 +1,296 @@
+/*
+ * h1940-uda1380.c -- ALSA Soc Audio Layer
+ *
+ * Copyright (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
+ * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
+ *
+ * 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/module.h>
+#include <linux/moduleparam.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/gpio.h>
+
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/uda1380.h>
+#include <sound/jack.h>
+
+#include <plat/regs-iis.h>
+
+#include <mach/h1940-latch.h>
+
+#include <asm/mach-types.h>
+
+#include "s3c-dma.h"
+#include "s3c24xx-i2s.h"
+#include "../codecs/uda1380.h"
+
+static unsigned int rates[] = {
+ 11025,
+ 22050,
+ 44100,
+};
+
+static struct snd_pcm_hw_constraint_list hw_rates = {
+ .count = ARRAY_SIZE(rates),
+ .list = rates,
+ .mask = 0,
+};
+
+static struct snd_soc_jack hp_jack;
+
+static struct snd_soc_jack_pin hp_jack_pins[] = {
+ {
+ .pin = "Headphone Jack",
+ .mask = SND_JACK_HEADPHONE,
+ },
+ {
+ .pin = "Speaker",
+ .mask = SND_JACK_HEADPHONE,
+ .invert = 1,
+ },
+};
+
+static struct snd_soc_jack_gpio hp_jack_gpios[] = {
+ {
+ .gpio = S3C2410_GPG(4),
+ .name = "hp-gpio",
+ .report = SND_JACK_HEADPHONE,
+ .invert = 1,
+ .debounce_time = 200,
+ },
+};
+
+static int h1940_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+
+ runtime->hw.rate_min = hw_rates.list[0];
+ runtime->hw.rate_max = hw_rates.list[hw_rates.count - 1];
+ runtime->hw.rates = SNDRV_PCM_RATE_KNOT;
+
+ return snd_pcm_hw_constraint_list(runtime, 0,
+ SNDRV_PCM_HW_PARAM_RATE,
+ &hw_rates);
+}
+
+static int h1940_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 *cpu_dai = rtd->cpu_dai;
+ struct snd_soc_dai *codec_dai = rtd->codec_dai;
+ int div;
+ int ret;
+ unsigned int rate = params_rate(params);
+
+ switch (rate) {
+ case 11025:
+ case 22050:
+ case 44100:
+ div = s3c24xx_i2s_get_clockrate() / (384 * rate);
+ if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (192 * rate))
+ div++;
+ break;
+ default:
+ dev_err(&rtd->dev, "%s: rate %d is not supported\n",
+ __func__, rate);
+ return -EINVAL;
+ }
+
+ /* set codec DAI configuration */
+ 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;
+
+ /* set cpu DAI configuration */
+ 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;
+
+ /* select clock source */
+ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C24XX_CLKSRC_PCLK, rate,
+ SND_SOC_CLOCK_OUT);
+ if (ret < 0)
+ return ret;
+
+ /* set MCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_MCLK,
+ S3C2410_IISMOD_384FS);
+ if (ret < 0)
+ return ret;
+
+ /* set BCLK division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_BCLK,
+ S3C2410_IISMOD_32FS);
+ if (ret < 0)
+ return ret;
+
+ /* set prescaler division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C24XX_DIV_PRESCALER,
+ S3C24XX_PRESCALE(div, div));
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static struct snd_soc_ops h1940_ops = {
+ .startup = h1940_startup,
+ .hw_params = h1940_hw_params,
+};
+
+static int h1940_spk_power(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ if (SND_SOC_DAPM_EVENT_ON(event))
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 1);
+ else
+ gpio_set_value(H1940_LATCH_AUDIO_POWER, 0);
+
+ return 0;
+}
+
+/* h1940 machine dapm widgets */
+static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_MIC("Mic Jack", NULL),
+ SND_SOC_DAPM_SPK("Speaker", h1940_spk_power),
+};
+
+/* h1940 machine audio_map */
+static const struct snd_soc_dapm_route audio_map[] = {
+ /* headphone connected to VOUTLHP, VOUTRHP */
+ {"Headphone Jack", NULL, "VOUTLHP"},
+ {"Headphone Jack", NULL, "VOUTRHP"},
+
+ /* ext speaker connected to VOUTL, VOUTR */
+ {"Speaker", NULL, "VOUTL"},
+ {"Speaker", NULL, "VOUTR"},
+
+ /* mic is connected to VINM */
+ {"VINM", NULL, "Mic Jack"},
+};
+
+static struct platform_device *s3c24xx_snd_device;
+
+static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_codec *codec = rtd->codec;
+ int err;
+
+ /* Add h1940 specific widgets */
+ err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
+ ARRAY_SIZE(uda1380_dapm_widgets));
+ if (err)
+ return err;
+
+ /* Set up h1940 specific audio path audio_mapnects */
+ err = snd_soc_dapm_add_routes(codec, audio_map,
+ ARRAY_SIZE(audio_map));
+ if (err)
+ return err;
+
+ snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+ snd_soc_dapm_enable_pin(codec, "Speaker");
+ snd_soc_dapm_enable_pin(codec, "Mic Jack");
+
+ snd_soc_dapm_sync(codec);
+
+ snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
+ &hp_jack);
+
+ snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
+ hp_jack_pins);
+
+ snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+
+ return 0;
+}
+
+/* s3c24xx digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link h1940_uda1380_dai[] = {
+ {
+ .name = "uda1380",
+ .stream_name = "UDA1380 Duplex",
+ .cpu_dai_name = "s3c24xx-iis",
+ .codec_dai_name = "uda1380-hifi",
+ .init = h1940_uda1380_init,
+ .platform_name = "s3c24xx-pcm-audio",
+ .codec_name = "uda1380-codec.0-001a",
+ .ops = &h1940_ops,
+ },
+};
+
+static struct snd_soc_card h1940_asoc = {
+ .name = "h1940",
+ .dai_link = h1940_uda1380_dai,
+ .num_links = ARRAY_SIZE(h1940_uda1380_dai),
+};
+
+static int __init h1940_init(void)
+{
+ int ret;
+
+ if (!machine_is_h1940())
+ return -ENODEV;
+
+ /* configure some gpios */
+ ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
+ if (ret)
+ goto err_out;
+
+ ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
+ if (ret)
+ goto err_gpio;
+
+ s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
+ if (!s3c24xx_snd_device) {
+ ret = -ENOMEM;
+ goto err_gpio;
+ }
+
+ platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
+ ret = platform_device_add(s3c24xx_snd_device);
+
+ if (ret)
+ goto err_plat;
+
+ return 0;
+
+err_plat:
+ platform_device_put(s3c24xx_snd_device);
+err_gpio:
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+
+err_out:
+ return ret;
+}
+
+static void __exit h1940_exit(void)
+{
+ platform_device_unregister(s3c24xx_snd_device);
+ snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
+ hp_jack_gpios);
+ gpio_free(H1940_LATCH_AUDIO_POWER);
+}
+
+module_init(h1940_init);
+module_exit(h1940_exit);
+
+/* Module information */
+MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
+MODULE_DESCRIPTION("ALSA SoC H1940");
+MODULE_LICENSE("GPL");
--
1.7.2.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH RESEND v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-27 7:47 ` [PATCH RESEND " Vasily Khoruzhick
@ 2010-09-27 15:06 ` Mark Brown
2010-09-27 15:29 ` Vasily Khoruzhick
2010-10-15 7:49 ` Vasily khoruzhick
0 siblings, 2 replies; 21+ messages in thread
From: Mark Brown @ 2010-09-27 15:06 UTC (permalink / raw)
To: Vasily Khoruzhick
Cc: alsa-devel, Arnaud Patard (Rtp), Ben Dooks, Liam Girdwood
On Mon, Sep 27, 2010 at 10:47:48AM +0300, Vasily Khoruzhick wrote:
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
> ---
> This patch can be merged upstream now, since dependencies
> were merged into Ben's tree
We need to wait until Ben's tree has been merged into mainline and back
up into ASoC - probably after/during the next merge window - unless Ben
has a focused branch with this stuff on it which I can pull.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RESEND v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-27 15:06 ` Mark Brown
@ 2010-09-27 15:29 ` Vasily Khoruzhick
2010-10-15 7:49 ` Vasily khoruzhick
1 sibling, 0 replies; 21+ messages in thread
From: Vasily Khoruzhick @ 2010-09-27 15:29 UTC (permalink / raw)
To: alsa-devel; +Cc: Mark Brown, Ben Dooks, Arnaud Patard (Rtp), Liam Girdwood
On 27 of September 2010 18:06:10 Mark Brown wrote:
> On Mon, Sep 27, 2010 at 10:47:48AM +0300, Vasily Khoruzhick wrote:
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
> > ---
> > This patch can be merged upstream now, since dependencies
> > were merged into Ben's tree
>
> We need to wait until Ben's tree has been merged into mainline and back
> up into ASoC - probably after/during the next merge window - unless Ben
> has a focused branch with this stuff on it which I can pull.
Well, then it should be discussed with Ben.
Regards
Vasily
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RESEND v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-09-27 15:06 ` Mark Brown
2010-09-27 15:29 ` Vasily Khoruzhick
@ 2010-10-15 7:49 ` Vasily khoruzhick
2010-10-15 11:37 ` Mark Brown
1 sibling, 1 reply; 21+ messages in thread
From: Vasily khoruzhick @ 2010-10-15 7:49 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Ben Dooks, Arnaud Patard (Rtp), Liam Girdwood
[-- Attachment #1.1: Type: text/plain, Size: 745 bytes --]
On Mon, 27 Sep 2010 08:06:10 -0700
Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Mon, Sep 27, 2010 at 10:47:48AM +0300, Vasily Khoruzhick wrote:
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > Tested-by: Arnaud Patard <arnaud.patard@rtp-net.org>
> > ---
> > This patch can be merged upstream now, since dependencies
> > were merged into Ben's tree
>
> We need to wait until Ben's tree has been merged into mainline and back
> up into ASoC - probably after/during the next merge window - unless Ben
> has a focused branch with this stuff on it which I can pull.
Dependencies was merged into linux-next tonight, so I suspect this
patch can be merged if you pull from linux-next.
Regards,
Vasily
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RESEND v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-10-15 7:49 ` Vasily khoruzhick
@ 2010-10-15 11:37 ` Mark Brown
2010-10-15 12:52 ` Vasily khoruzhick
0 siblings, 1 reply; 21+ messages in thread
From: Mark Brown @ 2010-10-15 11:37 UTC (permalink / raw)
To: Vasily khoruzhick
Cc: alsa-devel, Ben Dooks, Arnaud Patard (Rtp), Liam Girdwood
On Fri, Oct 15, 2010 at 10:49:27AM +0300, Vasily khoruzhick wrote:
> Dependencies was merged into linux-next tonight, so I suspect this
> patch can be merged if you pull from linux-next.
-next is an integration tree which should never be merged into other
trees. I really need either Linus' tree or a specific branch I can
merge into ASoC.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RESEND v3 1/1] ASoC: Add HP iPAQ H1940 support
2010-10-15 11:37 ` Mark Brown
@ 2010-10-15 12:52 ` Vasily khoruzhick
0 siblings, 0 replies; 21+ messages in thread
From: Vasily khoruzhick @ 2010-10-15 12:52 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Ben Dooks, Arnaud Patard (Rtp), Liam Girdwood
[-- Attachment #1.1: Type: text/plain, Size: 734 bytes --]
On Fri, 15 Oct 2010 12:37:38 +0100
Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Fri, Oct 15, 2010 at 10:49:27AM +0300, Vasily khoruzhick wrote:
>
> > Dependencies was merged into linux-next tonight, so I suspect this
> > patch can be merged if you pull from linux-next.
>
> -next is an integration tree which should never be merged into other
> trees. I really need either Linus' tree or a specific branch I can
> merge into ASoC.
It's next-samsung from Ben's tree
(git://git.fluff.org/bjdooks/linux.git), I suspect it will be merged into
Linus' tree during 2.6.37 merge window, not sure if it's safe/ok to merge it
into ASoC right now. Let's wait for 2.6.37 merge window then.
Regards
Vasily
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2010-10-15 12:54 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-12 10:55 [PATCH] ASoC: Add HP iPAQ H1940 support Vasily Khoruzhick
2010-09-12 12:14 ` Jassi Brar
2010-09-12 12:15 ` Vasily Khoruzhick
2010-09-12 12:18 ` [PATCH v2 0/1] " Vasily Khoruzhick
2010-09-12 12:18 ` [PATCH v2 1/1] " Vasily Khoruzhick
2010-09-12 13:25 ` Marek Vasut
2010-09-12 17:07 ` Jassi Brar
2010-09-12 18:09 ` Vasily Khoruzhick
2010-09-13 1:09 ` Jassi Brar
2010-09-13 9:05 ` Mark Brown
2010-09-13 9:12 ` Vasily Khoruzhick
2010-09-13 9:47 ` [PATCH v3 0/1] " Vasily Khoruzhick
2010-09-13 9:47 ` [PATCH v3 1/1] " Vasily Khoruzhick
2010-09-20 10:38 ` Mark Brown
2010-09-27 7:47 ` [PATCH RESEND " Vasily Khoruzhick
2010-09-27 15:06 ` Mark Brown
2010-09-27 15:29 ` Vasily Khoruzhick
2010-10-15 7:49 ` Vasily khoruzhick
2010-10-15 11:37 ` Mark Brown
2010-10-15 12:52 ` Vasily khoruzhick
2010-09-13 9:07 ` [PATCH v2 " Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.