* [PATCH 0/4] ASoC updates
@ 2008-11-05 18:52 Mark Brown
2008-11-05 18:53 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Mark Brown
0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-11-05 18:52 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
The following changes since commit 0ee4663617fb0f78cec4cc6558a096ccbd8c3ffc:
Takashi Iwai (1):
ALSA: ASoC - Remove unnecessary inclusion of linux/version.h
are available in the git repository at:
git://opensource.wolfsonmicro.com/linux-2.6-asoc for-tiwai
David Anders (1):
ASoC: Add new parameter to s3c24xx_pcm_enqueue
Marek Vasut (1):
ASoC: Add Palm/PXA27x unified ASoC audio driver
Mark Brown (1):
ASoC: Remove core version number
Troy Kisky (1):
ASoC: TLV320AIC23B Support more sample rates
arch/arm/mach-pxa/include/mach/palmasoc.h | 13 ++
include/sound/soc.h | 2 -
sound/soc/codecs/tlv320aic23.c | 227 +++++++++++++++++++-----
sound/soc/pxa/Kconfig | 9 +
sound/soc/pxa/Makefile | 2 +
sound/soc/pxa/palm27x.c | 269 +++++++++++++++++++++++++++++
sound/soc/s3c24xx/s3c24xx-pcm.c | 12 +-
sound/soc/soc-core.c | 1 -
8 files changed, 483 insertions(+), 52 deletions(-)
create mode 100644 arch/arm/mach-pxa/include/mach/palmasoc.h
create mode 100644 sound/soc/pxa/palm27x.c
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
2008-11-05 18:52 [PATCH 0/4] ASoC updates Mark Brown
@ 2008-11-05 18:53 ` Mark Brown
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Mark Brown @ 2008-11-05 18:53 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Mark Brown, Troy Kisky
From: Troy Kisky <troy.kisky@boundarydevices.com>
Add support for more sample rates, different crystals
and split playback/capture rates.
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Arun KS <arunks@mistralsolutions.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/codecs/tlv320aic23.c | 227 ++++++++++++++++++++++++++++++++--------
1 files changed, 182 insertions(+), 45 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index 44308da..c1b2060 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -37,12 +37,6 @@
#define AIC23_VERSION "0.1"
-struct tlv320aic23_srate_reg_info {
- u32 sample_rate;
- u8 control; /* SR3, SR2, SR1, SR0 and BOSR */
- u8 divider; /* if 0 CLKIN = MCLK, if 1 CLKIN = MCLK/2 */
-};
-
/*
* AIC23 register cache
*/
@@ -261,19 +255,155 @@ static const struct snd_soc_dapm_route intercon[] = {
};
-/* tlv320aic23 related */
-static const struct tlv320aic23_srate_reg_info srate_reg_info[] = {
- {4000, 0x06, 1}, /* 4000 */
- {8000, 0x06, 0}, /* 8000 */
- {16000, 0x0C, 1}, /* 16000 */
- {22050, 0x11, 1}, /* 22050 */
- {24000, 0x00, 1}, /* 24000 */
- {32000, 0x0C, 0}, /* 32000 */
- {44100, 0x11, 0}, /* 44100 */
- {48000, 0x00, 0}, /* 48000 */
- {88200, 0x1F, 0}, /* 88200 */
- {96000, 0x0E, 0}, /* 96000 */
+/* AIC23 driver data */
+struct aic23 {
+ struct snd_soc_codec codec;
+ int mclk;
+ int requested_adc;
+ int requested_dac;
+};
+
+/*
+ * Common Crystals used
+ * 11.2896 Mhz /128 = *88.2k /192 = 58.8k
+ * 12.0000 Mhz /125 = *96k /136 = 88.235K
+ * 12.2880 Mhz /128 = *96k /192 = 64k
+ * 16.9344 Mhz /128 = 132.3k /192 = *88.2k
+ * 18.4320 Mhz /128 = 144k /192 = *96k
+ */
+
+/*
+ * Normal BOSR 0-256/2 = 128, 1-384/2 = 192
+ * USB BOSR 0-250/2 = 125, 1-272/2 = 136
+ */
+static const int bosr_usb_divisor_table[] = {
+ 128, 125, 192, 136
+};
+#define LOWER_GROUP ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<6) | (1<<7))
+#define UPPER_GROUP ((1<<8) | (1<<9) | (1<<10) | (1<<11) | (1<<15))
+static const unsigned short sr_valid_mask[] = {
+ LOWER_GROUP|UPPER_GROUP, /* Normal, bosr - 0*/
+ LOWER_GROUP|UPPER_GROUP, /* Normal, bosr - 1*/
+ LOWER_GROUP, /* Usb, bosr - 0*/
+ UPPER_GROUP, /* Usb, bosr - 1*/
+};
+/*
+ * Every divisor is a factor of 11*12
+ */
+#define SR_MULT (11*12)
+#define A(x) (x) ? (SR_MULT/x) : 0
+static const unsigned char sr_adc_mult_table[] = {
+ A(2), A(2), A(12), A(12), A(0), A(0), A(3), A(1),
+ A(2), A(2), A(11), A(11), A(0), A(0), A(0), A(1)
};
+static const unsigned char sr_dac_mult_table[] = {
+ A(2), A(12), A(2), A(12), A(0), A(0), A(3), A(1),
+ A(2), A(11), A(2), A(11), A(0), A(0), A(0), A(1)
+};
+
+unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
+ int dac, int dac_l, int dac_h, int need_dac)
+{
+ if ((adc >= adc_l) && (adc <= adc_h) &&
+ (dac >= dac_l) && (dac <= dac_h)) {
+ unsigned diff_adc = need_adc - adc;
+ unsigned diff_dac = need_dac - dac;
+ unsigned score;
+ if (((int)diff_adc) < 0)
+ diff_adc = -diff_adc;
+ if (((int)diff_dac) < 0)
+ diff_dac = -diff_dac;
+ score = diff_adc + diff_dac;
+ return score;
+ }
+ return 0xffffffff;
+}
+int find_rate(int mclk, u32 need_adc, u32 need_dac)
+{
+ int i, j;
+ int best_i = -1;
+ int best_j = -1;
+ int best_div = 0;
+ unsigned best_score = 0xffffffff;
+ int adc_l, adc_h, dac_l, dac_h;
+
+ need_adc *= SR_MULT;
+ need_dac *= SR_MULT;
+ /*
+ * rates given are +/- 1/32
+ */
+ adc_l = need_adc - (need_adc >> 5);
+ adc_h = need_adc + (need_adc >> 5);
+ dac_l = need_dac - (need_dac >> 5);
+ dac_h = need_dac + (need_dac >> 5);
+ for (i = 0; i < 4; i++) {
+ int base = mclk / bosr_usb_divisor_table[i];
+ int mask = sr_valid_mask[i];
+ for (j = 0; j < 16; j++, mask >>= 1) {
+ int adc;
+ int dac;
+ int score;
+ if ((mask & 1) == 0)
+ continue;
+ adc = base * sr_adc_mult_table[j];
+ dac = base * sr_dac_mult_table[j];
+ score = get_score(adc, adc_l, adc_h, need_adc,
+ dac, dac_l, dac_h, need_dac);
+ if (best_score > score) {
+ best_score = score;
+ best_i = i;
+ best_j = j;
+ best_div = 0;
+ }
+ score = get_score((adc >> 1), adc_l, adc_h, need_adc,
+ (dac >> 1), dac_l, dac_h, need_dac);
+ /* prefer to have a /2 */
+ if ((score != 0xffffffff) && (best_score >= score)) {
+ best_score = score;
+ best_i = i;
+ best_j = j;
+ best_div = 1;
+ }
+ }
+ }
+ return (best_j << 2) | best_i | (best_div << TLV320AIC23_CLKIN_SHIFT);
+}
+
+static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk,
+ u32 *sample_rate_adc, u32 *sample_rate_dac)
+{
+ int src = tlv320aic23_read_reg_cache(codec, TLV320AIC23_SRATE);
+ int sr = (src >> 2) & 0x0f;
+ int val = (mclk / bosr_usb_divisor_table[src & 3]);
+ int adc = (val * sr_adc_mult_table[sr]) / SR_MULT;
+ int dac = (val * sr_dac_mult_table[sr]) / SR_MULT;
+ if (src & TLV320AIC23_CLKIN_HALF) {
+ adc >>= 1;
+ dac >>= 1;
+ }
+ *sample_rate_adc = adc;
+ *sample_rate_dac = dac;
+}
+
+static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk,
+ u32 sample_rate_adc, u32 sample_rate_dac)
+{
+ /* Search for the right sample rate */
+ int data = find_rate(mclk, sample_rate_adc, sample_rate_dac);
+ if (data < 0) {
+ printk(KERN_ERR "%s:Invalid rate %u,%u requested\n",
+ __func__, sample_rate_adc, sample_rate_dac);
+ return -EINVAL;
+ }
+ tlv320aic23_write(codec, TLV320AIC23_SRATE, data);
+ if (1) {
+ int adc, dac;
+ get_current_sample_rates(codec, mclk, &adc, &dac);
+ printk(KERN_DEBUG "actual samplerate = %u,%u reg=%x\n",
+ adc, dac, data);
+ }
+ return 0;
+}
static int tlv320aic23_add_widgets(struct snd_soc_codec *codec)
{
@@ -293,27 +423,30 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_codec *codec = socdev->codec;
- u16 iface_reg, data;
- u8 count = 0;
+ u16 iface_reg;
+ int ret;
+ struct aic23 *aic23 = container_of(codec, struct aic23, codec);
+ u32 sample_rate_adc = aic23->requested_adc;
+ u32 sample_rate_dac = aic23->requested_dac;
+ u32 sample_rate = params_rate(params);
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ aic23->requested_dac = sample_rate_dac = sample_rate;
+ if (!sample_rate_adc)
+ sample_rate_adc = sample_rate;
+ } else {
+ aic23->requested_adc = sample_rate_adc = sample_rate;
+ if (!sample_rate_dac)
+ sample_rate_dac = sample_rate;
+ }
+ ret = set_sample_rate_control(codec, aic23->mclk, sample_rate_adc,
+ sample_rate_dac);
+ if (ret < 0)
+ return ret;
iface_reg =
tlv320aic23_read_reg_cache(codec,
TLV320AIC23_DIGT_FMT) & ~(0x03 << 2);
-
- /* Search for the right sample rate */
- /* Verify what happens if the rate is not supported
- * now it goes to 96Khz */
- while ((srate_reg_info[count].sample_rate != params_rate(params)) &&
- (count < ARRAY_SIZE(srate_reg_info))) {
- count++;
- }
-
- data = (srate_reg_info[count].divider << TLV320AIC23_CLKIN_SHIFT) |
- (srate_reg_info[count]. control << TLV320AIC23_BOSR_SHIFT) |
- TLV320AIC23_USB_CLK_ON;
-
- tlv320aic23_write(codec, TLV320AIC23_SRATE, data);
-
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
break;
@@ -349,12 +482,17 @@ static void tlv320aic23_shutdown(struct snd_pcm_substream *substream)
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_codec *codec = socdev->codec;
+ struct aic23 *aic23 = container_of(codec, struct aic23, codec);
/* deactivate */
if (!codec->active) {
udelay(50);
tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0);
}
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ aic23->requested_dac = 0;
+ else
+ aic23->requested_adc = 0;
}
static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute)
@@ -422,12 +560,9 @@ static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{
struct snd_soc_codec *codec = codec_dai->codec;
-
- switch (freq) {
- case 12000000:
- return 0;
- }
- return -EINVAL;
+ struct aic23 *aic23 = container_of(codec, struct aic23, codec);
+ aic23->mclk = freq;
+ return 0;
}
static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec,
@@ -659,14 +794,15 @@ static int tlv320aic23_probe(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_codec *codec;
+ struct aic23 *aic23;
int ret = 0;
printk(KERN_INFO "AIC23 Audio Codec %s\n", AIC23_VERSION);
- codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
- if (codec == NULL)
+ aic23 = kzalloc(sizeof(struct aic23), GFP_KERNEL);
+ if (aic23 == NULL)
return -ENOMEM;
-
+ codec = &aic23->codec;
socdev->codec = codec;
mutex_init(&codec->mutex);
INIT_LIST_HEAD(&codec->dapm_widgets);
@@ -687,6 +823,7 @@ static int tlv320aic23_remove(struct platform_device *pdev)
{
struct snd_soc_device *socdev = platform_get_drvdata(pdev);
struct snd_soc_codec *codec = socdev->codec;
+ struct aic23 *aic23 = container_of(codec, struct aic23, codec);
if (codec->control_data)
tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_OFF);
@@ -697,7 +834,7 @@ static int tlv320aic23_remove(struct platform_device *pdev)
i2c_del_driver(&tlv320aic23_i2c_driver);
#endif
kfree(codec->reg_cache);
- kfree(codec);
+ kfree(aic23);
return 0;
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver
2008-11-05 18:53 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Mark Brown
@ 2008-11-05 18:53 ` Mark Brown
2008-11-05 18:53 ` [PATCH 3/4] ASoC: Remove core version number Mark Brown
` (2 more replies)
2008-11-05 20:35 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Takashi Iwai
2008-11-06 11:23 ` Takashi Iwai
2 siblings, 3 replies; 15+ messages in thread
From: Mark Brown @ 2008-11-05 18:53 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Marek Vasut, alsa-devel, Mark Brown
From: Marek Vasut <marek.vasut@gmail.com>
this patch adds asoc audio driver for pxa27x based Palm PDAs. I tested it for
palmtx, t5 and ld, it should work with palmz72 as well (slapin, please test).
I sent it here some time ago, but now I got to fixing bugs in it. It should
be somehow mostly ok and ready for applying.
[Converted to use snd_soc_dapm_nc_pin() -- broonie]
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
arch/arm/mach-pxa/include/mach/palmasoc.h | 13 ++
sound/soc/pxa/Kconfig | 9 +
sound/soc/pxa/Makefile | 2 +
sound/soc/pxa/palm27x.c | 269 +++++++++++++++++++++++++++++
4 files changed, 293 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-pxa/include/mach/palmasoc.h
create mode 100644 sound/soc/pxa/palm27x.c
diff --git a/arch/arm/mach-pxa/include/mach/palmasoc.h b/arch/arm/mach-pxa/include/mach/palmasoc.h
new file mode 100644
index 0000000..6c4b1f7
--- /dev/null
+++ b/arch/arm/mach-pxa/include/mach/palmasoc.h
@@ -0,0 +1,13 @@
+#ifndef _INCLUDE_PALMASOC_H_
+#define _INCLUDE_PALMASOC_H_
+struct palm27x_asoc_info {
+ int jack_gpio;
+};
+
+#ifdef CONFIG_SND_PXA2XX_SOC_PALM27X
+void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data);
+#else
+static inline void palm27x_asoc_set_pdata(struct palm27x_asoc_info *data) {}
+#endif
+
+#endif
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 4235524..1187603 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -79,6 +79,15 @@ config SND_PXA2XX_SOC_EM_X270
Say Y if you want to add support for SoC audio on
CompuLab EM-x270.
+config SND_PXA2XX_SOC_PALM27X
+ tristate "SoC Audio support for Palm T|X, T5 and LifeDrive"
+ depends on SND_PXA2XX_SOC && (MACH_PALMLD || MACH_PALMTX || MACH_PALMT5)
+ select SND_PXA2XX_SOC_AC97
+ select SND_SOC_WM9712
+ help
+ Say Y if you want to add support for SoC audio on
+ Palm T|X, T5 or LifeDrive handheld computer.
+
config SND_SOC_ZYLONITE
tristate "SoC Audio support for Marvell Zylonite"
depends on SND_PXA2XX_SOC && MACH_ZYLONITE
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index 00258ab..1a3a36e 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -16,6 +16,7 @@ snd-soc-tosa-objs := tosa.o
snd-soc-e800-objs := e800_wm9712.o
snd-soc-spitz-objs := spitz.o
snd-soc-em-x270-objs := em-x270.o
+snd-soc-palm27x-objs := palm27x.o
obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o
@@ -23,3 +24,4 @@ obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o
obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
+obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
new file mode 100644
index 0000000..e364abc
--- /dev/null
+++ b/sound/soc/pxa/palm27x.c
@@ -0,0 +1,269 @@
+/*
+ * linux/sound/soc/pxa/palm27x.c
+ *
+ * SoC Audio driver for Palm T|X, T5 and LifeDrive
+ *
+ * based on tosa.c
+ *
+ * Copyright (C) 2008 Marek Vasut <marek.vasut@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+#include <mach/audio.h>
+#include <mach/palmasoc.h>
+
+#include "../codecs/wm9712.h"
+#include "pxa2xx-pcm.h"
+#include "pxa2xx-ac97.h"
+
+static int palm27x_jack_func = 1;
+static int palm27x_spk_func = 1;
+static int palm27x_ep_gpio = -1;
+
+static void palm27x_ext_control(struct snd_soc_codec *codec)
+{
+ if (!palm27x_spk_func)
+ snd_soc_dapm_enable_pin(codec, "Speaker");
+ else
+ snd_soc_dapm_disable_pin(codec, "Speaker");
+
+ if (!palm27x_jack_func)
+ snd_soc_dapm_enable_pin(codec, "Headphone Jack");
+ else
+ snd_soc_dapm_disable_pin(codec, "Headphone Jack");
+
+ snd_soc_dapm_sync(codec);
+}
+
+static int palm27x_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_codec *codec = rtd->socdev->codec;
+
+ /* check the jack status at stream startup */
+ palm27x_ext_control(codec);
+ return 0;
+}
+
+static struct snd_soc_ops palm27x_ops = {
+ .startup = palm27x_startup,
+};
+
+static irqreturn_t palm27x_interrupt(int irq, void *v)
+{
+ palm27x_spk_func = gpio_get_value(palm27x_ep_gpio);
+ palm27x_jack_func = !palm27x_spk_func;
+ return IRQ_HANDLED;
+}
+
+static int palm27x_get_jack(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ ucontrol->value.integer.value[0] = palm27x_jack_func;
+ return 0;
+}
+
+static int palm27x_set_jack(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+
+ if (palm27x_jack_func == ucontrol->value.integer.value[0])
+ return 0;
+
+ palm27x_jack_func = ucontrol->value.integer.value[0];
+ palm27x_ext_control(codec);
+ return 1;
+}
+
+static int palm27x_get_spk(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ ucontrol->value.integer.value[0] = palm27x_spk_func;
+ return 0;
+}
+
+static int palm27x_set_spk(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+
+ if (palm27x_spk_func == ucontrol->value.integer.value[0])
+ return 0;
+
+ palm27x_spk_func = ucontrol->value.integer.value[0];
+ palm27x_ext_control(codec);
+ return 1;
+}
+
+/* PalmTX machine dapm widgets */
+static const struct snd_soc_dapm_widget palm27x_dapm_widgets[] = {
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_SPK("Speaker", NULL),
+};
+
+/* PalmTX audio map */
+static const struct snd_soc_dapm_route audio_map[] = {
+ /* headphone connected to HPOUTL, HPOUTR */
+ {"Headphone Jack", NULL, "HPOUTL"},
+ {"Headphone Jack", NULL, "HPOUTR"},
+
+ /* ext speaker connected to ROUT2, LOUT2 */
+ {"Speaker", NULL, "LOUT2"},
+ {"Speaker", NULL, "ROUT2"},
+};
+
+static const char *jack_function[] = {"Headphone", "Off"};
+static const char *spk_function[] = {"On", "Off"};
+static const struct soc_enum palm27x_enum[] = {
+ SOC_ENUM_SINGLE_EXT(2, jack_function),
+ SOC_ENUM_SINGLE_EXT(2, spk_function),
+};
+
+static const struct snd_kcontrol_new palm27x_controls[] = {
+ SOC_ENUM_EXT("Jack Function", palm27x_enum[0], palm27x_get_jack,
+ palm27x_set_jack),
+ SOC_ENUM_EXT("Speaker Function", palm27x_enum[1], palm27x_get_spk,
+ palm27x_set_spk),
+};
+
+static int palm27x_ac97_init(struct snd_soc_codec *codec)
+{
+ int i, err;
+
+ snd_soc_dapm_nc_pin(codec, "OUT3");
+ snd_soc_dapm_nc_pin(codec, "MONOOUT");
+
+ /* add palm27x specific controls */
+ for (i = 0; i < ARRAY_SIZE(palm27x_controls); i++) {
+ err = snd_ctl_add(codec->card,
+ snd_soc_cnew(&palm27x_controls[i],
+ codec, NULL));
+ if (err < 0)
+ return err;
+ }
+
+ /* add palm27x specific widgets */
+ snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets,
+ ARRAY_SIZE(palm27x_dapm_widgets));
+
+ /* set up palm27x specific audio path audio_map */
+ snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
+
+ snd_soc_dapm_sync(codec);
+ return 0;
+}
+
+static struct snd_soc_dai_link palm27x_dai[] = {
+{
+ .name = "AC97 HiFi",
+ .stream_name = "AC97 HiFi",
+ .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
+ .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI],
+ .init = palm27x_ac97_init,
+ .ops = &palm27x_ops,
+},
+{
+ .name = "AC97 Aux",
+ .stream_name = "AC97 Aux",
+ .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX],
+ .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX],
+ .ops = &palm27x_ops,
+},
+};
+
+static struct snd_soc_machine palm27x_asoc = {
+ .name = "Palm/PXA27x",
+ .dai_link = palm27x_dai,
+ .num_links = ARRAY_SIZE(palm27x_dai),
+};
+
+static struct snd_soc_device palm27x_snd_devdata = {
+ .machine = &palm27x_asoc,
+ .platform = &pxa2xx_soc_platform,
+ .codec_dev = &soc_codec_dev_wm9712,
+};
+
+static struct platform_device *palm27x_snd_device;
+
+static int __init palm27x_asoc_init(void)
+{
+ int ret;
+
+ if (!(machine_is_palmtx() || machine_is_palmt5() ||
+ machine_is_palmld()))
+ return -ENODEV;
+
+ ret = gpio_request(palm27x_ep_gpio, "Headphone Jack");
+ if (ret)
+ return ret;
+ ret = gpio_direction_input(palm27x_ep_gpio);
+ if (ret)
+ goto err_alloc;
+
+ if (request_irq(gpio_to_irq(palm27x_ep_gpio), palm27x_interrupt,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+ "Headphone jack", NULL))
+ goto err_alloc;
+
+ palm27x_snd_device = platform_device_alloc("soc-audio", -1);
+ if (!palm27x_snd_device) {
+ ret = -ENOMEM;
+ goto err_dev;
+ }
+
+ platform_set_drvdata(palm27x_snd_device, &palm27x_snd_devdata);
+ palm27x_snd_devdata.dev = &palm27x_snd_device->dev;
+ ret = platform_device_add(palm27x_snd_device);
+
+ if (ret != 0)
+ goto put_device;
+
+ return 0;
+
+put_device:
+ platform_device_put(palm27x_snd_device);
+err_dev:
+ free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
+err_alloc:
+ gpio_free(palm27x_ep_gpio);
+
+ return ret;
+}
+
+static void __exit palm27x_asoc_exit(void)
+{
+ free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
+ gpio_free(palm27x_ep_gpio);
+ platform_device_unregister(palm27x_snd_device);
+}
+
+void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data)
+{
+ palm27x_ep_gpio = data->jack_gpio;
+}
+
+module_init(palm27x_asoc_init);
+module_exit(palm27x_asoc_exit);
+
+/* Module information */
+MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
+MODULE_DESCRIPTION("ALSA SoC Palm T|X, T5 and LifeDrive");
+MODULE_LICENSE("GPL");
--
1.5.6.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/4] ASoC: Remove core version number
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
@ 2008-11-05 18:53 ` Mark Brown
2008-11-05 18:53 ` [PATCH 4/4] ASoC: Add new parameter to s3c24xx_pcm_enqueue Mark Brown
2008-11-05 19:35 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Marek Vasut
2008-11-05 20:35 ` Takashi Iwai
2 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-11-05 18:53 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Mark Brown
Rather than try to remember to keep the core version number updated
(which hasn't been happening) just remove it. It was much more useful
when ASoC was out of tree.
Signed-off-by: Mark brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 2 --
sound/soc/soc-core.c | 1 -
2 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index da0040b..fa1b99b 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -21,8 +21,6 @@
#include <sound/control.h>
#include <sound/ac97_codec.h>
-#define SND_SOC_VERSION "0.13.2"
-
/*
* Convenience kcontrol builders
*/
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1a17368..9feaa7b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1965,7 +1965,6 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
static int __devinit snd_soc_init(void)
{
- printk(KERN_INFO "ASoC version %s\n", SND_SOC_VERSION);
return platform_driver_register(&soc_driver);
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/4] ASoC: Add new parameter to s3c24xx_pcm_enqueue
2008-11-05 18:53 ` [PATCH 3/4] ASoC: Remove core version number Mark Brown
@ 2008-11-05 18:53 ` Mark Brown
0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2008-11-05 18:53 UTC (permalink / raw)
To: Takashi Iwai; +Cc: David Anders, alsa-devel, Mark Brown
From: David Anders <dave123_aml@yahoo.com>
The S3C24xx dma does not allow more than one buffer to be enqueue prior to
the dma transfers starting. This patch adds an additional parameter to
s3c24xx_pcm_enqueue() to allow for passing an initial dma maximum load
value.
Signed-off-by: David Anders <danders at amltd.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/s3c24xx/s3c24xx-pcm.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
index e13e614..341198b 100644
--- a/sound/soc/s3c24xx/s3c24xx-pcm.c
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -78,7 +78,8 @@ struct s3c24xx_runtime_data {
* place a dma buffer onto the queue for the dma system
* to handle.
*/
-static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
+static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream,
+ int dma_max)
{
struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
dma_addr_t pos = prtd->dma_pos;
@@ -86,7 +87,10 @@ static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
DBG("Entered %s\n", __func__);
- while (prtd->dma_loaded < prtd->dma_limit) {
+ if (!dma_max)
+ dma_max = prtd->dma_limit;
+
+ while (prtd->dma_loaded < dma_max) {
unsigned long len = prtd->dma_period;
DBG("dma_loaded: %d\n", prtd->dma_loaded);
@@ -132,7 +136,7 @@ static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
spin_lock(&prtd->lock);
if (prtd->state & ST_RUNNING) {
prtd->dma_loaded--;
- s3c24xx_pcm_enqueue(substream);
+ s3c24xx_pcm_enqueue(substream, 0);
}
spin_unlock(&prtd->lock);
@@ -249,7 +253,7 @@ static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
prtd->dma_pos = prtd->dma_start;
/* enqueue dma buffers */
- s3c24xx_pcm_enqueue(substream);
+ s3c24xx_pcm_enqueue(substream, 1);
return ret;
}
--
1.5.6.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
2008-11-05 18:53 ` [PATCH 3/4] ASoC: Remove core version number Mark Brown
@ 2008-11-05 19:35 ` Marek Vasut
2008-11-05 20:35 ` Takashi Iwai
2 siblings, 0 replies; 15+ messages in thread
From: Marek Vasut @ 2008-11-05 19:35 UTC (permalink / raw)
To: Mark Brown; +Cc: Takashi Iwai, alsa-devel
On Wednesday 05 of November 2008 19:53:29 Mark Brown wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
>
> this patch adds asoc audio driver for pxa27x based Palm PDAs. I tested it
> for palmtx, t5 and ld, it should work with palmz72 as well (slapin, please
> test). I sent it here some time ago, but now I got to fixing bugs in it. It
> should be somehow mostly ok and ready for applying.
>
> [Converted to use snd_soc_dapm_nc_pin() -- broonie]
Mark, thanks a lot for fixing it, I'm really overloaded with school recently
and I dont see it ending any soon.
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> arch/arm/mach-pxa/include/mach/palmasoc.h | 13 ++
> sound/soc/pxa/Kconfig | 9 +
> sound/soc/pxa/Makefile | 2 +
> sound/soc/pxa/palm27x.c | 269
> +++++++++++++++++++++++++++++ 4 files changed, 293 insertions(+), 0
> deletions(-)
> create mode 100644 arch/arm/mach-pxa/include/mach/palmasoc.h
> create mode 100644 sound/soc/pxa/palm27x.c
>
> diff --git a/arch/arm/mach-pxa/include/mach/palmasoc.h
> b/arch/arm/mach-pxa/include/mach/palmasoc.h new file mode 100644
> index 0000000..6c4b1f7
> --- /dev/null
> +++ b/arch/arm/mach-pxa/include/mach/palmasoc.h
> @@ -0,0 +1,13 @@
> +#ifndef _INCLUDE_PALMASOC_H_
> +#define _INCLUDE_PALMASOC_H_
> +struct palm27x_asoc_info {
> + int jack_gpio;
> +};
> +
> +#ifdef CONFIG_SND_PXA2XX_SOC_PALM27X
> +void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data);
> +#else
> +static inline void palm27x_asoc_set_pdata(struct palm27x_asoc_info *data)
> {} +#endif
> +
> +#endif
> diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
> index 4235524..1187603 100644
> --- a/sound/soc/pxa/Kconfig
> +++ b/sound/soc/pxa/Kconfig
> @@ -79,6 +79,15 @@ config SND_PXA2XX_SOC_EM_X270
> Say Y if you want to add support for SoC audio on
> CompuLab EM-x270.
>
> +config SND_PXA2XX_SOC_PALM27X
> + tristate "SoC Audio support for Palm T|X, T5 and LifeDrive"
> + depends on SND_PXA2XX_SOC && (MACH_PALMLD || MACH_PALMTX || MACH_PALMT5)
> + select SND_PXA2XX_SOC_AC97
> + select SND_SOC_WM9712
> + help
> + Say Y if you want to add support for SoC audio on
> + Palm T|X, T5 or LifeDrive handheld computer.
> +
> config SND_SOC_ZYLONITE
> tristate "SoC Audio support for Marvell Zylonite"
> depends on SND_PXA2XX_SOC && MACH_ZYLONITE
> diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
> index 00258ab..1a3a36e 100644
> --- a/sound/soc/pxa/Makefile
> +++ b/sound/soc/pxa/Makefile
> @@ -16,6 +16,7 @@ snd-soc-tosa-objs := tosa.o
> snd-soc-e800-objs := e800_wm9712.o
> snd-soc-spitz-objs := spitz.o
> snd-soc-em-x270-objs := em-x270.o
> +snd-soc-palm27x-objs := palm27x.o
>
> obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
> obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o
> @@ -23,3 +24,4 @@ obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o
> obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
> obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
> obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o
> +obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
> diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
> new file mode 100644
> index 0000000..e364abc
> --- /dev/null
> +++ b/sound/soc/pxa/palm27x.c
> @@ -0,0 +1,269 @@
> +/*
> + * linux/sound/soc/pxa/palm27x.c
> + *
> + * SoC Audio driver for Palm T|X, T5 and LifeDrive
> + *
> + * based on tosa.c
> + *
> + * Copyright (C) 2008 Marek Vasut <marek.vasut@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/device.h>
> +#include <linux/gpio.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/soc.h>
> +#include <sound/soc-dapm.h>
> +
> +#include <asm/mach-types.h>
> +#include <mach/audio.h>
> +#include <mach/palmasoc.h>
> +
> +#include "../codecs/wm9712.h"
> +#include "pxa2xx-pcm.h"
> +#include "pxa2xx-ac97.h"
> +
> +static int palm27x_jack_func = 1;
> +static int palm27x_spk_func = 1;
> +static int palm27x_ep_gpio = -1;
> +
> +static void palm27x_ext_control(struct snd_soc_codec *codec)
> +{
> + if (!palm27x_spk_func)
> + snd_soc_dapm_enable_pin(codec, "Speaker");
> + else
> + snd_soc_dapm_disable_pin(codec, "Speaker");
> +
> + if (!palm27x_jack_func)
> + snd_soc_dapm_enable_pin(codec, "Headphone Jack");
> + else
> + snd_soc_dapm_disable_pin(codec, "Headphone Jack");
> +
> + snd_soc_dapm_sync(codec);
> +}
> +
> +static int palm27x_startup(struct snd_pcm_substream *substream)
> +{
> + struct snd_soc_pcm_runtime *rtd = substream->private_data;
> + struct snd_soc_codec *codec = rtd->socdev->codec;
> +
> + /* check the jack status at stream startup */
> + palm27x_ext_control(codec);
> + return 0;
> +}
> +
> +static struct snd_soc_ops palm27x_ops = {
> + .startup = palm27x_startup,
> +};
> +
> +static irqreturn_t palm27x_interrupt(int irq, void *v)
> +{
> + palm27x_spk_func = gpio_get_value(palm27x_ep_gpio);
> + palm27x_jack_func = !palm27x_spk_func;
> + return IRQ_HANDLED;
> +}
> +
> +static int palm27x_get_jack(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + ucontrol->value.integer.value[0] = palm27x_jack_func;
> + return 0;
> +}
> +
> +static int palm27x_set_jack(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
> +
> + if (palm27x_jack_func == ucontrol->value.integer.value[0])
> + return 0;
> +
> + palm27x_jack_func = ucontrol->value.integer.value[0];
> + palm27x_ext_control(codec);
> + return 1;
> +}
> +
> +static int palm27x_get_spk(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + ucontrol->value.integer.value[0] = palm27x_spk_func;
> + return 0;
> +}
> +
> +static int palm27x_set_spk(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
> +
> + if (palm27x_spk_func == ucontrol->value.integer.value[0])
> + return 0;
> +
> + palm27x_spk_func = ucontrol->value.integer.value[0];
> + palm27x_ext_control(codec);
> + return 1;
> +}
> +
> +/* PalmTX machine dapm widgets */
> +static const struct snd_soc_dapm_widget palm27x_dapm_widgets[] = {
> + SND_SOC_DAPM_HP("Headphone Jack", NULL),
> + SND_SOC_DAPM_SPK("Speaker", NULL),
> +};
> +
> +/* PalmTX audio map */
> +static const struct snd_soc_dapm_route audio_map[] = {
> + /* headphone connected to HPOUTL, HPOUTR */
> + {"Headphone Jack", NULL, "HPOUTL"},
> + {"Headphone Jack", NULL, "HPOUTR"},
> +
> + /* ext speaker connected to ROUT2, LOUT2 */
> + {"Speaker", NULL, "LOUT2"},
> + {"Speaker", NULL, "ROUT2"},
> +};
> +
> +static const char *jack_function[] = {"Headphone", "Off"};
> +static const char *spk_function[] = {"On", "Off"};
> +static const struct soc_enum palm27x_enum[] = {
> + SOC_ENUM_SINGLE_EXT(2, jack_function),
> + SOC_ENUM_SINGLE_EXT(2, spk_function),
> +};
> +
> +static const struct snd_kcontrol_new palm27x_controls[] = {
> + SOC_ENUM_EXT("Jack Function", palm27x_enum[0], palm27x_get_jack,
> + palm27x_set_jack),
> + SOC_ENUM_EXT("Speaker Function", palm27x_enum[1], palm27x_get_spk,
> + palm27x_set_spk),
> +};
> +
> +static int palm27x_ac97_init(struct snd_soc_codec *codec)
> +{
> + int i, err;
> +
> + snd_soc_dapm_nc_pin(codec, "OUT3");
> + snd_soc_dapm_nc_pin(codec, "MONOOUT");
> +
> + /* add palm27x specific controls */
> + for (i = 0; i < ARRAY_SIZE(palm27x_controls); i++) {
> + err = snd_ctl_add(codec->card,
> + snd_soc_cnew(&palm27x_controls[i],
> + codec, NULL));
> + if (err < 0)
> + return err;
> + }
> +
> + /* add palm27x specific widgets */
> + snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets,
> + ARRAY_SIZE(palm27x_dapm_widgets));
> +
> + /* set up palm27x specific audio path audio_map */
> + snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
> +
> + snd_soc_dapm_sync(codec);
> + return 0;
> +}
> +
> +static struct snd_soc_dai_link palm27x_dai[] = {
> +{
> + .name = "AC97 HiFi",
> + .stream_name = "AC97 HiFi",
> + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
> + .codec_dai = &wm9712_dai[WM9712_DAI_AC97_HIFI],
> + .init = palm27x_ac97_init,
> + .ops = &palm27x_ops,
> +},
> +{
> + .name = "AC97 Aux",
> + .stream_name = "AC97 Aux",
> + .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX],
> + .codec_dai = &wm9712_dai[WM9712_DAI_AC97_AUX],
> + .ops = &palm27x_ops,
> +},
> +};
> +
> +static struct snd_soc_machine palm27x_asoc = {
> + .name = "Palm/PXA27x",
> + .dai_link = palm27x_dai,
> + .num_links = ARRAY_SIZE(palm27x_dai),
> +};
> +
> +static struct snd_soc_device palm27x_snd_devdata = {
> + .machine = &palm27x_asoc,
> + .platform = &pxa2xx_soc_platform,
> + .codec_dev = &soc_codec_dev_wm9712,
> +};
> +
> +static struct platform_device *palm27x_snd_device;
> +
> +static int __init palm27x_asoc_init(void)
> +{
> + int ret;
> +
> + if (!(machine_is_palmtx() || machine_is_palmt5() ||
> + machine_is_palmld()))
> + return -ENODEV;
> +
> + ret = gpio_request(palm27x_ep_gpio, "Headphone Jack");
> + if (ret)
> + return ret;
> + ret = gpio_direction_input(palm27x_ep_gpio);
> + if (ret)
> + goto err_alloc;
> +
> + if (request_irq(gpio_to_irq(palm27x_ep_gpio), palm27x_interrupt,
> + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
> + "Headphone jack", NULL))
> + goto err_alloc;
> +
> + palm27x_snd_device = platform_device_alloc("soc-audio", -1);
> + if (!palm27x_snd_device) {
> + ret = -ENOMEM;
> + goto err_dev;
> + }
> +
> + platform_set_drvdata(palm27x_snd_device, &palm27x_snd_devdata);
> + palm27x_snd_devdata.dev = &palm27x_snd_device->dev;
> + ret = platform_device_add(palm27x_snd_device);
> +
> + if (ret != 0)
> + goto put_device;
> +
> + return 0;
> +
> +put_device:
> + platform_device_put(palm27x_snd_device);
> +err_dev:
> + free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
> +err_alloc:
> + gpio_free(palm27x_ep_gpio);
> +
> + return ret;
> +}
> +
> +static void __exit palm27x_asoc_exit(void)
> +{
> + free_irq(gpio_to_irq(palm27x_ep_gpio), NULL);
> + gpio_free(palm27x_ep_gpio);
> + platform_device_unregister(palm27x_snd_device);
> +}
> +
> +void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data)
> +{
> + palm27x_ep_gpio = data->jack_gpio;
> +}
> +
> +module_init(palm27x_asoc_init);
> +module_exit(palm27x_asoc_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
> +MODULE_DESCRIPTION("ALSA SoC Palm T|X, T5 and LifeDrive");
> +MODULE_LICENSE("GPL");
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
2008-11-05 18:53 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Mark Brown
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
@ 2008-11-05 20:35 ` Takashi Iwai
2008-11-05 22:05 ` Mark Brown
2008-11-06 10:49 ` [PATCH 1/4] " Mark Brown
2008-11-06 11:23 ` Takashi Iwai
2 siblings, 2 replies; 15+ messages in thread
From: Takashi Iwai @ 2008-11-05 20:35 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Troy Kisky
At Wed, 5 Nov 2008 18:53:28 +0000,
Mark Brown wrote:
>
> From: Troy Kisky <troy.kisky@boundarydevices.com>
>
> Add support for more sample rates, different crystals
> and split playback/capture rates.
>
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
> Acked-by: Arun KS <arunks@mistralsolutions.com>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> sound/soc/codecs/tlv320aic23.c | 227 ++++++++++++++++++++++++++++++++--------
> 1 files changed, 182 insertions(+), 45 deletions(-)
>
> diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
> index 44308da..c1b2060 100644
> --- a/sound/soc/codecs/tlv320aic23.c
> +++ b/sound/soc/codecs/tlv320aic23.c
> +unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
> + int dac, int dac_l, int dac_h, int need_dac)
Should be static.
> +{
> + if ((adc >= adc_l) && (adc <= adc_h) &&
> + (dac >= dac_l) && (dac <= dac_h)) {
> + unsigned diff_adc = need_adc - adc;
> + unsigned diff_dac = need_dac - dac;
> + unsigned score;
> + if (((int)diff_adc) < 0)
> + diff_adc = -diff_adc;
> + if (((int)diff_dac) < 0)
> + diff_dac = -diff_dac;
> + score = diff_adc + diff_dac;
> + return score;
> + }
> + return 0xffffffff;
-1 would be simpler and safer (for possible missing f's).
> +}
> +int find_rate(int mclk, u32 need_adc, u32 need_dac)
Use static.
> +{
> + int i, j;
> + int best_i = -1;
> + int best_j = -1;
> + int best_div = 0;
> + unsigned best_score = 0xffffffff;
-1 would be safer.
> + int adc_l, adc_h, dac_l, dac_h;
> +
> + need_adc *= SR_MULT;
> + need_dac *= SR_MULT;
> + /*
> + * rates given are +/- 1/32
> + */
> + adc_l = need_adc - (need_adc >> 5);
> + adc_h = need_adc + (need_adc >> 5);
> + dac_l = need_dac - (need_dac >> 5);
> + dac_h = need_dac + (need_dac >> 5);
> + for (i = 0; i < 4; i++) {
> + int base = mclk / bosr_usb_divisor_table[i];
> + int mask = sr_valid_mask[i];
> + for (j = 0; j < 16; j++, mask >>= 1) {
> + int adc;
> + int dac;
> + int score;
> + if ((mask & 1) == 0)
> + continue;
> + adc = base * sr_adc_mult_table[j];
> + dac = base * sr_dac_mult_table[j];
> + score = get_score(adc, adc_l, adc_h, need_adc,
> + dac, dac_l, dac_h, need_dac);
> + if (best_score > score) {
> + best_score = score;
> + best_i = i;
> + best_j = j;
> + best_div = 0;
> + }
> + score = get_score((adc >> 1), adc_l, adc_h, need_adc,
> + (dac >> 1), dac_l, dac_h, need_dac);
> + /* prefer to have a /2 */
> + if ((score != 0xffffffff) && (best_score >= score)) {
> + best_score = score;
> + best_i = i;
> + best_j = j;
> + best_div = 1;
> + }
> + }
> + }
> + return (best_j << 2) | best_i | (best_div << TLV320AIC23_CLKIN_SHIFT);
> +}
> +
> +static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk,
> + u32 *sample_rate_adc, u32 *sample_rate_dac)
> +{
> + int src = tlv320aic23_read_reg_cache(codec, TLV320AIC23_SRATE);
> + int sr = (src >> 2) & 0x0f;
> + int val = (mclk / bosr_usb_divisor_table[src & 3]);
> + int adc = (val * sr_adc_mult_table[sr]) / SR_MULT;
> + int dac = (val * sr_dac_mult_table[sr]) / SR_MULT;
> + if (src & TLV320AIC23_CLKIN_HALF) {
> + adc >>= 1;
> + dac >>= 1;
> + }
> + *sample_rate_adc = adc;
> + *sample_rate_dac = dac;
> +}
> +
> +static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk,
> + u32 sample_rate_adc, u32 sample_rate_dac)
> +{
> + /* Search for the right sample rate */
> + int data = find_rate(mclk, sample_rate_adc, sample_rate_dac);
> + if (data < 0) {
> + printk(KERN_ERR "%s:Invalid rate %u,%u requested\n",
> + __func__, sample_rate_adc, sample_rate_dac);
> + return -EINVAL;
> + }
> + tlv320aic23_write(codec, TLV320AIC23_SRATE, data);
> + if (1) {
For what?
Takashi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
2008-11-05 18:53 ` [PATCH 3/4] ASoC: Remove core version number Mark Brown
2008-11-05 19:35 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Marek Vasut
@ 2008-11-05 20:35 ` Takashi Iwai
2008-11-05 21:54 ` Mark Brown
2 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2008-11-05 20:35 UTC (permalink / raw)
To: Mark Brown; +Cc: Marek Vasut, alsa-devel
At Wed, 5 Nov 2008 18:53:29 +0000,
Mark Brown wrote:
>
> From: Marek Vasut <marek.vasut@gmail.com>
>
> this patch adds asoc audio driver for pxa27x based Palm PDAs. I tested it for
> palmtx, t5 and ld, it should work with palmz72 as well (slapin, please test).
> I sent it here some time ago, but now I got to fixing bugs in it. It should
> be somehow mostly ok and ready for applying.
>
> [Converted to use snd_soc_dapm_nc_pin() -- broonie]
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> arch/arm/mach-pxa/include/mach/palmasoc.h | 13 ++
> sound/soc/pxa/Kconfig | 9 +
> sound/soc/pxa/Makefile | 2 +
> sound/soc/pxa/palm27x.c | 269 +++++++++++++++++++++++++++++
> 4 files changed, 293 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/mach-pxa/include/mach/palmasoc.h
> create mode 100644 sound/soc/pxa/palm27x.c
>
> diff --git a/arch/arm/mach-pxa/include/mach/palmasoc.h b/arch/arm/mach-pxa/include/mach/palmasoc.h
> new file mode 100644
> index 0000000..6c4b1f7
> --- /dev/null
> +++ b/arch/arm/mach-pxa/include/mach/palmasoc.h
> @@ -0,0 +1,13 @@
> +#ifndef _INCLUDE_PALMASOC_H_
> +#define _INCLUDE_PALMASOC_H_
> +struct palm27x_asoc_info {
> + int jack_gpio;
> +};
> +
> +#ifdef CONFIG_SND_PXA2XX_SOC_PALM27X
> +void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data);
I wonder whether it's really __init.
Note that the driver can be a module in theory.
Takashi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver
2008-11-05 20:35 ` Takashi Iwai
@ 2008-11-05 21:54 ` Mark Brown
0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2008-11-05 21:54 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Marek Vasut, alsa-devel
On Wed, Nov 05, 2008 at 09:35:53PM +0100, Takashi Iwai wrote:
> > +#ifdef CONFIG_SND_PXA2XX_SOC_PALM27X
> > +void __init palm27x_asoc_set_pdata(struct palm27x_asoc_info *data);
> I wonder whether it's really __init.
Yes. This will be set up by the machine init code which has to be built
in. It should be platform data but we can't support that yet.
> Note that the driver can be a module in theory.
Yeah, that practice won't actually build so should probably be masked
out in Kconfig.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
2008-11-05 20:35 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Takashi Iwai
@ 2008-11-05 22:05 ` Mark Brown
2008-11-06 23:11 ` [PATCH 1/1] [ALSA] " Troy Kisky
2008-11-06 10:49 ` [PATCH 1/4] " Mark Brown
1 sibling, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-11-05 22:05 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Troy Kisky
On Wed, Nov 05, 2008 at 09:35:01PM +0100, Takashi Iwai wrote:
> Mark Brown wrote:
> > + if (1) {
> For what?
That should be an ifdef DEBUG - sorry, looks like I've sent an old
version of the patch. My bad, sorry. Troy, when addressing Takashi's
other comments please send an incremental patch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
2008-11-05 20:35 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Takashi Iwai
2008-11-05 22:05 ` Mark Brown
@ 2008-11-06 10:49 ` Mark Brown
2008-11-06 11:03 ` Takashi Iwai
1 sibling, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-11-06 10:49 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Troy Kisky
On Wed, Nov 05, 2008 at 09:35:01PM +0100, Takashi Iwai wrote:
> Mark Brown wrote:
> > + return score;
> > + return 0xffffffff;
> -1 would be simpler and safer (for possible missing f's).
I'm not sure that'd add to the clarity - the goal isn't to have all bits
set, the goal is to have a much larger score than could ever otherwise
be achieved so putting in a very large constant expresses that much more
directly.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
2008-11-06 10:49 ` [PATCH 1/4] " Mark Brown
@ 2008-11-06 11:03 ` Takashi Iwai
0 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2008-11-06 11:03 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Troy Kisky
At Thu, 6 Nov 2008 10:49:06 +0000,
Mark Brown wrote:
>
> On Wed, Nov 05, 2008 at 09:35:01PM +0100, Takashi Iwai wrote:
> > Mark Brown wrote:
>
> > > + return score;
>
> > > + return 0xffffffff;
>
> > -1 would be simpler and safer (for possible missing f's).
>
> I'm not sure that'd add to the clarity - the goal isn't to have all bits
> set, the goal is to have a much larger score than could ever otherwise
> be achieved so putting in a very large constant expresses that much more
> directly.
In that case, the best form is UINT_MAX.
Takashi
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates
2008-11-05 18:53 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Mark Brown
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
2008-11-05 20:35 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Takashi Iwai
@ 2008-11-06 11:23 ` Takashi Iwai
2 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2008-11-06 11:23 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Troy Kisky
At Thu, 6 Nov 2008 10:49:06 +0000,
Mark Brown wrote:
>
> On Wed, Nov 05, 2008 at 09:35:01PM +0100, Takashi Iwai wrote:
> > Mark Brown wrote:
>
> > > + return score;
>
> > > + return 0xffffffff;
>
> > -1 would be simpler and safer (for possible missing f's).
>
> I'm not sure that'd add to the clarity - the goal isn't to have all bits
> set, the goal is to have a much larger score than could ever otherwise
> be achieved so putting in a very large constant expresses that much more
> directly.
Also, regarding unsigned integer:
> +unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
> + int dac, int dac_l, int dac_h, int need_dac)
> +{
> + if ((adc >= adc_l) && (adc <= adc_h) &&
> + (dac >= dac_l) && (dac <= dac_h)) {
> + unsigned diff_adc = need_adc - adc;
> + unsigned diff_dac = need_dac - dac;
> + unsigned score;
> + if (((int)diff_adc) < 0)
> + diff_adc = -diff_adc;
> + if (((int)diff_dac) < 0)
> + diff_dac = -diff_dac;
> + score = diff_adc + diff_dac;
> + return score;
It's more readable when diff_adc, diff_dac are int so that you have no
ugly cast:
int diff_adc = need_adc - adc;
int diff_dac = need_dac - dac;
unsigned score;
if (diff_adc < 0)
diff_adc = -diff_adc;
if (diff_dac < 0)
diff_dac = -diff_dac;
score = diff_adc + diff_dac;
return score;
And, even more readable with abs() (not surprisingly defined in
linux/kernel.h):
int diff_adc = need_adc - adc;
int diff_dac = need_dac - dac;
return abs(diff_adc) + abs(diff_dac);
Takashi
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/1] [ALSA] ASoC: TLV320AIC23B Support more sample rates
2008-11-05 22:05 ` Mark Brown
@ 2008-11-06 23:11 ` Troy Kisky
2008-11-07 14:10 ` Mark Brown
0 siblings, 1 reply; 15+ messages in thread
From: Troy Kisky @ 2008-11-06 23:11 UTC (permalink / raw)
To: alsa-devel; +Cc: arunks, broonie, Troy Kisky
Add support for more sample rates, different crystals
and split playback/capture rates.
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Mark, this is an incremental patch to the #ifdef DEBUG version
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c
index 0096842..8a9ef21 100644
--- a/sound/soc/codecs/tlv320aic23.c
+++ b/sound/soc/codecs/tlv320aic23.c
@@ -301,30 +301,25 @@ static const unsigned char sr_dac_mult_table[] = {
A(2), A(11), A(2), A(11), A(0), A(0), A(0), A(1)
};
-unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
+static unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
int dac, int dac_l, int dac_h, int need_dac)
{
if ((adc >= adc_l) && (adc <= adc_h) &&
(dac >= dac_l) && (dac <= dac_h)) {
- unsigned diff_adc = need_adc - adc;
- unsigned diff_dac = need_dac - dac;
- unsigned score;
- if (((int)diff_adc) < 0)
- diff_adc = -diff_adc;
- if (((int)diff_dac) < 0)
- diff_dac = -diff_dac;
- score = diff_adc + diff_dac;
- return score;
+ int diff_adc = need_adc - adc;
+ int diff_dac = need_dac - dac;
+ return abs(diff_adc) + abs(diff_dac);
}
- return 0xffffffff;
+ return UINT_MAX;
}
-int find_rate(int mclk, u32 need_adc, u32 need_dac)
+
+static int find_rate(int mclk, u32 need_adc, u32 need_dac)
{
int i, j;
int best_i = -1;
int best_j = -1;
int best_div = 0;
- unsigned best_score = 0xffffffff;
+ unsigned best_score = UINT_MAX;
int adc_l, adc_h, dac_l, dac_h;
need_adc *= SR_MULT;
@@ -359,7 +354,7 @@ int find_rate(int mclk, u32 need_adc, u32 need_dac)
score = get_score((adc >> 1), adc_l, adc_h, need_adc,
(dac >> 1), dac_l, dac_h, need_dac);
/* prefer to have a /2 */
- if ((score != 0xffffffff) && (best_score >= score)) {
+ if ((score != UINT_MAX) && (best_score >= score)) {
best_score = score;
best_i = i;
best_j = j;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/1] [ALSA] ASoC: TLV320AIC23B Support more sample rates
2008-11-06 23:11 ` [PATCH 1/1] [ALSA] " Troy Kisky
@ 2008-11-07 14:10 ` Mark Brown
0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2008-11-07 14:10 UTC (permalink / raw)
To: Troy Kisky; +Cc: alsa-devel, arunks
On Thu, Nov 06, 2008 at 04:11:08PM -0700, Troy Kisky wrote:
> Add support for more sample rates, different crystals
> and split playback/capture rates.
>
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
> Mark, this is an incremental patch to the #ifdef DEBUG version
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
I'll squash this down and push it today or Monday.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2008-11-07 14:10 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-05 18:52 [PATCH 0/4] ASoC updates Mark Brown
2008-11-05 18:53 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Mark Brown
2008-11-05 18:53 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Mark Brown
2008-11-05 18:53 ` [PATCH 3/4] ASoC: Remove core version number Mark Brown
2008-11-05 18:53 ` [PATCH 4/4] ASoC: Add new parameter to s3c24xx_pcm_enqueue Mark Brown
2008-11-05 19:35 ` [PATCH 2/4] ASoC: Add Palm/PXA27x unified ASoC audio driver Marek Vasut
2008-11-05 20:35 ` Takashi Iwai
2008-11-05 21:54 ` Mark Brown
2008-11-05 20:35 ` [PATCH 1/4] ASoC: TLV320AIC23B Support more sample rates Takashi Iwai
2008-11-05 22:05 ` Mark Brown
2008-11-06 23:11 ` [PATCH 1/1] [ALSA] " Troy Kisky
2008-11-07 14:10 ` Mark Brown
2008-11-06 10:49 ` [PATCH 1/4] " Mark Brown
2008-11-06 11:03 ` Takashi Iwai
2008-11-06 11:23 ` Takashi Iwai
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.