| Index: sound/soc/samsung/h1940_uda1380.c
|
| diff --git a/sound/soc/s3c24xx/rx1950_uda1380.c b/sound/soc/samsung/h1940_uda1380.c
|
| similarity index 54%
|
| copy from sound/soc/s3c24xx/rx1950_uda1380.c
|
| copy to sound/soc/samsung/h1940_uda1380.c
|
| index 468cc11fdf47abf84bc7a6b2dbcc5298bd6f16ce..241f55d0066070b299159c0f92f6f8836fed4ad5 100644
|
| --- a/sound/soc/s3c24xx/rx1950_uda1380.c
|
| +++ b/sound/soc/samsung/h1940_uda1380.c
|
| @@ -1,55 +1,33 @@
|
| /*
|
| - * rx1950.c -- ALSA Soc Audio Layer
|
| + * 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 smdk2440.c and magician.c
|
| + * Based on version from Arnaud Patard <arnaud.patard@rtp-net.org>
|
| *
|
| - * 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.
|
| + * 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 <linux/clk.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 <mach/h1940-latch.h>
|
| #include <asm/mach-types.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,
|
| + 11025,
|
| + 22050,
|
| 44100,
|
| - 48000,
|
| };
|
|
|
| static struct snd_pcm_hw_constraint_list hw_rates = {
|
| @@ -73,8 +51,8 @@ static struct snd_soc_jack_pin hp_jack_pins[] = {
|
| };
|
|
|
| static struct snd_soc_jack_gpio hp_jack_gpios[] = {
|
| - [0] = {
|
| - .gpio = S3C2410_GPG(12),
|
| + {
|
| + .gpio = S3C2410_GPG(4),
|
| .name = "hp-gpio",
|
| .report = SND_JACK_HEADPHONE,
|
| .invert = 1,
|
| @@ -82,55 +60,7 @@ static struct snd_soc_jack_gpio hp_jack_gpios[] = {
|
| },
|
| };
|
|
|
| -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 int rx1950_startup(struct snd_pcm_substream *substream)
|
| +static int h1940_startup(struct snd_pcm_substream *substream)
|
| {
|
| struct snd_pcm_runtime *runtime = substream->runtime;
|
|
|
| @@ -143,18 +73,7 @@ static int rx1950_startup(struct snd_pcm_substream *substream)
|
| &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_set_value(S3C2410_GPA(1), 1);
|
| - else
|
| - gpio_set_value(S3C2410_GPA(1), 0);
|
| -
|
| - return 0;
|
| -}
|
| -
|
| -static int rx1950_hw_params(struct snd_pcm_substream *substream,
|
| +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;
|
| @@ -163,25 +82,17 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
|
| 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_256FS;
|
| - div = s3c24xx_i2s_get_clockrate() / (256 * rate);
|
| - if (s3c24xx_i2s_get_clockrate() % (256 * rate) > (128 * rate))
|
| - div++;
|
| - break;
|
| + case 11025:
|
| + case 22050:
|
| case 44100:
|
| - case 88200:
|
| - clk_source = S3C24XX_CLKSRC_MPLL;
|
| - fs_mode = S3C2410_IISMOD_384FS;
|
| - div = 1;
|
| + 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",
|
| + dev_err(&rtd->dev, "%s: rate %d is not supported\n",
|
| __func__, rate);
|
| return -EINVAL;
|
| }
|
| @@ -199,14 +110,14 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
|
| return ret;
|
|
|
| /* select clock source */
|
| - ret = snd_soc_dai_set_sysclk(cpu_dai, clk_source, rate,
|
| + 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,
|
| - fs_mode);
|
| + S3C2410_IISMOD_384FS);
|
| if (ret < 0)
|
| return ret;
|
|
|
| @@ -225,29 +136,68 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
|
| return 0;
|
| }
|
|
|
| -static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
|
| +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;
|
| + struct snd_soc_dapm_context *dapm = &codec->dapm;
|
| int err;
|
|
|
| - /* Add rx1950 specific widgets */
|
| - err = snd_soc_dapm_new_controls(codec, uda1380_dapm_widgets,
|
| + /* Add h1940 specific widgets */
|
| + err = snd_soc_dapm_new_controls(dapm, uda1380_dapm_widgets,
|
| ARRAY_SIZE(uda1380_dapm_widgets));
|
| -
|
| if (err)
|
| return err;
|
|
|
| - /* Set up rx1950 specific audio path audio_mapnects */
|
| - err = snd_soc_dapm_add_routes(codec, audio_map,
|
| + /* Set up h1940 specific audio path audio_mapnects */
|
| + err = snd_soc_dapm_add_routes(dapm, 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(dapm, "Headphone Jack");
|
| + snd_soc_dapm_enable_pin(dapm, "Speaker");
|
| + snd_soc_dapm_enable_pin(dapm, "Mic Jack");
|
|
|
| - snd_soc_dapm_sync(codec);
|
| + snd_soc_dapm_sync(dapm);
|
|
|
| snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
|
| &hp_jack);
|
| @@ -261,59 +211,77 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
|
| return 0;
|
| }
|
|
|
| -static int __init rx1950_init(void)
|
| +/* 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 = "samsung-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_rx1950())
|
| + if (!machine_is_h1940())
|
| return -ENODEV;
|
|
|
| /* configure some gpios */
|
| - ret = gpio_request(S3C2410_GPA(1), "speaker-power");
|
| + ret = gpio_request(H1940_LATCH_AUDIO_POWER, "speaker-power");
|
| if (ret)
|
| - goto err_gpio;
|
| + goto err_out;
|
|
|
| - ret = gpio_direction_output(S3C2410_GPA(1), 0);
|
| + ret = gpio_direction_output(H1940_LATCH_AUDIO_POWER, 0);
|
| if (ret)
|
| - goto err_gpio_conf;
|
| + goto err_gpio;
|
|
|
| s3c24xx_snd_device = platform_device_alloc("soc-audio", -1);
|
| if (!s3c24xx_snd_device) {
|
| ret = -ENOMEM;
|
| - goto err_plat_alloc;
|
| + goto err_gpio;
|
| }
|
|
|
| - platform_set_drvdata(s3c24xx_snd_device, &rx1950_asoc);
|
| + platform_set_drvdata(s3c24xx_snd_device, &h1940_asoc);
|
| ret = platform_device_add(s3c24xx_snd_device);
|
|
|
| - if (ret) {
|
| - platform_device_put(s3c24xx_snd_device);
|
| - goto err_plat_add;
|
| - }
|
| + if (ret)
|
| + goto err_plat;
|
|
|
| return 0;
|
|
|
| -err_plat_add:
|
| -err_plat_alloc:
|
| -err_gpio_conf:
|
| - gpio_free(S3C2410_GPA(1));
|
| -
|
| +err_plat:
|
| + platform_device_put(s3c24xx_snd_device);
|
| err_gpio:
|
| + gpio_free(H1940_LATCH_AUDIO_POWER);
|
| +
|
| +err_out:
|
| return ret;
|
| }
|
|
|
| -static void __exit rx1950_exit(void)
|
| +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(S3C2410_GPA(1));
|
| + gpio_free(H1940_LATCH_AUDIO_POWER);
|
| }
|
|
|
| -module_init(rx1950_init);
|
| -module_exit(rx1950_exit);
|
| +module_init(h1940_init);
|
| +module_exit(h1940_exit);
|
|
|
| /* Module information */
|
| -MODULE_AUTHOR("Vasily Khoruzhick");
|
| -MODULE_DESCRIPTION("ALSA SoC RX1950");
|
| +MODULE_AUTHOR("Arnaud Patard, Vasily Khoruzhick");
|
| +MODULE_DESCRIPTION("ALSA SoC H1940");
|
| MODULE_LICENSE("GPL");
|
|
|