From: Marek Vasut <marek.vasut@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Vasily Khoruzhick <anarsoul@gmail.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Ben Dooks <ben-linux@fluff.org>,
Philipp Zabel <philipp.zabel@gmail.com>,
Liam Girdwood <lrg@slimlogic.co.uk>
Subject: Re: [PATCH v4 2/3] ASoC: Add HP iPAQ RX1950 support
Date: Sun, 29 Aug 2010 19:39:39 +0200 [thread overview]
Message-ID: <201008291939.39530.marek.vasut@gmail.com> (raw)
In-Reply-To: <1283101872-6410-3-git-send-email-anarsoul@gmail.com>
Dne Ne 29. srpna 2010 19:11:11 Vasily Khoruzhick napsal(a):
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> sound/soc/s3c24xx/Kconfig | 8 +
> sound/soc/s3c24xx/Makefile | 2 +
> sound/soc/s3c24xx/rx1950_uda1380.c | 326
> ++++++++++++++++++++++++++++++++++++ 3 files changed, 336 insertions(+), 0
> deletions(-)
> create mode 100644 sound/soc/s3c24xx/rx1950_uda1380.c
>
> diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
> index 1cdc37bd..7d8235d 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_RX1950_UDA1380
> + tristate "Audio support for the HP iPAQ RX1950"
> + depends on SND_S3C24XX_SOC && MACH_RX1950
> + select SND_S3C24XX_SOC_I2S
> + select SND_SOC_UDA1380
> + help
> + This driver provides audio support for HP iPAQ RX1950 PDA.
> +
> config SND_SOC_SMDK_WM9713
> tristate "SoC AC97 Audio support for SMDK with WM9713"
> depends on SND_S3C24XX_SOC && (MACH_SMDK6410 || MACH_SMDKC100 ||
> MACH_SMDKV210 || MACH_SMDKC110) diff --git a/sound/soc/s3c24xx/Makefile
> b/sound/soc/s3c24xx/Makefile index 47ed6d7..dd412a9 100644
> --- a/sound/soc/s3c24xx/Makefile
> +++ b/sound/soc/s3c24xx/Makefile
> @@ -27,6 +27,7 @@ snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o
> 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-smdk64xx-wm8580-objs := smdk64xx_wm8580.o
> snd-soc-smdk-wm9713-objs := smdk_wm9713.o
> snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
> @@ -42,6 +43,7 @@ obj-$(CONFIG_SND_S3C24XX_SOC_S3C24XX_UDA134X) +=
> snd-soc-s3c24xx-uda134x.o 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_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/rx1950_uda1380.c
> b/sound/soc/s3c24xx/rx1950_uda1380.c new file mode 100644
> index 0000000..c653c13
> --- /dev/null
> +++ b/sound/soc/s3c24xx/rx1950_uda1380.c
> @@ -0,0 +1,326 @@
> +/*
> + * rx1950.c -- ALSA Soc Audio Layer
> + *
> + * Copyright (c) 2010 Vasily Khoruzhick <anarsoul@gmail.com>
> + *
> + * Based on smdk2440.c and magician.c
> + *
> + * Authors: Graeme Gregory graeme.gregory@wolfsonmicro.com
> + * Philipp Zabel <philipp.zabel@gmail.com>
> + * Denis Grigoriev <dgreenday@gmail.com>
> + * Vasily Khoruzhick <anarsoul@gmail.com>
> + *
> + * 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/timer.h>
> +#include <linux/delay.h>
> +#include <linux/interrupt.h>
> +#include <linux/platform_device.h>
> +#include <linux/spinlock.h>
> +#include <linux/i2c.h>
> +#include <linux/gpio.h>
> +#include <linux/clk.h>
> +
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/pcm_params.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/regs-clock.h>
> +
> +#include "s3c-dma.h"
> +#include "s3c24xx-i2s.h"
> +#include "../codecs/uda1380.h"
> +
> +static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd);
> +static int rx1950_startup(struct snd_pcm_substream *substream);
> +static int rx1950_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params);
> +static int rx1950_spk_power(struct snd_soc_dapm_widget *w,
> + struct snd_kcontrol *kcontrol, int event);
> +
> +static unsigned int rates[] = {
> + 16000,
> + 44100,
> + 48000,
> + 88200,
> +};
> +
> +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[] = {
> + [0] = {
> + .gpio = S3C2410_GPG(12),
> + .name = "hp-gpio",
> + .report = SND_JACK_HEADPHONE,
> + .invert = 1,
> + .debounce_time = 200,
> + },
> +};
> +
> +static struct snd_soc_ops rx1950_ops = {
> + .startup = rx1950_startup,
> + .hw_params = rx1950_hw_params,
> +};
> +
> +/* s3c24xx digital audio interface glue - connects codec <--> CPU */
> +static struct snd_soc_dai_link rx1950_uda1380_dai[] = {
> + {
> + .name = "uda1380",
> + .stream_name = "UDA1380 Duplex",
> + .cpu_dai_name = "s3c24xx-iis",
> + .codec_dai_name = "uda1380-hifi",
> + .init = rx1950_uda1380_init,
> + .platform_name = "s3c24xx-pcm-audio",
> + .codec_name = "uda1380-codec.0-001a",
> + .ops = &rx1950_ops,
> + },
> +};
> +
> +static struct snd_soc_card rx1950_asoc = {
> + .name = "rx1950",
> + .dai_link = rx1950_uda1380_dai,
> + .num_links = ARRAY_SIZE(rx1950_uda1380_dai),
> +};
> +
> +/* rx1950 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", rx1950_spk_power),
> +};
> +
> +/* rx1950 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 struct clk *xtal;
> +
> +static int rx1950_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 rx1950_spk_power(struct snd_soc_dapm_widget *w,
> + struct snd_kcontrol *kcontrol, int event)
> +{
> + if (SND_SOC_DAPM_EVENT_ON(event))
> + gpio_direction_output(S3C2410_GPA(1), 1);
> + else
> + gpio_direction_output(S3C2410_GPA(1), 0);
gpio_set_value()
> +
> + return 0;
> +}
> +
> +static int rx1950_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);
> + int clk_source, fs_mode;
> +
> + switch (rate) {
> + case 16000:
> + case 48000:
> + clk_source = S3C24XX_CLKSRC_PCLK;
> + fs_mode = S3C2410_IISMOD_384FS;
> + div = s3c24xx_i2s_get_clockrate() / (384 * rate);
> + if (s3c24xx_i2s_get_clockrate() % (384 * rate) > (182 * rate))
> + div++;
> + break;
> + case 44100:
> + case 88200:
> + clk_source = S3C24XX_CLKSRC_MPLL;
> + fs_mode = S3C2410_IISMOD_256FS;
> + div = clk_get_rate(xtal) / (256 * rate);
> + if (clk_get_rate(xtal) % (256 * rate) > (128 * 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, clk_source, 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 int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
> +{
> + struct snd_soc_codec *codec = rtd->codec;
> + int err;
> +
> + /* Add rx1950 specific widgets */
> + snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
> + ARRAY_SIZE(uda1380_dapm_widgets));
> +
> + /* Set up rx1950 specific audio path audio_mapnects */
> + err = snd_soc_dapm_add_routes(codec, audio_map,
> + ARRAY_SIZE(audio_map));
> +
Handle return values
> + snd_soc_dapm_enable_pin(codec, "Headphone Jack");
> + snd_soc_dapm_enable_pin(codec, "Speaker");
> +
> + 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;
> +}
> +
> +static int __init rx1950_init(void)
> +{
> + int ret;
> +
> + /* configure some gpios */
> + ret = gpio_request(S3C2410_GPA(1), "speaker-power");
> + if (ret)
> + goto err_gpio;
> +
> + gpio_direction_output(S3C2410_GPA(1), 0);
Again, use gpio_set_value() after this and handle return value of
gpio_direction_output().
> +
> + s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
> + if (!s3c24xx_snd_device) {
> + ret = -ENOMEM;
> + goto err_plat_alloc;
> + }
> +
> + platform_set_drvdata(s3c24xx_snd_device, &rx1950_asoc);
> + ret = platform_device_add(s3c24xx_snd_device);
> +
> + if (ret) {
> + platform_device_put(s3c24xx_snd_device);
> + goto err_plat_add;
> + }
> +
> + xtal = clk_get(&s3c24xx_snd_device->dev, "xtal");
> +
> + if (IS_ERR(xtal)) {
> + ret = PTR_ERR(xtal);
> + platform_device_unregister(s3c24xx_snd_device);
> + goto err_clk;
> + }
> +
> + return 0;
> +
> +err_clk:
> +err_plat_add:
> +err_plat_alloc:
> + gpio_free(S3C2410_GPA(1));
> +
> +err_gpio:
> + return ret;
> +}
> +
> +static void __exit rx1950_exit(void)
> +{
> + platform_device_unregister(s3c24xx_snd_device);
> + snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
> + hp_jack_gpios);
> + clk_put(xtal);
> + gpio_free(S3C2410_GPA(1));
> +}
> +
> +module_init(rx1950_init);
> +module_exit(rx1950_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Vasily Khoruzhick");
> +MODULE_DESCRIPTION("ALSA SoC RX1950");
> +MODULE_LICENSE("GPL");
next prev parent reply other threads:[~2010-08-29 17:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-29 17:11 [PATCH v4 0/3] ASoC: Add iPAQ RX1950 support Vasily Khoruzhick
2010-08-29 17:11 ` [PATCH v4 1/3] ASoC: uda1380: make driver more powersave-friendly Vasily Khoruzhick
2010-08-29 17:37 ` Marek Vasut
2010-08-29 18:13 ` Vasily Khoruzhick
2010-08-29 19:11 ` Marek Vasut
2010-08-29 18:50 ` [PATCH v5 " Vasily Khoruzhick
2010-08-29 19:33 ` [PATCH v6 " Vasily Khoruzhick
2010-08-29 17:11 ` [PATCH v4 2/3] ASoC: Add HP iPAQ RX1950 support Vasily Khoruzhick
2010-08-29 17:39 ` Marek Vasut [this message]
2010-08-29 18:15 ` Vasily Khoruzhick
2010-08-29 18:53 ` [PATCH v5 " Vasily Khoruzhick
2010-08-29 19:16 ` Marek Vasut
2010-08-29 17:11 ` [PATCH v4 3/3] ARM: S3C24XX: I2S multi-component-related fixes Vasily Khoruzhick
2010-08-29 17:41 ` Marek Vasut
2010-08-29 17:47 ` Vasily Khoruzhick
2010-08-29 19:12 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201008291939.39530.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=anarsoul@gmail.com \
--cc=ben-linux@fluff.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@slimlogic.co.uk \
--cc=philipp.zabel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.